summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-04-02 20:23:54 +0000
committerSanjay Patel <spatel@rotateright.com>2018-04-02 20:23:54 +0000
commitbe0442eeaaefbce1e3ed1f0f1af5b7044544b99f (patch)
tree875b074aef2c68d0fda7e9cac1c7db8fb63238e6 /llvm/test/Transforms
parent399d96e39c64f1fd3a00b78886a02abe58cdb36f (diff)
downloadbcm5719-llvm-be0442eeaaefbce1e3ed1f0f1af5b7044544b99f.tar.gz
bcm5719-llvm-be0442eeaaefbce1e3ed1f0f1af5b7044544b99f.zip
[InstCombine] add tests for icmp (sub x, y), x (PR36969); NFC
llvm-svn: 329010
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/icmp.ll30
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(
OpenPOWER on IntegriCloud