blob: 7990b3158d6db61b0cc5e5d860edd70583ef474a [file] [log] [blame]
Matthijs Kooijmanbe4fc9b2008-09-29 10:42:13 +00001; 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).
4
Dan Gohman72a13d22009-09-08 22:34:10 +00005; RUN: opt %s -scalarrepl -S > %t
Matthijs Kooijmanbe4fc9b2008-09-29 10:42:13 +00006; RUN: cat %t | not grep alloca
7
8%struct.foo = type { i32, i32 }
9
10define i32 @test(%struct.foo* %P) {
11entry:
12 %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
13 %V = load %struct.foo* %P
14 store %struct.foo %V, %struct.foo* %L
15
16 %tmp4 = getelementptr %struct.foo* %L, i32 0, i32 0 ; <i32*> [#uses=1]
17 %tmp5 = load i32* %tmp4 ; <i32> [#uses=1]
18 ret i32 %tmp5
19}
20
21define %struct.foo @test2(i32 %A, i32 %B) {
22entry:
23 %L = alloca %struct.foo, align 8 ; <%struct.foo*> [#uses=2]
24 %L.0 = getelementptr %struct.foo* %L, i32 0, i32 0
25 store i32 %A, i32* %L.0
26 %L.1 = getelementptr %struct.foo* %L, i32 0, i32 1
27 store i32 %B, i32* %L.1
28 %V = load %struct.foo* %L
29 ret %struct.foo %V
30}