blob: 70b94f7b69a09020fbedd57e6b5376954acfbd84 [file] [log] [blame]
Hal Finkel9caa8f72013-07-16 17:10:55 +00001; RUN: opt < %s -inline -S | 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 nocapture readonly %a) {
9entry:
10 %x = alloca [2 x i32], align 4
David Blaikie79e6c742015-02-27 19:29:02 +000011 %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000012 %0 = load i32, i32* %a1, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000013 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
Manman Ren1047fe42013-09-30 18:17:35 +000014 store i32 %0, i32* %arrayidx, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000015 %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000016 %1 = load i32, i32* %b, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000017 %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
Manman Ren1047fe42013-09-30 18:17:35 +000018 store i32 %1, i32* %arrayidx2, align 4
Hal Finkel9caa8f72013-07-16 17:10:55 +000019 call void @bar(i32* %arrayidx) #2
20 ret void
21}
22
23define void @foo0(%struct.s* byval nocapture readonly %a) {
24entry:
25 %x = alloca [2 x i32]
David Blaikie79e6c742015-02-27 19:29:02 +000026 %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000027 %0 = load i32, i32* %a1, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000028 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
Manman Ren1047fe42013-09-30 18:17:35 +000029 store i32 %0, i32* %arrayidx, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000030 %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000031 %1 = load i32, i32* %b, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000032 %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
Manman Ren1047fe42013-09-30 18:17:35 +000033 store i32 %1, i32* %arrayidx2, align 4
Hal Finkel9caa8f72013-07-16 17:10:55 +000034 call void @bar(i32* %arrayidx) #2
35 ret void
36}
37
Hal Finkelec7cd262013-07-17 14:32:41 +000038define void @foo1(%struct.s* byval nocapture readonly %a) {
39entry:
40 %x = alloca [2 x i32], align 1
David Blaikie79e6c742015-02-27 19:29:02 +000041 %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000042 %0 = load i32, i32* %a1, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000043 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
Manman Ren1047fe42013-09-30 18:17:35 +000044 store i32 %0, i32* %arrayidx, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000045 %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000046 %1 = load i32, i32* %b, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000047 %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
Manman Ren1047fe42013-09-30 18:17:35 +000048 store i32 %1, i32* %arrayidx2, align 4
Hal Finkelec7cd262013-07-17 14:32:41 +000049 call void @bar(i32* %arrayidx) #2
50 ret void
51}
52
Hal Finkel9caa8f72013-07-16 17:10:55 +000053declare void @bar(i32*) #1
54
55define void @goo(%struct.s* byval nocapture readonly %a) {
56entry:
57 %x = alloca [2 x i32], align 32
David Blaikie79e6c742015-02-27 19:29:02 +000058 %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000059 %0 = load i32, i32* %a1, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000060 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0
Manman Ren1047fe42013-09-30 18:17:35 +000061 store i32 %0, i32* %arrayidx, align 32
David Blaikie79e6c742015-02-27 19:29:02 +000062 %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000063 %1 = load i32, i32* %b, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000064 %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1
Manman Ren1047fe42013-09-30 18:17:35 +000065 store i32 %1, i32* %arrayidx2, align 4
Hal Finkel9caa8f72013-07-16 17:10:55 +000066 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*
Manman Ren1047fe42013-09-30 18:17:35 +000081 store i32 1, i32* %a1, align 8
Hal Finkel9caa8f72013-07-16 17:10:55 +000082 call void @foo(%struct.s* byval %tmpcast)
Manman Ren1047fe42013-09-30 18:17:35 +000083 store i32 2, i32* %a1, align 8
Hal Finkel9caa8f72013-07-16 17:10:55 +000084 call void @goo(%struct.s* byval %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*
Manman Ren1047fe42013-09-30 18:17:35 +000099 store i32 1, i32* %a1, align 8
Hal Finkel9caa8f72013-07-16 17:10:55 +0000100 call void @foo0(%struct.s* byval %tmpcast)
Manman Ren1047fe42013-09-30 18:17:35 +0000101 store i32 2, i32* %a1, align 8
Hal Finkel9caa8f72013-07-16 17:10:55 +0000102 call void @goo(%struct.s* byval %tmpcast)
103 ret i32 0
104}