tripcount-overflow.ll 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. ; This test case documents how runtime loop unrolling handles the case
  4. ; when the backedge-count is -1.
  5. ; If %N, the backedge-taken count, is -1 then %0 unsigned-overflows
  6. ; and is 0. %xtraiter too is 0, signifying that the total trip-count
  7. ; is divisible by 2. The prologue then branches to the unrolled loop
  8. ; and executes the 2^32 iterations there, in groups of 2.
  9. ; CHECK: entry:
  10. ; CHECK-NEXT: %0 = add i32 %N, 1
  11. ; CHECK-NEXT: %xtraiter = and i32 %0, 1
  12. ; CHECK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
  13. ; CHECK-NEXT: br i1 %lcmp.mod, label %while.body.prol, label %entry.split
  14. ; CHECK: while.body.prol:
  15. ; CHECK: br label %entry.split
  16. ; CHECK: entry.split:
  17. ; Function Attrs: nounwind readnone ssp uwtable
  18. define i32 @foo(i32 %N) {
  19. entry:
  20. br label %while.body
  21. while.body: ; preds = %while.body, %entry
  22. %i = phi i32 [ 0, %entry ], [ %inc, %while.body ]
  23. %cmp = icmp eq i32 %i, %N
  24. %inc = add i32 %i, 1
  25. br i1 %cmp, label %while.end, label %while.body
  26. while.end: ; preds = %while.body
  27. ret i32 %i
  28. }