runtime-loop2.ll 1.3 KB

123456789101112131415161718192021222324252627282930
  1. ; RUN: opt < %s -S -loop-unroll -unroll-threshold=25 -unroll-runtime -unroll-count=8 | FileCheck %s
  2. ; Choose a smaller, power-of-two, unroll count if the loop is too large.
  3. ; This test makes sure we're not unrolling 'odd' counts
  4. ; CHECK: for.body.prol:
  5. ; CHECK: for.body:
  6. ; CHECK: br i1 %exitcond.3, label %for.end.loopexit{{.*}}, label %for.body
  7. ; CHECK-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
  8. define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly {
  9. entry:
  10. %cmp1 = icmp eq i32 %n, 0
  11. br i1 %cmp1, label %for.end, label %for.body
  12. for.body: ; preds = %for.body, %entry
  13. %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
  14. %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
  15. %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
  16. %0 = load i32, i32* %arrayidx, align 4
  17. %add = add nsw i32 %0, %sum.02
  18. %indvars.iv.next = add i64 %indvars.iv, 1
  19. %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  20. %exitcond = icmp eq i32 %lftr.wideiv, %n
  21. br i1 %exitcond, label %for.end, label %for.body
  22. for.end: ; preds = %for.body, %entry
  23. %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
  24. ret i32 %sum.0.lcssa
  25. }