1 ; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll | FileCheck %s -check-prefix=EPILOG 2 ; RUN: opt < %s -S -unroll-runtime -unroll-count=2 -loop-unroll -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG 3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 5 ; This test case documents how runtime loop unrolling handles the case 6 ; when the backedge-count is -1. 7 8 ; If %N, the backedge-taken count, is -1 then %0 unsigned-overflows 9 ; and is 0. %xtraiter too is 0, signifying that the total trip-count 10 ; is divisible by 2. The prologue then branches to the unrolled loop 11 ; and executes the 2^32 iterations there, in groups of 2. 12 13 ; EPILOG: entry: 14 15 ; EPILOG-NEXT: %0 = add i32 %N, 1 16 ; EPILOG-NEXT: %xtraiter = and i32 %0, 1 17 ; EPILOG-NEXT: %1 = icmp ult i32 %N, 1 18 ; EPILOG-NEXT: br i1 %1, label %while.end.unr-lcssa, label %entry.new 19 ; EPILOG: while.body: 20 21 ; EPILOG: %lcmp.mod = icmp ne i32 %xtraiter, 0 22 ; EPILOG-NEXT: br i1 %lcmp.mod, label %while.body.epil.preheader, label %while.end 23 ; EPILOG: while.body.epil: 24 25 ; PROLOG: entry: 26 ; PROLOG-NEXT: %0 = add i32 %N, 1 27 ; PROLOG-NEXT: %xtraiter = and i32 %0, 1 28 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0 29 ; PROLOG-NEXT: br i1 %lcmp.mod, label %while.body.prol.preheader, label %while.body.prol.loopexit 30 ; PROLOG: while.body.prol: 31 32 ; PROLOG: %1 = icmp ult i32 %N, 1 33 ; PROLOG-NEXT: br i1 %1, label %while.end, label %entry.new 34 ; PROLOG: while.body: 35 36 ; Function Attrs: nounwind readnone ssp uwtable 37 define i32 @foo(i32 %N) { 38 entry: 39 br label %while.body 40 41 while.body: ; preds = %while.body, %entry 42 %i = phi i32 [ 0, %entry ], [ %inc, %while.body ] 43 %cmp = icmp eq i32 %i, %N 44 %inc = add i32 %i, 1 45 br i1 %cmp, label %while.end, label %while.body 46 47 while.end: ; preds = %while.body 48 ret i32 %i 49 } 50