1 ; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
2 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 ; CHECK: Determining loop execution counts for: @test
5 ; CHECK: Loop %for.body: backedge-taken count is ((-2 + %len) /u 2)
6 ; CHECK: Loop %for.body: max backedge-taken count is 1073741823
8 define zeroext i16 @test(i16* nocapture %p, i32 %len) nounwind readonly {
10 %cmp2 = icmp sgt i32 %len, 1
11 br i1 %cmp2, label %for.body.preheader, label %for.end
13 for.body.preheader: ; preds = %entry
16 for.body: ; preds = %for.body, %for.body.preheader
17 %p.addr.05 = phi i16* [ %incdec.ptr, %for.body ], [ %p, %for.body.preheader ]
18 %len.addr.04 = phi i32 [ %sub, %for.body ], [ %len, %for.body.preheader ]
19 %res.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
20 %incdec.ptr = getelementptr inbounds i16, i16* %p.addr.05, i32 1
21 %0 = load i16, i16* %p.addr.05, align 2
22 %conv = zext i16 %0 to i32
23 %add = add i32 %conv, %res.03
24 %sub = add nsw i32 %len.addr.04, -2
25 %cmp = icmp sgt i32 %sub, 1
26 br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
28 for.cond.for.end_crit_edge: ; preds = %for.body
29 %extract.t = trunc i32 %add to i16
32 for.end: ; preds = %for.cond.for.end_crit_edge, %entry
33 %res.0.lcssa.off0 = phi i16 [ %extract.t, %for.cond.for.end_crit_edge ], [ 0, %entry ]
34 ret i16 %res.0.lcssa.off0