Eric Christopher | cab9e7a | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; This test makes sure that these instructions are properly constant propagated. |
| 2 | |
Bjorn Pettersson | c6d9e3d | 2021-11-18 10:14:04 +0100 | [diff] [blame] | 3 | ; RUN: opt < %s -passes=ipsccp -S | not grep load |
| 4 | ; RUN: opt < %s -passes=ipsccp -S | not grep add |
| 5 | ; RUN: opt < %s -passes=ipsccp -S | not grep phi |
Eric Christopher | cab9e7a | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 6 | |
| 7 | |
| 8 | @Y = constant [2 x { i212, float }] [ { i212, float } { i212 12, float 1.0 }, |
| 9 | { i212, float } { i212 37, float 2.0 } ] |
| 10 | |
| 11 | define internal float @test2() { |
Nikita Popov | 78713ab | 2022-11-01 17:05:47 +0100 | [diff] [blame] | 12 | %A = getelementptr [2 x { i212, float}], ptr @Y, i32 0, i32 1, i32 1 |
| 13 | %B = load float, ptr %A |
Eric Christopher | cab9e7a | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 14 | ret float %B |
| 15 | } |
| 16 | |
| 17 | define internal float @test3() { |
Nikita Popov | 78713ab | 2022-11-01 17:05:47 +0100 | [diff] [blame] | 18 | %A = getelementptr [2 x { i212, float}], ptr @Y, i32 0, i32 0, i32 1 |
| 19 | %B = load float, ptr %A |
Eric Christopher | cab9e7a | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 20 | ret float %B |
| 21 | } |
| 22 | |
| 23 | define internal float @test() |
| 24 | { |
| 25 | %A = call float @test2() |
| 26 | %B = call float @test3() |
| 27 | |
| 28 | %E = fdiv float %B, %A |
| 29 | ret float %E |
| 30 | } |
| 31 | |
| 32 | define float @All() |
| 33 | { |
| 34 | %A = call float @test() |
| 35 | %B = fcmp oge float %A, 1.0 |
| 36 | br i1 %B, label %T, label %F |
| 37 | T: |
| 38 | %C = fadd float %A, 1.0 |
| 39 | br label %exit |
| 40 | F: |
| 41 | %D = fadd float %A, 2.0 |
| 42 | br label %exit |
| 43 | exit: |
| 44 | %E = phi float [%C, %T], [%D, %F] |
| 45 | ret float %E |
| 46 | } |
| 47 | |
| 48 | |
| 49 | |