[InstCombine] Precommit new and-xor-or.ll tests. NFC.

This commit is contained in:
Stanislav Mekhanoshin 2021-10-26 12:57:17 -07:00
parent 9daec09551
commit 4faf88cc14
1 changed files with 119 additions and 0 deletions

View File

@ -812,6 +812,125 @@ define i32 @or_not_and_commute4(i32 %a, i32 %b, i32 %c0) {
ret i32 %or3
}
define i32 @or_not_and_commute5(i32 %a0, i32 %b, i32 %c0) {
; CHECK-LABEL: @or_not_and_commute5(
; CHECK-NEXT: [[A:%.*]] = sdiv i32 42, [[A0:%.*]]
; CHECK-NEXT: [[C:%.*]] = sdiv i32 42, [[C0:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[A]], [[B:%.*]]
; CHECK-NEXT: [[NOT1:%.*]] = xor i32 [[OR1]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[C]], [[NOT1]]
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[A]], [[C]]
; CHECK-NEXT: [[NOT2:%.*]] = xor i32 [[OR2]], -1
; CHECK-NEXT: [[AND2:%.*]] = and i32 [[NOT2]], [[B]]
; CHECK-NEXT: [[OR3:%.*]] = or i32 [[AND1]], [[AND2]]
; CHECK-NEXT: ret i32 [[OR3]]
;
%a = sdiv i32 42, %a0 ; thwart complexity-based canonicalization
%c = sdiv i32 42, %c0 ; thwart complexity-based canonicalization
%or1 = or i32 %a, %b
%not1 = xor i32 %or1, -1
%and1 = and i32 %c, %not1
%or2 = or i32 %a, %c
%not2 = xor i32 %or2, -1
%and2 = and i32 %not2, %b
%or3 = or i32 %and1, %and2
ret i32 %or3
}
define i32 @or_not_and_commute6(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: @or_not_and_commute6(
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[NOT1:%.*]] = xor i32 [[OR1]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NOT1]], [[C:%.*]]
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[C]], [[A]]
; CHECK-NEXT: [[NOT2:%.*]] = xor i32 [[OR2]], -1
; CHECK-NEXT: [[AND2:%.*]] = and i32 [[NOT2]], [[B]]
; CHECK-NEXT: [[OR3:%.*]] = or i32 [[AND1]], [[AND2]]
; CHECK-NEXT: ret i32 [[OR3]]
;
%or1 = or i32 %a, %b
%not1 = xor i32 %or1, -1
%and1 = and i32 %not1, %c
%or2 = or i32 %c, %a
%not2 = xor i32 %or2, -1
%and2 = and i32 %not2, %b
%or3 = or i32 %and1, %and2
ret i32 %or3
}
define i32 @or_not_and_commute7(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: @or_not_and_commute7(
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
; CHECK-NEXT: [[NOT1:%.*]] = xor i32 [[OR1]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NOT1]], [[C:%.*]]
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[A]], [[C]]
; CHECK-NEXT: [[NOT2:%.*]] = xor i32 [[OR2]], -1
; CHECK-NEXT: [[AND2:%.*]] = and i32 [[NOT2]], [[B]]
; CHECK-NEXT: [[OR3:%.*]] = or i32 [[AND1]], [[AND2]]
; CHECK-NEXT: ret i32 [[OR3]]
;
%or1 = or i32 %b, %a
%not1 = xor i32 %or1, -1
%and1 = and i32 %not1, %c
%or2 = or i32 %a, %c
%not2 = xor i32 %or2, -1
%and2 = and i32 %not2, %b
%or3 = or i32 %and1, %and2
ret i32 %or3
}
define i32 @or_not_and_commute8(i32 %a0, i32 %b0, i32 %c) {
; CHECK-LABEL: @or_not_and_commute8(
; CHECK-NEXT: [[A:%.*]] = sdiv i32 42, [[A0:%.*]]
; CHECK-NEXT: [[B:%.*]] = sdiv i32 42, [[B0:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[A]], [[B]]
; CHECK-NEXT: [[NOT1:%.*]] = xor i32 [[OR1]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NOT1]], [[C:%.*]]
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[A]], [[C]]
; CHECK-NEXT: [[NOT2:%.*]] = xor i32 [[OR2]], -1
; CHECK-NEXT: [[AND2:%.*]] = and i32 [[B]], [[NOT2]]
; CHECK-NEXT: [[OR3:%.*]] = or i32 [[AND1]], [[AND2]]
; CHECK-NEXT: ret i32 [[OR3]]
;
%a = sdiv i32 42, %a0 ; thwart complexity-based canonicalization
%b = sdiv i32 42, %b0 ; thwart complexity-based canonicalization
%or1 = or i32 %a, %b
%not1 = xor i32 %or1, -1
%and1 = and i32 %not1, %c
%or2 = or i32 %c, %a
%not2 = xor i32 %or2, -1
%and2 = and i32 %b, %not2
%or3 = or i32 %and1, %and2
ret i32 %or3
}
define i32 @or_not_and_commute9(i32 %a0, i32 %b0, i32 %c0) {
; CHECK-LABEL: @or_not_and_commute9(
; CHECK-NEXT: [[A:%.*]] = sdiv i32 42, [[A0:%.*]]
; CHECK-NEXT: [[B:%.*]] = sdiv i32 42, [[B0:%.*]]
; CHECK-NEXT: [[C:%.*]] = sdiv i32 42, [[C0:%.*]]
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[A]], [[B]]
; CHECK-NEXT: [[NOT1:%.*]] = xor i32 [[OR1]], -1
; CHECK-NEXT: [[AND1:%.*]] = and i32 [[C]], [[NOT1]]
; CHECK-NEXT: [[OR2:%.*]] = or i32 [[A]], [[C]]
; CHECK-NEXT: [[NOT2:%.*]] = xor i32 [[OR2]], -1
; CHECK-NEXT: [[AND2:%.*]] = and i32 [[B]], [[NOT2]]
; CHECK-NEXT: [[OR3:%.*]] = or i32 [[AND1]], [[AND2]]
; CHECK-NEXT: ret i32 [[OR3]]
;
%a = sdiv i32 42, %a0 ; thwart complexity-based canonicalization
%b = sdiv i32 42, %b0 ; thwart complexity-based canonicalization
%c = sdiv i32 42, %c0 ; thwart complexity-based canonicalization
%or1 = or i32 %a, %b
%not1 = xor i32 %or1, -1
%and1 = and i32 %not1, %c
%or2 = or i32 %a, %c
%not2 = xor i32 %or2, -1
%and2 = and i32 %b, %not2
%or3 = or i32 %and1, %and2
ret i32 %or3
}
define i32 @or_not_and_extra_not_use1(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: @or_not_and_extra_not_use1(
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[A:%.*]], [[B:%.*]]