blob: c5008ac1312fea5fe0eb4defcd0b88a16a4bb186 [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).
Kenneth Uildriks90fedc62009-11-03 15:29:06 +00004target 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 Kooijmanbe4fc9b2008-09-29 10:42:13 +00005
Dan Gohman18800922009-09-11 18:01:28 +00006; RUN: opt < %s -scalarrepl -S > %t
Matthijs Kooijmanbe4fc9b2008-09-29 10:42:13 +00007; RUN: cat %t | not grep alloca
8
9%struct.foo = type { i32, i32 }
10
11define i32 @test(%struct.foo* %P) {
12entry:
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
22define %struct.foo @test2(i32 %A, i32 %B) {
23entry:
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}