• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-count=8 | FileCheck %s  -check-prefix=EPILOG
2; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
3
4; Choose a smaller, power-of-two, unroll count if the loop is too large.
5; This test makes sure we're not unrolling 'odd' counts
6
7; EPILOG: for.body:
8; EPILOG: br i1 %niter.ncmp.3, label %for.end.loopexit.unr-lcssa.loopexit{{.*}}, label %for.body
9; EPILOG-NOT: br i1 %niter.ncmp.4, label %for.end.loopexit.unr-lcssa.loopexit{{.*}}, label %for.body
10; EPILOG: for.body.epil:
11
12; PROLOG: for.body.prol:
13; PROLOG: for.body:
14; PROLOG: br i1 %exitcond.3, label %for.end.loopexit{{.*}}, label %for.body
15; PROLOG-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
16
17define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly {
18entry:
19  %cmp1 = icmp eq i32 %n, 0
20  br i1 %cmp1, label %for.end, label %for.body
21
22for.body:                                         ; preds = %for.body, %entry
23  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
24  %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
25  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
26  %0 = load i32, i32* %arrayidx, align 4
27  %add = add nsw i32 %0, %sum.02
28  %indvars.iv.next = add i64 %indvars.iv, 1
29  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
30  %exitcond = icmp eq i32 %lftr.wideiv, %n
31  br i1 %exitcond, label %for.end, label %for.body
32
33for.end:                                          ; preds = %for.body, %entry
34  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
35  ret i32 %sum.0.lcssa
36}
37