Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | ; The loop canonicalization pass should guarantee that there is one backedge |
| 2 | ; for all loops. This allows the -indvars pass to recognize the %IV |
| 3 | ; induction variable in this testcase. |
| 4 | |
Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 5 | ; RUN: opt < %s -indvars -S | grep indvar |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 6 | |
Tanya Lattner | 348c618 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 7 | define i32 @test(i1 %C) { |
| 8 | ; <label>:0 |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 9 | br label %Loop |
Tanya Lattner | 348c618 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 10 | Loop: ; preds = %BE2, %BE1, %0 |
Dan Gohman | 5983efa | 2009-04-28 22:05:13 +0000 | [diff] [blame] | 11 | %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2] |
| 12 | store i32 %IV, i32* null |
Tanya Lattner | 348c618 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 13 | %IV2 = add i32 %IV, 2 ; <i32> [#uses=2] |
| 14 | br i1 %C, label %BE1, label %BE2 |
| 15 | BE1: ; preds = %Loop |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 16 | br label %Loop |
Tanya Lattner | 348c618 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 17 | BE2: ; preds = %Loop |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 18 | br label %Loop |
| 19 | } |
Tanya Lattner | 348c618 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 20 | |