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