1 ; Base should not be i*3, it should be i*2.
2 ; RUN: opt < %s -loop-reduce -S | \
3 ; RUN: not grep "mul.*%i, 3"
5 ; Indvar should not start at zero:
6 ; RUN: opt < %s -loop-reduce -S | \
7 ; RUN: not grep "phi i32 .* 0"
12 target datalayout = "e-p:32:32-n32"
13 target triple = "i686-apple-darwin8"
14 @flags2 = external global [8193 x i8], align 32 ; <ptr> [#uses=1]
16 define void @foo(i32 %k, i32 %i.s) {
18 %i = bitcast i32 %i.s to i32 ; <i32> [#uses=2]
19 %k_addr.012 = shl i32 %i.s, 1 ; <i32> [#uses=1]
20 %tmp14 = icmp sgt i32 %k_addr.012, 8192 ; <i1> [#uses=1]
21 br i1 %tmp14, label %return, label %bb.preheader
22 bb.preheader: ; preds = %entry
23 %tmp. = shl i32 %i, 1 ; <i32> [#uses=1]
25 bb: ; preds = %bb, %bb.preheader
26 %indvar = phi i32 [ %indvar.next, %bb ], [ 0, %bb.preheader ] ; <i32> [#uses=2]
27 %tmp.15 = mul i32 %indvar, %i ; <i32> [#uses=1]
28 %tmp.16 = add i32 %tmp.15, %tmp. ; <i32> [#uses=2]
29 %k_addr.0.0 = bitcast i32 %tmp.16 to i32 ; <i32> [#uses=1]
30 %gep.upgrd.1 = zext i32 %tmp.16 to i64 ; <i64> [#uses=1]
31 %tmp = getelementptr [8193 x i8], ptr @flags2, i32 0, i64 %gep.upgrd.1 ; <ptr> [#uses=1]
33 %k_addr.0 = add i32 %k_addr.0.0, %i.s ; <i32> [#uses=1]
34 %tmp.upgrd.2 = icmp sgt i32 %k_addr.0, 8192 ; <i1> [#uses=1]
35 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
36 br i1 %tmp.upgrd.2, label %return.loopexit, label %bb
37 return.loopexit: ; preds = %bb
39 return: ; preds = %return.loopexit, %entry