summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-11 18:50:48 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-11 18:50:48 +0000
commit9eac2717c65864f60b0da53d20a4912b557e8188 (patch)
treebf9e1601505116ab0b526c9495fb734c36c1e1d9
parent957a94cc03791f44b17bf42cdf17164b9ed7d55b (diff)
downloadbcm5719-llvm-9eac2717c65864f60b0da53d20a4912b557e8188.tar.gz
bcm5719-llvm-9eac2717c65864f60b0da53d20a4912b557e8188.zip
[InstCombine] Add testcases for (B&A)^A -> ~B & A and (B|A)^A -> B & ~A
llvm-svn: 299971
-rw-r--r--llvm/test/Transforms/InstCombine/xor.ll88
1 files changed, 88 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/xor.ll b/llvm/test/Transforms/InstCombine/xor.ll
index b5fbfabbda2..570155b1623 100644
--- a/llvm/test/Transforms/InstCombine/xor.ll
+++ b/llvm/test/Transforms/InstCombine/xor.ll
@@ -448,3 +448,91 @@ final:
%value = xor <2 x i32> %A, <i32 123, i32 333>
ret <2 x i32> %value
}
+
+define i32 @test31(i32 %A, i32 %B) {
+; CHECK-LABEL: @test31(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = or i32 %A, %B
+ %xor = xor i32 %B, %and
+ ret i32 %xor
+}
+
+define i32 @test32(i32 %A, i32 %B) {
+; CHECK-LABEL: @test32(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = or i32 %B, %A
+ %xor = xor i32 %B, %and
+ ret i32 %xor
+}
+
+define i32 @test33(i32 %A, i32 %B) {
+; CHECK-LABEL: @test33(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = or i32 %A, %B
+ %xor = xor i32 %and, %B
+ ret i32 %xor
+}
+
+define i32 @test34(i32 %A, i32 %B) {
+; CHECK-LABEL: @test34(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = or i32 %B, %A
+ %xor = xor i32 %and, %B
+ ret i32 %xor
+}
+
+define i32 @test35(i32 %A, i32 %B) {
+; CHECK-LABEL: @test35(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = and i32 %A, %B
+ %xor = xor i32 %B, %and
+ ret i32 %xor
+}
+
+define i32 @test36(i32 %A, i32 %B) {
+; CHECK-LABEL: @test36(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = and i32 %B, %A
+ %xor = xor i32 %B, %and
+ ret i32 %xor
+}
+
+define i32 @test37(i32 %A, i32 %B) {
+; CHECK-LABEL: @test37(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = and i32 %A, %B
+ %xor = xor i32 %and, %B
+ ret i32 %xor
+}
+
+define i32 @test38(i32 %A, i32 %B) {
+; CHECK-LABEL: @test38(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1
+; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]]
+; CHECK-NEXT: ret i32 [[XOR]]
+;
+ %and = and i32 %B, %A
+ %xor = xor i32 %and, %B
+ ret i32 %xor
+}
OpenPOWER on IntegriCloud