summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/min-positive.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/InstCombine/min-positive.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/min-positive.ll34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/min-positive.ll b/llvm/test/Transforms/InstCombine/min-positive.ll
new file mode 100644
index 00000000000..9bbdb2944a3
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/min-positive.ll
@@ -0,0 +1,34 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+
+@g = external global i32
+
+define i1 @test(i32 %other) {
+; CHECK-LABEL: @test
+; CHECK: %test = icmp sgt i32 %other, 0
+ %positive = load i32, i32* @g, !range !{i32 1, i32 2048}
+ %cmp = icmp slt i32 %positive, %other
+ %sel = select i1 %cmp, i32 %positive, i32 %other
+ %test = icmp sgt i32 %sel, 0
+ ret i1 %test
+}
+
+define i1 @test2(i32 %other) {
+; CHECK-LABEL: @test2
+; CHECK: %test = icmp sgt i32 %other, 0
+ %positive = load i32, i32* @g, !range !{i32 1, i32 2048}
+ %cmp = icmp slt i32 %other, %positive
+ %sel = select i1 %cmp, i32 %other, i32 %positive
+ %test = icmp sgt i32 %sel, 0
+ ret i1 %test
+}
+
+; %positive might be zero
+define i1 @test3(i32 %other) {
+; CHECK-LABEL: @test3
+; CHECK: %test = icmp sgt i32 %sel, 0
+ %positive = load i32, i32* @g, !range !{i32 0, i32 2048}
+ %cmp = icmp slt i32 %positive, %other
+ %sel = select i1 %cmp, i32 %positive, i32 %other
+ %test = icmp sgt i32 %sel, 0
+ ret i1 %test
+}
OpenPOWER on IntegriCloud