1cee313d2SEric Christopher; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-a57 -unroll-runtime-epilog=true  | FileCheck %s -check-prefix=EPILOG
2cee313d2SEric Christopher; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-a57 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
3*2b6e0c90SNicholas Guy; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-r82 -unroll-runtime-epilog=true  | FileCheck %s -check-prefix=EPILOG
4*2b6e0c90SNicholas Guy; RUN: opt < %s -S -loop-unroll -mtriple aarch64 -mcpu=cortex-r82 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
5cee313d2SEric Christopher
6cee313d2SEric Christopher; Tests for unrolling loops with run-time trip counts
7cee313d2SEric Christopher
8cee313d2SEric Christopher; EPILOG:  %xtraiter = and i32 %n
9cee313d2SEric Christopher; EPILOG:  for.body:
10cee313d2SEric Christopher; EPILOG:  %lcmp.mod = icmp ne i32 %xtraiter, 0
11cee313d2SEric Christopher; EPILOG:  br i1 %lcmp.mod, label %for.body.epil.preheader, label %for.end.loopexit
12cee313d2SEric Christopher; EPILOG:  for.body.epil:
13cee313d2SEric Christopher
14cee313d2SEric Christopher; PROLOG:  %xtraiter = and i32 %n
15cee313d2SEric Christopher; PROLOG:  %lcmp.mod = icmp ne i32 %xtraiter, 0
16cee313d2SEric Christopher; PROLOG:  br i1 %lcmp.mod, label %for.body.prol.preheader, label %for.body.prol.loopexit
17cee313d2SEric Christopher; PROLOG:  for.body.prol:
18cee313d2SEric Christopher; PROLOG:  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}
40cee313d2SEric Christopher
41cee313d2SEric Christopher
42