1 ; RUN: opt -irce-print-range-checks -irce-print-changed-loops -verify-loop-info -irce < %s 2>&1 | FileCheck %s
2 ; RUN: opt -irce-print-range-checks -irce-print-changed-loops -verify-loop-info -passes='require<branch-prob>,loop(irce)' < %s 2>&1 | FileCheck %s
4 ; CHECK: irce: loop has 1 inductive range checks:
5 ; CHECK-NEXT: InductiveRangeCheck:
6 ; CHECK-NEXT: Begin: (-1 + %n) Step: -1 End: 2147483647
7 ; CHECK-NEXT: CheckUse: br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1 Operand: 0
8 ; CHECK-NEXT: irce: in function only_lower_check: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
10 define void @only_lower_check(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
12 %len = load i32, i32* %a_len_ptr, !range !0
13 %first.itr.check = icmp sgt i32 %n, 0
14 %start = sub i32 %n, 1
15 br i1 %first.itr.check, label %loop, label %exit
18 %idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ]
19 %idx.dec = sub i32 %idx, 1
20 %abc = icmp sge i32 %idx, 0
21 br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
24 %addr = getelementptr i32, i32* %arr, i32 %idx
25 store i32 0, i32* %addr
26 %next = icmp sgt i32 %idx.dec, -1
27 br i1 %next, label %loop, label %exit
36 !0 = !{i32 0, i32 2147483647}
37 !1 = !{!"branch_weights", i32 64, i32 4}