1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -jump-threading < %s | FileCheck %s 3 4define i8 @test(i32 %a, i32 %length) { 5; CHECK-LABEL: @test( 6; CHECK-NEXT: entry: 7; CHECK-NEXT: br label [[BACKEDGE:%.*]] 8; CHECK: 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:%.*]] 13; CHECK: exit: 14; CHECK-NEXT: ret i8 0 15; 16entry: 17 br label %loop 18 19loop: 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 24 25backedge: 26 %iv.next = add nsw i32 %iv, 1 27 %cont = icmp slt i32 %iv.next, 400 28 br i1 %cont, label %loop, label %exit 29exit: 30 ret i8 0 31} 32 33