summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/JumpThreading/induction.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/JumpThreading/induction.ll')
-rw-r--r--llvm/test/Transforms/JumpThreading/induction.ll25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/test/Transforms/JumpThreading/induction.ll b/llvm/test/Transforms/JumpThreading/induction.ll
new file mode 100644
index 00000000000..714c28d1443
--- /dev/null
+++ b/llvm/test/Transforms/JumpThreading/induction.ll
@@ -0,0 +1,25 @@
+; RUN: opt -S -jump-threading < %s | FileCheck %s
+
+define i8 @test(i32 %a, i32 %length) {
+; CHECK-LABEL: @test
+entry:
+; CHECK: br label %backedge
+ br label %loop
+
+loop:
+; CHECK-LABEL: backedge:
+; CHECK: phi i32
+; CHECK: br i1 %cont, label %backedge, label %exit
+ %iv = phi i32 [0, %entry], [%iv.next, %backedge]
+ ;; We can use an inductive argument to prove %iv is always positive
+ %cnd = icmp sge i32 %iv, 0
+ br i1 %cnd, label %backedge, label %exit
+
+backedge:
+ %iv.next = add nsw i32 %iv, 1
+ %cont = icmp slt i32 %iv.next, 400
+ br i1 %cont, label %loop, label %exit
+exit:
+ ret i8 0
+}
+
OpenPOWER on IntegriCloud