Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | ; edgefailure - This function illustrates how SCCP is not doing it's job. This |
| 2 | ; function should be optimized almost completely away: the loop should be |
| 3 | ; analyzed to detect that the body executes exactly once, and thus the branch |
| 4 | ; can be eliminated and code becomes trivially dead. This is distilled from a |
| 5 | ; real benchmark (mst from Olden benchmark, MakeGraph function). When SCCP is |
| 6 | ; fixed, this should be eliminated by a single SCCP application. |
| 7 | ; |
Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 8 | ; RUN: opt < %s -sccp -S | not grep loop |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 9 | |
Tanya Lattner | ba93e2d | 2008-03-19 04:14:49 +0000 | [diff] [blame] | 10 | define i32* @test() { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 11 | bb1: |
Tanya Lattner | ba93e2d | 2008-03-19 04:14:49 +0000 | [diff] [blame] | 12 | %A = malloc i32 ; <i32*> [#uses=2] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 13 | br label %bb2 |
Tanya Lattner | ba93e2d | 2008-03-19 04:14:49 +0000 | [diff] [blame] | 14 | bb2: ; preds = %bb2, %bb1 |
| 15 | ;; Always 0 |
| 16 | %i = phi i32 [ %i2, %bb2 ], [ 0, %bb1 ] ; <i32> [#uses=2] |
| 17 | ;; Always 1 |
| 18 | %i2 = add i32 %i, 1 ; <i32> [#uses=2] |
| 19 | store i32 %i, i32* %A |
| 20 | ;; Always false |
| 21 | %loop = icmp sle i32 %i2, 0 ; <i1> [#uses=1] |
| 22 | br i1 %loop, label %bb2, label %bb3 |
| 23 | bb3: ; preds = %bb2 |
| 24 | ret i32* %A |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 25 | } |
Tanya Lattner | ba93e2d | 2008-03-19 04:14:49 +0000 | [diff] [blame] | 26 | |