runtime-loop5.ll 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ; RUN: opt < %s -S -loop-unroll -unroll-runtime=true -unroll-count=16 | FileCheck --check-prefix=UNROLL-16 %s
  2. ; RUN: opt < %s -S -loop-unroll -unroll-runtime=true -unroll-count=4 | FileCheck --check-prefix=UNROLL-4 %s
  3. ; Given that the trip-count of this loop is a 3-bit value, we cannot
  4. ; safely unroll it with a count of anything more than 8.
  5. define i3 @test(i3* %a, i3 %n) {
  6. ; UNROLL-16-LABEL: @test(
  7. ; UNROLL-4-LABEL: @test(
  8. entry:
  9. %cmp1 = icmp eq i3 %n, 0
  10. br i1 %cmp1, label %for.end, label %for.body
  11. ; UNROLL-16-NOT: for.body.prol:
  12. ; UNROLL-4: for.body.prol:
  13. for.body: ; preds = %for.body, %entry
  14. ; UNROLL-16-LABEL: for.body:
  15. ; UNROLL-4-LABEL: for.body:
  16. %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
  17. %sum.02 = phi i3 [ %add, %for.body ], [ 0, %entry ]
  18. %arrayidx = getelementptr inbounds i3, i3* %a, i64 %indvars.iv
  19. ; UNROLL-16-LABEL: for.body
  20. ; UNROLL-16-LABEL: getelementptr
  21. ; UNROLL-16-LABEL-NOT: getelementptr
  22. ; UNROLL-4-LABEL: getelementptr
  23. ; UNROLL-4-LABEL: getelementptr
  24. ; UNROLL-4-LABEL: getelementptr
  25. ; UNROLL-4-LABEL: getelementptr
  26. %0 = load i3, i3* %arrayidx
  27. %add = add nsw i3 %0, %sum.02
  28. %indvars.iv.next = add i64 %indvars.iv, 1
  29. %lftr.wideiv = trunc i64 %indvars.iv.next to i3
  30. %exitcond = icmp eq i3 %lftr.wideiv, %n
  31. br i1 %exitcond, label %for.end, label %for.body
  32. ; UNROLL-16-LABEL: for.end
  33. ; UNROLL-4-LABEL: for.end
  34. for.end: ; preds = %for.body, %entry
  35. %sum.0.lcssa = phi i3 [ 0, %entry ], [ %add, %for.body ]
  36. ret i3 %sum.0.lcssa
  37. }