diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-12-24 17:31:38 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-12-24 17:31:38 +0000 |
| commit | 010337c8385b919f75d98f6cb383214817c13257 (patch) | |
| tree | c23a474c8e335acf01b8411d5935bfda96db0677 /llvm/test/Transforms | |
| parent | 175543ac7817e78cb7f474353ae078f396c34f84 (diff) | |
| download | bcm5719-llvm-010337c8385b919f75d98f6cb383214817c13257.tar.gz bcm5719-llvm-010337c8385b919f75d98f6cb383214817c13257.zip | |
InstCombine: Canonicalize (2^n)-1 - x into (2^n)-1 ^ x iff x is known to be smaller than 2^n.
This has the obvious advantage of being commutable and is always a win on x86 because
const - x wastes a register there. On less weird architectures this may lead to
a regression because other arithmetic doesn't fuse with it anymore. I'll address that
problem in a followup.
llvm-svn: 147254
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/sub-xor.ll | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub-xor.ll b/llvm/test/Transforms/InstCombine/sub-xor.ll new file mode 100644 index 00000000000..41e01fbdae8 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/sub-xor.ll @@ -0,0 +1,12 @@ +; RUN: opt -instcombine -S < %s | FileCheck %s + +define i32 @test1(i32 %x) nounwind { + %and = and i32 %x, 31 + %sub = sub i32 63, %and + ret i32 %sub + +; CHECK: @test1 +; CHECK-NEXT: and i32 %x, 31 +; CHECK-NEXT: xor i32 %and, 63 +; CHECK-NEXT: ret +} |

