Home | History | Annotate | Download | only in LoopUnroll
      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 
      4 ; This test case documents how runtime loop unrolling handles the case
      5 ; when the backedge-count is -1.
      6 
      7 ; If %N, the backedge-taken count, is -1 then %0 unsigned-overflows
      8 ; and is 0.  %xtraiter too is 0, signifying that the total trip-count
      9 ; is divisible by 2.  The prologue then branches to the unrolled loop
     10 ; and executes the 2^32 iterations there, in groups of 2.
     11 
     12 
     13 ; CHECK: entry:
     14 ; CHECK-NEXT: %0 = add i32 %N, 1
     15 ; CHECK-NEXT: %xtraiter = and i32 %0, 1
     16 ; CHECK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
     17 ; CHECK-NEXT: br i1 %lcmp.mod, label %while.body.prol, label %entry.split
     18 
     19 ; CHECK: while.body.prol:
     20 ; CHECK: br label %entry.split
     21 
     22 ; CHECK: entry.split:
     23 
     24 ; Function Attrs: nounwind readnone ssp uwtable
     25 define i32 @foo(i32 %N) {
     26 entry:
     27   br label %while.body
     28 
     29 while.body:                                       ; preds = %while.body, %entry
     30   %i = phi i32 [ 0, %entry ], [ %inc, %while.body ]
     31   %cmp = icmp eq i32 %i, %N
     32   %inc = add i32 %i, 1
     33   br i1 %cmp, label %while.end, label %while.body
     34 
     35 while.end:                                        ; preds = %while.body
     36   ret i32 %i
     37 }
     38