1 ; RUN: llc -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -amdgpu-scalarize-global-loads=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI,MESA %s
2 ; RUN: llc -march=amdgcn -mcpu=hawaii -amdgpu-scalarize-global-loads=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI,MESA %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -amdgpu-scalarize-global-loads=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9,VI,MESA %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -mattr=-flat-for-global -amdgpu-scalarize-global-loads=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI,HSA %s
6 declare hidden void @external_void_func_i1(i1) #0
7 declare hidden void @external_void_func_i1_signext(i1 signext) #0
8 declare hidden void @external_void_func_i1_zeroext(i1 zeroext) #0
10 declare hidden void @external_void_func_i8(i8) #0
11 declare hidden void @external_void_func_i8_signext(i8 signext) #0
12 declare hidden void @external_void_func_i8_zeroext(i8 zeroext) #0
14 declare hidden void @external_void_func_i16(i16) #0
15 declare hidden void @external_void_func_i16_signext(i16 signext) #0
16 declare hidden void @external_void_func_i16_zeroext(i16 zeroext) #0
18 declare hidden void @external_void_func_i32(i32) #0
19 declare hidden void @external_void_func_i64(i64) #0
20 declare hidden void @external_void_func_v2i64(<2 x i64>) #0
21 declare hidden void @external_void_func_v3i64(<3 x i64>) #0
22 declare hidden void @external_void_func_v4i64(<4 x i64>) #0
24 declare hidden void @external_void_func_f16(half) #0
25 declare hidden void @external_void_func_f32(float) #0
26 declare hidden void @external_void_func_f64(double) #0
27 declare hidden void @external_void_func_v2f32(<2 x float>) #0
28 declare hidden void @external_void_func_v2f64(<2 x double>) #0
29 declare hidden void @external_void_func_v3f64(<3 x double>) #0
31 declare hidden void @external_void_func_v2i16(<2 x i16>) #0
32 declare hidden void @external_void_func_v2f16(<2 x half>) #0
33 declare hidden void @external_void_func_v3i16(<3 x i16>) #0
34 declare hidden void @external_void_func_v3f16(<3 x half>) #0
35 declare hidden void @external_void_func_v4i16(<4 x i16>) #0
36 declare hidden void @external_void_func_v4f16(<4 x half>) #0
38 declare hidden void @external_void_func_v2i32(<2 x i32>) #0
39 declare hidden void @external_void_func_v3i32(<3 x i32>) #0
40 declare hidden void @external_void_func_v3i32_i32(<3 x i32>, i32) #0
41 declare hidden void @external_void_func_v4i32(<4 x i32>) #0
42 declare hidden void @external_void_func_v8i32(<8 x i32>) #0
43 declare hidden void @external_void_func_v16i32(<16 x i32>) #0
44 declare hidden void @external_void_func_v32i32(<32 x i32>) #0
45 declare hidden void @external_void_func_v32i32_i32(<32 x i32>, i32) #0
47 ; return value and argument
48 declare hidden i32 @external_i32_func_i32(i32) #0
51 declare hidden void @external_void_func_struct_i8_i32({ i8, i32 }) #0
52 declare hidden void @external_void_func_byval_struct_i8_i32({ i8, i32 } addrspace(5)* byval) #0
53 declare hidden void @external_void_func_sret_struct_i8_i32_byval_struct_i8_i32({ i8, i32 } addrspace(5)* sret, { i8, i32 } addrspace(5)* byval) #0
55 declare hidden void @external_void_func_v16i8(<16 x i8>) #0
58 ; FIXME: Should be passing -1
59 ; GCN-LABEL: {{^}}test_call_external_void_func_i1_imm:
60 ; MESA: s_mov_b32 s36, SCRATCH_RSRC_DWORD
62 ; MESA-DAG: s_mov_b64 s[0:1], s[36:37]
64 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
65 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i1@rel32@lo+4
66 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i1@rel32@hi+4
67 ; GCN-DAG: v_mov_b32_e32 v0, 1{{$}}
68 ; MESA-DAG: s_mov_b64 s[2:3], s[38:39]
70 ; GCN: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
72 define amdgpu_kernel void @test_call_external_void_func_i1_imm() #0 {
73 call void @external_void_func_i1(i1 true)
77 ; GCN-LABEL: {{^}}test_call_external_void_func_i1_signext:
78 ; MESA: s_mov_b32 s33, s3{{$}}
79 ; HSA: s_mov_b32 s33, s9{{$}}
81 ; GCN: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
82 ; GCN-NEXT: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i1_signext@rel32@lo+4
83 ; GCN-NEXT: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i1_signext@rel32@hi+4
84 ; GCN-NEXT: buffer_load_ubyte [[VAR:v[0-9]+]]
85 ; HSA-NEXT: s_mov_b32 s4, s33
86 ; HSA-NEXT: s_mov_b32 s32, s33
88 ; MESA-DAG: s_mov_b32 s4, s33{{$}}
89 ; MESA-DAG: s_mov_b32 s32, s33{{$}}
91 ; GCN: s_waitcnt vmcnt(0)
92 ; GCN-NEXT: v_bfe_i32 v0, v0, 0, 1
93 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
95 define amdgpu_kernel void @test_call_external_void_func_i1_signext(i32) #0 {
96 %var = load volatile i1, i1 addrspace(1)* undef
97 call void @external_void_func_i1_signext(i1 %var)
101 ; FIXME: load should be scheduled before getpc
102 ; GCN-LABEL: {{^}}test_call_external_void_func_i1_zeroext:
103 ; MESA: s_mov_b32 s33, s3{{$}}
105 ; GCN: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
106 ; GCN-NEXT: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i1_zeroext@rel32@lo+4
107 ; GCN-NEXT: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i1_zeroext@rel32@hi+4
108 ; GCN-NEXT: buffer_load_ubyte v0
110 ; GCN-DAG: s_mov_b32 s4, s33{{$}}
111 ; GCN-DAG: s_mov_b32 s32, s33{{$}}
113 ; GCN: s_waitcnt vmcnt(0)
114 ; GCN-NEXT: v_and_b32_e32 v0, 1, v0
115 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
117 define amdgpu_kernel void @test_call_external_void_func_i1_zeroext(i32) #0 {
118 %var = load volatile i1, i1 addrspace(1)* undef
119 call void @external_void_func_i1_zeroext(i1 %var)
123 ; GCN-LABEL: {{^}}test_call_external_void_func_i8_imm:
124 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
126 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
127 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i8@rel32@lo+4
128 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i8@rel32@hi+4
129 ; GCN-DAG: v_mov_b32_e32 v0, 0x7b
131 ; HSA-DAG: s_mov_b32 s4, s33{{$}}
132 ; GCN-DAG: s_mov_b32 s32, s33{{$}}
134 ; GCN: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
136 define amdgpu_kernel void @test_call_external_void_func_i8_imm(i32) #0 {
137 call void @external_void_func_i8(i8 123)
141 ; FIXME: don't wait before call
142 ; GCN-LABEL: {{^}}test_call_external_void_func_i8_signext:
143 ; HSA-DAG: s_mov_b32 s33, s9{{$}}
144 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
146 ; GCN-DAG: buffer_load_sbyte v0
147 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
148 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i8_signext@rel32@lo+4
149 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i8_signext@rel32@hi+4
151 ; GCN-DAG: s_mov_b32 s4, s33
152 ; GCN-DAG: s_mov_b32 s32, s3
154 ; GCN: s_waitcnt vmcnt(0)
155 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
157 define amdgpu_kernel void @test_call_external_void_func_i8_signext(i32) #0 {
158 %var = load volatile i8, i8 addrspace(1)* undef
159 call void @external_void_func_i8_signext(i8 %var)
163 ; GCN-LABEL: {{^}}test_call_external_void_func_i8_zeroext:
164 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
165 ; HSA-DAG: s_mov_b32 s33, s9{{$}}
167 ; GCN-DAG: buffer_load_ubyte v0
168 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
169 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i8_zeroext@rel32@lo+4
170 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i8_zeroext@rel32@hi+4
172 ; GCN-DAG: s_mov_b32 s32, s33
174 ; GCN: s_waitcnt vmcnt(0)
175 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
177 define amdgpu_kernel void @test_call_external_void_func_i8_zeroext(i32) #0 {
178 %var = load volatile i8, i8 addrspace(1)* undef
179 call void @external_void_func_i8_zeroext(i8 %var)
183 ; GCN-LABEL: {{^}}test_call_external_void_func_i16_imm:
184 ; GCN-DAG: v_mov_b32_e32 v0, 0x7b{{$}}
186 ; GCN-DAG: s_mov_b32 s4, s33
187 ; GCN-DAG: s_mov_b32 s32, s33
190 define amdgpu_kernel void @test_call_external_void_func_i16_imm() #0 {
191 call void @external_void_func_i16(i16 123)
195 ; GCN-LABEL: {{^}}test_call_external_void_func_i16_signext:
196 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
198 ; GCN-DAG: buffer_load_sshort v0
199 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
200 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i16_signext@rel32@lo+4
201 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i16_signext@rel32@hi+4
203 ; GCN-DAG: s_mov_b32 s32, s33
205 ; GCN: s_waitcnt vmcnt(0)
206 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
208 define amdgpu_kernel void @test_call_external_void_func_i16_signext(i32) #0 {
209 %var = load volatile i16, i16 addrspace(1)* undef
210 call void @external_void_func_i16_signext(i16 %var)
214 ; GCN-LABEL: {{^}}test_call_external_void_func_i16_zeroext:
215 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
218 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
219 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i16_zeroext@rel32@lo+4
220 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i16_zeroext@rel32@hi+4
222 ; GCN-DAG: s_mov_b32 s32, s33
224 ; GCN: s_waitcnt vmcnt(0)
225 ; GCN-NEXT: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
227 define amdgpu_kernel void @test_call_external_void_func_i16_zeroext(i32) #0 {
228 %var = load volatile i16, i16 addrspace(1)* undef
229 call void @external_void_func_i16_zeroext(i16 %var)
233 ; GCN-LABEL: {{^}}test_call_external_void_func_i32_imm:
234 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
236 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
237 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i32@rel32@lo+4
238 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i32@rel32@hi+4
239 ; GCN-DAG: v_mov_b32_e32 v0, 42
240 ; GCN-DAG: s_mov_b32 s4, s33
241 ; GCN-DAG: s_mov_b32 s32, s33
243 ; GCN: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
245 define amdgpu_kernel void @test_call_external_void_func_i32_imm(i32) #0 {
246 call void @external_void_func_i32(i32 42)
250 ; GCN-LABEL: {{^}}test_call_external_void_func_i64_imm:
251 ; GCN-DAG: s_movk_i32 [[K0:s[0-9]+]], 0x7b{{$}}
252 ; GCN-DAG: s_mov_b32 [[K1:s[0-9]+]], 0{{$}}
253 ; GCN-DAG: v_mov_b32_e32 v0, [[K0]]
254 ; GCN-DAG: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}}
255 ; GCN-DAG: s_add_u32 s[[PC_LO]], s[[PC_LO]], external_void_func_i64@rel32@lo+4
256 ; GCN-DAG: s_addc_u32 s[[PC_HI]], s[[PC_HI]], external_void_func_i64@rel32@hi+4
257 ; GCN-DAG: v_mov_b32_e32 v1, [[K1]]
258 ; GCN: s_swappc_b64 s[30:31], s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}}
260 define amdgpu_kernel void @test_call_external_void_func_i64_imm() #0 {
261 call void @external_void_func_i64(i64 123)
265 ; GCN-LABEL: {{^}}test_call_external_void_func_v2i64:
266 ; GCN: buffer_load_dwordx4 v[0:3]
268 ; GCN-NEXT: s_swappc_b64
269 define amdgpu_kernel void @test_call_external_void_func_v2i64() #0 {
270 %val = load <2 x i64>, <2 x i64> addrspace(1)* null
271 call void @external_void_func_v2i64(<2 x i64> %val)
275 ; GCN-LABEL: {{^}}test_call_external_void_func_v2i64_imm:
276 ; GCN-DAG: v_mov_b32_e32 v0, 1
277 ; GCN-DAG: v_mov_b32_e32 v1, 2
278 ; GCN-DAG: v_mov_b32_e32 v2, 3
279 ; GCN-DAG: v_mov_b32_e32 v3, 4
281 define amdgpu_kernel void @test_call_external_void_func_v2i64_imm() #0 {
282 call void @external_void_func_v2i64(<2 x i64> <i64 8589934593, i64 17179869187>)
286 ; GCN-LABEL: {{^}}test_call_external_void_func_v3i64:
287 ; GCN: buffer_load_dwordx4 v[0:3]
288 ; GCN: v_mov_b32_e32 v4, 1
289 ; GCN: v_mov_b32_e32 v5, 2
291 ; GCN-NEXT: s_swappc_b64
292 define amdgpu_kernel void @test_call_external_void_func_v3i64() #0 {
293 %load = load <2 x i64>, <2 x i64> addrspace(1)* null
294 %val = shufflevector <2 x i64> %load, <2 x i64> <i64 8589934593, i64 undef>, <3 x i32> <i32 0, i32 1, i32 2>
296 call void @external_void_func_v3i64(<3 x i64> %val)
300 ; GCN-LABEL: {{^}}test_call_external_void_func_v4i64:
301 ; GCN: buffer_load_dwordx4 v[0:3]
302 ; GCN-DAG: v_mov_b32_e32 v4, 1
303 ; GCN-DAG: v_mov_b32_e32 v5, 2
304 ; GCN-DAG: v_mov_b32_e32 v6, 3
305 ; GCN-DAG: v_mov_b32_e32 v7, 4
308 ; GCN-NEXT: s_swappc_b64
309 define amdgpu_kernel void @test_call_external_void_func_v4i64() #0 {
310 %load = load <2 x i64>, <2 x i64> addrspace(1)* null
311 %val = shufflevector <2 x i64> %load, <2 x i64> <i64 8589934593, i64 17179869187>, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
312 call void @external_void_func_v4i64(<4 x i64> %val)
316 ; GCN-LABEL: {{^}}test_call_external_void_func_f16_imm:
317 ; VI: v_mov_b32_e32 v0, 0x4400
318 ; CI: v_mov_b32_e32 v0, 4.0
321 define amdgpu_kernel void @test_call_external_void_func_f16_imm() #0 {
322 call void @external_void_func_f16(half 4.0)
326 ; GCN-LABEL: {{^}}test_call_external_void_func_f32_imm:
327 ; GCN: v_mov_b32_e32 v0, 4.0
330 define amdgpu_kernel void @test_call_external_void_func_f32_imm() #0 {
331 call void @external_void_func_f32(float 4.0)
335 ; GCN-LABEL: {{^}}test_call_external_void_func_v2f32_imm:
336 ; GCN-DAG: v_mov_b32_e32 v0, 1.0
337 ; GCN-DAG: v_mov_b32_e32 v1, 2.0
339 define amdgpu_kernel void @test_call_external_void_func_v2f32_imm() #0 {
340 call void @external_void_func_v2f32(<2 x float> <float 1.0, float 2.0>)
344 ; GCN-LABEL: {{^}}test_call_external_void_func_f64_imm:
345 ; GCN: v_mov_b32_e32 v0, 0{{$}}
346 ; GCN: v_mov_b32_e32 v1, 0x40100000
348 define amdgpu_kernel void @test_call_external_void_func_f64_imm() #0 {
349 call void @external_void_func_f64(double 4.0)
353 ; GCN-LABEL: {{^}}test_call_external_void_func_v2f64_imm:
354 ; GCN: v_mov_b32_e32 v0, 0{{$}}
355 ; GCN: v_mov_b32_e32 v1, 2.0
356 ; GCN: v_mov_b32_e32 v2, 0{{$}}
357 ; GCN: v_mov_b32_e32 v3, 0x40100000
359 define amdgpu_kernel void @test_call_external_void_func_v2f64_imm() #0 {
360 call void @external_void_func_v2f64(<2 x double> <double 2.0, double 4.0>)
364 ; GCN-LABEL: {{^}}test_call_external_void_func_v3f64_imm:
365 ; GCN-DAG: v_mov_b32_e32 v0, 0{{$}}
366 ; GCN-DAG: v_mov_b32_e32 v1, 2.0
367 ; GCN-DAG: v_mov_b32_e32 v2, 0{{$}}
368 ; GCN-DAG: v_mov_b32_e32 v3, 0x40100000
369 ; GCN-DAG: v_mov_b32_e32 v4, 0{{$}}
370 ; GCN-DAG: v_mov_b32_e32 v5, 0x40200000
371 ; GCN-DAG: s_swappc_b64
372 define amdgpu_kernel void @test_call_external_void_func_v3f64_imm() #0 {
373 call void @external_void_func_v3f64(<3 x double> <double 2.0, double 4.0, double 8.0>)
377 ; GCN-LABEL: {{^}}test_call_external_void_func_v2i16:
378 ; GFX9: buffer_load_dword v0
381 define amdgpu_kernel void @test_call_external_void_func_v2i16() #0 {
382 %val = load <2 x i16>, <2 x i16> addrspace(1)* undef
383 call void @external_void_func_v2i16(<2 x i16> %val)
387 ; GCN-LABEL: {{^}}test_call_external_void_func_v3i16:
388 ; GFX9: buffer_load_dwordx2 v[0:1]
392 define amdgpu_kernel void @test_call_external_void_func_v3i16() #0 {
393 %val = load <3 x i16>, <3 x i16> addrspace(1)* undef
394 call void @external_void_func_v3i16(<3 x i16> %val)
398 ; GCN-LABEL: {{^}}test_call_external_void_func_v3f16:
399 ; GFX9: buffer_load_dwordx2 v[0:1]
403 define amdgpu_kernel void @test_call_external_void_func_v3f16() #0 {
404 %val = load <3 x half>, <3 x half> addrspace(1)* undef
405 call void @external_void_func_v3f16(<3 x half> %val)
409 ; GCN-LABEL: {{^}}test_call_external_void_func_v3i16_imm:
410 ; GFX9: v_mov_b32_e32 v0, 0x20001
411 ; GFX9: v_mov_b32_e32 v1, 3
413 define amdgpu_kernel void @test_call_external_void_func_v3i16_imm() #0 {
414 call void @external_void_func_v3i16(<3 x i16> <i16 1, i16 2, i16 3>)
418 ; GCN-LABEL: {{^}}test_call_external_void_func_v3f16_imm:
419 ; GFX9: v_mov_b32_e32 v0, 0x40003c00
420 ; GFX9: v_mov_b32_e32 v1, 0x4400
422 define amdgpu_kernel void @test_call_external_void_func_v3f16_imm() #0 {
423 call void @external_void_func_v3f16(<3 x half> <half 1.0, half 2.0, half 4.0>)
427 ; GCN-LABEL: {{^}}test_call_external_void_func_v4i16:
428 ; GFX9: buffer_load_dwordx2 v[0:1]
432 define amdgpu_kernel void @test_call_external_void_func_v4i16() #0 {
433 %val = load <4 x i16>, <4 x i16> addrspace(1)* undef
434 call void @external_void_func_v4i16(<4 x i16> %val)
438 ; GCN-LABEL: {{^}}test_call_external_void_func_v4i16_imm:
439 ; GFX9-DAG: v_mov_b32_e32 v0, 0x20001
440 ; GFX9-DAG: v_mov_b32_e32 v1, 0x40003
442 define amdgpu_kernel void @test_call_external_void_func_v4i16_imm() #0 {
443 call void @external_void_func_v4i16(<4 x i16> <i16 1, i16 2, i16 3, i16 4>)
447 ; GCN-LABEL: {{^}}test_call_external_void_func_v2f16:
448 ; GFX9: buffer_load_dword v0
451 define amdgpu_kernel void @test_call_external_void_func_v2f16() #0 {
452 %val = load <2 x half>, <2 x half> addrspace(1)* undef
453 call void @external_void_func_v2f16(<2 x half> %val)
457 ; GCN-LABEL: {{^}}test_call_external_void_func_v2i32:
458 ; GCN: buffer_load_dwordx2 v[0:1]
460 ; GCN-NEXT: s_swappc_b64
461 define amdgpu_kernel void @test_call_external_void_func_v2i32() #0 {
462 %val = load <2 x i32>, <2 x i32> addrspace(1)* undef
463 call void @external_void_func_v2i32(<2 x i32> %val)
467 ; GCN-LABEL: {{^}}test_call_external_void_func_v2i32_imm:
468 ; GCN-DAG: v_mov_b32_e32 v0, 1
469 ; GCN-DAG: v_mov_b32_e32 v1, 2
471 define amdgpu_kernel void @test_call_external_void_func_v2i32_imm() #0 {
472 call void @external_void_func_v2i32(<2 x i32> <i32 1, i32 2>)
476 ; GCN-LABEL: {{^}}test_call_external_void_func_v3i32_imm:
477 ; HSA-DAG: s_mov_b32 s33, s9
478 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
481 ; GCN-DAG: v_mov_b32_e32 v0, 3
482 ; GCN-DAG: v_mov_b32_e32 v1, 4
483 ; GCN-DAG: v_mov_b32_e32 v2, 5
486 define amdgpu_kernel void @test_call_external_void_func_v3i32_imm(i32) #0 {
487 call void @external_void_func_v3i32(<3 x i32> <i32 3, i32 4, i32 5>)
491 ; GCN-LABEL: {{^}}test_call_external_void_func_v3i32_i32:
492 ; GCN-DAG: v_mov_b32_e32 v0, 3
493 ; GCN-DAG: v_mov_b32_e32 v1, 4
494 ; GCN-DAG: v_mov_b32_e32 v2, 5
495 ; GCN-DAG: v_mov_b32_e32 v3, 6
496 define amdgpu_kernel void @test_call_external_void_func_v3i32_i32(i32) #0 {
497 call void @external_void_func_v3i32_i32(<3 x i32> <i32 3, i32 4, i32 5>, i32 6)
501 ; GCN-LABEL: {{^}}test_call_external_void_func_v4i32:
502 ; GCN: buffer_load_dwordx4 v[0:3]
504 ; GCN-NEXT: s_swappc_b64
505 define amdgpu_kernel void @test_call_external_void_func_v4i32() #0 {
506 %val = load <4 x i32>, <4 x i32> addrspace(1)* undef
507 call void @external_void_func_v4i32(<4 x i32> %val)
511 ; GCN-LABEL: {{^}}test_call_external_void_func_v4i32_imm:
512 ; GCN-DAG: v_mov_b32_e32 v0, 1
513 ; GCN-DAG: v_mov_b32_e32 v1, 2
514 ; GCN-DAG: v_mov_b32_e32 v2, 3
515 ; GCN-DAG: v_mov_b32_e32 v3, 4
517 define amdgpu_kernel void @test_call_external_void_func_v4i32_imm() #0 {
518 call void @external_void_func_v4i32(<4 x i32> <i32 1, i32 2, i32 3, i32 4>)
522 ; GCN-LABEL: {{^}}test_call_external_void_func_v8i32:
523 ; GCN-DAG: buffer_load_dwordx4 v[0:3], off
524 ; GCN-DAG: buffer_load_dwordx4 v[4:7], off
526 ; GCN-NEXT: s_swappc_b64
527 define amdgpu_kernel void @test_call_external_void_func_v8i32() #0 {
528 %ptr = load <8 x i32> addrspace(1)*, <8 x i32> addrspace(1)* addrspace(4)* undef
529 %val = load <8 x i32>, <8 x i32> addrspace(1)* %ptr
530 call void @external_void_func_v8i32(<8 x i32> %val)
534 ; GCN-LABEL: {{^}}test_call_external_void_func_v8i32_imm:
535 ; GCN-DAG: v_mov_b32_e32 v0, 1
536 ; GCN-DAG: v_mov_b32_e32 v1, 2
537 ; GCN-DAG: v_mov_b32_e32 v2, 3
538 ; GCN-DAG: v_mov_b32_e32 v3, 4
539 ; GCN-DAG: v_mov_b32_e32 v4, 5
540 ; GCN-DAG: v_mov_b32_e32 v5, 6
541 ; GCN-DAG: v_mov_b32_e32 v6, 7
542 ; GCN-DAG: v_mov_b32_e32 v7, 8
544 define amdgpu_kernel void @test_call_external_void_func_v8i32_imm() #0 {
545 call void @external_void_func_v8i32(<8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>)
549 ; GCN-LABEL: {{^}}test_call_external_void_func_v16i32:
550 ; GCN-DAG: buffer_load_dwordx4 v[0:3], off
551 ; GCN-DAG: buffer_load_dwordx4 v[4:7], off
552 ; GCN-DAG: buffer_load_dwordx4 v[8:11], off
553 ; GCN-DAG: buffer_load_dwordx4 v[12:15], off
555 ; GCN-NEXT: s_swappc_b64
556 define amdgpu_kernel void @test_call_external_void_func_v16i32() #0 {
557 %ptr = load <16 x i32> addrspace(1)*, <16 x i32> addrspace(1)* addrspace(4)* undef
558 %val = load <16 x i32>, <16 x i32> addrspace(1)* %ptr
559 call void @external_void_func_v16i32(<16 x i32> %val)
563 ; GCN-LABEL: {{^}}test_call_external_void_func_v32i32:
564 ; GCN-DAG: buffer_load_dwordx4 v[0:3], off
565 ; GCN-DAG: buffer_load_dwordx4 v[4:7], off
566 ; GCN-DAG: buffer_load_dwordx4 v[8:11], off
567 ; GCN-DAG: buffer_load_dwordx4 v[12:15], off
568 ; GCN-DAG: buffer_load_dwordx4 v[16:19], off
569 ; GCN-DAG: buffer_load_dwordx4 v[20:23], off
570 ; GCN-DAG: buffer_load_dwordx4 v[24:27], off
571 ; GCN-DAG: buffer_load_dwordx4 v[28:31], off
573 ; GCN-NEXT: s_swappc_b64
574 define amdgpu_kernel void @test_call_external_void_func_v32i32() #0 {
575 %ptr = load <32 x i32> addrspace(1)*, <32 x i32> addrspace(1)* addrspace(4)* undef
576 %val = load <32 x i32>, <32 x i32> addrspace(1)* %ptr
577 call void @external_void_func_v32i32(<32 x i32> %val)
581 ; GCN-LABEL: {{^}}test_call_external_void_func_v32i32_i32:
582 ; HSA-DAG: s_mov_b32 s33, s9
583 ; HSA-NOT: s_add_u32 s32
585 ; MESA-DAG: s_mov_b32 s33, s3{{$}}
586 ; MESA-NOT: s_add_u32 s32
588 ; GCN-DAG: buffer_load_dword [[VAL1:v[0-9]+]], off, s[{{[0-9]+}}:{{[0-9]+}}], 0{{$}}
589 ; GCN-DAG: buffer_load_dwordx4 v[0:3], off
590 ; GCN-DAG: buffer_load_dwordx4 v[4:7], off
591 ; GCN-DAG: buffer_load_dwordx4 v[8:11], off
592 ; GCN-DAG: buffer_load_dwordx4 v[12:15], off
593 ; GCN-DAG: buffer_load_dwordx4 v[16:19], off
594 ; GCN-DAG: buffer_load_dwordx4 v[20:23], off
595 ; GCN-DAG: buffer_load_dwordx4 v[24:27], off
596 ; GCN-DAG: buffer_load_dwordx4 v[28:31], off
599 ; GCN: buffer_store_dword [[VAL1]], off, s[{{[0-9]+}}:{{[0-9]+}}], s32 offset:4{{$}}
602 define amdgpu_kernel void @test_call_external_void_func_v32i32_i32(i32) #0 {
603 %ptr0 = load <32 x i32> addrspace(1)*, <32 x i32> addrspace(1)* addrspace(4)* undef
604 %val0 = load <32 x i32>, <32 x i32> addrspace(1)* %ptr0
605 %val1 = load i32, i32 addrspace(1)* undef
606 call void @external_void_func_v32i32_i32(<32 x i32> %val0, i32 %val1)
610 ; FIXME: No wait after call
611 ; GCN-LABEL: {{^}}test_call_external_i32_func_i32_imm:
612 ; GCN: v_mov_b32_e32 v0, 42
613 ; GCN: s_swappc_b64 s[30:31],
614 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
615 ; GCN-NEXT: buffer_store_dword v0, off, s[36:39], 0
616 define amdgpu_kernel void @test_call_external_i32_func_i32_imm(i32 addrspace(1)* %out) #0 {
617 %val = call i32 @external_i32_func_i32(i32 42)
618 store volatile i32 %val, i32 addrspace(1)* %out
622 ; GCN-LABEL: {{^}}test_call_external_void_func_struct_i8_i32:
623 ; GCN: buffer_load_ubyte v0, off
624 ; GCN: buffer_load_dword v1, off
625 ; GCN: s_waitcnt vmcnt(0)
626 ; GCN-NEXT: s_swappc_b64
627 define amdgpu_kernel void @test_call_external_void_func_struct_i8_i32() #0 {
628 %ptr0 = load { i8, i32 } addrspace(1)*, { i8, i32 } addrspace(1)* addrspace(4)* undef
629 %val = load { i8, i32 }, { i8, i32 } addrspace(1)* %ptr0
630 call void @external_void_func_struct_i8_i32({ i8, i32 } %val)
634 ; GCN-LABEL: {{^}}test_call_external_void_func_byval_struct_i8_i32:
635 ; GCN-DAG: s_add_u32 [[SP:s[0-9]+]], s33, 0x400{{$}}
637 ; GCN-DAG: v_mov_b32_e32 [[VAL0:v[0-9]+]], 3
638 ; GCN-DAG: v_mov_b32_e32 [[VAL1:v[0-9]+]], 8
639 ; MESA-DAG: buffer_store_byte [[VAL0]], off, s[36:39], s33 offset:8
640 ; MESA-DAG: buffer_store_dword [[VAL1]], off, s[36:39], s33 offset:12
642 ; HSA-DAG: buffer_store_byte [[VAL0]], off, s[0:3], s33 offset:8
643 ; HSA-DAG: buffer_store_dword [[VAL1]], off, s[0:3], s33 offset:12
645 ; GCN-NOT: s_add_u32 [[SP]],
647 ; HSA: buffer_load_dword [[RELOAD_VAL0:v[0-9]+]], off, s[0:3], s33 offset:8
648 ; HSA: buffer_load_dword [[RELOAD_VAL1:v[0-9]+]], off, s[0:3], s33 offset:12
650 ; HSA-DAG: buffer_store_dword [[RELOAD_VAL0]], off, s[0:3], [[SP]] offset:4
651 ; HSA-DAG: buffer_store_dword [[RELOAD_VAL1]], off, s[0:3], [[SP]] offset:8
654 ; MESA: buffer_load_dword [[RELOAD_VAL0:v[0-9]+]], off, s[36:39], s33 offset:8
655 ; MESA: buffer_load_dword [[RELOAD_VAL1:v[0-9]+]], off, s[36:39], s33 offset:12
657 ; MESA-DAG: buffer_store_dword [[RELOAD_VAL0]], off, s[36:39], [[SP]] offset:4
658 ; MESA-DAG: buffer_store_dword [[RELOAD_VAL1]], off, s[36:39], [[SP]] offset:8
660 ; GCN-NEXT: s_swappc_b64
662 define amdgpu_kernel void @test_call_external_void_func_byval_struct_i8_i32() #0 {
663 %val = alloca { i8, i32 }, align 4, addrspace(5)
664 %gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %val, i32 0, i32 0
665 %gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %val, i32 0, i32 1
666 store i8 3, i8 addrspace(5)* %gep0
667 store i32 8, i32 addrspace(5)* %gep1
668 call void @external_void_func_byval_struct_i8_i32({ i8, i32 } addrspace(5)* %val)
672 ; GCN-LABEL: {{^}}test_call_external_void_func_sret_struct_i8_i32_byval_struct_i8_i32:
673 ; MESA-DAG: s_add_u32 [[SP:s[0-9]+]], [[FP_REG:s[0-9]+]], 0x800{{$}}
674 ; HSA-DAG: s_add_u32 [[SP:s[0-9]+]], [[FP_REG:s[0-9]+]], 0x800{{$}}
676 ; GCN-DAG: v_mov_b32_e32 [[VAL0:v[0-9]+]], 3
677 ; GCN-DAG: v_mov_b32_e32 [[VAL1:v[0-9]+]], 8
678 ; GCN-DAG: buffer_store_byte [[VAL0]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:8
679 ; GCN-DAG: buffer_store_dword [[VAL1]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:12
681 ; GCN-DAG: buffer_load_dword [[RELOAD_VAL0:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:8
682 ; GCN-DAG: buffer_load_dword [[RELOAD_VAL1:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:12
684 ; GCN-NOT: s_add_u32 [[SP]]
685 ; GCN-DAG: buffer_store_dword [[RELOAD_VAL0]], off, s{{\[[0-9]+:[0-9]+\]}}, [[SP]] offset:4
686 ; GCN-DAG: buffer_store_dword [[RELOAD_VAL1]], off, s{{\[[0-9]+:[0-9]+\]}}, [[SP]] offset:8
688 ; GCN-DAG: buffer_load_ubyte [[LOAD_OUT_VAL0:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:16
689 ; GCN-DAG: buffer_load_dword [[LOAD_OUT_VAL1:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, [[FP_REG]] offset:20
690 ; GCN-NOT: s_sub_u32 [[SP]]
692 ; GCN: buffer_store_byte [[LOAD_OUT_VAL0]], off
693 ; GCN: buffer_store_dword [[LOAD_OUT_VAL1]], off
694 define amdgpu_kernel void @test_call_external_void_func_sret_struct_i8_i32_byval_struct_i8_i32(i32) #0 {
695 %in.val = alloca { i8, i32 }, align 4, addrspace(5)
696 %out.val = alloca { i8, i32 }, align 4, addrspace(5)
697 %in.gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %in.val, i32 0, i32 0
698 %in.gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %in.val, i32 0, i32 1
699 store i8 3, i8 addrspace(5)* %in.gep0
700 store i32 8, i32 addrspace(5)* %in.gep1
701 call void @external_void_func_sret_struct_i8_i32_byval_struct_i8_i32({ i8, i32 } addrspace(5)* %out.val, { i8, i32 } addrspace(5)* %in.val)
702 %out.gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %out.val, i32 0, i32 0
703 %out.gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %out.val, i32 0, i32 1
704 %out.val0 = load i8, i8 addrspace(5)* %out.gep0
705 %out.val1 = load i32, i32 addrspace(5)* %out.gep1
707 store volatile i8 %out.val0, i8 addrspace(1)* undef
708 store volatile i32 %out.val1, i32 addrspace(1)* undef
712 ; GCN-LABEL: {{^}}test_call_external_void_func_v16i8:
713 define amdgpu_kernel void @test_call_external_void_func_v16i8() #0 {
714 %ptr = load <16 x i8> addrspace(1)*, <16 x i8> addrspace(1)* addrspace(4)* undef
715 %val = load <16 x i8>, <16 x i8> addrspace(1)* %ptr
716 call void @external_void_func_v16i8(<16 x i8> %val)
720 ; GCN-LABEL: {{^}}stack_passed_arg_alignment_v32i32_f64:
721 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, s32 offset:8
722 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, s32 offset:4
724 define amdgpu_kernel void @stack_passed_arg_alignment_v32i32_f64(<32 x i32> %val, double %tmp) #0 {
726 call void @stack_passed_f64_arg(<32 x i32> %val, double %tmp)
730 ; GCN-LABEL: {{^}}tail_call_byval_align16:
731 ; GCN: s_mov_b32 s5, s32
732 ; GCN: buffer_store_dword v32, off, s[0:3], s5 offset:28 ; 4-byte Folded Spill
733 ; GCN: buffer_store_dword v33, off, s[0:3], s5 offset:24 ; 4-byte Folded Spill
734 ; GCN: buffer_load_dword v32, off, s[0:3], s5 offset:32
735 ; GCN: buffer_load_dword v33, off, s[0:3], s5 offset:36
736 ; GCN: buffer_store_dword v33, off, s[0:3], s5 offset:20
737 ; GCN: buffer_store_dword v32, off, s[0:3], s5 offset:16
739 ; GCN: buffer_load_dword v33, off, s[0:3], s5 offset:24 ; 4-byte Folded Reload
740 ; GCN: buffer_load_dword v32, off, s[0:3], s5 offset:28 ; 4-byte Folded Reload
742 define void @tail_call_byval_align16(<32 x i32> %val, double %tmp) #0 {
744 %alloca = alloca double, align 8, addrspace(5)
745 tail call void @byval_align16_f64_arg(<32 x i32> %val, double addrspace(5)* byval align 16 %alloca)
749 ; GCN-LABEL: {{^}}tail_call_stack_passed_arg_alignment_v32i32_f64:
750 ; GCN: s_mov_b32 s5, s32
751 ; GCN: buffer_store_dword v32, off, s[0:3], s5 offset:16 ; 4-byte Folded Spill
752 ; GCN: buffer_store_dword v33, off, s[0:3], s5 offset:12 ; 4-byte Folded Spill
753 ; GCN: buffer_load_dword v32, off, s[0:3], s5 offset:4
754 ; GCN: buffer_load_dword v33, off, s[0:3], s5 offset:8
755 ; GCN: buffer_store_dword v33, off, s[0:3], s5 offset:8
756 ; GCN: buffer_store_dword v32, off, s[0:3], s5 offset:4
758 ; GCN: buffer_load_dword v33, off, s[0:3], s5 offset:12 ; 4-byte Folded Reload
759 ; GCN: buffer_load_dword v32, off, s[0:3], s5 offset:16 ; 4-byte Folded Reload
761 define void @tail_call_stack_passed_arg_alignment_v32i32_f64(<32 x i32> %val, double %tmp) #0 {
763 tail call void @stack_passed_f64_arg(<32 x i32> %val, double %tmp)
767 declare hidden void @byval_align16_f64_arg(<32 x i32>, double addrspace(5)* byval align 16) #0
768 declare hidden void @stack_passed_f64_arg(<32 x i32>, double) #0
770 attributes #0 = { nounwind }
771 attributes #1 = { nounwind readnone }
772 attributes #2 = { nounwind noinline }