[InstCombine] consolidate more DeMorgan tests; NFC

llvm-svn: 301800
This commit is contained in:
Sanjay Patel 2017-05-01 14:10:59 +00:00
parent da4b52e4bf
commit 4e312203af
4 changed files with 56 additions and 29 deletions

View 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

View 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

View 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

View 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) {