1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -jump-threading < %s | FileCheck %s
4 define i8 @test(i32 %a, i32 %length) {
7 ; CHECK-NEXT: br label [[BACKEDGE:%.*]]
9 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE]] ]
10 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i32 [[IV]], 1
11 ; CHECK-NEXT: [[CONT:%.*]] = icmp slt i32 [[IV_NEXT]], 400
12 ; CHECK-NEXT: br i1 [[CONT]], label [[BACKEDGE]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: ret i8 0
20 %iv = phi i32 [0, %entry], [%iv.next, %backedge]
21 ;; We can use an inductive argument to prove %iv is always positive
22 %cnd = icmp sge i32 %iv, 0
23 br i1 %cnd, label %backedge, label %exit
26 %iv.next = add nsw i32 %iv, 1
27 %cont = icmp slt i32 %iv.next, 400
28 br i1 %cont, label %loop, label %exit