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"
4 ; This test case documents how runtime loop unrolling handles the case
5 ; when the backedge-count is -1.
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.
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
19 ; CHECK: while.body.prol:
20 ; CHECK: br label %entry.split
24 ; Function Attrs: nounwind readnone ssp uwtable
25 define i32 @foo(i32 %N) {
29 while.body: ; preds = %while.body, %entry
30 %i = phi i32 [ 0, %entry ], [ %inc, %while.body ]
31 %cmp = icmp eq i32 %i, %N
33 br i1 %cmp, label %while.end, label %while.body
35 while.end: ; preds = %while.body