[llvm] a26cd73 - [InstSimplify] add/move tests for or with not op (PR46083); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 05:13:49 PDT 2020


Author: Sanjay Patel
Date: 2020-06-03T08:13:36-04:00
New Revision: a26cd73d3377a276ab92d2381d5a80b81a81770d

URL: https://github.com/llvm/llvm-project/commit/a26cd73d3377a276ab92d2381d5a80b81a81770d
DIFF: https://github.com/llvm/llvm-project/commit/a26cd73d3377a276ab92d2381d5a80b81a81770d.diff

LOG: [InstSimplify] add/move tests for or with not op (PR46083); NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/or-xor.ll
    llvm/test/Transforms/InstSimplify/or.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/or-xor.ll b/llvm/test/Transforms/InstCombine/or-xor.ll
index 4663d196a281..6ee5999d1a36 100644
--- a/llvm/test/Transforms/InstCombine/or-xor.ll
+++ b/llvm/test/Transforms/InstCombine/or-xor.ll
@@ -59,26 +59,6 @@ define i32 @test4(i32 %x, i32 %y) {
   ret i32 %z
 }
 
-define i32 @test5(i32 %x, i32 %y) {
-; CHECK-LABEL: @test5(
-; CHECK-NEXT:    ret i32 -1
-;
-  %and = and i32 %x, %y
-  %not = xor i32 %and, -1
-  %z = or i32 %x, %not
-  ret i32 %z
-}
-
-define i32 @test6(i32 %x, i32 %y) {
-; CHECK-LABEL: @test6(
-; CHECK-NEXT:    ret i32 -1
-;
-  %and = and i32 %x, %y
-  %not = xor i32 %and, -1
-  %z = or i32 %y, %not
-  ret i32 %z
-}
-
 define i32 @test7(i32 %x, i32 %y) {
 ; CHECK-LABEL: @test7(
 ; CHECK-NEXT:    [[Z:%.*]] = or i32 [[X:%.*]], [[Y:%.*]]

diff  --git a/llvm/test/Transforms/InstSimplify/or.ll b/llvm/test/Transforms/InstSimplify/or.ll
index 465b30c9cf94..619c8eba554a 100644
--- a/llvm/test/Transforms/InstSimplify/or.ll
+++ b/llvm/test/Transforms/InstSimplify/or.ll
@@ -243,3 +243,57 @@ define <2 x i399> @test8_apint(<2 x i399> %V, <2 x i399> %M) {
   %R = or <2 x i399> %D, %B
   ret <2 x i399> %R
 }
+
+; A | ~(A & B) = -1
+
+define i1 @or_with_not_op_commute1(i1 %a, i1 %b) {
+; CHECK-LABEL: @or_with_not_op_commute1(
+; CHECK-NEXT:    [[AB:%.*]] = and i1 [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT:    [[NOT:%.*]] = xor i1 [[AB]], true
+; CHECK-NEXT:    [[R:%.*]] = or i1 [[A]], [[NOT]]
+; CHECK-NEXT:    ret i1 [[R]]
+;
+  %ab = and i1 %a, %b
+  %not = xor i1 %ab, -1
+  %r = or i1 %a, %not
+  ret i1 %r
+}
+
+; A | ~(B & A) = -1
+
+define i8 @or_with_not_op_commute2(i8 %a, i8 %b) {
+; CHECK-LABEL: @or_with_not_op_commute2(
+; CHECK-NEXT:    [[AB:%.*]] = and i8 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT:    [[NOT:%.*]] = xor i8 [[AB]], -1
+; CHECK-NEXT:    [[R:%.*]] = or i8 [[A]], [[NOT]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %ab = and i8 %b, %a
+  %not = xor i8 %ab, -1
+  %r = or i8 %a, %not
+  ret i8 %r
+}
+
+; ~(A & B) | A = -1
+
+define <3 x i17> @or_with_not_op_commute3(<3 x i17> %a, <3 x i17> %b) {
+; CHECK-LABEL: @or_with_not_op_commute3(
+; CHECK-NEXT:    ret <3 x i17> <i17 -1, i17 -1, i17 -1>
+;
+  %ab = and <3 x i17> %a, %b
+  %not = xor <3 x i17> %ab, <i17 -1, i17 -1, i17 -1>
+  %r = or <3 x i17> %not, %a
+  ret <3 x i17> %r
+}
+
+; ~(B & A) | A = -1
+
+define <2 x i1> @or_with_not_op_commute4(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @or_with_not_op_commute4(
+; CHECK-NEXT:    ret <2 x i1> <i1 true, i1 true>
+;
+  %ab = and <2 x i1> %b, %a
+  %not = xor <2 x i1> %ab, <i1 -1, i1 undef>
+  %r = or <2 x i1> %not, %a
+  ret <2 x i1> %r
+}


        


More information about the llvm-commits mailing list