[llvm] r299971 - [InstCombine] Add testcases for (B&A)^A -> ~B & A and (B|A)^A -> B & ~A
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 11:50:49 PDT 2017
Author: ctopper
Date: Tue Apr 11 13:50:48 2017
New Revision: 299971
URL: http://llvm.org/viewvc/llvm-project?rev=299971&view=rev
Log:
[InstCombine] Add testcases for (B&A)^A -> ~B & A and (B|A)^A -> B & ~A
Modified:
llvm/trunk/test/Transforms/InstCombine/xor.ll
Modified: llvm/trunk/test/Transforms/InstCombine/xor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor.ll?rev=299971&r1=299970&r2=299971&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/xor.ll Tue Apr 11 13:50:48 2017
@@ -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
+}
More information about the llvm-commits
mailing list