Revamp the loop unroller, extending it to correctly update PHI nodes
[oota-llvm.git] / test / Transforms / LoopUnroll / pr2253.ll
1 ; RUN: llvm-as < %s | opt -loop-unroll -unroll-count 2 | llvm-dis | grep add | count 2
2 ; PR2253
3
4 ; There's a use outside the loop, and the PHI needs an incoming edge for
5 ; each unrolled iteration, since the trip count is unknown and any iteration
6 ; could exit.
7
8 define i32 @fib(i32 %n) nounwind {
9 entry:
10         br i1 false, label %bb, label %return
11
12 bb:
13         %t0 = phi i32 [ 0, %entry ], [ %t1, %bb ]
14         %t1 = add i32 %t0, 1
15         %c = icmp ne i32 %t0, %n
16         br i1 %c, label %bb, label %return
17
18 return:
19         %f2.0.lcssa = phi i32 [ -1, %entry ], [ %t0, %bb ]
20         ret i32 %f2.0.lcssa
21 }