Devang Patel | edea5b3 | 2007-08-25 00:56:38 +0000 | [diff] [blame] | 1 | ; Split loop. Save last value. Split value is off by one in this example. |
Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -loop-index-split -disable-output -stats |& \ |
Devang Patel | edea5b3 | 2007-08-25 00:56:38 +0000 | [diff] [blame] | 3 | ; RUN: grep "loop-index-split" | count 1 |
| 4 | |
| 5 | @k = external global i32 ; <i32*> [#uses=2] |
| 6 | |
| 7 | define void @foobar(i32 %a, i32 %b) { |
| 8 | entry: |
| 9 | br label %bb |
| 10 | |
| 11 | bb: ; preds = %cond_next16, %entry |
| 12 | %i.01.0 = phi i32 [ 0, %entry ], [ %tmp18, %cond_next16 ] ; <i32> [#uses=5] |
| 13 | %tsum.18.0 = phi i32 [ 42, %entry ], [ %tsum.013.1, %cond_next16 ] ; <i32> [#uses=3] |
| 14 | %tmp1 = icmp sgt i32 %i.01.0, 50 ; <i1> [#uses=1] |
| 15 | br i1 %tmp1, label %cond_true, label %cond_false |
| 16 | |
| 17 | cond_true: ; preds = %bb |
| 18 | %tmp4 = tail call i32 @foo( i32 %i.01.0 ) ; <i32> [#uses=1] |
| 19 | %tmp6 = add i32 %tmp4, %tsum.18.0 ; <i32> [#uses=2] |
| 20 | %tmp914 = load i32* @k, align 4 ; <i32> [#uses=1] |
| 21 | %tmp1015 = icmp eq i32 %tmp914, 0 ; <i1> [#uses=1] |
| 22 | br i1 %tmp1015, label %cond_next16, label %cond_true13 |
| 23 | |
| 24 | cond_false: ; preds = %bb |
| 25 | %tmp8 = tail call i32 @bar( i32 %i.01.0 ) ; <i32> [#uses=0] |
| 26 | %tmp9 = load i32* @k, align 4 ; <i32> [#uses=1] |
| 27 | %tmp10 = icmp eq i32 %tmp9, 0 ; <i1> [#uses=1] |
| 28 | br i1 %tmp10, label %cond_next16, label %cond_true13 |
| 29 | |
| 30 | cond_true13: ; preds = %cond_false, %cond_true |
| 31 | %tsum.013.0 = phi i32 [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ] ; <i32> [#uses=1] |
| 32 | %tmp15 = tail call i32 @bar( i32 %i.01.0 ) ; <i32> [#uses=0] |
| 33 | br label %cond_next16 |
| 34 | |
| 35 | cond_next16: ; preds = %cond_false, %cond_true, %cond_true13 |
| 36 | %tsum.013.1 = phi i32 [ %tsum.013.0, %cond_true13 ], [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ] ; <i32> [#uses=2] |
| 37 | %tmp18 = add i32 %i.01.0, 1 ; <i32> [#uses=3] |
| 38 | %tmp21 = icmp slt i32 %tmp18, 100 ; <i1> [#uses=1] |
| 39 | br i1 %tmp21, label %bb, label %bb24 |
| 40 | |
| 41 | bb24: ; preds = %cond_next16 |
| 42 | %tmp18.lcssa = phi i32 [ %tmp18, %cond_next16 ] ; <i32> [#uses=1] |
| 43 | %tsum.013.1.lcssa = phi i32 [ %tsum.013.1, %cond_next16 ] ; <i32> [#uses=1] |
| 44 | %tmp27 = tail call i32 @t( i32 %tmp18.lcssa, i32 %tsum.013.1.lcssa ) ; <i32> [#uses=0] |
| 45 | ret void |
| 46 | } |
| 47 | |
| 48 | declare i32 @foo(i32) |
| 49 | |
| 50 | declare i32 @bar(i32) |
| 51 | |
| 52 | declare i32 @t(i32, i32) |