Matthijs Kooijman | be4fc9b | 2008-09-29 10:42:13 +0000 | [diff] [blame] | 1 | ; This testcase shows that scalarrepl is able to replace struct alloca's which |
| 2 | ; are directly loaded from or stored to (using the first class aggregates |
| 3 | ; feature). |
Kenneth Uildriks | 90fedc6 | 2009-11-03 15:29:06 +0000 | [diff] [blame] | 4 | target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" |
Matthijs Kooijman | be4fc9b | 2008-09-29 10:42:13 +0000 | [diff] [blame] | 5 | |
Dan Gohman | 1880092 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 6 | ; RUN: opt < %s -scalarrepl -S > %t |
Matthijs Kooijman | be4fc9b | 2008-09-29 10:42:13 +0000 | [diff] [blame] | 7 | ; RUN: cat %t | not grep alloca |
| 8 | |
| 9 | %struct.foo = type { i32, i32 } |
| 10 | |
| 11 | define i32 @test(%struct.foo* %P) { |
| 12 | entry: |
| 13 | %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2] |
| 14 | %V = load %struct.foo* %P |
| 15 | store %struct.foo %V, %struct.foo* %L |
| 16 | |
| 17 | %tmp4 = getelementptr %struct.foo* %L, i32 0, i32 0 ; <i32*> [#uses=1] |
| 18 | %tmp5 = load i32* %tmp4 ; <i32> [#uses=1] |
| 19 | ret i32 %tmp5 |
| 20 | } |
| 21 | |
| 22 | define %struct.foo @test2(i32 %A, i32 %B) { |
| 23 | entry: |
| 24 | %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2] |
| 25 | %L.0 = getelementptr %struct.foo* %L, i32 0, i32 0 |
| 26 | store i32 %A, i32* %L.0 |
| 27 | %L.1 = getelementptr %struct.foo* %L, i32 0, i32 1 |
| 28 | store i32 %B, i32* %L.1 |
| 29 | %V = load %struct.foo* %L |
| 30 | ret %struct.foo %V |
| 31 | } |