nsw-tripcount.ll 692 B

1234567891011121314151617181920212223242526272829303132
  1. ; RUN: opt -loop-unroll -S %s | FileCheck %s
  2. ; extern void f(int);
  3. ; void test1(int v) {
  4. ; for (int i=v; i<=v+1; ++i)
  5. ; f(i);
  6. ; }
  7. ;
  8. ; We can use the nsw information to see that the tripcount will be 2, so the
  9. ; loop should be unrolled as this is always beneficial
  10. declare void @f(i32)
  11. ; CHECK-LABEL: @test1
  12. define void @test1(i32 %v) {
  13. entry:
  14. %add = add nsw i32 %v, 1
  15. br label %for.body
  16. for.body:
  17. %i.04 = phi i32 [ %v, %entry ], [ %inc, %for.body ]
  18. tail call void @f(i32 %i.04)
  19. %inc = add nsw i32 %i.04, 1
  20. %cmp = icmp slt i32 %i.04, %add
  21. br i1 %cmp, label %for.body, label %for.end
  22. ; CHECK: call void @f
  23. ; CHECK-NOT: br i1
  24. ; CHECK: call void @f
  25. for.end:
  26. ret void
  27. }