summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/Transforms/InstCombine/and.ll13
-rw-r--r--llvm/test/Transforms/InstCombine/apint-and1.ll8
-rw-r--r--llvm/test/Transforms/InstCombine/apint-and2.ll8
-rw-r--r--llvm/test/Transforms/InstCombine/demorgan.ll56
4 files changed, 56 insertions, 29 deletions
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index a2715c12fa8..8ef7870891f 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -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
diff --git a/llvm/test/Transforms/InstCombine/apint-and1.ll b/llvm/test/Transforms/InstCombine/apint-and1.ll
index 495e687ae4c..08e9fc25e86 100644
--- a/llvm/test/Transforms/InstCombine/apint-and1.ll
+++ b/llvm/test/Transforms/InstCombine/apint-and1.ll
@@ -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
diff --git a/llvm/test/Transforms/InstCombine/apint-and2.ll b/llvm/test/Transforms/InstCombine/apint-and2.ll
index 427c9e63d7c..8a76eae3001 100644
--- a/llvm/test/Transforms/InstCombine/apint-and2.ll
+++ b/llvm/test/Transforms/InstCombine/apint-and2.ll
@@ -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
diff --git a/llvm/test/Transforms/InstCombine/demorgan.ll b/llvm/test/Transforms/InstCombine/demorgan.ll
index 30413ce521f..d2aeb9c957a 100644
--- a/llvm/test/Transforms/InstCombine/demorgan.ll
+++ b/llvm/test/Transforms/InstCombine/demorgan.ll
@@ -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) {
OpenPOWER on IntegriCloud