blob: 7e7fb97871308363e283435116cb9c589cf4d072 [file] [log] [blame]
Dehao Chenc3f87f02017-01-17 23:39:33 +00001; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-partial-threshold=25 -unroll-runtime -unroll-runtime-epilog=true -unroll-count=8 | FileCheck %s -check-prefix=EPILOG
2; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-partial-threshold=25 -unroll-runtime -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
Andrew Trickd04d15292011-12-09 06:19:40 +00003
Chandler Carruthce40fa12017-01-25 02:49:01 +00004; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop(unroll)' -unroll-threshold=25 -unroll-partial-threshold=25 -unroll-runtime -unroll-runtime-epilog=true -unroll-count=8 | FileCheck %s -check-prefix=EPILOG
5; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop(unroll)' -unroll-threshold=25 -unroll-partial-threshold=25 -unroll-runtime -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
6
Andrew Trickd04d15292011-12-09 06:19:40 +00007; Choose a smaller, power-of-two, unroll count if the loop is too large.
8; This test makes sure we're not unrolling 'odd' counts
9
David L Kreitzer188de5a2016-04-05 12:19:35 +000010; EPILOG: for.body:
11; EPILOG: br i1 %niter.ncmp.3, label %for.end.loopexit.unr-lcssa.loopexit{{.*}}, label %for.body
12; EPILOG-NOT: br i1 %niter.ncmp.4, label %for.end.loopexit.unr-lcssa.loopexit{{.*}}, label %for.body
13; EPILOG: for.body.epil:
14
15; PROLOG: for.body.prol:
16; PROLOG: for.body:
17; PROLOG: br i1 %exitcond.3, label %for.end.loopexit{{.*}}, label %for.body
18; PROLOG-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
Andrew Trickd04d15292011-12-09 06:19:40 +000019
20define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly {
21entry:
22 %cmp1 = icmp eq i32 %n, 0
23 br i1 %cmp1, label %for.end, label %for.body
24
25for.body: ; preds = %for.body, %entry
26 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
27 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +000028 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
David Blaikiea79ac142015-02-27 21:17:42 +000029 %0 = load i32, i32* %arrayidx, align 4
Andrew Trickd04d15292011-12-09 06:19:40 +000030 %add = add nsw i32 %0, %sum.02
31 %indvars.iv.next = add i64 %indvars.iv, 1
32 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
33 %exitcond = icmp eq i32 %lftr.wideiv, %n
34 br i1 %exitcond, label %for.end, label %for.body
35
36for.end: ; preds = %for.body, %entry
37 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
38 ret i32 %sum.0.lcssa
39}