blob: 3a48ffdda9ed22deb0b0adc6cc268903ae866e3b [file] [log] [blame]
Matt Arsenault607a7562017-11-28 23:40:12 +00001; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +00003
4%struct.ByValStruct = type { [4 x i32] }
5
6; GCN-LABEL: {{^}}void_func_byval_struct:
7; GCN: s_mov_b32 s5, s32
Matt Arsenaultd1867c02017-08-02 00:59:51 +00008; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:4{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +00009; GCN-NOT: s32
Matt Arsenaultd1867c02017-08-02 00:59:51 +000010; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s5 offset:4{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000011; GCN-NOT: s32
12
Matt Arsenaultd1867c02017-08-02 00:59:51 +000013; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:20{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000014; GCN-NOT: s32
Matt Arsenaultd1867c02017-08-02 00:59:51 +000015; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s5 offset:20{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000016; GCN-NOT: s32
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000017define void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg0, %struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg1) #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000018entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000019 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
20 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000021 %add = add nsw i32 %tmp, 1
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000022 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
23 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
24 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000025 %add3 = add nsw i32 %tmp1, 2
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000026 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000027 store volatile i32 9, i32 addrspace(1)* null, align 4
28 ret void
29}
30
31; GCN-LABEL: {{^}}void_func_byval_struct_non_leaf:
32; GCN: s_mov_b32 s5, s32
Matt Arsenault8e8f8f42017-08-02 01:52:45 +000033; GCN-DAG: buffer_store_dword v32
34; GCN-DAG: buffer_store_dword v33
Matt Arsenaultecb43ef2017-09-13 23:47:01 +000035; GCN-NOT: v_writelane_b32 v{{[0-9]+}}, s32
Tim Renouf2a99fa22018-02-28 19:10:32 +000036; GCN-DAG: v_writelane_b32
Matt Arsenaultffb132e2018-03-29 20:22:04 +000037; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultd1867c02017-08-02 00:59:51 +000038; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:4{{$}}
Tim Renouf2a99fa22018-02-28 19:10:32 +000039; GCN-DAG: v_add_{{[iu]}}32_e32 [[ADD0:v[0-9]+]], vcc, 1, [[LOAD0]]
40; GCN-DAG: buffer_store_dword [[ADD0]], off, s[0:3], s5 offset:4{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000041
Tim Renouf2a99fa22018-02-28 19:10:32 +000042; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:20{{$}}
43; GCN-DAG: v_add_{{[iu]}}32_e32 [[ADD1:v[0-9]+]], vcc, 2, [[LOAD1]]
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000044
45; GCN: s_swappc_b64
46
Matt Arsenaultd1867c02017-08-02 00:59:51 +000047; GCN: buffer_store_dword [[ADD1]], off, s[0:3], s5 offset:20{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000048
49; GCN: v_readlane_b32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +000050; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultdcdf3dd2018-11-26 17:17:07 +000051; GCN-DAG: buffer_load_dword v32,
52; GCN-DAG: buffer_load_dword v33,
Matt Arsenaultffb132e2018-03-29 20:22:04 +000053; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000054; GCN: s_setpc_b64
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000055define void @void_func_byval_struct_non_leaf(%struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg0, %struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg1) #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000056entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000057 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
58 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000059 %add = add nsw i32 %tmp, 1
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000060 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
61 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
62 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000063 %add3 = add nsw i32 %tmp1, 2
64 call void @external_void_func_void()
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000065 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000066 store volatile i32 9, i32 addrspace(1)* null, align 4
67 ret void
68}
69
70; GCN-LABEL: {{^}}call_void_func_byval_struct_func:
71; GCN: s_mov_b32 s5, s32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +000072; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
73; GCN-DAG: v_writelane_b32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000074
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000075; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
76; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
77
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000078; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s5 offset:8
79; GCN-DAG: buffer_store_dword [[THIRTEEN]], off, s[0:3], s5 offset:24
80
Matt Arsenaultf4320112018-09-24 13:18:15 +000081; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:24
82; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:28
83; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:32
84; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:36
85
86; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:20
87; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:24
88; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:28
89; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:32
90
Tim Renouf2a99fa22018-02-28 19:10:32 +000091; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8
92; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:12
93; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:16
94; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:20
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000095
Matt Arsenaultdefe3712017-09-14 17:37:40 +000096; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000097
Matt Arsenaultd1867c02017-08-02 00:59:51 +000098; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:4{{$}}
99; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:8
100; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:12
101; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:16
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000102
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000103
104; GCN: s_swappc_b64
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000105; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000106; GCN: v_readlane_b32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000107; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000108
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000109; GCN-NOT: s_sub_u32 s32, s32, 0x800
110
111; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000112; GCN-NEXT: s_waitcnt
113; GCN-NEXT: s_setpc_b64
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000114define void @call_void_func_byval_struct_func() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000115entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000116 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
117 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
118 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
119 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
120 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
121 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
122 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
123 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
124 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
125 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
126 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
127 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
128 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000129 ret void
130}
131
132; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel:
Geoff Berry4e38e022017-08-17 04:04:11 +0000133; GCN: s_mov_b32 s33, s7
Matt Arsenaultffb132e2018-03-29 20:22:04 +0000134; GCN: s_add_u32 s32, s33, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000135
136; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
137; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
Geoff Berry4e38e022017-08-17 04:04:11 +0000138; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
139; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000140
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000141; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000142
Geoff Berry4e38e022017-08-17 04:04:11 +0000143; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
144; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
145; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
146; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000147
Matt Arsenaultd1867c02017-08-02 00:59:51 +0000148; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:4{{$}}
149; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:8
150; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:12
151; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:16
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000152
Matt Arsenaultacc5e822017-08-02 00:43:42 +0000153; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
154; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
155; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
156; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000157
Matt Arsenaultd1867c02017-08-02 00:59:51 +0000158; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:20
159; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:24
160; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:28
161; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000162
163
164; GCN: s_swappc_b64
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000165; GCN-NOT: s_sub_u32 s32
166; GCN: s_endpgm
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000167define amdgpu_kernel void @call_void_func_byval_struct_kernel() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000168entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000169 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
170 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
171 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
172 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
173 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
174 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
175 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
176 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
177 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
178 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
179 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
180 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
181 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000182 ret void
183}
184
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000185; GCN-LABEL: {{^}}void_func_byval_struct_align8:
186; GCN: s_mov_b32 s5, s32
187; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8{{$}}
188; GCN-NOT: s32
189; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s5 offset:8{{$}}
190; GCN-NOT: s32
191
192; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:24{{$}}
193; GCN-NOT: s32
194; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s5 offset:24{{$}}
195; GCN-NOT: s32
196define void @void_func_byval_struct_align8(%struct.ByValStruct addrspace(5)* byval noalias nocapture align 8 %arg0, %struct.ByValStruct addrspace(5)* byval noalias nocapture align 8 %arg1) #1 {
197entry:
198 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
199 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 8
200 %add = add nsw i32 %tmp, 1
201 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 8
202 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
203 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 8
204 %add3 = add nsw i32 %tmp1, 2
205 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 8
206 store volatile i32 9, i32 addrspace(1)* null, align 4
207 ret void
208}
209
210; Make sure the byval alignment is respected in the call frame setup
211; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_kernel:
212; GCN: s_mov_b32 s33, s7
213; GCN: s_add_u32 s32, s33, 0xc00{{$}}
214
215; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
216; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
217; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
218; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
219
220; GCN-NOT: s_add_u32 s32, s32, 0x800
221
222; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
223; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
224; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
225; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
226
227; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:8{{$}}
228; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:12
229; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:16
230; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:20
231
232; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
233; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
234; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
235; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
236
237; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:24
238; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:28
239; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:32
240; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:36
241
242
243; GCN: s_swappc_b64
244; GCN-NOT: s_sub_u32 s32
245; GCN: s_endpgm
246define amdgpu_kernel void @call_void_func_byval_struct_align8_kernel() #1 {
247entry:
248 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
249 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
250 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
251 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
252 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
253 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
254 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
255 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
256 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
257 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
258 call void @void_func_byval_struct_align8(%struct.ByValStruct addrspace(5)* byval nonnull align 8 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 8 %arg1)
259 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
260 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
261 ret void
262}
263
264; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_func:
265; GCN: s_mov_b32 s5, s32
266; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
267; GCN-DAG: v_writelane_b32
268
269; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
270; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
271
272; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s5 offset:8
273; GCN-DAG: buffer_store_dword [[THIRTEEN]], off, s[0:3], s5 offset:24
274
Matt Arsenaultf4320112018-09-24 13:18:15 +0000275; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:24
276; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:28
277; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:32
278; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:36
279
280; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:24
281; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:28
282; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:32
283; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:36
284
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000285; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8
286; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:12
287; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:16
288; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:20
289
290; GCN-NOT: s_add_u32 s32, s32, 0x800
291
292; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:8{{$}}
293; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:12
294; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:16
295; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:20
296
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000297
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000298
299; GCN: s_swappc_b64
300; GCN-NOT: v_readlane_b32 s32
301; GCN: v_readlane_b32
302; GCN-NOT: v_readlane_b32 s32
303
304; GCN-NOT: s_sub_u32 s32, s32, 0x800
305
306; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
307; GCN-NEXT: s_waitcnt
308; GCN-NEXT: s_setpc_b64
309define void @call_void_func_byval_struct_align8_func() #0 {
310entry:
311 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
312 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
313 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
314 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
315 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
316 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
317 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
318 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
319 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
320 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
321 call void @void_func_byval_struct_align8(%struct.ByValStruct addrspace(5)* byval nonnull align 8 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 8 %arg1)
322 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
323 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
324 ret void
325}
326
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000327; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel_no_frame_pointer_elim:
328define amdgpu_kernel void @call_void_func_byval_struct_kernel_no_frame_pointer_elim() #2 {
329entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000330 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
331 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
332 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
333 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
334 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
335 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
336 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
337 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
338 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
339 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
340 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
341 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
342 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000343 ret void
344}
345
346declare void @external_void_func_void() #0
347
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000348declare void @llvm.lifetime.start.p5i8(i64, i8 addrspace(5)* nocapture) #3
349declare void @llvm.lifetime.end.p5i8(i64, i8 addrspace(5)* nocapture) #3
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000350
351attributes #0 = { nounwind }
352attributes #1 = { noinline norecurse nounwind }
353attributes #2 = { nounwind norecurse "no-frame-pointer-elim"="true" }