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

This commit is contained in:
Sanjay Patel 2020-06-03 08:00:35 -04:00
parent 82aac878be
commit a26cd73d33
2 changed files with 54 additions and 20 deletions

View File

@ -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:%.*]]

View File

@ -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
}