| Andrew Trick | 5b28cc8 | 2011-09-13 03:17:25 +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 |
| Chris Lattner | 3e53700 | 2003-10-12 22:26:42 +0000 | [diff] [blame] | 3 | ; induction variable in this testcase. |
| 4 | |
| Andrew Trick | 5b28cc8 | 2011-09-13 03:17:25 +0000 | [diff] [blame] | 5 | ; RUN: opt < %s -indvars -S | FileCheck %s |
| 6 | ; CHECK: Loop.backedge: |
| 7 | ; CHECK-NOT: br |
| 8 | ; CHECK: br label %Loop |
| Chris Lattner | 3e53700 | 2003-10-12 22:26:42 +0000 | [diff] [blame] | 9 | |
| Tanya Lattner | 8bf97c2 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 10 | define i32 @test(i1 %C) { |
| 11 | ; <label>:0 |
| Chris Lattner | 3e53700 | 2003-10-12 22:26:42 +0000 | [diff] [blame] | 12 | br label %Loop |
| Tanya Lattner | 8bf97c2 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 13 | Loop: ; preds = %BE2, %BE1, %0 |
| Dan Gohman | ed7f3a0 | 2009-04-28 22:05:13 +0000 | [diff] [blame] | 14 | %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2] |
| 15 | store i32 %IV, i32* null |
| Tanya Lattner | 8bf97c2 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 16 | %IV2 = add i32 %IV, 2 ; <i32> [#uses=2] |
| 17 | br i1 %C, label %BE1, label %BE2 |
| 18 | BE1: ; preds = %Loop |
| Chris Lattner | 3e53700 | 2003-10-12 22:26:42 +0000 | [diff] [blame] | 19 | br label %Loop |
| Tanya Lattner | 8bf97c2 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 20 | BE2: ; preds = %Loop |
| Chris Lattner | 3e53700 | 2003-10-12 22:26:42 +0000 | [diff] [blame] | 21 | br label %Loop |
| 22 | } |
| Tanya Lattner | 8bf97c2 | 2008-03-25 04:26:08 +0000 | [diff] [blame] | 23 | |