blob: 26f007b3c05a58d1c764b6b50fcb1a247266bc1c [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
3
4;; Store of integer to whole alloca struct.
5define i32 @test1(i64 %V) nounwind {
6 %X = alloca {{i32, i32}}
7 %Y = bitcast {{i32,i32}}* %X to i64*
8 store i64 %V, i64* %Y
9
10 %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
11 %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1
12 %a = load i32* %A
13 %b = load i32* %B
14 %c = add i32 %a, %b
15 ret i32 %c
16}
17
18;; Store of integer to whole struct/array alloca.
19define float @test2(i128 %V) nounwind {
20 %X = alloca {[4 x float]}
21 %Y = bitcast {[4 x float]}* %X to i128*
22 store i128 %V, i128* %Y
23
24 %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
25 %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
26 %a = load float* %A
27 %b = load float* %B
Dan Gohman7ce405e2009-06-04 22:49:04 +000028 %c = fadd float %a, %b
Chris Lattner71c75342009-01-07 08:11:13 +000029 ret float %c
30}
31
Chris Lattner28401db2009-01-08 05:42:05 +000032;; Load of whole alloca struct as integer
33define i64 @test3(i32 %a, i32 %b) nounwind {
34 %X = alloca {{i32, i32}}
35
36 %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
37 %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1
38 store i32 %a, i32* %A
39 store i32 %b, i32* %B
40
41 %Y = bitcast {{i32,i32}}* %X to i64*
42 %Z = load i64* %Y
43 ret i64 %Z
44}
45
46;; load of integer from whole struct/array alloca.
47define i128 @test4(float %a, float %b) nounwind {
48 %X = alloca {[4 x float]}
49 %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
50 %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
51 store float %a, float* %A
52 store float %b, float* %B
53
54 %Y = bitcast {[4 x float]}* %X to i128*
55 %V = load i128* %Y
56 ret i128 %V
57}