blob: b0268dc61eec005069be1aac7dadc4f81ae9e8f0 [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 Arsenaultb62a4eb2017-08-01 19:54:18 +000051; GCN: buffer_load_dword v32,
Matt Arsenault8e8f8f42017-08-02 01:52:45 +000052; GCN: 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
Tim Renouf2a99fa22018-02-28 19:10:32 +000081; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8
82; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:12
83; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:16
84; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:20
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000085
Matt Arsenaultdefe3712017-09-14 17:37:40 +000086; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000087
Matt Arsenaultd1867c02017-08-02 00:59:51 +000088; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:4{{$}}
89; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:8
90; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:12
91; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:16
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000092
Matt Arsenaultacc5e822017-08-02 00:43:42 +000093; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:24
94; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:28
95; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:32
96; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:36
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000097
Matt Arsenaultd1867c02017-08-02 00:59:51 +000098; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:20
99; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:24
100; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:28
101; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000102
103; GCN: s_swappc_b64
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000104; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000105; GCN: v_readlane_b32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000106; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000107
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000108; GCN-NOT: s_sub_u32 s32, s32, 0x800
109
110; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000111; GCN-NEXT: s_waitcnt
112; GCN-NEXT: s_setpc_b64
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000113define void @call_void_func_byval_struct_func() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000114entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000115 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
116 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
117 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
118 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
119 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
120 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
121 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
122 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
123 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
124 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
125 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
126 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
127 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000128 ret void
129}
130
131; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel:
Geoff Berry4e38e022017-08-17 04:04:11 +0000132; GCN: s_mov_b32 s33, s7
Matt Arsenaultffb132e2018-03-29 20:22:04 +0000133; GCN: s_add_u32 s32, s33, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000134
135; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
136; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
Geoff Berry4e38e022017-08-17 04:04:11 +0000137; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
138; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000139
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000140; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000141
Geoff Berry4e38e022017-08-17 04:04:11 +0000142; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
143; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
144; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
145; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000146
Matt Arsenaultd1867c02017-08-02 00:59:51 +0000147; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:4{{$}}
148; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:8
149; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:12
150; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:16
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000151
Matt Arsenaultacc5e822017-08-02 00:43:42 +0000152; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
153; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
154; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
155; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000156
Matt Arsenaultd1867c02017-08-02 00:59:51 +0000157; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:20
158; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:24
159; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:28
160; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000161
162
163; GCN: s_swappc_b64
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000164; GCN-NOT: s_sub_u32 s32
165; GCN: s_endpgm
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000166define amdgpu_kernel void @call_void_func_byval_struct_kernel() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000167entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000168 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
169 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
170 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
171 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
172 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
173 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
174 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
175 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
176 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
177 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
178 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
179 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
180 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000181 ret void
182}
183
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000184; GCN-LABEL: {{^}}void_func_byval_struct_align8:
185; GCN: s_mov_b32 s5, s32
186; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8{{$}}
187; GCN-NOT: s32
188; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s5 offset:8{{$}}
189; GCN-NOT: s32
190
191; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:24{{$}}
192; GCN-NOT: s32
193; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s5 offset:24{{$}}
194; GCN-NOT: s32
195define 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 {
196entry:
197 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
198 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 8
199 %add = add nsw i32 %tmp, 1
200 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 8
201 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
202 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 8
203 %add3 = add nsw i32 %tmp1, 2
204 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 8
205 store volatile i32 9, i32 addrspace(1)* null, align 4
206 ret void
207}
208
209; Make sure the byval alignment is respected in the call frame setup
210; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_kernel:
211; GCN: s_mov_b32 s33, s7
212; GCN: s_add_u32 s32, s33, 0xc00{{$}}
213
214; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
215; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
216; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
217; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
218
219; GCN-NOT: s_add_u32 s32, s32, 0x800
220
221; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
222; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
223; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
224; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
225
226; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:8{{$}}
227; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:12
228; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:16
229; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:20
230
231; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
232; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
233; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
234; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
235
236; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:24
237; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:28
238; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:32
239; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:36
240
241
242; GCN: s_swappc_b64
243; GCN-NOT: s_sub_u32 s32
244; GCN: s_endpgm
245define amdgpu_kernel void @call_void_func_byval_struct_align8_kernel() #1 {
246entry:
247 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
248 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
249 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
250 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
251 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
252 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
253 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
254 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
255 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
256 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
257 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)
258 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
259 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
260 ret void
261}
262
263; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_func:
264; GCN: s_mov_b32 s5, s32
265; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
266; GCN-DAG: v_writelane_b32
267
268; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
269; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
270
271; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s5 offset:8
272; GCN-DAG: buffer_store_dword [[THIRTEEN]], off, s[0:3], s5 offset:24
273
274; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5 offset:8
275; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:12
276; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:16
277; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:20
278
279; GCN-NOT: s_add_u32 s32, s32, 0x800
280
281; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32 offset:8{{$}}
282; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:12
283; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:16
284; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:20
285
286; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:24
287; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:28
288; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:32
289; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:36
290
291; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:24
292; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:28
293; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:32
294; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:36
295
296; GCN: s_swappc_b64
297; GCN-NOT: v_readlane_b32 s32
298; GCN: v_readlane_b32
299; GCN-NOT: v_readlane_b32 s32
300
301; GCN-NOT: s_sub_u32 s32, s32, 0x800
302
303; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
304; GCN-NEXT: s_waitcnt
305; GCN-NEXT: s_setpc_b64
306define void @call_void_func_byval_struct_align8_func() #0 {
307entry:
308 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
309 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
310 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
311 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
312 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
313 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
314 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
315 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
316 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
317 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
318 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)
319 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
320 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
321 ret void
322}
323
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000324; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel_no_frame_pointer_elim:
325define amdgpu_kernel void @call_void_func_byval_struct_kernel_no_frame_pointer_elim() #2 {
326entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000327 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
328 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
329 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
330 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
331 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
332 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
333 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
334 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
335 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
336 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
337 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
338 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
339 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000340 ret void
341}
342
343declare void @external_void_func_void() #0
344
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000345declare void @llvm.lifetime.start.p5i8(i64, i8 addrspace(5)* nocapture) #3
346declare void @llvm.lifetime.end.p5i8(i64, i8 addrspace(5)* nocapture) #3
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000347
348attributes #0 = { nounwind }
349attributes #1 = { noinline norecurse nounwind }
350attributes #2 = { nounwind norecurse "no-frame-pointer-elim"="true" }