1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc < %s -mtriple=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck -check-prefixes=GFX68,VERDE %s
3 ; RUN: llc < %s -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck -check-prefixes=GFX68,GFX8 %s
4 ; RUN: llc < %s -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs | FileCheck -check-prefixes=GFX11 %s
6 define amdgpu_ps void @buffer_store(<4 x i32> inreg, <4 x float>, <4 x float>, <4 x float>) {
7 ; GFX68-LABEL: buffer_store:
8 ; GFX68: ; %bb.0: ; %main_body
9 ; GFX68-NEXT: v_mov_b32_e32 v12, 0
10 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v12, s[0:3], 0 idxen
11 ; GFX68-NEXT: buffer_store_dwordx4 v[4:7], v12, s[0:3], 0 idxen glc
12 ; GFX68-NEXT: buffer_store_dwordx4 v[8:11], v12, s[0:3], 0 idxen slc
13 ; GFX68-NEXT: s_endpgm
15 ; GFX11-LABEL: buffer_store:
16 ; GFX11: ; %bb.0: ; %main_body
17 ; GFX11-NEXT: v_mov_b32_e32 v12, 0
18 ; GFX11-NEXT: s_clause 0x2
19 ; GFX11-NEXT: buffer_store_b128 v[0:3], v12, s[0:3], 0 idxen
20 ; GFX11-NEXT: buffer_store_b128 v[4:7], v12, s[0:3], 0 idxen glc
21 ; GFX11-NEXT: buffer_store_b128 v[8:11], v12, s[0:3], 0 idxen slc
22 ; GFX11-NEXT: s_endpgm
24 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 0, i32 0, i32 0)
25 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %2, <4 x i32> %0, i32 0, i32 0, i32 0, i32 1)
26 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %3, <4 x i32> %0, i32 0, i32 0, i32 0, i32 2)
30 define amdgpu_ps void @buffer_store_immoffs(<4 x i32> inreg, <4 x float>) {
31 ; GFX68-LABEL: buffer_store_immoffs:
32 ; GFX68: ; %bb.0: ; %main_body
33 ; GFX68-NEXT: v_mov_b32_e32 v4, 0
34 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v4, s[0:3], 0 idxen offset:42
35 ; GFX68-NEXT: s_endpgm
37 ; GFX11-LABEL: buffer_store_immoffs:
38 ; GFX11: ; %bb.0: ; %main_body
39 ; GFX11-NEXT: v_mov_b32_e32 v4, 0
40 ; GFX11-NEXT: buffer_store_b128 v[0:3], v4, s[0:3], 0 idxen offset:42
41 ; GFX11-NEXT: s_endpgm
43 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 42, i32 0, i32 0)
47 define amdgpu_ps void @buffer_store_idx(<4 x i32> inreg, <4 x float>, i32) {
48 ; GFX68-LABEL: buffer_store_idx:
49 ; GFX68: ; %bb.0: ; %main_body
50 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v4, s[0:3], 0 idxen
51 ; GFX68-NEXT: s_endpgm
53 ; GFX11-LABEL: buffer_store_idx:
54 ; GFX11: ; %bb.0: ; %main_body
55 ; GFX11-NEXT: buffer_store_b128 v[0:3], v4, s[0:3], 0 idxen
56 ; GFX11-NEXT: s_endpgm
58 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 0, i32 0, i32 0)
62 define amdgpu_ps void @buffer_store_ofs(<4 x i32> inreg, <4 x float>, i32) {
63 ; GFX68-LABEL: buffer_store_ofs:
64 ; GFX68: ; %bb.0: ; %main_body
65 ; GFX68-NEXT: s_mov_b32 s4, 0
66 ; GFX68-NEXT: v_mov_b32_e32 v5, v4
67 ; GFX68-NEXT: v_mov_b32_e32 v4, s4
68 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[0:3], 0 idxen offen
69 ; GFX68-NEXT: s_endpgm
71 ; GFX11-LABEL: buffer_store_ofs:
72 ; GFX11: ; %bb.0: ; %main_body
73 ; GFX11-NEXT: s_mov_b32 s4, 0
74 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
75 ; GFX11-NEXT: v_dual_mov_b32 v5, v4 :: v_dual_mov_b32 v4, s4
76 ; GFX11-NEXT: buffer_store_b128 v[0:3], v[4:5], s[0:3], 0 idxen offen
77 ; GFX11-NEXT: s_endpgm
79 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 %2, i32 0, i32 0)
83 define amdgpu_ps void @buffer_store_both(<4 x i32> inreg, <4 x float>, i32, i32) {
84 ; GFX68-LABEL: buffer_store_both:
85 ; GFX68: ; %bb.0: ; %main_body
86 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v[4:5], s[0:3], 0 idxen offen
87 ; GFX68-NEXT: s_endpgm
89 ; GFX11-LABEL: buffer_store_both:
90 ; GFX11: ; %bb.0: ; %main_body
91 ; GFX11-NEXT: buffer_store_b128 v[0:3], v[4:5], s[0:3], 0 idxen offen
92 ; GFX11-NEXT: s_endpgm
94 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 %3, i32 0, i32 0)
98 define amdgpu_ps void @buffer_store_both_reversed(<4 x i32> inreg, <4 x float>, i32, i32) {
99 ; GFX68-LABEL: buffer_store_both_reversed:
100 ; GFX68: ; %bb.0: ; %main_body
101 ; GFX68-NEXT: v_mov_b32_e32 v6, v4
102 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v[5:6], s[0:3], 0 idxen offen
103 ; GFX68-NEXT: s_endpgm
105 ; GFX11-LABEL: buffer_store_both_reversed:
106 ; GFX11: ; %bb.0: ; %main_body
107 ; GFX11-NEXT: v_mov_b32_e32 v6, v4
108 ; GFX11-NEXT: buffer_store_b128 v[0:3], v[5:6], s[0:3], 0 idxen offen
109 ; GFX11-NEXT: s_endpgm
111 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 %3, i32 %2, i32 0, i32 0)
115 ; Ideally, the register allocator would avoid the wait here
116 define amdgpu_ps void @buffer_store_wait(<4 x i32> inreg, <4 x float>, i32, i32, i32) {
117 ; VERDE-LABEL: buffer_store_wait:
118 ; VERDE: ; %bb.0: ; %main_body
119 ; VERDE-NEXT: buffer_store_dwordx4 v[0:3], v4, s[0:3], 0 idxen
120 ; VERDE-NEXT: s_waitcnt expcnt(0)
121 ; VERDE-NEXT: buffer_load_dwordx4 v[0:3], v5, s[0:3], 0 idxen
122 ; VERDE-NEXT: s_waitcnt vmcnt(0)
123 ; VERDE-NEXT: buffer_store_dwordx4 v[0:3], v6, s[0:3], 0 idxen
124 ; VERDE-NEXT: s_endpgm
126 ; GFX8-LABEL: buffer_store_wait:
127 ; GFX8: ; %bb.0: ; %main_body
128 ; GFX8-NEXT: buffer_store_dwordx4 v[0:3], v4, s[0:3], 0 idxen
129 ; GFX8-NEXT: buffer_load_dwordx4 v[0:3], v5, s[0:3], 0 idxen
130 ; GFX8-NEXT: s_waitcnt vmcnt(0)
131 ; GFX8-NEXT: buffer_store_dwordx4 v[0:3], v6, s[0:3], 0 idxen
132 ; GFX8-NEXT: s_endpgm
134 ; GFX11-LABEL: buffer_store_wait:
135 ; GFX11: ; %bb.0: ; %main_body
136 ; GFX11-NEXT: buffer_store_b128 v[0:3], v4, s[0:3], 0 idxen
137 ; GFX11-NEXT: buffer_load_b128 v[0:3], v5, s[0:3], 0 idxen
138 ; GFX11-NEXT: s_waitcnt vmcnt(0)
139 ; GFX11-NEXT: buffer_store_b128 v[0:3], v6, s[0:3], 0 idxen
140 ; GFX11-NEXT: s_endpgm
142 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 0, i32 0, i32 0)
143 %data = call <4 x float> @llvm.amdgcn.struct.buffer.load.v4f32(<4 x i32> %0, i32 %3, i32 0, i32 0, i32 0)
144 call void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float> %data, <4 x i32> %0, i32 %4, i32 0, i32 0, i32 0)
148 define amdgpu_ps void @buffer_store_x1(<4 x i32> inreg %rsrc, float %data, i32 %index) {
149 ; GFX68-LABEL: buffer_store_x1:
150 ; GFX68: ; %bb.0: ; %main_body
151 ; GFX68-NEXT: buffer_store_dword v0, v1, s[0:3], 0 idxen
152 ; GFX68-NEXT: s_endpgm
154 ; GFX11-LABEL: buffer_store_x1:
155 ; GFX11: ; %bb.0: ; %main_body
156 ; GFX11-NEXT: buffer_store_b32 v0, v1, s[0:3], 0 idxen
157 ; GFX11-NEXT: s_endpgm
159 call void @llvm.amdgcn.struct.buffer.store.f32(float %data, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
163 define amdgpu_ps void @buffer_store_x2(<4 x i32> inreg %rsrc, <2 x float> %data, i32 %index) #0 {
164 ; GFX68-LABEL: buffer_store_x2:
165 ; GFX68: ; %bb.0: ; %main_body
166 ; GFX68-NEXT: buffer_store_dwordx2 v[0:1], v2, s[0:3], 0 idxen
167 ; GFX68-NEXT: s_endpgm
169 ; GFX11-LABEL: buffer_store_x2:
170 ; GFX11: ; %bb.0: ; %main_body
171 ; GFX11-NEXT: buffer_store_b64 v[0:1], v2, s[0:3], 0 idxen
172 ; GFX11-NEXT: s_endpgm
174 call void @llvm.amdgcn.struct.buffer.store.v2f32(<2 x float> %data, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
178 define amdgpu_ps void @buffer_store_int(<4 x i32> inreg, <4 x i32>, <2 x i32>, i32) {
179 ; GFX68-LABEL: buffer_store_int:
180 ; GFX68: ; %bb.0: ; %main_body
181 ; GFX68-NEXT: v_mov_b32_e32 v7, 0
182 ; GFX68-NEXT: buffer_store_dwordx4 v[0:3], v7, s[0:3], 0 idxen
183 ; GFX68-NEXT: buffer_store_dwordx2 v[4:5], v7, s[0:3], 0 idxen glc
184 ; GFX68-NEXT: buffer_store_dword v6, v7, s[0:3], 0 idxen slc
185 ; GFX68-NEXT: s_endpgm
187 ; GFX11-LABEL: buffer_store_int:
188 ; GFX11: ; %bb.0: ; %main_body
189 ; GFX11-NEXT: v_mov_b32_e32 v7, 0
190 ; GFX11-NEXT: s_clause 0x2
191 ; GFX11-NEXT: buffer_store_b128 v[0:3], v7, s[0:3], 0 idxen
192 ; GFX11-NEXT: buffer_store_b64 v[4:5], v7, s[0:3], 0 idxen glc
193 ; GFX11-NEXT: buffer_store_b32 v6, v7, s[0:3], 0 idxen slc
194 ; GFX11-NEXT: s_endpgm
196 call void @llvm.amdgcn.struct.buffer.store.v4i32(<4 x i32> %1, <4 x i32> %0, i32 0, i32 0, i32 0, i32 0)
197 call void @llvm.amdgcn.struct.buffer.store.v2i32(<2 x i32> %2, <4 x i32> %0, i32 0, i32 0, i32 0, i32 1)
198 call void @llvm.amdgcn.struct.buffer.store.i32(i32 %3, <4 x i32> %0, i32 0, i32 0, i32 0, i32 2)
202 define amdgpu_ps void @struct_buffer_store_byte(<4 x i32> inreg %rsrc, float %v1, i32 %index) {
203 ; GFX68-LABEL: struct_buffer_store_byte:
204 ; GFX68: ; %bb.0: ; %main_body
205 ; GFX68-NEXT: v_cvt_u32_f32_e32 v0, v0
206 ; GFX68-NEXT: buffer_store_byte v0, v1, s[0:3], 0 idxen
207 ; GFX68-NEXT: s_endpgm
209 ; GFX11-LABEL: struct_buffer_store_byte:
210 ; GFX11: ; %bb.0: ; %main_body
211 ; GFX11-NEXT: v_cvt_u32_f32_e32 v0, v0
212 ; GFX11-NEXT: buffer_store_b8 v0, v1, s[0:3], 0 idxen
213 ; GFX11-NEXT: s_endpgm
215 %v2 = fptoui float %v1 to i32
216 %v3 = trunc i32 %v2 to i8
217 call void @llvm.amdgcn.struct.buffer.store.i8(i8 %v3, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
221 define amdgpu_ps void @struct_buffer_store_f16(<4 x i32> inreg %rsrc, float %v1, i32 %index) {
222 ; GFX68-LABEL: struct_buffer_store_f16:
224 ; GFX68-NEXT: v_cvt_f16_f32_e32 v0, v0
225 ; GFX68-NEXT: buffer_store_short v0, v1, s[0:3], 0 idxen
226 ; GFX68-NEXT: s_endpgm
228 ; GFX11-LABEL: struct_buffer_store_f16:
230 ; GFX11-NEXT: v_cvt_f16_f32_e32 v0, v0
231 ; GFX11-NEXT: buffer_store_b16 v0, v1, s[0:3], 0 idxen
232 ; GFX11-NEXT: s_endpgm
233 %v2 = fptrunc float %v1 to half
234 call void @llvm.amdgcn.struct.buffer.store.f16(half %v2, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
238 define amdgpu_ps void @struct_buffer_store_v2f16(<4 x i32> inreg %rsrc, <2 x half> %v1, i32 %index) {
239 ; VERDE-LABEL: struct_buffer_store_v2f16:
241 ; VERDE-NEXT: v_cvt_f16_f32_e32 v1, v1
242 ; VERDE-NEXT: v_cvt_f16_f32_e32 v0, v0
243 ; VERDE-NEXT: v_lshlrev_b32_e32 v1, 16, v1
244 ; VERDE-NEXT: v_or_b32_e32 v0, v0, v1
245 ; VERDE-NEXT: buffer_store_dword v0, v2, s[0:3], 0 idxen
246 ; VERDE-NEXT: s_endpgm
248 ; GFX8-LABEL: struct_buffer_store_v2f16:
250 ; GFX8-NEXT: buffer_store_dword v0, v1, s[0:3], 0 idxen
251 ; GFX8-NEXT: s_endpgm
253 ; GFX11-LABEL: struct_buffer_store_v2f16:
255 ; GFX11-NEXT: buffer_store_b32 v0, v1, s[0:3], 0 idxen
256 ; GFX11-NEXT: s_endpgm
257 call void @llvm.amdgcn.struct.buffer.store.v2f16(<2 x half> %v1, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
261 define amdgpu_ps void @struct_buffer_store_v4f16(<4 x i32> inreg %rsrc, <4 x half> %v1, i32 %index) {
262 ; VERDE-LABEL: struct_buffer_store_v4f16:
264 ; VERDE-NEXT: v_cvt_f16_f32_e32 v3, v3
265 ; VERDE-NEXT: v_cvt_f16_f32_e32 v2, v2
266 ; VERDE-NEXT: v_cvt_f16_f32_e32 v5, v1
267 ; VERDE-NEXT: v_cvt_f16_f32_e32 v0, v0
268 ; VERDE-NEXT: v_lshlrev_b32_e32 v1, 16, v3
269 ; VERDE-NEXT: v_or_b32_e32 v1, v2, v1
270 ; VERDE-NEXT: v_lshlrev_b32_e32 v2, 16, v5
271 ; VERDE-NEXT: v_or_b32_e32 v0, v0, v2
272 ; VERDE-NEXT: buffer_store_dwordx2 v[0:1], v4, s[0:3], 0 idxen
273 ; VERDE-NEXT: s_endpgm
275 ; GFX8-LABEL: struct_buffer_store_v4f16:
277 ; GFX8-NEXT: buffer_store_dwordx2 v[0:1], v2, s[0:3], 0 idxen
278 ; GFX8-NEXT: s_endpgm
280 ; GFX11-LABEL: struct_buffer_store_v4f16:
282 ; GFX11-NEXT: buffer_store_b64 v[0:1], v2, s[0:3], 0 idxen
283 ; GFX11-NEXT: s_endpgm
284 call void @llvm.amdgcn.struct.buffer.store.v4f16(<4 x half> %v1, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
288 define amdgpu_ps void @struct_buffer_store_i16(<4 x i32> inreg %rsrc, float %v1, i32 %index) {
289 ; GFX68-LABEL: struct_buffer_store_i16:
290 ; GFX68: ; %bb.0: ; %main_body
291 ; GFX68-NEXT: v_cvt_u32_f32_e32 v0, v0
292 ; GFX68-NEXT: buffer_store_short v0, v1, s[0:3], 0 idxen
293 ; GFX68-NEXT: s_endpgm
295 ; GFX11-LABEL: struct_buffer_store_i16:
296 ; GFX11: ; %bb.0: ; %main_body
297 ; GFX11-NEXT: v_cvt_u32_f32_e32 v0, v0
298 ; GFX11-NEXT: buffer_store_b16 v0, v1, s[0:3], 0 idxen
299 ; GFX11-NEXT: s_endpgm
301 %v2 = fptoui float %v1 to i32
302 %v3 = trunc i32 %v2 to i16
303 call void @llvm.amdgcn.struct.buffer.store.i16(i16 %v3, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
307 define amdgpu_ps void @struct_buffer_store_vif16(<4 x i32> inreg %rsrc, <2 x i16> %v1, i32 %index) {
308 ; VERDE-LABEL: struct_buffer_store_vif16:
310 ; VERDE-NEXT: v_lshlrev_b32_e32 v1, 16, v1
311 ; VERDE-NEXT: v_and_b32_e32 v0, 0xffff, v0
312 ; VERDE-NEXT: v_or_b32_e32 v0, v0, v1
313 ; VERDE-NEXT: buffer_store_dword v0, v2, s[0:3], 0 idxen
314 ; VERDE-NEXT: s_endpgm
316 ; GFX8-LABEL: struct_buffer_store_vif16:
318 ; GFX8-NEXT: buffer_store_dword v0, v1, s[0:3], 0 idxen
319 ; GFX8-NEXT: s_endpgm
321 ; GFX11-LABEL: struct_buffer_store_vif16:
323 ; GFX11-NEXT: buffer_store_b32 v0, v1, s[0:3], 0 idxen
324 ; GFX11-NEXT: s_endpgm
325 call void @llvm.amdgcn.struct.buffer.store.v2i16(<2 x i16> %v1, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
329 define amdgpu_ps void @struct_buffer_store_v4i16(<4 x i32> inreg %rsrc, <4 x i16> %v1, i32 %index) {
330 ; VERDE-LABEL: struct_buffer_store_v4i16:
332 ; VERDE-NEXT: v_lshlrev_b32_e32 v3, 16, v3
333 ; VERDE-NEXT: v_and_b32_e32 v2, 0xffff, v2
334 ; VERDE-NEXT: v_lshlrev_b32_e32 v1, 16, v1
335 ; VERDE-NEXT: v_and_b32_e32 v0, 0xffff, v0
336 ; VERDE-NEXT: v_or_b32_e32 v2, v2, v3
337 ; VERDE-NEXT: v_or_b32_e32 v1, v0, v1
338 ; VERDE-NEXT: buffer_store_dwordx2 v[1:2], v4, s[0:3], 0 idxen
339 ; VERDE-NEXT: s_endpgm
341 ; GFX8-LABEL: struct_buffer_store_v4i16:
343 ; GFX8-NEXT: buffer_store_dwordx2 v[0:1], v2, s[0:3], 0 idxen
344 ; GFX8-NEXT: s_endpgm
346 ; GFX11-LABEL: struct_buffer_store_v4i16:
348 ; GFX11-NEXT: buffer_store_b64 v[0:1], v2, s[0:3], 0 idxen
349 ; GFX11-NEXT: s_endpgm
350 call void @llvm.amdgcn.struct.buffer.store.v4i16(<4 x i16> %v1, <4 x i32> %rsrc, i32 %index, i32 0, i32 0, i32 0)
354 declare void @llvm.amdgcn.struct.buffer.store.f32(float, <4 x i32>, i32, i32, i32, i32) #0
355 declare void @llvm.amdgcn.struct.buffer.store.v2f32(<2 x float>, <4 x i32>, i32, i32, i32, i32) #0
356 declare void @llvm.amdgcn.struct.buffer.store.v4f32(<4 x float>, <4 x i32>, i32, i32, i32, i32) #0
357 declare void @llvm.amdgcn.struct.buffer.store.i32(i32, <4 x i32>, i32, i32, i32, i32) #0
358 declare void @llvm.amdgcn.struct.buffer.store.v2i32(<2 x i32>, <4 x i32>, i32, i32, i32, i32) #0
359 declare void @llvm.amdgcn.struct.buffer.store.v4i32(<4 x i32>, <4 x i32>, i32, i32, i32, i32) #0
360 declare <4 x float> @llvm.amdgcn.struct.buffer.load.v4f32(<4 x i32>, i32, i32, i32, i32) #1
361 declare void @llvm.amdgcn.struct.buffer.store.i8(i8, <4 x i32>, i32, i32, i32, i32) #0
362 declare void @llvm.amdgcn.struct.buffer.store.i16(i16, <4 x i32>, i32, i32, i32, i32) #0
363 declare void @llvm.amdgcn.struct.buffer.store.v2i16(<2 x i16>, <4 x i32>, i32, i32, i32, i32) #0
364 declare void @llvm.amdgcn.struct.buffer.store.v4i16(<4 x i16>, <4 x i32>, i32, i32, i32, i32) #0
365 declare void @llvm.amdgcn.struct.buffer.store.f16(half, <4 x i32>, i32, i32, i32, i32) #0
366 declare void @llvm.amdgcn.struct.buffer.store.v2f16(<2 x half>, <4 x i32>, i32, i32, i32, i32) #0
367 declare void @llvm.amdgcn.struct.buffer.store.v4f16(<4 x half>, <4 x i32>, i32, i32, i32, i32) #0
369 attributes #0 = { nounwind }
370 attributes #1 = { nounwind readonly }