Devang Patel | 5e98a99 | 2007-08-17 22:02:15 +0000 | [diff] [blame^] | 1 | ; Loop is elimianted |
| 2 | ; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \ |
| 3 | ; RUN: grep "loop-index-split" | count 1 |
| 4 | %struct.anon = type { i32 } |
| 5 | @S1 = external global i32 ; <i32*> [#uses=1] |
| 6 | @W1 = external global i32 ; <i32*> [#uses=1] |
| 7 | @Y = weak global [100 x %struct.anon] zeroinitializer, align 32 ; <[100 x %struct.anon]*> [#uses=1] |
| 8 | @ti = external global i32 ; <i32*> [#uses=1] |
| 9 | @T2 = external global [100 x [100 x i32]] ; <[100 x [100 x i32]]*> [#uses=1] |
| 10 | @d = external global i32 ; <i32*> [#uses=1] |
| 11 | @T1 = external global i32 ; <i32*> [#uses=2] |
| 12 | @N2 = external global i32 ; <i32*> [#uses=2] |
| 13 | |
| 14 | define void @foo() { |
| 15 | entry: |
| 16 | %tmp = load i32* @S1, align 4 ; <i32> [#uses=2] |
| 17 | %tmp266 = load i32* @N2, align 4 ; <i32> [#uses=1] |
| 18 | %tmp288 = icmp ult i32 %tmp, %tmp266 ; <i1> [#uses=1] |
| 19 | br i1 %tmp288, label %bb.preheader, label %return |
| 20 | |
| 21 | bb.preheader: ; preds = %entry |
| 22 | %tmp1 = load i32* @W1, align 4 ; <i32> [#uses=1] |
| 23 | %tmp13 = load i32* @ti, align 4 ; <i32> [#uses=1] |
| 24 | %tmp18 = load i32* @d, align 4 ; <i32> [#uses=1] |
| 25 | %tmp26 = load i32* @N2, align 4 ; <i32> [#uses=1] |
| 26 | %T1.promoted = load i32* @T1 ; <i32> [#uses=1] |
| 27 | br label %bb |
| 28 | |
| 29 | bb: ; preds = %bb.preheader, %bb25 |
| 30 | %T1.tmp.1 = phi i32 [ %T1.promoted, %bb.preheader ], [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=3] |
| 31 | %tj.01.0 = phi i32 [ %tmp24, %bb25 ], [ %tmp, %bb.preheader ] ; <i32> [#uses=4] |
| 32 | %tmp3 = icmp eq i32 %tj.01.0, %tmp1 ; <i1> [#uses=1] |
| 33 | br i1 %tmp3, label %cond_true, label %bb25 |
| 34 | |
| 35 | cond_true: ; preds = %bb |
| 36 | %tmp7 = getelementptr [100 x %struct.anon]* @Y, i32 0, i32 %tj.01.0, i32 0 ; <i32*> [#uses=1] |
| 37 | %tmp8 = load i32* %tmp7, align 4 ; <i32> [#uses=1] |
| 38 | %tmp9 = icmp sgt i32 %tmp8, 0 ; <i1> [#uses=1] |
| 39 | br i1 %tmp9, label %cond_true12, label %bb25 |
| 40 | |
| 41 | cond_true12: ; preds = %cond_true |
| 42 | %tmp16 = getelementptr [100 x [100 x i32]]* @T2, i32 0, i32 %tmp13, i32 %tj.01.0 ; <i32*> [#uses=1] |
| 43 | %tmp17 = load i32* %tmp16, align 4 ; <i32> [#uses=1] |
| 44 | %tmp19 = mul i32 %tmp18, %tmp17 ; <i32> [#uses=1] |
| 45 | %tmp21 = add i32 %tmp19, %T1.tmp.1 ; <i32> [#uses=1] |
| 46 | br label %bb25 |
| 47 | |
| 48 | bb25: ; preds = %cond_true, %bb, %cond_true12 |
| 49 | %T1.tmp.0 = phi i32 [ %T1.tmp.1, %bb ], [ %T1.tmp.1, %cond_true ], [ %tmp21, %cond_true12 ] ; <i32> [#uses=2] |
| 50 | %tmp24 = add i32 %tj.01.0, 1 ; <i32> [#uses=2] |
| 51 | %tmp28 = icmp ult i32 %tmp24, %tmp26 ; <i1> [#uses=1] |
| 52 | br i1 %tmp28, label %bb, label %return.loopexit |
| 53 | |
| 54 | return.loopexit: ; preds = %bb25 |
| 55 | %T1.tmp.0.lcssa = phi i32 [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=1] |
| 56 | store i32 %T1.tmp.0.lcssa, i32* @T1 |
| 57 | br label %return |
| 58 | |
| 59 | return: ; preds = %return.loopexit, %entry |
| 60 | ret void |
| 61 | } |