Reid Spencer | c6b9efa | 2007-04-13 22:33:10 +0000 | [diff] [blame^] | 1 | ; This test makes sure that these instructions are properly constant propagated. |
| 2 | ; |
| 3 | |
| 4 | ; RUN: llvm-as < %s | opt -ipsccp | llvm-dis -o /dev/null -f && |
| 5 | ; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep load |
| 6 | ; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep add |
| 7 | ; RUN: llvm-as < %s | opt -ipsccp | llvm-dis | not grep phi |
| 8 | |
| 9 | |
| 10 | @Y = constant [2 x { i212, float }] [ { i212, float } { i212 12, float 1.0 }, |
| 11 | { i212, float } { i212 37, float 2.0 } ] |
| 12 | |
| 13 | define internal float @test2() { |
| 14 | %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 1, i32 1 |
| 15 | %B = load float* %A |
| 16 | ret float %B |
| 17 | } |
| 18 | |
| 19 | define internal float @test3() { |
| 20 | %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 0, i32 1 |
| 21 | %B = load float* %A |
| 22 | ret float %B |
| 23 | } |
| 24 | |
| 25 | define internal float @test() |
| 26 | { |
| 27 | %A = call float @test2() |
| 28 | %B = call float @test3() |
| 29 | |
| 30 | %E = fdiv float %B, %A |
| 31 | ret float %E |
| 32 | } |
| 33 | |
| 34 | define float @All() |
| 35 | { |
| 36 | %A = call float @test() |
| 37 | %B = fcmp oge float %A, 1.0 |
| 38 | br i1 %B, label %T, label %F |
| 39 | T: |
| 40 | %C = add float %A, 1.0 |
| 41 | br label %exit |
| 42 | F: |
| 43 | %D = add float %A, 2.0 |
| 44 | br label %exit |
| 45 | exit: |
| 46 | %E = phi float [%C, %T], [%D, %F] |
| 47 | ret float %E |
| 48 | } |
| 49 | |
| 50 | |
| 51 | |