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 fdiv |
| 7 | |
| 8 | @X = constant i212 42 |
| 9 | @Y = constant [2 x { i212, float }] [ { i212, float } { i212 12, float 1.0 }, |
| 10 | { i212, float } { i212 37, float 1.2312 } ] |
| 11 | define i212 @test1() { |
| 12 | %B = load i212* @X |
| 13 | ret i212 %B |
| 14 | } |
| 15 | |
| 16 | define internal float @test2() { |
| 17 | %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 1, i32 1 |
| 18 | %B = load float* %A |
| 19 | ret float %B |
| 20 | } |
| 21 | |
| 22 | define internal i212 @test3() { |
| 23 | %A = getelementptr [2 x { i212, float}]* @Y, i32 0, i32 0, i32 0 |
| 24 | %B = load i212* %A |
| 25 | ret i212 %B |
| 26 | } |
| 27 | |
| 28 | define float @All() |
| 29 | { |
| 30 | %A = call float @test2() |
| 31 | %B = call i212 @test3() |
| 32 | %C = mul i212 %B, -1234567 |
| 33 | %D = sitofp i212 %C to float |
| 34 | %E = fdiv float %A, %D |
| 35 | ret float %E |
| 36 | } |
| 37 | |
| 38 | |