forked from OSchip/llvm-project
[InstCombine] add tests for icmp (sub x, y), x (PR36969); NFC
llvm-svn: 329010
This commit is contained in:
parent
399d96e39c
commit
be0442eeaa
|
@ -545,6 +545,36 @@ define i1 @test36(i32 %x, i32 %y) {
|
||||||
ret i1 %c
|
ret i1 %c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR36969 - https://bugs.llvm.org/show_bug.cgi?id=36969
|
||||||
|
|
||||||
|
define i1 @ugt_sub(i32 %xsrc, i32 %y) {
|
||||||
|
; CHECK-LABEL: @ugt_sub(
|
||||||
|
; CHECK-NEXT: [[X:%.*]] = udiv i32 [[XSRC:%.*]], 42
|
||||||
|
; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[X]], [[Y:%.*]]
|
||||||
|
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[SUB]], [[X]]
|
||||||
|
; CHECK-NEXT: ret i1 [[CMP]]
|
||||||
|
;
|
||||||
|
%x = udiv i32 %xsrc, 42 ; thwart complexity-based canonicalization
|
||||||
|
%sub = sub i32 %x, %y
|
||||||
|
%cmp = icmp ugt i32 %sub, %x
|
||||||
|
ret i1 %cmp
|
||||||
|
}
|
||||||
|
|
||||||
|
; Swap operands and predicate. Try a vector type to verify that works too.
|
||||||
|
|
||||||
|
define <2 x i1> @ult_sub(<2 x i8> %xsrc, <2 x i8> %y) {
|
||||||
|
; CHECK-LABEL: @ult_sub(
|
||||||
|
; CHECK-NEXT: [[X:%.*]] = udiv <2 x i8> [[XSRC:%.*]], <i8 42, i8 -42>
|
||||||
|
; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[X]], [[Y:%.*]]
|
||||||
|
; CHECK-NEXT: [[CMP:%.*]] = icmp ult <2 x i8> [[X]], [[SUB]]
|
||||||
|
; CHECK-NEXT: ret <2 x i1> [[CMP]]
|
||||||
|
;
|
||||||
|
%x = udiv <2 x i8> %xsrc, <i8 42, i8 -42> ; thwart complexity-based canonicalization
|
||||||
|
%sub = sub <2 x i8> %x, %y
|
||||||
|
%cmp = icmp ult <2 x i8> %x, %sub
|
||||||
|
ret <2 x i1> %cmp
|
||||||
|
}
|
||||||
|
|
||||||
; X - Y > X - Z -> Z > Y if there is no overflow.
|
; X - Y > X - Z -> Z > Y if there is no overflow.
|
||||||
define i1 @test37(i32 %x, i32 %y, i32 %z) {
|
define i1 @test37(i32 %x, i32 %y, i32 %z) {
|
||||||
; CHECK-LABEL: @test37(
|
; CHECK-LABEL: @test37(
|
||||||
|
|
Loading…
Reference in New Issue