1 ; RUN: opt -indvars -S < %s | FileCheck %s 2 3 define void @infer_via_ranges(i32 *%arr, i32 %n) { 4 ; CHECK-LABEL: @infer_via_ranges 5 entry: 6 %first.itr.check = icmp sgt i32 %n, 0 7 %start = sub i32 %n, 1 8 br i1 %first.itr.check, label %loop, label %exit 9 10 loop: 11 ; CHECK-LABEL: loop: 12 %idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ] 13 %idx.dec = sub i32 %idx, 1 14 %abc = icmp sge i32 %idx, 0 15 ; CHECK: br i1 true, label %in.bounds, label %out.of.bounds 16 br i1 %abc, label %in.bounds, label %out.of.bounds 17 18 in.bounds: 19 ; CHECK-LABEL: in.bounds: 20 %addr = getelementptr i32, i32* %arr, i32 %idx 21 store i32 0, i32* %addr 22 %next = icmp sgt i32 %idx.dec, -1 23 br i1 %next, label %loop, label %exit 24 25 out.of.bounds: 26 ret void 27 28 exit: 29 ret void 30 } 31