1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck %s
4 ; LDS is allocated per-kernel. Module scope variables are gathered into a struct which is
5 ; allocated at address zero, if used by the kernel. Kernel scope variables are gathered into
6 ; a per-kernel struct and allocated immediately after the module scope.
7 ; This test checks that the module and kernel scope variables are allocated in deterministic
8 ; order without spurious alignment padding between the two
10 ; External LDS is checked because it influences LDS padding in general and because it will
11 ; not be moved into either module or kernel struct
13 @module_variable = addrspace(3) global i16 undef
15 ; Variables are allocated into module scope block when used by a non-kernel function
16 define void @use_module() #0 {
17 ; CHECK-LABEL: use_module:
19 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
20 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
21 ; CHECK-NEXT: ds_write_b16 v0, v0
22 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
23 ; CHECK-NEXT: s_setpc_b64 s[30:31]
24 store i16 0, ptr addrspace(3) @module_variable
28 ; Variables only used by kernels are specialised and allocated per-kernel
29 @kernel_normal = addrspace(3) global i16 undef
30 @kernel_overalign = addrspace(3) global i16 undef, align 4
32 ; External LDS shall not introduce padding between module and kernel scope variables
33 @extern_normal = external addrspace(3) global [0 x float]
34 @extern_overalign = external addrspace(3) global [0 x float], align 8
37 ; External LDS does not influence the frame when called indirectly either
38 define void @use_extern_normal() #0 {
39 ; CHECK-LABEL: use_extern_normal:
41 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
42 ; CHECK-NEXT: s_getpc_b64 s[6:7]
43 ; CHECK-NEXT: s_add_u32 s6, s6, llvm.amdgcn.dynlds.offset.table@rel32@lo+4
44 ; CHECK-NEXT: s_addc_u32 s7, s7, llvm.amdgcn.dynlds.offset.table@rel32@hi+12
45 ; CHECK-NEXT: s_mov_b32 s4, s15
46 ; CHECK-NEXT: s_ashr_i32 s5, s15, 31
47 ; CHECK-NEXT: v_mov_b32_e32 v0, 0x4048f5c3
48 ; CHECK-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
49 ; CHECK-NEXT: s_add_u32 s4, s4, s6
50 ; CHECK-NEXT: s_addc_u32 s5, s5, s7
51 ; CHECK-NEXT: s_load_dword s4, s[4:5], 0x0
52 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
53 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
54 ; CHECK-NEXT: ds_write_b32 v1, v0
55 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
56 ; CHECK-NEXT: s_setpc_b64 s[30:31]
57 %arrayidx = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_normal, i32 0, i32 0
58 store float 0x40091EB860000000, ptr addrspace(3) %arrayidx
62 define void @use_extern_overalign() #0 {
63 ; CHECK-LABEL: use_extern_overalign:
65 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
66 ; CHECK-NEXT: s_getpc_b64 s[6:7]
67 ; CHECK-NEXT: s_add_u32 s6, s6, llvm.amdgcn.dynlds.offset.table@rel32@lo+4
68 ; CHECK-NEXT: s_addc_u32 s7, s7, llvm.amdgcn.dynlds.offset.table@rel32@hi+12
69 ; CHECK-NEXT: s_mov_b32 s4, s15
70 ; CHECK-NEXT: s_ashr_i32 s5, s15, 31
71 ; CHECK-NEXT: v_mov_b32_e32 v0, 0x42280000
72 ; CHECK-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
73 ; CHECK-NEXT: s_add_u32 s4, s4, s6
74 ; CHECK-NEXT: s_addc_u32 s5, s5, s7
75 ; CHECK-NEXT: s_load_dword s4, s[4:5], 0x0
76 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
77 ; CHECK-NEXT: v_mov_b32_e32 v1, s4
78 ; CHECK-NEXT: ds_write_b32 v1, v0 offset:4
79 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
80 ; CHECK-NEXT: s_setpc_b64 s[30:31]
81 %arrayidx = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_overalign, i32 0, i32 1
82 store float 4.200000e+01, ptr addrspace(3) %arrayidx
87 ; First 2^3 of 2^4 cases encoded into function names
88 ; no use of extern variable from nested function
89 ; module_variable used/not-used
90 ; kernel variable normal/overaligned
91 ; extern variable normal/overaligned
93 define amdgpu_kernel void @module_0_kernel_normal_extern_normal(i32 %idx) {
94 ; CHECK-LABEL: module_0_kernel_normal_extern_normal:
96 ; CHECK-NEXT: s_load_dword s0, s[4:5], 0x0
97 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
98 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
99 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
100 ; CHECK-NEXT: s_lshl_b32 s0, s0, 2
101 ; CHECK-NEXT: s_add_i32 s0, s0, 4
102 ; CHECK-NEXT: v_mov_b32_e32 v2, s0
103 ; CHECK-NEXT: ds_write_b16 v0, v1
104 ; CHECK-NEXT: ds_write_b32 v2, v0
105 ; CHECK-NEXT: s_endpgm
106 store i16 2, ptr addrspace(3) @kernel_normal
108 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_normal, i32 0, i32 %idx
109 store float 0.0, ptr addrspace(3) %arrayidx1
113 define amdgpu_kernel void @module_1_kernel_normal_extern_normal(i32 %idx) {
114 ; CHECK-LABEL: module_1_kernel_normal_extern_normal:
116 ; CHECK-NEXT: s_add_u32 s8, s8, s11
117 ; CHECK-NEXT: s_mov_b32 s32, 0
118 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
119 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
120 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
121 ; CHECK-NEXT: s_add_u32 s0, s0, s11
122 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
123 ; CHECK-NEXT: s_getpc_b64 s[8:9]
124 ; CHECK-NEXT: s_add_u32 s8, s8, use_module@gotpcrel32@lo+4
125 ; CHECK-NEXT: s_addc_u32 s9, s9, use_module@gotpcrel32@hi+12
126 ; CHECK-NEXT: s_load_dwordx2 s[10:11], s[8:9], 0x0
127 ; CHECK-NEXT: s_load_dword s12, s[6:7], 0x0
128 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
129 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
130 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[10:11]
131 ; CHECK-NEXT: s_lshl_b32 s4, s12, 2
132 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
133 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
134 ; CHECK-NEXT: s_add_i32 s4, s4, 4
135 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
136 ; CHECK-NEXT: v_mov_b32_e32 v3, s4
137 ; CHECK-NEXT: ds_write_b16 v0, v1
138 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:2
139 ; CHECK-NEXT: ds_write_b32 v3, v0
140 ; CHECK-NEXT: s_endpgm
141 call void @use_module()
142 store i16 1, ptr addrspace(3) @module_variable
144 store i16 2, ptr addrspace(3) @kernel_normal
146 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_normal, i32 0, i32 %idx
147 store float 0.0, ptr addrspace(3) %arrayidx1
151 define amdgpu_kernel void @module_0_kernel_overalign_extern_normal(i32 %idx) {
152 ; CHECK-LABEL: module_0_kernel_overalign_extern_normal:
154 ; CHECK-NEXT: s_load_dword s0, s[4:5], 0x0
155 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
156 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
157 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
158 ; CHECK-NEXT: s_lshl_b32 s0, s0, 2
159 ; CHECK-NEXT: s_add_i32 s0, s0, 4
160 ; CHECK-NEXT: v_mov_b32_e32 v2, s0
161 ; CHECK-NEXT: ds_write_b16 v0, v1
162 ; CHECK-NEXT: ds_write_b32 v2, v0
163 ; CHECK-NEXT: s_endpgm
164 store i16 2, ptr addrspace(3) @kernel_overalign
166 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_normal, i32 0, i32 %idx
167 store float 0.0, ptr addrspace(3) %arrayidx1
171 define amdgpu_kernel void @module_1_kernel_overalign_extern_normal(i32 %idx) {
172 ; CHECK-LABEL: module_1_kernel_overalign_extern_normal:
174 ; CHECK-NEXT: s_add_u32 s8, s8, s11
175 ; CHECK-NEXT: s_mov_b32 s32, 0
176 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
177 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
178 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
179 ; CHECK-NEXT: s_add_u32 s0, s0, s11
180 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
181 ; CHECK-NEXT: s_getpc_b64 s[8:9]
182 ; CHECK-NEXT: s_add_u32 s8, s8, use_module@gotpcrel32@lo+4
183 ; CHECK-NEXT: s_addc_u32 s9, s9, use_module@gotpcrel32@hi+12
184 ; CHECK-NEXT: s_load_dwordx2 s[10:11], s[8:9], 0x0
185 ; CHECK-NEXT: s_load_dword s12, s[6:7], 0x0
186 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
187 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
188 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[10:11]
189 ; CHECK-NEXT: s_lshl_b32 s4, s12, 2
190 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
191 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
192 ; CHECK-NEXT: s_add_i32 s4, s4, 8
193 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
194 ; CHECK-NEXT: v_mov_b32_e32 v3, s4
195 ; CHECK-NEXT: ds_write_b16 v0, v1
196 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:4
197 ; CHECK-NEXT: ds_write_b32 v3, v0
198 ; CHECK-NEXT: s_endpgm
199 call void @use_module()
200 store i16 1, ptr addrspace(3) @module_variable
202 store i16 2, ptr addrspace(3) @kernel_overalign
204 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_normal, i32 0, i32 %idx
205 store float 0.0, ptr addrspace(3) %arrayidx1
209 define amdgpu_kernel void @module_0_kernel_normal_extern_overalign(i32 %idx) {
210 ; CHECK-LABEL: module_0_kernel_normal_extern_overalign:
212 ; CHECK-NEXT: s_load_dword s0, s[4:5], 0x0
213 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
214 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
215 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
216 ; CHECK-NEXT: s_lshl_b32 s0, s0, 2
217 ; CHECK-NEXT: s_add_i32 s0, s0, 8
218 ; CHECK-NEXT: v_mov_b32_e32 v2, s0
219 ; CHECK-NEXT: ds_write_b16 v0, v1
220 ; CHECK-NEXT: ds_write_b32 v2, v0
221 ; CHECK-NEXT: s_endpgm
222 store i16 2, ptr addrspace(3) @kernel_normal
224 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_overalign, i32 0, i32 %idx
225 store float 0.0, ptr addrspace(3) %arrayidx1
229 define amdgpu_kernel void @module_1_kernel_normal_extern_overalign(i32 %idx) {
230 ; CHECK-LABEL: module_1_kernel_normal_extern_overalign:
232 ; CHECK-NEXT: s_add_u32 s8, s8, s11
233 ; CHECK-NEXT: s_mov_b32 s32, 0
234 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
235 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
236 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
237 ; CHECK-NEXT: s_add_u32 s0, s0, s11
238 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
239 ; CHECK-NEXT: s_getpc_b64 s[8:9]
240 ; CHECK-NEXT: s_add_u32 s8, s8, use_module@gotpcrel32@lo+4
241 ; CHECK-NEXT: s_addc_u32 s9, s9, use_module@gotpcrel32@hi+12
242 ; CHECK-NEXT: s_load_dwordx2 s[10:11], s[8:9], 0x0
243 ; CHECK-NEXT: s_load_dword s12, s[6:7], 0x0
244 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
245 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
246 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[10:11]
247 ; CHECK-NEXT: s_lshl_b32 s4, s12, 2
248 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
249 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
250 ; CHECK-NEXT: s_add_i32 s4, s4, 8
251 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
252 ; CHECK-NEXT: v_mov_b32_e32 v3, s4
253 ; CHECK-NEXT: ds_write_b16 v0, v1
254 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:2
255 ; CHECK-NEXT: ds_write_b32 v3, v0
256 ; CHECK-NEXT: s_endpgm
257 call void @use_module()
258 store i16 1, ptr addrspace(3) @module_variable
260 store i16 2, ptr addrspace(3) @kernel_normal
262 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_overalign, i32 0, i32 %idx
263 store float 0.0, ptr addrspace(3) %arrayidx1
267 define amdgpu_kernel void @module_0_kernel_overalign_extern_overalign(i32 %idx) {
268 ; CHECK-LABEL: module_0_kernel_overalign_extern_overalign:
270 ; CHECK-NEXT: s_load_dword s0, s[4:5], 0x0
271 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
272 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
273 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
274 ; CHECK-NEXT: s_lshl_b32 s0, s0, 2
275 ; CHECK-NEXT: s_add_i32 s0, s0, 8
276 ; CHECK-NEXT: v_mov_b32_e32 v2, s0
277 ; CHECK-NEXT: ds_write_b16 v0, v1
278 ; CHECK-NEXT: ds_write_b32 v2, v0
279 ; CHECK-NEXT: s_endpgm
280 store i16 2, ptr addrspace(3) @kernel_overalign
282 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_overalign, i32 0, i32 %idx
283 store float 0.0, ptr addrspace(3) %arrayidx1
287 define amdgpu_kernel void @module_1_kernel_overalign_extern_overalign(i32 %idx) {
288 ; CHECK-LABEL: module_1_kernel_overalign_extern_overalign:
290 ; CHECK-NEXT: s_add_u32 s8, s8, s11
291 ; CHECK-NEXT: s_mov_b32 s32, 0
292 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
293 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
294 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
295 ; CHECK-NEXT: s_add_u32 s0, s0, s11
296 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
297 ; CHECK-NEXT: s_getpc_b64 s[8:9]
298 ; CHECK-NEXT: s_add_u32 s8, s8, use_module@gotpcrel32@lo+4
299 ; CHECK-NEXT: s_addc_u32 s9, s9, use_module@gotpcrel32@hi+12
300 ; CHECK-NEXT: s_load_dwordx2 s[10:11], s[8:9], 0x0
301 ; CHECK-NEXT: s_load_dword s12, s[6:7], 0x0
302 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
303 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
304 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[10:11]
305 ; CHECK-NEXT: s_lshl_b32 s4, s12, 2
306 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
307 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
308 ; CHECK-NEXT: s_add_i32 s4, s4, 8
309 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
310 ; CHECK-NEXT: v_mov_b32_e32 v3, s4
311 ; CHECK-NEXT: ds_write_b16 v0, v1
312 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:4
313 ; CHECK-NEXT: ds_write_b32 v3, v0
314 ; CHECK-NEXT: s_endpgm
315 call void @use_module()
316 store i16 1, ptr addrspace(3) @module_variable
318 store i16 2, ptr addrspace(3) @kernel_overalign
320 %arrayidx1 = getelementptr inbounds [0 x float], ptr addrspace(3) @extern_overalign, i32 0, i32 %idx
321 store float 0.0, ptr addrspace(3) %arrayidx1
326 ;; Second 2^3 of 2^4 cases encoded into function names
327 ; with extern variable from nested function
328 ; module_variable used/not-used
329 ; kernel variable normal/overaligned
330 ; extern variable normal/overaligned
332 define amdgpu_kernel void @module_0_kernel_normal_indirect_extern_normal(i32 %idx) {
333 ; CHECK-LABEL: module_0_kernel_normal_indirect_extern_normal:
335 ; CHECK-NEXT: s_add_u32 s8, s8, s11
336 ; CHECK-NEXT: s_mov_b32 s32, 0
337 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
338 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
339 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
340 ; CHECK-NEXT: s_add_u32 s0, s0, s11
341 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
342 ; CHECK-NEXT: s_getpc_b64 s[6:7]
343 ; CHECK-NEXT: s_add_u32 s6, s6, use_extern_normal@gotpcrel32@lo+4
344 ; CHECK-NEXT: s_addc_u32 s7, s7, use_extern_normal@gotpcrel32@hi+12
345 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
346 ; CHECK-NEXT: s_load_dwordx2 s[8:9], s[6:7], 0x0
347 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
348 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
349 ; CHECK-NEXT: s_mov_b32 s15, 0
350 ; CHECK-NEXT: ds_write_b16 v0, v1
351 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
352 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[8:9]
353 ; CHECK-NEXT: s_endpgm
354 store i16 2, ptr addrspace(3) @kernel_normal
356 call void @use_extern_normal()
360 define amdgpu_kernel void @module_1_kernel_normal_indirect_extern_normal(i32 %idx) {
361 ; CHECK-LABEL: module_1_kernel_normal_indirect_extern_normal:
363 ; CHECK-NEXT: s_add_u32 s8, s8, s11
364 ; CHECK-NEXT: s_mov_b32 s32, 0
365 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
366 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
367 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
368 ; CHECK-NEXT: s_add_u32 s0, s0, s11
369 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
370 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
371 ; CHECK-NEXT: s_getpc_b64 s[4:5]
372 ; CHECK-NEXT: s_add_u32 s4, s4, use_module@gotpcrel32@lo+4
373 ; CHECK-NEXT: s_addc_u32 s5, s5, use_module@gotpcrel32@hi+12
374 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
375 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
376 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
377 ; CHECK-NEXT: s_getpc_b64 s[4:5]
378 ; CHECK-NEXT: s_add_u32 s4, s4, use_extern_normal@gotpcrel32@lo+4
379 ; CHECK-NEXT: s_addc_u32 s5, s5, use_extern_normal@gotpcrel32@hi+12
380 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
381 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
382 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
383 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
384 ; CHECK-NEXT: s_mov_b32 s15, 4
385 ; CHECK-NEXT: ds_write_b16 v0, v1
386 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:2
387 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
388 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
389 ; CHECK-NEXT: s_endpgm
390 call void @use_module()
391 store i16 1, ptr addrspace(3) @module_variable
393 store i16 2, ptr addrspace(3) @kernel_normal
395 call void @use_extern_normal()
399 define amdgpu_kernel void @module_0_kernel_overalign_indirect_extern_normal(i32 %idx) {
400 ; CHECK-LABEL: module_0_kernel_overalign_indirect_extern_normal:
402 ; CHECK-NEXT: s_add_u32 s8, s8, s11
403 ; CHECK-NEXT: s_mov_b32 s32, 0
404 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
405 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
406 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
407 ; CHECK-NEXT: s_add_u32 s0, s0, s11
408 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
409 ; CHECK-NEXT: s_getpc_b64 s[6:7]
410 ; CHECK-NEXT: s_add_u32 s6, s6, use_extern_normal@gotpcrel32@lo+4
411 ; CHECK-NEXT: s_addc_u32 s7, s7, use_extern_normal@gotpcrel32@hi+12
412 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
413 ; CHECK-NEXT: s_load_dwordx2 s[8:9], s[6:7], 0x0
414 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
415 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
416 ; CHECK-NEXT: s_mov_b32 s15, 2
417 ; CHECK-NEXT: ds_write_b16 v0, v1
418 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
419 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[8:9]
420 ; CHECK-NEXT: s_endpgm
421 store i16 2, ptr addrspace(3) @kernel_overalign
423 call void @use_extern_normal()
427 define amdgpu_kernel void @module_1_kernel_overalign_indirect_extern_normal(i32 %idx) {
428 ; CHECK-LABEL: module_1_kernel_overalign_indirect_extern_normal:
430 ; CHECK-NEXT: s_add_u32 s8, s8, s11
431 ; CHECK-NEXT: s_mov_b32 s32, 0
432 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
433 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
434 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
435 ; CHECK-NEXT: s_add_u32 s0, s0, s11
436 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
437 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
438 ; CHECK-NEXT: s_getpc_b64 s[4:5]
439 ; CHECK-NEXT: s_add_u32 s4, s4, use_module@gotpcrel32@lo+4
440 ; CHECK-NEXT: s_addc_u32 s5, s5, use_module@gotpcrel32@hi+12
441 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
442 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
443 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
444 ; CHECK-NEXT: s_getpc_b64 s[4:5]
445 ; CHECK-NEXT: s_add_u32 s4, s4, use_extern_normal@gotpcrel32@lo+4
446 ; CHECK-NEXT: s_addc_u32 s5, s5, use_extern_normal@gotpcrel32@hi+12
447 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
448 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
449 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
450 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
451 ; CHECK-NEXT: s_mov_b32 s15, 6
452 ; CHECK-NEXT: ds_write_b16 v0, v1
453 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:4
454 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
455 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
456 ; CHECK-NEXT: s_endpgm
457 call void @use_module()
458 store i16 1, ptr addrspace(3) @module_variable
460 store i16 2, ptr addrspace(3) @kernel_overalign
462 call void @use_extern_normal()
466 define amdgpu_kernel void @module_0_kernel_normal_indirect_extern_overalign(i32 %idx) {
467 ; CHECK-LABEL: module_0_kernel_normal_indirect_extern_overalign:
469 ; CHECK-NEXT: s_add_u32 s8, s8, s11
470 ; CHECK-NEXT: s_mov_b32 s32, 0
471 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
472 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
473 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
474 ; CHECK-NEXT: s_add_u32 s0, s0, s11
475 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
476 ; CHECK-NEXT: s_getpc_b64 s[6:7]
477 ; CHECK-NEXT: s_add_u32 s6, s6, use_extern_overalign@gotpcrel32@lo+4
478 ; CHECK-NEXT: s_addc_u32 s7, s7, use_extern_overalign@gotpcrel32@hi+12
479 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
480 ; CHECK-NEXT: s_load_dwordx2 s[8:9], s[6:7], 0x0
481 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
482 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
483 ; CHECK-NEXT: s_mov_b32 s15, 1
484 ; CHECK-NEXT: ds_write_b16 v0, v1
485 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
486 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[8:9]
487 ; CHECK-NEXT: s_endpgm
488 store i16 2, ptr addrspace(3) @kernel_normal
490 call void @use_extern_overalign()
494 define amdgpu_kernel void @module_1_kernel_normal_indirect_extern_overalign(i32 %idx) {
495 ; CHECK-LABEL: module_1_kernel_normal_indirect_extern_overalign:
497 ; CHECK-NEXT: s_add_u32 s8, s8, s11
498 ; CHECK-NEXT: s_mov_b32 s32, 0
499 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
500 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
501 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
502 ; CHECK-NEXT: s_add_u32 s0, s0, s11
503 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
504 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
505 ; CHECK-NEXT: s_getpc_b64 s[4:5]
506 ; CHECK-NEXT: s_add_u32 s4, s4, use_module@gotpcrel32@lo+4
507 ; CHECK-NEXT: s_addc_u32 s5, s5, use_module@gotpcrel32@hi+12
508 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
509 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
510 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
511 ; CHECK-NEXT: s_getpc_b64 s[4:5]
512 ; CHECK-NEXT: s_add_u32 s4, s4, use_extern_overalign@gotpcrel32@lo+4
513 ; CHECK-NEXT: s_addc_u32 s5, s5, use_extern_overalign@gotpcrel32@hi+12
514 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
515 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
516 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
517 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
518 ; CHECK-NEXT: s_mov_b32 s15, 5
519 ; CHECK-NEXT: ds_write_b16 v0, v1
520 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:2
521 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
522 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
523 ; CHECK-NEXT: s_endpgm
524 call void @use_module()
525 store i16 1, ptr addrspace(3) @module_variable
527 store i16 2, ptr addrspace(3) @kernel_normal
529 call void @use_extern_overalign()
533 define amdgpu_kernel void @module_0_kernel_overalign_indirect_extern_overalign(i32 %idx) {
534 ; CHECK-LABEL: module_0_kernel_overalign_indirect_extern_overalign:
536 ; CHECK-NEXT: s_add_u32 s8, s8, s11
537 ; CHECK-NEXT: s_mov_b32 s32, 0
538 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
539 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
540 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
541 ; CHECK-NEXT: s_add_u32 s0, s0, s11
542 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
543 ; CHECK-NEXT: s_getpc_b64 s[6:7]
544 ; CHECK-NEXT: s_add_u32 s6, s6, use_extern_overalign@gotpcrel32@lo+4
545 ; CHECK-NEXT: s_addc_u32 s7, s7, use_extern_overalign@gotpcrel32@hi+12
546 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
547 ; CHECK-NEXT: s_load_dwordx2 s[8:9], s[6:7], 0x0
548 ; CHECK-NEXT: v_mov_b32_e32 v1, 2
549 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
550 ; CHECK-NEXT: s_mov_b32 s15, 3
551 ; CHECK-NEXT: ds_write_b16 v0, v1
552 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
553 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[8:9]
554 ; CHECK-NEXT: s_endpgm
555 store i16 2, ptr addrspace(3) @kernel_overalign
557 call void @use_extern_overalign()
561 define amdgpu_kernel void @module_1_kernel_overalign_indirect_extern_overalign(i32 %idx) {
562 ; CHECK-LABEL: module_1_kernel_overalign_indirect_extern_overalign:
564 ; CHECK-NEXT: s_add_u32 s8, s8, s11
565 ; CHECK-NEXT: s_mov_b32 s32, 0
566 ; CHECK-NEXT: s_addc_u32 s9, s9, 0
567 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s8
568 ; CHECK-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s9
569 ; CHECK-NEXT: s_add_u32 s0, s0, s11
570 ; CHECK-NEXT: s_addc_u32 s1, s1, 0
571 ; CHECK-NEXT: s_mov_b64 s[6:7], s[4:5]
572 ; CHECK-NEXT: s_getpc_b64 s[4:5]
573 ; CHECK-NEXT: s_add_u32 s4, s4, use_module@gotpcrel32@lo+4
574 ; CHECK-NEXT: s_addc_u32 s5, s5, use_module@gotpcrel32@hi+12
575 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
576 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
577 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
578 ; CHECK-NEXT: s_getpc_b64 s[4:5]
579 ; CHECK-NEXT: s_add_u32 s4, s4, use_extern_overalign@gotpcrel32@lo+4
580 ; CHECK-NEXT: s_addc_u32 s5, s5, use_extern_overalign@gotpcrel32@hi+12
581 ; CHECK-NEXT: v_mov_b32_e32 v0, 0
582 ; CHECK-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0
583 ; CHECK-NEXT: v_mov_b32_e32 v1, 1
584 ; CHECK-NEXT: v_mov_b32_e32 v2, 2
585 ; CHECK-NEXT: s_mov_b32 s15, 7
586 ; CHECK-NEXT: ds_write_b16 v0, v1
587 ; CHECK-NEXT: ds_write_b16 v0, v2 offset:4
588 ; CHECK-NEXT: s_waitcnt lgkmcnt(0)
589 ; CHECK-NEXT: s_swappc_b64 s[30:31], s[4:5]
590 ; CHECK-NEXT: s_endpgm
591 call void @use_module()
592 store i16 1, ptr addrspace(3) @module_variable
594 store i16 2, ptr addrspace(3) @kernel_overalign
596 call void @use_extern_overalign()
601 attributes #0 = { noinline }