aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/or-to-xor.ll
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-11-30 13:52:49 +0000
committerBill Wendling <isanbard@gmail.com>2008-11-30 13:52:49 +0000
commitb01865c210f4272904b3b3099474ee7f43bc7bec (patch)
tree575c6c446caa69f5b369926dbc4174d22ec2269d /test/Transforms/InstCombine/or-to-xor.ll
parent7f0ef6b325d0f6061c584ab93ebb083b87bca4ff (diff)
Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all permutations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60291 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/or-to-xor.ll')
-rw-r--r--test/Transforms/InstCombine/or-to-xor.ll42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/or-to-xor.ll b/test/Transforms/InstCombine/or-to-xor.ll
new file mode 100644
index 0000000000..f403412bd5
--- /dev/null
+++ b/test/Transforms/InstCombine/or-to-xor.ll
@@ -0,0 +1,42 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {xor i32 %b, %a} | count 4
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {and}
+
+define i32 @func1(i32 %a, i32 %b) nounwind readnone {
+entry:
+ %b_not = xor i32 %b, -1
+ %0 = and i32 %a, %b_not
+ %a_not = xor i32 %a, -1
+ %1 = and i32 %a_not, %b
+ %2 = or i32 %0, %1
+ ret i32 %2
+}
+
+define i32 @func2(i32 %a, i32 %b) nounwind readnone {
+entry:
+ %b_not = xor i32 %b, -1
+ %0 = and i32 %b_not, %a
+ %a_not = xor i32 %a, -1
+ %1 = and i32 %a_not, %b
+ %2 = or i32 %0, %1
+ ret i32 %2
+}
+
+define i32 @func3(i32 %a, i32 %b) nounwind readnone {
+entry:
+ %b_not = xor i32 %b, -1
+ %0 = and i32 %a, %b_not
+ %a_not = xor i32 %a, -1
+ %1 = and i32 %b, %a_not
+ %2 = or i32 %0, %1
+ ret i32 %2
+}
+
+define i32 @func4(i32 %a, i32 %b) nounwind readnone {
+entry:
+ %b_not = xor i32 %b, -1
+ %0 = and i32 %b_not, %a
+ %a_not = xor i32 %a, -1
+ %1 = and i32 %b, %a_not
+ %2 = or i32 %0, %1
+ ret i32 %2
+}