diff options
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index c67fd0aeb70..6e6a9135350 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -545,6 +545,36 @@ define i1 @test36(i32 %x, i32 %y) { 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. define i1 @test37(i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: @test37( |

