forked from OSchip/llvm-project
[InstCombine] Add test cases for D51398
These tests contain the pattern (neg (max ~X, C)) which we should transform to ((min X, ~C) + 1) llvm-svn: 341023
This commit is contained in:
parent
b7b353be60
commit
f0531da109
|
@ -1056,3 +1056,96 @@ define <2 x i32> @test63vec(<2 x i32> %A) {
|
|||
%D = sub <2 x i32> <i32 2, i32 2>, %C
|
||||
ret <2 x i32> %D
|
||||
}
|
||||
|
||||
; FIXME: Transform (neg (max ~X, C)) -> ((min X, ~C) + 1). Same for min.
|
||||
define i32 @test64(i32 %x) {
|
||||
; CHECK-LABEL: @test64(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -256
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 [[TMP1]], i32 -256
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub i32 0, [[TMP3]]
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
%1 = xor i32 %x, -1
|
||||
%2 = icmp sgt i32 %1, -256
|
||||
%3 = select i1 %2, i32 %1, i32 -256
|
||||
%res = sub i32 0, %3
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @test65(i32 %x) {
|
||||
; CHECK-LABEL: @test65(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 255
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 [[TMP1]], i32 255
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub i32 0, [[TMP3]]
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
%1 = xor i32 %x, -1
|
||||
%2 = icmp slt i32 %1, 255
|
||||
%3 = select i1 %2, i32 %1, i32 255
|
||||
%res = sub i32 0, %3
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @test66(i32 %x) {
|
||||
; CHECK-LABEL: @test66(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt i32 [[TMP1]], 100
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 [[TMP1]], i32 100
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub i32 0, [[TMP3]]
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
%1 = xor i32 %x, -1
|
||||
%2 = icmp ugt i32 %1, 100
|
||||
%3 = select i1 %2, i32 %1, i32 100
|
||||
%res = sub i32 0, %3
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
define i32 @test67(i32 %x) {
|
||||
; CHECK-LABEL: @test67(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 [[TMP1]], -101
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 [[TMP1]], i32 -101
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub i32 0, [[TMP3]]
|
||||
; CHECK-NEXT: ret i32 [[RES]]
|
||||
;
|
||||
%1 = xor i32 %x, -1
|
||||
%2 = icmp ult i32 %1, -101
|
||||
%3 = select i1 %2, i32 %1, i32 -101
|
||||
%res = sub i32 0, %3
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
; Check splat vectors too
|
||||
define <2 x i32> @test68(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @test68(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], <i32 -1, i32 -1>
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[TMP1]], <i32 -256, i32 -256>
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP1]], <2 x i32> <i32 -256, i32 -256>
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub <2 x i32> zeroinitializer, [[TMP3]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[RES]]
|
||||
;
|
||||
%1 = xor <2 x i32> %x, <i32 -1, i32 -1>
|
||||
%2 = icmp sgt <2 x i32> %1, <i32 -256, i32 -256>
|
||||
%3 = select <2 x i1> %2, <2 x i32> %1, <2 x i32> <i32 -256, i32 -256>
|
||||
%res = sub <2 x i32> zeroinitializer, %3
|
||||
ret <2 x i32> %res
|
||||
}
|
||||
|
||||
; And non-splat constant vectors.
|
||||
define <2 x i32> @test69(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @test69(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], <i32 -1, i32 -1>
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[TMP1]], <i32 -256, i32 -128>
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP1]], <2 x i32> <i32 -256, i32 -128>
|
||||
; CHECK-NEXT: [[RES:%.*]] = sub <2 x i32> zeroinitializer, [[TMP3]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[RES]]
|
||||
;
|
||||
%1 = xor <2 x i32> %x, <i32 -1, i32 -1>
|
||||
%2 = icmp sgt <2 x i32> %1, <i32 -256, i32 -128>
|
||||
%3 = select <2 x i1> %2, <2 x i32> %1, <2 x i32> <i32 -256, i32 -128>
|
||||
%res = sub <2 x i32> zeroinitializer, %3
|
||||
ret <2 x i32> %res
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue