llvm.org GIT mirror llvm / 9a2f931
Build the correct range for loops with unusual bounds. Fix from Jay Foad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42394 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 13 years ago
2 changed file(s) with 22 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
24692469 APInt End = A.sge(One) ? (Range.getUpper() - One) : Range.getLower();
24702470
24712471 // The exit value should be (End+A)/A.
2472 APInt ExitVal = (End + A).sdiv(A);
2472 APInt ExitVal = (End + A).udiv(A);
24732473 ConstantInt *ExitValue = ConstantInt::get(ExitVal);
24742474
24752475 // Evaluate at the exit value. If we really did fall out of the valid
0 ; RUN: llvm-as < %s | opt -analyze -scalar-evolution 2>&1 | grep "13 iterations"
1 ; PR1706
2
3 define i32 @f() {
4 entry:
5 br label %bb5
6
7 bb: ; preds = %bb5
8 %tmp2 = shl i32 %j.0, 1 ; [#uses=1]
9 %tmp4 = add i32 %i.0, 268435456 ; [#uses=1]
10 br label %bb5
11
12 bb5: ; preds = %bb, %entry
13 %j.0 = phi i32 [ 1, %entry ], [ %tmp2, %bb ] ; [#uses=2]
14 %i.0 = phi i32 [ -1879048192, %entry ], [ %tmp4, %bb ] ; [#uses=2]
15 %tmp7 = icmp slt i32 %i.0, 1610612736 ; [#uses=1]
16 br i1 %tmp7, label %bb, label %return
17
18 return: ; preds = %bb5
19 ret i32 %j.0
20 }