| 1 |
; RUN: opt < %s -S -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -passes=loop-unroll -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG |
| 2 |
; RUN: opt < %s -S -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -passes=loop-unroll -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG |
| 3 |
|
| 4 |
define i32 @test(ptr nocapture %a, i32 %n) nounwind uwtable readonly { |
| 5 |
entry: |
| 6 |
%cmp1 = icmp eq i32 %n, 0 |
| 7 |
br i1 %cmp1, label %for.end, label %for.body |
| 8 |
|
| 9 |
for.body: ; preds = %for.body, %entry |
| 10 |
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] |
| 11 |
%sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ] |
| 12 |
%arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv |
| 13 |
%0 = load i32, ptr %arrayidx, align 4 |
| 14 |
%add = add nsw i32 %0, %sum.02 |
| 15 |
%indvars.iv.next = add i64 %indvars.iv, 1 |
| 16 |
%lftr.wideiv = trunc i64 %indvars.iv.next to i32 |
| 17 |
%exitcond = icmp eq i32 %lftr.wideiv, %n |
| 18 |
br i1 %exitcond, label %for.end, label %for.body |
| 19 |
|
| 20 |
for.end: ; preds = %for.body, %entry |
| 21 |
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ] |
| 22 |
ret i32 %sum.0.lcssa |
| 23 |
} |
| 24 |
|
| 25 |
; EPILOG-LABEL: @test |
| 26 |
; EPILOG: for.body: |
| 27 |
; EPILOG: br i1 %niter.ncmp.7, label %for.end.loopexit{{.*}}, label %for.body |
| 28 |
; EPILOG: for.body.epil{{.*}}: |
| 29 |
|
| 30 |
; PROLOG-LABEL: @test |
| 31 |
; PROLOG: for.body.prol{{.*}}: |
| 32 |
; PROLOG: for.body: |
| 33 |
; PROLOG: br i1 %exitcond.7, label %for.end.loopexit{{.*}}, label %for.body |
| 34 |
|