1 ; RUN: opt < %s -S -O2 -unroll-runtime=true -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
2 ; RUN: opt < %s -S -O2 -unroll-runtime=true -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
4 ; Check runtime unrolling prologue can be promoted by LICM pass.
10 ; EPILOG: br i1 %lcmp.mod
17 ; PROLOG: br i1 %lcmp.mod
20 define void @unroll(i32 %iter, i32* %addr1, i32* %addr2) nounwind {
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
31 %e = icmp uge i32 %iter, 1
32 br i1 %e, label %loop2, label %exit2
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
46 %inc1 = add i32 %iv1, 1
47 %exitcnd1 = icmp uge i32 %inc1, 1024
48 br i1 %exitcnd1, label %exit, label %loop1