blob: c272cba6e6f44b4f27d359a0b96feef735f5aad7 [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:
Matt Arsenault34c8b832019-06-05 22:37:50 +00007; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s32{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +00008; GCN-NOT: s32
Matt Arsenault34c8b832019-06-05 22:37:50 +00009; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000010; GCN-NOT: s32
11
Matt Arsenault34c8b832019-06-05 22:37:50 +000012; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s32 offset:16{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000013; GCN-NOT: s32
Matt Arsenault34c8b832019-06-05 22:37:50 +000014; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:16{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000015; GCN-NOT: s32
Scott Linderafc24ed2019-02-01 21:23:28 +000016define hidden 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 +000017entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000018 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
19 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000020 %add = add nsw i32 %tmp, 1
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000021 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
22 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
23 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000024 %add3 = add nsw i32 %tmp1, 2
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000025 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000026 store volatile i32 9, i32 addrspace(1)* null, align 4
27 ret void
28}
29
Matt Arsenault60957cb2019-06-24 14:53:56 +000030; Make sure the offset is folded and function's frame register is used
31; rather than the global scratch wave offset.
32; GCN-LABEL: {{^}}void_func_byval_struct_use_outside_entry_block:
33; GCN-NOT: v_lshrrev_b32
34; GCN-NOT: s_sub_u32
35
36; GCN: s_and_saveexec_b64
37; GCN: s_cbranch_execz [[BB1:BB[0-9]+_[0-9]+]]
38
39; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s32{{$}}
40; GCN-NOT: s32
41; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
42; GCN-NOT: s32
43
44; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s32 offset:16{{$}}
45; GCN-NOT: s32
46; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:16{{$}}
47; GCN-NOT: s32
48
49; GCN: [[BB1]]
50; GCN: s_or_b64 exec, exec
51define hidden void @void_func_byval_struct_use_outside_entry_block(%struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg0, %struct.ByValStruct addrspace(5)* byval noalias nocapture align 4 %arg1, i1 %cond) #1 {
52entry:
53 br i1 %cond, label %bb0, label %bb1
54
55bb0:
56 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
57 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
58 %add = add nsw i32 %tmp, 1
59 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
60 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
61 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
62 %add3 = add nsw i32 %tmp1, 2
63 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
64 store volatile i32 9, i32 addrspace(1)* null, align 4
65 br label %bb1
66
67bb1:
68 ret void
69}
70
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000071; GCN-LABEL: {{^}}void_func_byval_struct_non_leaf:
72; GCN: s_mov_b32 s5, s32
Matt Arsenault3d59e382019-05-24 18:18:51 +000073; GCN: s_add_u32 s32, s32, 0xc00{{$}}
Matt Arsenault8e8f8f42017-08-02 01:52:45 +000074; GCN-DAG: buffer_store_dword v32
75; GCN-DAG: buffer_store_dword v33
Matt Arsenaultecb43ef2017-09-13 23:47:01 +000076; GCN-NOT: v_writelane_b32 v{{[0-9]+}}, s32
Tim Renouf2a99fa22018-02-28 19:10:32 +000077; GCN-DAG: v_writelane_b32
Matt Arsenault34c8b832019-06-05 22:37:50 +000078; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5{{$}}
Tim Renouf2a99fa22018-02-28 19:10:32 +000079; GCN-DAG: v_add_{{[iu]}}32_e32 [[ADD0:v[0-9]+]], vcc, 1, [[LOAD0]]
Matt Arsenault34c8b832019-06-05 22:37:50 +000080; GCN-DAG: buffer_store_dword [[ADD0]], off, s[0:3], s5{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000081
Matt Arsenault34c8b832019-06-05 22:37:50 +000082; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:16{{$}}
Tim Renouf2a99fa22018-02-28 19:10:32 +000083; GCN-DAG: v_add_{{[iu]}}32_e32 [[ADD1:v[0-9]+]], vcc, 2, [[LOAD1]]
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000084
85; GCN: s_swappc_b64
86
Matt Arsenault34c8b832019-06-05 22:37:50 +000087; GCN: buffer_store_dword [[ADD1]], off, s[0:3], s5 offset:16{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000088
89; GCN: v_readlane_b32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +000090; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultdcdf3dd2018-11-26 17:17:07 +000091; GCN-DAG: buffer_load_dword v32,
92; GCN-DAG: buffer_load_dword v33,
Matt Arsenaultffb132e2018-03-29 20:22:04 +000093; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000094; GCN: s_setpc_b64
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000095define 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 +000096entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000097 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
98 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +000099 %add = add nsw i32 %tmp, 1
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000100 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
101 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
102 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000103 %add3 = add nsw i32 %tmp1, 2
104 call void @external_void_func_void()
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000105 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000106 store volatile i32 9, i32 addrspace(1)* null, align 4
107 ret void
108}
109
110; GCN-LABEL: {{^}}call_void_func_byval_struct_func:
111; GCN: s_mov_b32 s5, s32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000112; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
113; GCN-DAG: v_writelane_b32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000114
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000115; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
116; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
117
Matt Arsenault34c8b832019-06-05 22:37:50 +0000118; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s5{{$}}
119; GCN-DAG: buffer_store_dword [[THIRTEEN]], off, s[0:3], s5 offset:16
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000120
Matt Arsenault34c8b832019-06-05 22:37:50 +0000121; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5{{$}}
122; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:4
123; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:8
124; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:12
Matt Arsenault99e6f4d2019-05-16 15:10:27 +0000125
126; GCN-NOT: s_add_u32 s32, s32, 0x800
127
128
Matt Arsenault34c8b832019-06-05 22:37:50 +0000129; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
130; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:4
131; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:8
132; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:12
Matt Arsenault99e6f4d2019-05-16 15:10:27 +0000133
Matt Arsenault34c8b832019-06-05 22:37:50 +0000134; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:16
135; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:20
136; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:24
137; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:28
Matt Arsenaultf4320112018-09-24 13:18:15 +0000138
Matt Arsenault34c8b832019-06-05 22:37:50 +0000139; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:16
140; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:20
141; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:24
142; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:28
Matt Arsenaultf4320112018-09-24 13:18:15 +0000143
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000144; GCN: s_swappc_b64
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000145; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000146; GCN: v_readlane_b32
Matt Arsenaultecb43ef2017-09-13 23:47:01 +0000147; GCN-NOT: v_readlane_b32 s32
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000148
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000149; GCN-NOT: s_sub_u32 s32, s32, 0x800
150
151; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000152; GCN-NEXT: s_waitcnt
153; GCN-NEXT: s_setpc_b64
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000154define void @call_void_func_byval_struct_func() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000155entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000156 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
157 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
158 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
159 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
160 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
161 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
162 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
163 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
164 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
165 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
166 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
167 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
168 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000169 ret void
170}
171
172; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel:
Geoff Berry4e38e022017-08-17 04:04:11 +0000173; GCN: s_mov_b32 s33, s7
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000174; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000175
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000176; GCN: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
177; GCN: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
178; GCN: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
Geoff Berry4e38e022017-08-17 04:04:11 +0000179; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000180
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000181; GCN-NOT: s_add_u32 s32, s32, 0x800
Geoff Berry4e38e022017-08-17 04:04:11 +0000182; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
183; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000184; GCN-DAG: s_add_u32 s32, s33, 0xc00{{$}}
Geoff Berry4e38e022017-08-17 04:04:11 +0000185; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
186; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000187
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000188; GCN: s_getpc_b64
189
Matt Arsenault34c8b832019-06-05 22:37:50 +0000190; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
191; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:4
192; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:8
193; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:12
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000194
Matt Arsenaultacc5e822017-08-02 00:43:42 +0000195; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
196; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
197; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
198; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000199
Matt Arsenault34c8b832019-06-05 22:37:50 +0000200; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:16
201; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:20
202; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:24
203; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:28
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000204
205
206; GCN: s_swappc_b64
Matt Arsenaultdefe3712017-09-14 17:37:40 +0000207; GCN-NOT: s_sub_u32 s32
208; GCN: s_endpgm
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000209define amdgpu_kernel void @call_void_func_byval_struct_kernel() #1 {
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000210entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000211 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
212 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
213 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
214 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
215 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
216 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
217 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
218 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
219 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
220 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
221 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
222 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
223 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000224 ret void
225}
226
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000227; GCN-LABEL: {{^}}void_func_byval_struct_align8:
Matt Arsenault34c8b832019-06-05 22:37:50 +0000228; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s32{{$}}
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000229; GCN-NOT: s32
Matt Arsenault34c8b832019-06-05 22:37:50 +0000230; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000231; GCN-NOT: s32
232
Matt Arsenault34c8b832019-06-05 22:37:50 +0000233; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s32 offset:16{{$}}
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000234; GCN-NOT: s32
Matt Arsenault34c8b832019-06-05 22:37:50 +0000235; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:16{{$}}
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000236; GCN-NOT: s32
Scott Linderafc24ed2019-02-01 21:23:28 +0000237define hidden 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 {
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000238entry:
239 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
240 %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 8
241 %add = add nsw i32 %tmp, 1
242 store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 8
243 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
244 %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 8
245 %add3 = add nsw i32 %tmp1, 2
246 store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 8
247 store volatile i32 9, i32 addrspace(1)* null, align 4
248 ret void
249}
250
251; Make sure the byval alignment is respected in the call frame setup
252; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_kernel:
253; GCN: s_mov_b32 s33, s7
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000254; GCN-NOT: s_add_u32 s32, s32, 0x800
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000255
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000256; GCN: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
257; GCN: buffer_store_dword [[NINE]], off, s[0:3], s33 offset:8
258; GCN: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000259; GCN: buffer_store_dword [[THIRTEEN]], off, s[0:3], s33 offset:24
260
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000261
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000262; GCN-NOT: s_add_u32 s32, s32, 0x800
263
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000264; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s33 offset:8
265; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s33 offset:12
266; GCN-DAG: s_add_u32 s32, s33, 0xc00{{$}}
267; GCN: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s33 offset:16
268; GCN: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s33 offset:20
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000269
Matt Arsenault4f3472d2019-07-03 00:30:47 +0000270; GCN: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:12
271; GCN: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:8
272; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:4
273; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
274
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000275
276; GCN-DAG: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s33 offset:24
277; GCN-DAG: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s33 offset:28
278; GCN-DAG: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s33 offset:32
279; GCN-DAG: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s33 offset:36
280
Matt Arsenault34c8b832019-06-05 22:37:50 +0000281; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:16
282; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:20
283; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:24
284; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:28
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000285
286
287; GCN: s_swappc_b64
288; GCN-NOT: s_sub_u32 s32
289; GCN: s_endpgm
290define amdgpu_kernel void @call_void_func_byval_struct_align8_kernel() #1 {
291entry:
292 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
293 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
294 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
295 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
296 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
297 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
298 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
299 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
300 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
301 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
302 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)
303 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
304 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
305 ret void
306}
307
308; GCN-LABEL: {{^}}call_void_func_byval_struct_align8_func:
309; GCN: s_mov_b32 s5, s32
310; GCN-DAG: s_add_u32 s32, s32, 0xc00{{$}}
311; GCN-DAG: v_writelane_b32
312
313; GCN-DAG: v_mov_b32_e32 [[NINE:v[0-9]+]], 9
314; GCN-DAG: v_mov_b32_e32 [[THIRTEEN:v[0-9]+]], 13
315
Matt Arsenault34c8b832019-06-05 22:37:50 +0000316; GCN-DAG: buffer_store_dword [[NINE]], off, s[0:3], s5{{$}}
317; GCN-DAG: buffer_store_dword [[THIRTEEN]], off, s[0:3], s5 offset:16
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000318
Matt Arsenault34c8b832019-06-05 22:37:50 +0000319; GCN-DAG: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s5{{$}}
320; GCN-DAG: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s5 offset:4
321; GCN-DAG: buffer_load_dword [[LOAD2:v[0-9]+]], off, s[0:3], s5 offset:8
322; GCN-DAG: buffer_load_dword [[LOAD3:v[0-9]+]], off, s[0:3], s5 offset:12
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000323
324; GCN-NOT: s_add_u32 s32, s32, 0x800
325
Matt Arsenault34c8b832019-06-05 22:37:50 +0000326; GCN-DAG: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
327; GCN-DAG: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:4
328; GCN-DAG: buffer_store_dword [[LOAD2]], off, s[0:3], s32 offset:8
329; GCN-DAG: buffer_store_dword [[LOAD3]], off, s[0:3], s32 offset:12
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000330
Matt Arsenault34c8b832019-06-05 22:37:50 +0000331; GCN: buffer_load_dword [[LOAD4:v[0-9]+]], off, s[0:3], s5 offset:16
332; GCN: buffer_load_dword [[LOAD5:v[0-9]+]], off, s[0:3], s5 offset:20
333; GCN: buffer_load_dword [[LOAD6:v[0-9]+]], off, s[0:3], s5 offset:24
334; GCN: buffer_load_dword [[LOAD7:v[0-9]+]], off, s[0:3], s5 offset:28
335; GCN: s_waitcnt vmcnt(0)
336; GCN-DAG: buffer_store_dword [[LOAD4]], off, s[0:3], s32 offset:16
337; GCN-DAG: buffer_store_dword [[LOAD5]], off, s[0:3], s32 offset:20
338; GCN-DAG: buffer_store_dword [[LOAD6]], off, s[0:3], s32 offset:24
339; GCN-DAG: buffer_store_dword [[LOAD7]], off, s[0:3], s32 offset:28
Matt Arsenaultbb8e64e2018-08-22 11:09:45 +0000340
341; GCN: s_swappc_b64
342; GCN-NOT: v_readlane_b32 s32
343; GCN: v_readlane_b32
344; GCN-NOT: v_readlane_b32 s32
345
346; GCN-NOT: s_sub_u32 s32, s32, 0x800
347
348; GCN: s_sub_u32 s32, s32, 0xc00{{$}}
349; GCN-NEXT: s_waitcnt
350; GCN-NEXT: s_setpc_b64
351define void @call_void_func_byval_struct_align8_func() #0 {
352entry:
353 %arg0 = alloca %struct.ByValStruct, align 8, addrspace(5)
354 %arg1 = alloca %struct.ByValStruct, align 8, addrspace(5)
355 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
356 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
357 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
358 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
359 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
360 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 8
361 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
362 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 8
363 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)
364 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
365 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
366 ret void
367}
368
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000369; GCN-LABEL: {{^}}call_void_func_byval_struct_kernel_no_frame_pointer_elim:
370define amdgpu_kernel void @call_void_func_byval_struct_kernel_no_frame_pointer_elim() #2 {
371entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000372 %arg0 = alloca %struct.ByValStruct, align 4, addrspace(5)
373 %arg1 = alloca %struct.ByValStruct, align 4, addrspace(5)
374 %tmp = bitcast %struct.ByValStruct addrspace(5)* %arg0 to i8 addrspace(5)*
375 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp)
376 %tmp1 = bitcast %struct.ByValStruct addrspace(5)* %arg1 to i8 addrspace(5)*
377 call void @llvm.lifetime.start.p5i8(i64 32, i8 addrspace(5)* %tmp1)
378 %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
379 store volatile i32 9, i32 addrspace(5)* %arrayidx, align 4
380 %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
381 store volatile i32 13, i32 addrspace(5)* %arrayidx2, align 4
382 call void @void_func_byval_struct(%struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg0, %struct.ByValStruct addrspace(5)* byval nonnull align 4 %arg1)
383 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp1)
384 call void @llvm.lifetime.end.p5i8(i64 32, i8 addrspace(5)* %tmp)
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000385 ret void
386}
387
388declare void @external_void_func_void() #0
389
Yaxun Liu2a22c5d2018-02-02 16:07:16 +0000390declare void @llvm.lifetime.start.p5i8(i64, i8 addrspace(5)* nocapture) #3
391declare void @llvm.lifetime.end.p5i8(i64, i8 addrspace(5)* nocapture) #3
Matt Arsenaultb62a4eb2017-08-01 19:54:18 +0000392
393attributes #0 = { nounwind }
394attributes #1 = { noinline norecurse nounwind }
Matt Arsenault5dbe4a92019-06-20 17:03:27 +0000395attributes #2 = { nounwind norecurse "frame-pointer"="all" }