OSDN Git Service

[InstCombine] consolidate more DeMorgan tests; NFC
authorSanjay Patel <spatel@rotateright.com>
Mon, 1 May 2017 14:10:59 +0000 (14:10 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 1 May 2017 14:10:59 +0000 (14:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301800 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/and.ll
test/Transforms/InstCombine/apint-and1.ll
test/Transforms/InstCombine/apint-and2.ll
test/Transforms/InstCombine/demorgan.ll

index a2715c1..8ef7870 100644 (file)
@@ -172,19 +172,6 @@ define i8 @test16(i8 %A) {
   ret i8 %C
 }
 
-;; ~(~X & Y) --> (X | ~Y)
-define i8 @test17(i8 %X, i8 %Y) {
-; CHECK-LABEL: @test17(
-; CHECK-NEXT:    [[Y_NOT:%.*]] = xor i8 %Y, -1
-; CHECK-NEXT:    [[D:%.*]] = or i8 [[Y_NOT]], %X
-; CHECK-NEXT:    ret i8 [[D]]
-;
-  %B = xor i8 %X, -1
-  %C = and i8 %B, %Y
-  %D = xor i8 %C, -1
-  ret i8 %D
-}
-
 define i1 @test18(i32 %A) {
 ; CHECK-LABEL: @test18(
 ; CHECK-NEXT:    [[C:%.*]] = icmp ugt i32 %A, 127
index 495e687..08e9fc2 100644 (file)
@@ -34,14 +34,6 @@ define i7 @test5(i7 %A, i7* %P) {
         ret i7 %r
 }
 
-define i7 @test6(i7 %A, i7 %B) {
-        ;; ~(~X & Y) --> (X | ~Y)
-        %t0 = xor i7 %A, -1
-        %t1 = and i7 %t0, %B
-        %r = xor i7 %t1, -1
-        ret i7 %r
-}
-
 define i47 @test7(i47 %A) {
         %X = ashr i47 %A, 39 ;; sign extend
         %C1 = and i47 %X, 255
index 427c9e6..8a76eae 100644 (file)
@@ -35,14 +35,6 @@ define i117 @test5(i117 %A, i117* %P) {
         ret i117 %r
 }
 
-define i117 @test6(i117 %A, i117 %B) {
-        ;; ~(~X & Y) --> (X | ~Y)
-        %t0 = xor i117 %A, -1
-        %t1 = and i117 %t0, %B
-        %r = xor i117 %t1, -1
-        ret i117 %r
-}
-
 define i1024 @test7(i1024 %A) {
         %X = ashr i1024 %A, 1016 ;; sign extend
         %C1 = and i1024 %X, 255
index 30413ce..d2aeb9c 100644 (file)
@@ -186,6 +186,62 @@ define i71 @test5_apint(i71 %A, i71 %B) {
   ret i71 %notc
 }
 
+; ~(~A & B) --> (A | ~B)
+
+define i8 @demorgan_nand(i8 %A, i8 %B) {
+; CHECK-LABEL: @demorgan_nand(
+; CHECK-NEXT:    [[B_NOT:%.*]] = xor i8 %B, -1
+; CHECK-NEXT:    [[NOTC:%.*]] = or i8 [[B_NOT]], %A
+; CHECK-NEXT:    ret i8 [[NOTC]]
+;
+  %notx = xor i8 %A, -1
+  %c = and i8 %notx, %B
+  %notc = xor i8 %c, -1
+  ret i8 %notc
+}
+
+; ~(~A & B) --> (A | ~B)
+
+define i7 @demorgan_nand_apint1(i7 %A, i7 %B) {
+; CHECK-LABEL: @demorgan_nand_apint1(
+; CHECK-NEXT:    [[B_NOT:%.*]] = xor i7 %B, -1
+; CHECK-NEXT:    [[NOTC:%.*]] = or i7 [[B_NOT]], %A
+; CHECK-NEXT:    ret i7 [[NOTC]]
+;
+  %nota = xor i7 %A, -1
+  %c = and i7 %nota, %B
+  %notc = xor i7 %c, -1
+  ret i7 %notc
+}
+
+; ~(~A & B) --> (A | ~B)
+
+define i117 @demorgan_nand_apint2(i117 %A, i117 %B) {
+; CHECK-LABEL: @demorgan_nand_apint2(
+; CHECK-NEXT:    [[B_NOT:%.*]] = xor i117 %B, -1
+; CHECK-NEXT:    [[NOTC:%.*]] = or i117 [[B_NOT]], %A
+; CHECK-NEXT:    ret i117 [[NOTC]]
+;
+  %nota = xor i117 %A, -1
+  %c = and i117 %nota, %B
+  %notc = xor i117 %c, -1
+  ret i117 %notc
+}
+
+; ~(~A | B) --> (A & ~B)
+
+define i8 @demorgan_nor(i8 %A, i8 %B) {
+; CHECK-LABEL: @demorgan_nor(
+; CHECK-NEXT:    [[B_NOT:%.*]] = xor i8 %B, -1
+; CHECK-NEXT:    [[NOTC:%.*]] = and i8 [[B_NOT]], %A
+; CHECK-NEXT:    ret i8 [[NOTC]]
+;
+  %notx = xor i8 %A, -1
+  %c = or i8 %notx, %B
+  %notc = xor i8 %c, -1
+  ret i8 %notc
+}
+
 ; FIXME: Do not apply DeMorgan's Law to constants. We prefer 'not' ops.
 
 define i32 @demorganize_constant1(i32 %a) {