mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
[InstCombine] update tests for logic folds to exercise commuted patterns; NFC
This was the intent for D88551. I also varied the types a bit for extra coverage and tried to make better test/value names.
This commit is contained in:
parent
23c4b1ff43
commit
885b6533d2
@ -1172,76 +1172,70 @@ define i8 @not_ashr_wrong_const(i8 %x) {
|
||||
ret i8 %r
|
||||
}
|
||||
|
||||
; (~A & B) ^ A --> (A | B)
|
||||
; The division ops are here to thwart complexity-based canonicalization: all ops are binops.
|
||||
; (~A & B) ^ A --> A | B
|
||||
|
||||
define i32 @test52(i32 %p1, i32 %p2) {
|
||||
; CHECK-LABEL: @test52(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
|
||||
; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[A]]
|
||||
; CHECK-NEXT: ret i32 [[Z]]
|
||||
define <2 x i32> @xor_andn_commute1(<2 x i32> %a, <2 x i32> %b) {
|
||||
; CHECK-LABEL: @xor_andn_commute1(
|
||||
; CHECK-NEXT: [[NOTA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
|
||||
; CHECK-NEXT: [[R:%.*]] = and <2 x i32> [[NOTA]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor <2 x i32> [[R]], [[A]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[Z]]
|
||||
;
|
||||
%a = udiv i32 42, %p1
|
||||
%b = udiv i32 42, %p2
|
||||
%o = xor i32 %a, -1
|
||||
%r = and i32 %o, %b
|
||||
%z = xor i32 %r, %a
|
||||
ret i32 %z
|
||||
%nota = xor <2 x i32> %a, <i32 -1, i32 -1>
|
||||
%r = and <2 x i32> %nota, %b
|
||||
%z = xor <2 x i32> %r, %a
|
||||
ret <2 x i32> %z
|
||||
}
|
||||
|
||||
; (~B & A) ^ B --> (A | B)
|
||||
; The division ops are here to thwart complexity-based canonicalization: all ops are binops.
|
||||
; (B & ~A) ^ A --> A | B
|
||||
|
||||
define i32 @test53(i32 %p1, i32 %p2) {
|
||||
; CHECK-LABEL: @test53(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
|
||||
; CHECK-NEXT: [[O:%.*]] = xor i32 [[B]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[A]], [[O]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[B]]
|
||||
; CHECK-NEXT: ret i32 [[Z]]
|
||||
define i33 @xor_andn_commute2(i33 %a, i33 %pb) {
|
||||
; CHECK-LABEL: @xor_andn_commute2(
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i33 42, [[PB:%.*]]
|
||||
; CHECK-NEXT: [[NOTA:%.*]] = xor i33 [[A:%.*]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i33 [[B]], [[NOTA]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i33 [[R]], [[A]]
|
||||
; CHECK-NEXT: ret i33 [[Z]]
|
||||
;
|
||||
%a = udiv i32 42, %p1
|
||||
%b = udiv i32 42, %p2
|
||||
%o = xor i32 %b, -1
|
||||
%r = and i32 %o, %a
|
||||
%z = xor i32 %r, %b
|
||||
ret i32 %z
|
||||
%b = udiv i33 42, %pb ; thwart complexity-based canonicalization
|
||||
%nota = xor i33 %a, -1
|
||||
%r = and i33 %b, %nota
|
||||
%z = xor i33 %r, %a
|
||||
ret i33 %z
|
||||
}
|
||||
|
||||
define i32 @test54(i32 %p1, i32 %p2) {
|
||||
; CHECK-LABEL: @test54(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
|
||||
; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[R]], [[A]]
|
||||
; CHECK-NEXT: ret i32 [[Z]]
|
||||
;
|
||||
%a = udiv i32 42, %p1
|
||||
%b = udiv i32 42, %p2
|
||||
%o = xor i32 %a, -1
|
||||
%r = and i32 %b, %o
|
||||
%z = xor i32 %r, %a
|
||||
ret i32 %z
|
||||
}
|
||||
; A ^ (~A & B) --> A | B
|
||||
|
||||
define i32 @test55(i32 %p1, i32 %p2) {
|
||||
; CHECK-LABEL: @test55(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[P1:%.*]]
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[P2:%.*]]
|
||||
; CHECK-NEXT: [[O:%.*]] = xor i32 [[A]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[O]]
|
||||
define i32 @xor_andn_commute3(i32 %pa, i32 %b) {
|
||||
; CHECK-LABEL: @xor_andn_commute3(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[PA:%.*]]
|
||||
; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[NOTA]], [[B:%.*]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[A]], [[R]]
|
||||
; CHECK-NEXT: ret i32 [[Z]]
|
||||
;
|
||||
%a = udiv i32 42, %p1
|
||||
%b = udiv i32 42, %p2
|
||||
%o = xor i32 %a, -1
|
||||
%r = and i32 %o, %b
|
||||
%a = udiv i32 42, %pa ; thwart complexity-based canonicalization
|
||||
%nota = xor i32 %a, -1
|
||||
%r = and i32 %nota, %b
|
||||
%z = xor i32 %a, %r
|
||||
ret i32 %z
|
||||
}
|
||||
|
||||
; A ^ (B & ~A) --> A | B
|
||||
|
||||
define i32 @xor_andn_commute4(i32 %pa, i32 %pb) {
|
||||
; CHECK-LABEL: @xor_andn_commute4(
|
||||
; CHECK-NEXT: [[A:%.*]] = udiv i32 42, [[PA:%.*]]
|
||||
; CHECK-NEXT: [[B:%.*]] = udiv i32 42, [[PB:%.*]]
|
||||
; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
|
||||
; CHECK-NEXT: [[R:%.*]] = and i32 [[B]], [[NOTA]]
|
||||
; CHECK-NEXT: [[Z:%.*]] = xor i32 [[A]], [[R]]
|
||||
; CHECK-NEXT: ret i32 [[Z]]
|
||||
;
|
||||
%a = udiv i32 42, %pa ; thwart complexity-based canonicalization
|
||||
%b = udiv i32 42, %pb ; thwart complexity-based canonicalization
|
||||
%nota = xor i32 %a, -1
|
||||
%r = and i32 %b, %nota
|
||||
%z = xor i32 %a, %r
|
||||
ret i32 %z
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user