summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/sub-xor.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-12-24 17:31:38 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-12-24 17:31:38 +0000
commit1fdfae05b0a4356d1ed0633bf3d6cdc6eba2e173 (patch)
treeccea4fe8b620b42f8d495936698c5c6f46e543d7 /test/Transforms/InstCombine/sub-xor.ll
parentce618af3e880ae0ec0ddd81aca8ed5bbd4096ae4 (diff)
downloadllvm-1fdfae05b0a4356d1ed0633bf3d6cdc6eba2e173.tar.gz
llvm-1fdfae05b0a4356d1ed0633bf3d6cdc6eba2e173.tar.bz2
llvm-1fdfae05b0a4356d1ed0633bf3d6cdc6eba2e173.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/sub-xor.ll')
-rw-r--r--test/Transforms/InstCombine/sub-xor.ll12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/sub-xor.ll b/test/Transforms/InstCombine/sub-xor.ll
new file mode 100644
index 0000000000..41e01fbdae
--- /dev/null
+++ b/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
+}