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