1; RUN: opt < %s -inline -S -enable-new-pm=0 | FileCheck %s
2
3target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
4target triple = "powerpc64-unknown-linux-gnu"
5
6%struct.s = type { i32, i32 }
7
8define void @foo(%struct.s* byval(%struct.s) nocapture readonly %a) {
9entry:
10  %x = alloca [2 x i32], align 4
11  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
12  %0 = load i32, i32* %a1, align 4
13  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
14  store i32 %0, i32* %arrayidx, align 4
15  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
16  %1 = load i32, i32* %b, align 4
17  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
18  store i32 %1, i32* %arrayidx2, align 4
19  call void @bar(i32* %arrayidx) #2
20  ret void
21}
22
23define void @foo0(%struct.s* byval(%struct.s) nocapture readonly %a) {
24entry:
25  %x = alloca [2 x i32]
26  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
27  %0 = load i32, i32* %a1, align 4
28  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
29  store i32 %0, i32* %arrayidx, align 4
30  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
31  %1 = load i32, i32* %b, align 4
32  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
33  store i32 %1, i32* %arrayidx2, align 4
34  call void @bar(i32* %arrayidx) #2
35  ret void
36}
37
38define void @foo1(%struct.s* byval(%struct.s) nocapture readonly %a) {
39entry:
40  %x = alloca [2 x i32], align 1
41  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
42  %0 = load i32, i32* %a1, align 4
43  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
44  store i32 %0, i32* %arrayidx, align 4
45  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
46  %1 = load i32, i32* %b, align 4
47  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
48  store i32 %1, i32* %arrayidx2, align 4
49  call void @bar(i32* %arrayidx) #2
50  ret void
51}
52
53declare void @bar(i32*) #1
54
55define void @goo(%struct.s* byval(%struct.s) nocapture readonly %a) {
56entry:
57  %x = alloca [2 x i32], align 32
58  %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
59  %0 = load i32, i32* %a1, align 4
60  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
61  store i32 %0, i32* %arrayidx, align 32
62  %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
63  %1 = load i32, i32* %b, align 4
64  %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
65  store i32 %1, i32* %arrayidx2, align 4
66  call void @bar(i32* %arrayidx) #2
67  ret void
68}
69
70; CHECK-LABEL: @main
71; CHECK: alloca [2 x i32], align 32
72; CHECK-NOT: alloca [2 x i32]
73; CHECK: ret i32 0
74
75define signext i32 @main() {
76entry:
77  %a = alloca i64, align 8
78  %tmpcast = bitcast i64* %a to %struct.s*
79  store i64 0, i64* %a, align 8
80  %a1 = bitcast i64* %a to i32*
81  store i32 1, i32* %a1, align 8
82  call void @foo(%struct.s* byval(%struct.s) %tmpcast)
83  store i32 2, i32* %a1, align 8
84  call void @goo(%struct.s* byval(%struct.s) %tmpcast)
85  ret i32 0
86}
87
88; CHECK-LABEL: @test0
89; CHECK: alloca [2 x i32], align 32
90; CHECK-NOT: alloca [2 x i32]
91; CHECK: ret i32 0
92
93define signext i32 @test0() {
94entry:
95  %a = alloca i64, align 8
96  %tmpcast = bitcast i64* %a to %struct.s*
97  store i64 0, i64* %a, align 8
98  %a1 = bitcast i64* %a to i32*
99  store i32 1, i32* %a1, align 8
100  call void @foo0(%struct.s* byval(%struct.s) %tmpcast)
101  store i32 2, i32* %a1, align 8
102  call void @goo(%struct.s* byval(%struct.s) %tmpcast)
103  ret i32 0
104}
105