From 8e3a89da1950286da87106f61ed78166e5dbb0de Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 1 May 2017 14:10:59 +0000 Subject: [PATCH] [InstCombine] consolidate more DeMorgan tests; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301800 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/and.ll | 13 ------ test/Transforms/InstCombine/apint-and1.ll | 8 ---- test/Transforms/InstCombine/apint-and2.ll | 8 ---- test/Transforms/InstCombine/demorgan.ll | 56 +++++++++++++++++++++++ 4 files changed, 56 insertions(+), 29 deletions(-) diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll index a2715c12fa8..8ef7870891f 100644 --- a/test/Transforms/InstCombine/and.ll +++ b/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/test/Transforms/InstCombine/apint-and1.ll b/test/Transforms/InstCombine/apint-and1.ll index 495e687ae4c..08e9fc25e86 100644 --- a/test/Transforms/InstCombine/apint-and1.ll +++ b/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/test/Transforms/InstCombine/apint-and2.ll b/test/Transforms/InstCombine/apint-and2.ll index 427c9e63d7c..8a76eae3001 100644 --- a/test/Transforms/InstCombine/apint-and2.ll +++ b/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/test/Transforms/InstCombine/demorgan.ll b/test/Transforms/InstCombine/demorgan.ll index 30413ce521f..d2aeb9c957a 100644 --- a/test/Transforms/InstCombine/demorgan.ll +++ b/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) { -- 2.50.1