Fix for PR2607: SCEV miscomputing the loop count for loops with an
[oota-llvm.git] / test / Analysis / ScalarEvolution / 2008-07-29-SGTTripCount.ll
1 ; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
2 ; RUN:   -scalar-evolution-max-iterations=0 | \
3 ; RUN: grep -F "( -1 + ( -1 *  %j)) iterations"
4 ; PR2607
5
6 define i32 @_Z1aj(i32 %j) nounwind  {
7 entry:
8         icmp sgt i32 0, %j              ; <i1>:0 [#uses=1]
9         br i1 %0, label %bb.preheader, label %return
10
11 bb.preheader:           ; preds = %entry
12         br label %bb
13
14 bb:             ; preds = %bb, %bb.preheader
15         %i.01 = phi i32 [ %1, %bb ], [ 0, %bb.preheader ]               ; <i32> [#uses=1]
16         add i32 %i.01, -1               ; <i32>:1 [#uses=3]
17         icmp sgt i32 %1, %j             ; <i1>:2 [#uses=1]
18         br i1 %2, label %bb, label %return.loopexit
19
20 return.loopexit:                ; preds = %bb
21         br label %return
22
23 return:         ; preds = %return.loopexit, %entry
24         %i.0.lcssa = phi i32 [ 0, %entry ], [ %1, %return.loopexit ]            ; <i32> [#uses=1]
25         ret i32 %i.0.lcssa
26 }
27