ephemeral.ll 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ; RUN: opt < %s -S -loop-unroll -unroll-threshold=50 | FileCheck %s
  2. ; Make sure this loop is completely unrolled...
  3. ; CHECK-LABEL: @test1
  4. ; CHECK: for.body:
  5. ; CHECK-NOT: for.end:
  6. define i32 @test1(i32* nocapture %a) nounwind uwtable readonly {
  7. entry:
  8. br label %for.body
  9. for.body: ; preds = %for.body, %entry
  10. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  11. %sum.01 = phi i32 [ 0, %entry ], [ %add, %for.body ]
  12. %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
  13. %0 = load i32, i32* %arrayidx, align 4
  14. ; This loop will be completely unrolled, even with these extra instructions,
  15. ; but only because they're ephemeral (and, thus, free).
  16. %1 = add nsw i32 %0, 2
  17. %2 = add nsw i32 %1, 4
  18. %3 = add nsw i32 %2, 4
  19. %4 = add nsw i32 %3, 4
  20. %5 = add nsw i32 %4, 4
  21. %6 = add nsw i32 %5, 4
  22. %7 = add nsw i32 %6, 4
  23. %8 = add nsw i32 %7, 4
  24. %9 = add nsw i32 %8, 4
  25. %10 = add nsw i32 %9, 4
  26. %ca = icmp sgt i32 %10, -7
  27. call void @llvm.assume(i1 %ca)
  28. %add = add nsw i32 %0, %sum.01
  29. %indvars.iv.next = add i64 %indvars.iv, 1
  30. %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  31. %exitcond = icmp eq i32 %lftr.wideiv, 5
  32. br i1 %exitcond, label %for.end, label %for.body
  33. for.end: ; preds = %for.body
  34. ret i32 %add
  35. }
  36. declare void @llvm.assume(i1) nounwind