blob: 29924138762fc4e142b298f98e587d65b3d0fc46 [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -scalarrepl -S | not grep alloca
Chris Lattner71c75342009-01-07 08:11:13 +00002; PR3290
Kenneth Uildriksa092c122009-11-03 15:29:06 +00003target 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"
Chris Lattner71c75342009-01-07 08:11:13 +00004
5;; Store of integer to whole alloca struct.
6define i32 @test1(i64 %V) nounwind {
7 %X = alloca {{i32, i32}}
8 %Y = bitcast {{i32,i32}}* %X to i64*
9 store i64 %V, i64* %Y
10
11 %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
12 %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1
13 %a = load i32* %A
14 %b = load i32* %B
15 %c = add i32 %a, %b
16 ret i32 %c
17}
18
19;; Store of integer to whole struct/array alloca.
20define float @test2(i128 %V) nounwind {
21 %X = alloca {[4 x float]}
22 %Y = bitcast {[4 x float]}* %X to i128*
23 store i128 %V, i128* %Y
24
25 %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
26 %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
27 %a = load float* %A
28 %b = load float* %B
Dan Gohman7ce405e2009-06-04 22:49:04 +000029 %c = fadd float %a, %b
Chris Lattner71c75342009-01-07 08:11:13 +000030 ret float %c
31}
32
Chris Lattner28401db2009-01-08 05:42:05 +000033;; Load of whole alloca struct as integer
34define i64 @test3(i32 %a, i32 %b) nounwind {
35 %X = alloca {{i32, i32}}
36
37 %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
38 %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1
39 store i32 %a, i32* %A
40 store i32 %b, i32* %B
41
42 %Y = bitcast {{i32,i32}}* %X to i64*
43 %Z = load i64* %Y
44 ret i64 %Z
45}
46
47;; load of integer from whole struct/array alloca.
48define i128 @test4(float %a, float %b) nounwind {
49 %X = alloca {[4 x float]}
50 %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
51 %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
52 store float %a, float* %A
53 store float %b, float* %B
54
55 %Y = bitcast {[4 x float]}* %X to i128*
56 %V = load i128* %Y
57 ret i128 %V
58}