blob: 176362a344561ef0528ef75164152f1e7409945e [file] [log] [blame]
Hal Finkel38dd5902015-01-10 00:30:55 +00001; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-count=8 | FileCheck %s
Andrew Trickd04d15292011-12-09 06:19:40 +00002
3; Choose a smaller, power-of-two, unroll count if the loop is too large.
4; This test makes sure we're not unrolling 'odd' counts
5
Kevin Qinfc02e3c2014-09-29 11:15:00 +00006; CHECK: for.body.prol:
Andrew Trickd04d15292011-12-09 06:19:40 +00007; CHECK: for.body:
8; CHECK: br i1 %exitcond.3, label %for.end.loopexit{{.*}}, label %for.body
9; CHECK-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
10
11define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly {
12entry:
13 %cmp1 = icmp eq i32 %n, 0
14 br i1 %cmp1, label %for.end, label %for.body
15
16for.body: ; preds = %for.body, %entry
17 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
18 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
19 %arrayidx = getelementptr inbounds i32* %a, i64 %indvars.iv
20 %0 = load i32* %arrayidx, align 4
21 %add = add nsw i32 %0, %sum.02
22 %indvars.iv.next = add i64 %indvars.iv, 1
23 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
24 %exitcond = icmp eq i32 %lftr.wideiv, %n
25 br i1 %exitcond, label %for.end, label %for.body
26
27for.end: ; preds = %for.body, %entry
28 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
29 ret i32 %sum.0.lcssa
30}