1; RUN: opt < %s -S -O2 -unroll-runtime=true | FileCheck %s -check-prefix=EPILOG 2; RUN: opt < %s -S -O2 -unroll-runtime=true -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG 3 4; Check runtime unrolling prologue can be promoted by LICM pass. 5 6; EPILOG: entry: 7; EPILOG: %xtraiter 8; EPILOG: %lcmp.mod 9; EPILOG: loop1: 10; EPILOG: br i1 %lcmp.mod 11; EPILOG: loop2.epil: 12 13; PROLOG: entry: 14; PROLOG: %xtraiter 15; PROLOG: %lcmp.mod 16; PROLOG: loop1: 17; PROLOG: br i1 %lcmp.mod 18; PROLOG: loop2.prol: 19 20define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind { 21entry: 22 br label %loop1 23 24loop1: 25 %iv1 = phi i32 [ 0, %entry ], [ %inc1, %loop1.latch ] 26 %offset1 = getelementptr i32, i32* %addr1, i32 %iv1 27 store i32 %iv1, i32* %offset1, align 4 28 br label %loop2.header 29 30loop2.header: 31 %e = icmp uge i32 %iter, 1 32 br i1 %e, label %loop2, label %exit2 33 34loop2: 35 %iv2 = phi i32 [ 0, %loop2.header ], [ %inc2, %loop2 ] 36 %offset2 = getelementptr i32, i32* %addr2, i32 %iv2 37 store i32 %iv2, i32* %offset2, align 4 38 %inc2 = add i32 %iv2, 1 39 %exitcnd2 = icmp uge i32 %inc2, %iter 40 br i1 %exitcnd2, label %exit2, label %loop2 41 42exit2: 43 br label %loop1.latch 44 45loop1.latch: 46 %inc1 = add i32 %iv1, 1 47 %exitcnd1 = icmp uge i32 %inc1, 1024 48 br i1 %exitcnd1, label %exit, label %loop1 49 50exit: 51 ret void 52} 53