1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -mcpu=kaveri -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=CIVI,CI %s
3 ; RUN: llc -amdgpu-scalarize-global-loads=false -mcpu=tonga -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=CIVI,GFX8 %s
4 ; RUN: llc -amdgpu-scalarize-global-loads=false -mcpu=gfx900 -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX9 %s
5 ; RUN: llc -amdgpu-scalarize-global-loads=false -mcpu=gfx1100 -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX11 %s
7 ; FIXME: Should be able to do scalar op
8 define amdgpu_kernel void @s_fneg_f16(ptr addrspace(1) %out, half %in) #0 {
9 ; CI-LABEL: s_fneg_f16:
11 ; CI-NEXT: s_load_dword s2, s[6:7], 0x2
12 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
13 ; CI-NEXT: s_waitcnt lgkmcnt(0)
14 ; CI-NEXT: s_xor_b32 s2, s2, 0x8000
15 ; CI-NEXT: v_mov_b32_e32 v0, s0
16 ; CI-NEXT: v_mov_b32_e32 v1, s1
17 ; CI-NEXT: v_mov_b32_e32 v2, s2
18 ; CI-NEXT: flat_store_short v[0:1], v2
21 ; GFX8-LABEL: s_fneg_f16:
23 ; GFX8-NEXT: s_load_dword s2, s[6:7], 0x8
24 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
25 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
26 ; GFX8-NEXT: s_xor_b32 s2, s2, 0x8000
27 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
28 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
29 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
30 ; GFX8-NEXT: flat_store_short v[0:1], v2
33 ; GFX9-LABEL: s_fneg_f16:
35 ; GFX9-NEXT: s_load_dword s2, s[6:7], 0x8
36 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
37 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
38 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
39 ; GFX9-NEXT: s_xor_b32 s2, s2, 0x8000
40 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
41 ; GFX9-NEXT: global_store_short v0, v1, s[0:1]
44 ; GFX11-LABEL: s_fneg_f16:
46 ; GFX11-NEXT: s_clause 0x1
47 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
48 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
49 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
50 ; GFX11-NEXT: s_xor_b32 s2, s4, 0x8000
51 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
52 ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
53 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
55 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
56 ; GFX11-NEXT: s_endpgm
57 %fneg = fsub half -0.0, %in
58 store half %fneg, ptr addrspace(1) %out
62 ; FIXME: Should be able to use bit operations when illegal type as
64 define amdgpu_kernel void @v_fneg_f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
65 ; CI-LABEL: v_fneg_f16:
67 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x2
68 ; CI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
69 ; CI-NEXT: s_waitcnt lgkmcnt(0)
70 ; CI-NEXT: v_mov_b32_e32 v1, s1
71 ; CI-NEXT: v_add_i32_e32 v0, vcc, s0, v0
72 ; CI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
73 ; CI-NEXT: flat_load_ushort v2, v[0:1]
74 ; CI-NEXT: s_waitcnt vmcnt(0)
75 ; CI-NEXT: v_xor_b32_e32 v2, 0x8000, v2
76 ; CI-NEXT: flat_store_short v[0:1], v2
79 ; GFX8-LABEL: v_fneg_f16:
81 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x8
82 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 1, v0
83 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
84 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
85 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0
86 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
87 ; GFX8-NEXT: flat_load_ushort v2, v[0:1]
88 ; GFX8-NEXT: s_waitcnt vmcnt(0)
89 ; GFX8-NEXT: v_xor_b32_e32 v2, 0x8000, v2
90 ; GFX8-NEXT: flat_store_short v[0:1], v2
93 ; GFX9-LABEL: v_fneg_f16:
95 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x8
96 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 1, v0
97 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
98 ; GFX9-NEXT: global_load_ushort v1, v0, s[0:1]
99 ; GFX9-NEXT: s_waitcnt vmcnt(0)
100 ; GFX9-NEXT: v_xor_b32_e32 v1, 0x8000, v1
101 ; GFX9-NEXT: global_store_short v0, v1, s[0:1]
102 ; GFX9-NEXT: s_endpgm
104 ; GFX11-LABEL: v_fneg_f16:
106 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x8
107 ; GFX11-NEXT: v_and_b32_e32 v0, 0x3ff, v0
108 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
109 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
110 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
111 ; GFX11-NEXT: global_load_u16 v1, v0, s[0:1]
112 ; GFX11-NEXT: s_waitcnt vmcnt(0)
113 ; GFX11-NEXT: v_xor_b32_e32 v1, 0x8000, v1
114 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
115 ; GFX11-NEXT: s_nop 0
116 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
117 ; GFX11-NEXT: s_endpgm
118 %tid = call i32 @llvm.amdgcn.workitem.id.x()
119 %gep.in = getelementptr inbounds half, ptr addrspace(1) %in, i32 %tid
120 %gep.out = getelementptr inbounds half, ptr addrspace(1) %in, i32 %tid
121 %val = load half, ptr addrspace(1) %gep.in, align 2
122 %fneg = fsub half -0.0, %val
123 store half %fneg, ptr addrspace(1) %gep.out
127 define amdgpu_kernel void @s_fneg_free_f16(ptr addrspace(1) %out, i16 %in) #0 {
128 ; CI-LABEL: s_fneg_free_f16:
130 ; CI-NEXT: s_load_dword s2, s[6:7], 0x2
131 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
132 ; CI-NEXT: s_waitcnt lgkmcnt(0)
133 ; CI-NEXT: s_xor_b32 s2, s2, 0x8000
134 ; CI-NEXT: v_mov_b32_e32 v0, s0
135 ; CI-NEXT: v_mov_b32_e32 v1, s1
136 ; CI-NEXT: v_mov_b32_e32 v2, s2
137 ; CI-NEXT: flat_store_short v[0:1], v2
140 ; GFX8-LABEL: s_fneg_free_f16:
142 ; GFX8-NEXT: s_load_dword s2, s[6:7], 0x8
143 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
144 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
145 ; GFX8-NEXT: s_xor_b32 s2, s2, 0x8000
146 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
147 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
148 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
149 ; GFX8-NEXT: flat_store_short v[0:1], v2
150 ; GFX8-NEXT: s_endpgm
152 ; GFX9-LABEL: s_fneg_free_f16:
154 ; GFX9-NEXT: s_load_dword s2, s[6:7], 0x8
155 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
156 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
157 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
158 ; GFX9-NEXT: s_xor_b32 s2, s2, 0x8000
159 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
160 ; GFX9-NEXT: global_store_short v0, v1, s[0:1]
161 ; GFX9-NEXT: s_endpgm
163 ; GFX11-LABEL: s_fneg_free_f16:
165 ; GFX11-NEXT: s_clause 0x1
166 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
167 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
168 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
169 ; GFX11-NEXT: s_xor_b32 s2, s4, 0x8000
170 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
171 ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
172 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
173 ; GFX11-NEXT: s_nop 0
174 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
175 ; GFX11-NEXT: s_endpgm
176 %bc = bitcast i16 %in to half
177 %fsub = fsub half -0.0, %bc
178 store half %fsub, ptr addrspace(1) %out
182 define amdgpu_kernel void @v_fneg_fold_f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
183 ; CI-LABEL: v_fneg_fold_f16:
185 ; CI-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
186 ; CI-NEXT: s_waitcnt lgkmcnt(0)
187 ; CI-NEXT: v_mov_b32_e32 v0, s2
188 ; CI-NEXT: v_mov_b32_e32 v1, s3
189 ; CI-NEXT: flat_load_ushort v0, v[0:1]
190 ; CI-NEXT: s_waitcnt vmcnt(0)
191 ; CI-NEXT: v_cvt_f32_f16_e32 v1, v0
192 ; CI-NEXT: v_cvt_f32_f16_e64 v0, -v0
193 ; CI-NEXT: v_mul_f32_e32 v0, v0, v1
194 ; CI-NEXT: v_cvt_f16_f32_e32 v2, v0
195 ; CI-NEXT: v_mov_b32_e32 v0, s0
196 ; CI-NEXT: v_mov_b32_e32 v1, s1
197 ; CI-NEXT: flat_store_short v[0:1], v2
200 ; GFX8-LABEL: v_fneg_fold_f16:
202 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
203 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
204 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
205 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
206 ; GFX8-NEXT: flat_load_ushort v2, v[0:1]
207 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
208 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
209 ; GFX8-NEXT: s_waitcnt vmcnt(0)
210 ; GFX8-NEXT: v_mul_f16_e64 v2, -v2, v2
211 ; GFX8-NEXT: flat_store_short v[0:1], v2
212 ; GFX8-NEXT: s_endpgm
214 ; GFX9-LABEL: v_fneg_fold_f16:
216 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
217 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
218 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
219 ; GFX9-NEXT: global_load_ushort v1, v0, s[2:3]
220 ; GFX9-NEXT: s_waitcnt vmcnt(0)
221 ; GFX9-NEXT: v_mul_f16_e64 v1, -v1, v1
222 ; GFX9-NEXT: global_store_short v0, v1, s[0:1]
223 ; GFX9-NEXT: s_endpgm
225 ; GFX11-LABEL: v_fneg_fold_f16:
227 ; GFX11-NEXT: s_load_b128 s[0:3], s[2:3], 0x0
228 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
229 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
230 ; GFX11-NEXT: global_load_u16 v1, v0, s[2:3]
231 ; GFX11-NEXT: s_waitcnt vmcnt(0)
232 ; GFX11-NEXT: v_mul_f16_e64 v1, -v1, v1
233 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
234 ; GFX11-NEXT: s_nop 0
235 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
236 ; GFX11-NEXT: s_endpgm
237 %val = load half, ptr addrspace(1) %in
238 %fsub = fsub half -0.0, %val
239 %fmul = fmul half %fsub, %val
240 store half %fmul, ptr addrspace(1) %out
244 define amdgpu_kernel void @s_fneg_v2f16(ptr addrspace(1) %out, <2 x half> %in) #0 {
245 ; CI-LABEL: s_fneg_v2f16:
247 ; CI-NEXT: s_load_dword s2, s[6:7], 0x2
248 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
249 ; CI-NEXT: s_waitcnt lgkmcnt(0)
250 ; CI-NEXT: s_xor_b32 s2, s2, 0x80008000
251 ; CI-NEXT: v_mov_b32_e32 v0, s0
252 ; CI-NEXT: v_mov_b32_e32 v1, s1
253 ; CI-NEXT: v_mov_b32_e32 v2, s2
254 ; CI-NEXT: flat_store_dword v[0:1], v2
257 ; GFX8-LABEL: s_fneg_v2f16:
259 ; GFX8-NEXT: s_load_dword s2, s[6:7], 0x8
260 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
261 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
262 ; GFX8-NEXT: s_xor_b32 s2, s2, 0x80008000
263 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
264 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
265 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
266 ; GFX8-NEXT: flat_store_dword v[0:1], v2
267 ; GFX8-NEXT: s_endpgm
269 ; GFX9-LABEL: s_fneg_v2f16:
271 ; GFX9-NEXT: s_load_dword s2, s[6:7], 0x8
272 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
273 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
274 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
275 ; GFX9-NEXT: s_xor_b32 s2, s2, 0x80008000
276 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
277 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
278 ; GFX9-NEXT: s_endpgm
280 ; GFX11-LABEL: s_fneg_v2f16:
282 ; GFX11-NEXT: s_clause 0x1
283 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
284 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
285 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
286 ; GFX11-NEXT: s_xor_b32 s2, s4, 0x80008000
287 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
288 ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
289 ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1]
290 ; GFX11-NEXT: s_nop 0
291 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
292 ; GFX11-NEXT: s_endpgm
293 %fneg = fsub <2 x half> <half -0.0, half -0.0>, %in
294 store <2 x half> %fneg, ptr addrspace(1) %out
298 define amdgpu_kernel void @s_fneg_v2f16_nonload(ptr addrspace(1) %out) #0 {
299 ; CIVI-LABEL: s_fneg_v2f16_nonload:
301 ; CIVI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
302 ; CIVI-NEXT: ;;#ASMSTART
303 ; CIVI-NEXT: ; def s2
304 ; CIVI-NEXT: ;;#ASMEND
305 ; CIVI-NEXT: s_xor_b32 s2, s2, 0x80008000
306 ; CIVI-NEXT: v_mov_b32_e32 v2, s2
307 ; CIVI-NEXT: s_waitcnt lgkmcnt(0)
308 ; CIVI-NEXT: v_mov_b32_e32 v0, s0
309 ; CIVI-NEXT: v_mov_b32_e32 v1, s1
310 ; CIVI-NEXT: flat_store_dword v[0:1], v2
311 ; CIVI-NEXT: s_endpgm
313 ; GFX9-LABEL: s_fneg_v2f16_nonload:
315 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
316 ; GFX9-NEXT: ;;#ASMSTART
317 ; GFX9-NEXT: ; def s2
318 ; GFX9-NEXT: ;;#ASMEND
319 ; GFX9-NEXT: s_xor_b32 s2, s2, 0x80008000
320 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
321 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
322 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
323 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
324 ; GFX9-NEXT: s_endpgm
326 ; GFX11-LABEL: s_fneg_v2f16_nonload:
328 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
329 ; GFX11-NEXT: ;;#ASMSTART
330 ; GFX11-NEXT: ; def s2
331 ; GFX11-NEXT: ;;#ASMEND
332 ; GFX11-NEXT: s_xor_b32 s2, s2, 0x80008000
333 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
334 ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
335 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
336 ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1]
337 ; GFX11-NEXT: s_nop 0
338 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
339 ; GFX11-NEXT: s_endpgm
340 %in = call i32 asm sideeffect "; def $0", "=s"()
341 %in.bc = bitcast i32 %in to <2 x half>
342 %fneg = fsub <2 x half> <half -0.0, half -0.0>, %in.bc
343 store <2 x half> %fneg, ptr addrspace(1) %out
347 define amdgpu_kernel void @v_fneg_v2f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
348 ; CI-LABEL: v_fneg_v2f16:
350 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x2
351 ; CI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
352 ; CI-NEXT: s_waitcnt lgkmcnt(0)
353 ; CI-NEXT: v_mov_b32_e32 v1, s1
354 ; CI-NEXT: v_add_i32_e32 v0, vcc, s0, v0
355 ; CI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
356 ; CI-NEXT: flat_load_dword v2, v[0:1]
357 ; CI-NEXT: s_waitcnt vmcnt(0)
358 ; CI-NEXT: v_xor_b32_e32 v2, 0x80008000, v2
359 ; CI-NEXT: flat_store_dword v[0:1], v2
362 ; GFX8-LABEL: v_fneg_v2f16:
364 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x8
365 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 2, v0
366 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
367 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
368 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0
369 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
370 ; GFX8-NEXT: flat_load_dword v2, v[0:1]
371 ; GFX8-NEXT: s_waitcnt vmcnt(0)
372 ; GFX8-NEXT: v_xor_b32_e32 v2, 0x80008000, v2
373 ; GFX8-NEXT: flat_store_dword v[0:1], v2
374 ; GFX8-NEXT: s_endpgm
376 ; GFX9-LABEL: v_fneg_v2f16:
378 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x8
379 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 2, v0
380 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
381 ; GFX9-NEXT: global_load_dword v1, v0, s[0:1]
382 ; GFX9-NEXT: s_waitcnt vmcnt(0)
383 ; GFX9-NEXT: v_xor_b32_e32 v1, 0x80008000, v1
384 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
385 ; GFX9-NEXT: s_endpgm
387 ; GFX11-LABEL: v_fneg_v2f16:
389 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x8
390 ; GFX11-NEXT: v_and_b32_e32 v0, 0x3ff, v0
391 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
392 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 2, v0
393 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
394 ; GFX11-NEXT: global_load_b32 v1, v0, s[0:1]
395 ; GFX11-NEXT: s_waitcnt vmcnt(0)
396 ; GFX11-NEXT: v_xor_b32_e32 v1, 0x80008000, v1
397 ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1]
398 ; GFX11-NEXT: s_nop 0
399 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
400 ; GFX11-NEXT: s_endpgm
401 %tid = call i32 @llvm.amdgcn.workitem.id.x()
402 %gep.in = getelementptr inbounds <2 x half>, ptr addrspace(1) %in, i32 %tid
403 %gep.out = getelementptr inbounds <2 x half>, ptr addrspace(1) %in, i32 %tid
404 %val = load <2 x half>, ptr addrspace(1) %gep.in, align 2
405 %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val
406 store <2 x half> %fneg, ptr addrspace(1) %gep.out
410 define amdgpu_kernel void @fneg_free_v2f16(ptr addrspace(1) %out, i32 %in) #0 {
411 ; CI-LABEL: fneg_free_v2f16:
413 ; CI-NEXT: s_load_dword s2, s[6:7], 0x2
414 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
415 ; CI-NEXT: s_waitcnt lgkmcnt(0)
416 ; CI-NEXT: s_xor_b32 s2, s2, 0x80008000
417 ; CI-NEXT: v_mov_b32_e32 v0, s0
418 ; CI-NEXT: v_mov_b32_e32 v1, s1
419 ; CI-NEXT: v_mov_b32_e32 v2, s2
420 ; CI-NEXT: flat_store_dword v[0:1], v2
423 ; GFX8-LABEL: fneg_free_v2f16:
425 ; GFX8-NEXT: s_load_dword s2, s[6:7], 0x8
426 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
427 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
428 ; GFX8-NEXT: s_xor_b32 s2, s2, 0x80008000
429 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
430 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
431 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
432 ; GFX8-NEXT: flat_store_dword v[0:1], v2
433 ; GFX8-NEXT: s_endpgm
435 ; GFX9-LABEL: fneg_free_v2f16:
437 ; GFX9-NEXT: s_load_dword s2, s[6:7], 0x8
438 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
439 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
440 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
441 ; GFX9-NEXT: s_xor_b32 s2, s2, 0x80008000
442 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
443 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
444 ; GFX9-NEXT: s_endpgm
446 ; GFX11-LABEL: fneg_free_v2f16:
448 ; GFX11-NEXT: s_clause 0x1
449 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
450 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
451 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
452 ; GFX11-NEXT: s_xor_b32 s2, s4, 0x80008000
453 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
454 ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
455 ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1]
456 ; GFX11-NEXT: s_nop 0
457 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
458 ; GFX11-NEXT: s_endpgm
459 %bc = bitcast i32 %in to <2 x half>
460 %fsub = fsub <2 x half> <half -0.0, half -0.0>, %bc
461 store <2 x half> %fsub, ptr addrspace(1) %out
465 define amdgpu_kernel void @v_fneg_fold_v2f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
466 ; CI-LABEL: v_fneg_fold_v2f16:
468 ; CI-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
469 ; CI-NEXT: s_waitcnt lgkmcnt(0)
470 ; CI-NEXT: v_mov_b32_e32 v0, s2
471 ; CI-NEXT: v_mov_b32_e32 v1, s3
472 ; CI-NEXT: flat_load_dword v0, v[0:1]
473 ; CI-NEXT: s_waitcnt vmcnt(0)
474 ; CI-NEXT: v_xor_b32_e32 v2, 0x80008000, v0
475 ; CI-NEXT: v_lshrrev_b32_e32 v1, 16, v0
476 ; CI-NEXT: v_lshrrev_b32_e32 v3, 16, v2
477 ; CI-NEXT: v_cvt_f32_f16_e32 v1, v1
478 ; CI-NEXT: v_cvt_f32_f16_e32 v3, v3
479 ; CI-NEXT: v_cvt_f32_f16_e32 v0, v0
480 ; CI-NEXT: v_cvt_f32_f16_e32 v2, v2
481 ; CI-NEXT: v_mul_f32_e32 v1, v3, v1
482 ; CI-NEXT: v_cvt_f16_f32_e32 v3, v1
483 ; CI-NEXT: v_mul_f32_e32 v0, v2, v0
484 ; CI-NEXT: v_cvt_f16_f32_e32 v2, v0
485 ; CI-NEXT: v_mov_b32_e32 v0, s0
486 ; CI-NEXT: v_lshlrev_b32_e32 v3, 16, v3
487 ; CI-NEXT: v_mov_b32_e32 v1, s1
488 ; CI-NEXT: v_or_b32_e32 v2, v2, v3
489 ; CI-NEXT: flat_store_dword v[0:1], v2
492 ; GFX8-LABEL: v_fneg_fold_v2f16:
494 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
495 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
496 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
497 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
498 ; GFX8-NEXT: flat_load_dword v2, v[0:1]
499 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
500 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
501 ; GFX8-NEXT: s_waitcnt vmcnt(0)
502 ; GFX8-NEXT: v_mul_f16_sdwa v3, -v2, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
503 ; GFX8-NEXT: v_mul_f16_e64 v2, -v2, v2
504 ; GFX8-NEXT: v_or_b32_e32 v2, v2, v3
505 ; GFX8-NEXT: flat_store_dword v[0:1], v2
506 ; GFX8-NEXT: s_endpgm
508 ; GFX9-LABEL: v_fneg_fold_v2f16:
510 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
511 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
512 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
513 ; GFX9-NEXT: global_load_dword v1, v0, s[2:3]
514 ; GFX9-NEXT: s_waitcnt vmcnt(0)
515 ; GFX9-NEXT: v_pk_mul_f16 v1, v1, v1 neg_lo:[1,0] neg_hi:[1,0]
516 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
517 ; GFX9-NEXT: s_endpgm
519 ; GFX11-LABEL: v_fneg_fold_v2f16:
521 ; GFX11-NEXT: s_load_b128 s[0:3], s[2:3], 0x0
522 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
523 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
524 ; GFX11-NEXT: global_load_b32 v1, v0, s[2:3]
525 ; GFX11-NEXT: s_waitcnt vmcnt(0)
526 ; GFX11-NEXT: v_pk_mul_f16 v1, v1, v1 neg_lo:[1,0] neg_hi:[1,0]
527 ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1]
528 ; GFX11-NEXT: s_nop 0
529 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
530 ; GFX11-NEXT: s_endpgm
531 %val = load <2 x half>, ptr addrspace(1) %in
532 %fsub = fsub <2 x half> <half -0.0, half -0.0>, %val
533 %fmul = fmul <2 x half> %fsub, %val
534 store <2 x half> %fmul, ptr addrspace(1) %out
538 define amdgpu_kernel void @v_extract_fneg_fold_v2f16(ptr addrspace(1) %in) #0 {
539 ; CI-LABEL: v_extract_fneg_fold_v2f16:
541 ; CI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
542 ; CI-NEXT: s_waitcnt lgkmcnt(0)
543 ; CI-NEXT: v_mov_b32_e32 v0, s0
544 ; CI-NEXT: v_mov_b32_e32 v1, s1
545 ; CI-NEXT: flat_load_dword v0, v[0:1]
546 ; CI-NEXT: s_waitcnt vmcnt(0)
547 ; CI-NEXT: v_lshrrev_b32_e32 v1, 16, v0
548 ; CI-NEXT: v_cvt_f32_f16_e32 v0, v0
549 ; CI-NEXT: v_cvt_f32_f16_e32 v1, v1
550 ; CI-NEXT: v_mul_f32_e32 v0, -4.0, v0
551 ; CI-NEXT: v_sub_f32_e32 v1, 2.0, v1
552 ; CI-NEXT: v_cvt_f16_f32_e32 v0, v0
553 ; CI-NEXT: v_cvt_f16_f32_e32 v1, v1
554 ; CI-NEXT: flat_store_short v[0:1], v0
555 ; CI-NEXT: s_waitcnt vmcnt(0)
556 ; CI-NEXT: flat_store_short v[0:1], v1
557 ; CI-NEXT: s_waitcnt vmcnt(0)
560 ; GFX8-LABEL: v_extract_fneg_fold_v2f16:
562 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
563 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
564 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
565 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
566 ; GFX8-NEXT: flat_load_dword v0, v[0:1]
567 ; GFX8-NEXT: v_mov_b32_e32 v1, 0x4000
568 ; GFX8-NEXT: s_waitcnt vmcnt(0)
569 ; GFX8-NEXT: v_mul_f16_e32 v2, -4.0, v0
570 ; GFX8-NEXT: v_sub_f16_sdwa v0, v1, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
571 ; GFX8-NEXT: flat_store_short v[0:1], v2
572 ; GFX8-NEXT: s_waitcnt vmcnt(0)
573 ; GFX8-NEXT: flat_store_short v[0:1], v0
574 ; GFX8-NEXT: s_waitcnt vmcnt(0)
575 ; GFX8-NEXT: s_endpgm
577 ; GFX9-LABEL: v_extract_fneg_fold_v2f16:
579 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
580 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
581 ; GFX9-NEXT: v_mov_b32_e32 v1, 0x4000
582 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
583 ; GFX9-NEXT: global_load_dword v0, v0, s[0:1]
584 ; GFX9-NEXT: s_waitcnt vmcnt(0)
585 ; GFX9-NEXT: v_mul_f16_e32 v2, -4.0, v0
586 ; GFX9-NEXT: v_sub_f16_sdwa v0, v1, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
587 ; GFX9-NEXT: global_store_short v[0:1], v2, off
588 ; GFX9-NEXT: s_waitcnt vmcnt(0)
589 ; GFX9-NEXT: global_store_short v[0:1], v0, off
590 ; GFX9-NEXT: s_waitcnt vmcnt(0)
591 ; GFX9-NEXT: s_endpgm
593 ; GFX11-LABEL: v_extract_fneg_fold_v2f16:
595 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
596 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
597 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
598 ; GFX11-NEXT: global_load_b32 v0, v0, s[0:1]
599 ; GFX11-NEXT: s_waitcnt vmcnt(0)
600 ; GFX11-NEXT: v_lshrrev_b32_e32 v1, 16, v0
601 ; GFX11-NEXT: v_mul_f16_e32 v0, -4.0, v0
602 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2)
603 ; GFX11-NEXT: v_sub_f16_e32 v1, 2.0, v1
604 ; GFX11-NEXT: global_store_b16 v[0:1], v0, off dlc
605 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
606 ; GFX11-NEXT: global_store_b16 v[0:1], v1, off dlc
607 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
608 ; GFX11-NEXT: s_nop 0
609 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
610 ; GFX11-NEXT: s_endpgm
611 %val = load <2 x half>, ptr addrspace(1) %in
612 %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val
613 %elt0 = extractelement <2 x half> %fneg, i32 0
614 %elt1 = extractelement <2 x half> %fneg, i32 1
616 %fmul0 = fmul half %elt0, 4.0
617 %fadd1 = fadd half %elt1, 2.0
618 store volatile half %fmul0, ptr addrspace(1) undef
619 store volatile half %fadd1, ptr addrspace(1) undef
623 define amdgpu_kernel void @v_extract_fneg_no_fold_v2f16(ptr addrspace(1) %in) #0 {
624 ; CIVI-LABEL: v_extract_fneg_no_fold_v2f16:
626 ; CIVI-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
627 ; CIVI-NEXT: s_waitcnt lgkmcnt(0)
628 ; CIVI-NEXT: v_mov_b32_e32 v0, s0
629 ; CIVI-NEXT: v_mov_b32_e32 v1, s1
630 ; CIVI-NEXT: flat_load_dword v0, v[0:1]
631 ; CIVI-NEXT: s_waitcnt vmcnt(0)
632 ; CIVI-NEXT: v_xor_b32_e32 v0, 0x80008000, v0
633 ; CIVI-NEXT: v_lshrrev_b32_e32 v1, 16, v0
634 ; CIVI-NEXT: flat_store_short v[0:1], v0
635 ; CIVI-NEXT: s_waitcnt vmcnt(0)
636 ; CIVI-NEXT: flat_store_short v[0:1], v1
637 ; CIVI-NEXT: s_waitcnt vmcnt(0)
638 ; CIVI-NEXT: s_endpgm
640 ; GFX9-LABEL: v_extract_fneg_no_fold_v2f16:
642 ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
643 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
644 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
645 ; GFX9-NEXT: global_load_dword v0, v0, s[0:1]
646 ; GFX9-NEXT: s_waitcnt vmcnt(0)
647 ; GFX9-NEXT: v_xor_b32_e32 v0, 0x80008000, v0
648 ; GFX9-NEXT: global_store_short v[0:1], v0, off
649 ; GFX9-NEXT: s_waitcnt vmcnt(0)
650 ; GFX9-NEXT: global_store_short_d16_hi v[0:1], v0, off
651 ; GFX9-NEXT: s_waitcnt vmcnt(0)
652 ; GFX9-NEXT: s_endpgm
654 ; GFX11-LABEL: v_extract_fneg_no_fold_v2f16:
656 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
657 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
658 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
659 ; GFX11-NEXT: global_load_b32 v0, v0, s[0:1]
660 ; GFX11-NEXT: s_waitcnt vmcnt(0)
661 ; GFX11-NEXT: v_xor_b32_e32 v0, 0x80008000, v0
662 ; GFX11-NEXT: global_store_b16 v[0:1], v0, off dlc
663 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
664 ; GFX11-NEXT: global_store_d16_hi_b16 v[0:1], v0, off dlc
665 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
666 ; GFX11-NEXT: s_nop 0
667 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
668 ; GFX11-NEXT: s_endpgm
669 %val = load <2 x half>, ptr addrspace(1) %in
670 %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val
671 %elt0 = extractelement <2 x half> %fneg, i32 0
672 %elt1 = extractelement <2 x half> %fneg, i32 1
673 store volatile half %elt0, ptr addrspace(1) undef
674 store volatile half %elt1, ptr addrspace(1) undef
678 declare i32 @llvm.amdgcn.workitem.id.x() #1
680 attributes #0 = { nounwind }
681 attributes #1 = { nounwind readnone }