trip-count-switch.ll 817 B

123456789101112131415161718192021222324252627282930
  1. ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
  2. declare void @foo()
  3. define void @test1() nounwind {
  4. entry:
  5. br label %for.cond
  6. for.cond: ; preds = %if.end, %entry
  7. %i.0 = phi i32 [ 2, %entry ], [ %dec, %if.end ]
  8. switch i32 %i.0, label %if.end [
  9. i32 0, label %for.end
  10. i32 1, label %if.then
  11. ]
  12. if.then: ; preds = %for.cond
  13. tail call void @foo()
  14. br label %if.end
  15. if.end: ; preds = %for.cond, %if.then
  16. %dec = add nsw i32 %i.0, -1
  17. br label %for.cond
  18. for.end: ; preds = %for.cond
  19. ret void
  20. ; CHECK-LABEL: @test1
  21. ; CHECK: Loop %for.cond: backedge-taken count is 2
  22. ; CHECK: Loop %for.cond: max backedge-taken count is 2
  23. }