| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2 | |
| ; RUN: llc -mtriple=amdgpu7.00--amdhsa < %s | FileCheck -enable-var-scope -check-prefixes=CIVI,CI %s | |
| ; RUN: llc -mtriple=amdgpu8.02--amdhsa < %s | FileCheck -enable-var-scope -check-prefixes=CIVI,GFX8 %s | |
| ; RUN: llc -mtriple=amdgpu9.00--amdhsa < %s | FileCheck -enable-var-scope -check-prefixes=GFX9 %s | |
| ; RUN: llc -mattr=+real-true16 -mtriple=amdgpu11.00--amdhsa < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-TRUE16 %s | |
| ; RUN: llc -mattr=-real-true16 -mtriple=amdgpu11.00--amdhsa < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-FAKE16 %s | |
| ; FIXME: Should be able to do scalar op | |
| define amdgpu_kernel void @s_fneg_f16(ptr addrspace(1) %out, half %in) #0 { | |
| ; CI-LABEL: s_fneg_f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dword s2, s[8:9], 0x2 | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; CI-NEXT: v_mov_b32_e32 v0, s0 | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_mov_b32_e32 v2, s2 | |
| ; CI-NEXT: flat_store_short v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: s_fneg_f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX8-NEXT: v_mov_b32_e32 v0, s0 | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_mov_b32_e32 v2, s2 | |
| ; GFX8-NEXT: flat_store_short v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: s_fneg_f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX9-NEXT: v_mov_b32_e32 v0, 0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX9-NEXT: v_mov_b32_e32 v1, s2 | |
| ; GFX9-NEXT: global_store_short v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-TRUE16-LABEL: s_fneg_f16: | |
| ; GFX11-TRUE16: ; %bb.0: | |
| ; GFX11-TRUE16-NEXT: s_clause 0x1 | |
| ; GFX11-TRUE16-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-TRUE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-TRUE16-NEXT: v_mov_b32_e32 v1, 0 | |
| ; GFX11-TRUE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-TRUE16-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX11-TRUE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-TRUE16-NEXT: v_mov_b16_e32 v0.l, s2 | |
| ; GFX11-TRUE16-NEXT: global_store_b16 v1, v0, s[0:1] | |
| ; GFX11-TRUE16-NEXT: s_endpgm | |
| ; | |
| ; GFX11-FAKE16-LABEL: s_fneg_f16: | |
| ; GFX11-FAKE16: ; %bb.0: | |
| ; GFX11-FAKE16-NEXT: s_clause 0x1 | |
| ; GFX11-FAKE16-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-FAKE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-FAKE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-FAKE16-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX11-FAKE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-FAKE16-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 | |
| ; GFX11-FAKE16-NEXT: global_store_b16 v0, v1, s[0:1] | |
| ; GFX11-FAKE16-NEXT: s_endpgm | |
| %fneg = fsub half -0.0, %in | |
| store half %fneg, ptr addrspace(1) %out | |
| ret void | |
| } | |
| ; FIXME: Should be able to use bit operations when illegal type as | |
| ; well. | |
| define amdgpu_kernel void @v_fneg_f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 { | |
| ; CI-LABEL: v_fneg_f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x2 | |
| ; CI-NEXT: v_lshlrev_b32_e32 v0, 1, v0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_add_i32_e32 v0, vcc, s0, v0 | |
| ; CI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc | |
| ; CI-NEXT: flat_load_ushort v2, v[0:1] | |
| ; CI-NEXT: s_waitcnt vmcnt(0) | |
| ; CI-NEXT: v_xor_b32_e32 v2, 0x8000, v2 | |
| ; CI-NEXT: flat_store_short v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: v_fneg_f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x8 | |
| ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 1, v0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0 | |
| ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc | |
| ; GFX8-NEXT: flat_load_ushort v2, v[0:1] | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX8-NEXT: v_xor_b32_e32 v2, 0x8000, v2 | |
| ; GFX8-NEXT: flat_store_short v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: v_fneg_f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x8 | |
| ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 1, v0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: global_load_ushort v1, v0, s[0:1] | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: v_xor_b32_e32 v1, 0x8000, v1 | |
| ; GFX9-NEXT: global_store_short v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-TRUE16-LABEL: v_fneg_f16: | |
| ; GFX11-TRUE16: ; %bb.0: | |
| ; GFX11-TRUE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x8 | |
| ; GFX11-TRUE16-NEXT: v_and_b32_e32 v0, 0x3ff, v0 | |
| ; GFX11-TRUE16-NEXT: s_delay_alu instid0(VALU_DEP_1) | |
| ; GFX11-TRUE16-NEXT: v_lshlrev_b32_e32 v1, 1, v0 | |
| ; GFX11-TRUE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-TRUE16-NEXT: global_load_d16_b16 v0, v1, s[0:1] | |
| ; GFX11-TRUE16-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX11-TRUE16-NEXT: v_xor_b16 v0.l, 0x8000, v0.l | |
| ; GFX11-TRUE16-NEXT: global_store_b16 v1, v0, s[0:1] | |
| ; GFX11-TRUE16-NEXT: s_endpgm | |
| ; | |
| ; GFX11-FAKE16-LABEL: v_fneg_f16: | |
| ; GFX11-FAKE16: ; %bb.0: | |
| ; GFX11-FAKE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x8 | |
| ; GFX11-FAKE16-NEXT: v_and_b32_e32 v0, 0x3ff, v0 | |
| ; GFX11-FAKE16-NEXT: s_delay_alu instid0(VALU_DEP_1) | |
| ; GFX11-FAKE16-NEXT: v_lshlrev_b32_e32 v0, 1, v0 | |
| ; GFX11-FAKE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-FAKE16-NEXT: global_load_u16 v1, v0, s[0:1] | |
| ; GFX11-FAKE16-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX11-FAKE16-NEXT: v_xor_b32_e32 v1, 0x8000, v1 | |
| ; GFX11-FAKE16-NEXT: global_store_b16 v0, v1, s[0:1] | |
| ; GFX11-FAKE16-NEXT: s_endpgm | |
| %tid = call i32 @llvm.amdgcn.workitem.id.x() | |
| %gep.in = getelementptr inbounds half, ptr addrspace(1) %in, i32 %tid | |
| %gep.out = getelementptr inbounds half, ptr addrspace(1) %in, i32 %tid | |
| %val = load half, ptr addrspace(1) %gep.in, align 2 | |
| %fneg = fsub half -0.0, %val | |
| store half %fneg, ptr addrspace(1) %gep.out | |
| ret void | |
| } | |
| define amdgpu_kernel void @s_fneg_free_f16(ptr addrspace(1) %out, i16 %in) #0 { | |
| ; CI-LABEL: s_fneg_free_f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dword s2, s[8:9], 0x2 | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; CI-NEXT: v_mov_b32_e32 v0, s0 | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_mov_b32_e32 v2, s2 | |
| ; CI-NEXT: flat_store_short v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: s_fneg_free_f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX8-NEXT: v_mov_b32_e32 v0, s0 | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_mov_b32_e32 v2, s2 | |
| ; GFX8-NEXT: flat_store_short v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: s_fneg_free_f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX9-NEXT: v_mov_b32_e32 v0, 0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX9-NEXT: v_mov_b32_e32 v1, s2 | |
| ; GFX9-NEXT: global_store_short v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-TRUE16-LABEL: s_fneg_free_f16: | |
| ; GFX11-TRUE16: ; %bb.0: | |
| ; GFX11-TRUE16-NEXT: s_clause 0x1 | |
| ; GFX11-TRUE16-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-TRUE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-TRUE16-NEXT: v_mov_b32_e32 v1, 0 | |
| ; GFX11-TRUE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-TRUE16-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX11-TRUE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-TRUE16-NEXT: v_mov_b16_e32 v0.l, s2 | |
| ; GFX11-TRUE16-NEXT: global_store_b16 v1, v0, s[0:1] | |
| ; GFX11-TRUE16-NEXT: s_endpgm | |
| ; | |
| ; GFX11-FAKE16-LABEL: s_fneg_free_f16: | |
| ; GFX11-FAKE16: ; %bb.0: | |
| ; GFX11-FAKE16-NEXT: s_clause 0x1 | |
| ; GFX11-FAKE16-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-FAKE16-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-FAKE16-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-FAKE16-NEXT: s_xor_b32 s2, s2, 0x8000 | |
| ; GFX11-FAKE16-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-FAKE16-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 | |
| ; GFX11-FAKE16-NEXT: global_store_b16 v0, v1, s[0:1] | |
| ; GFX11-FAKE16-NEXT: s_endpgm | |
| %bc = bitcast i16 %in to half | |
| %fsub = fsub half -0.0, %bc | |
| store half %fsub, ptr addrspace(1) %out | |
| ret void | |
| } | |
| define half @v_fneg_fold_f16(half %in) #0 { | |
| ; CI-LABEL: v_fneg_fold_f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v1, v0 | |
| ; CI-NEXT: v_cvt_f32_f16_e64 v0, -v0 | |
| ; CI-NEXT: v_mul_f32_e32 v0, v0, v1 | |
| ; CI-NEXT: v_cvt_f16_f32_e32 v0, v0 | |
| ; CI-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX8-LABEL: v_fneg_fold_f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX8-NEXT: v_mul_f16_e64 v0, -v0, v0 | |
| ; GFX8-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX9-LABEL: v_fneg_fold_f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX9-NEXT: v_mul_f16_e64 v0, -v0, v0 | |
| ; GFX9-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-TRUE16-LABEL: v_fneg_fold_f16: | |
| ; GFX11-TRUE16: ; %bb.0: | |
| ; GFX11-TRUE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-TRUE16-NEXT: v_mul_f16_e64 v0.l, -v0.l, v0.l | |
| ; GFX11-TRUE16-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-FAKE16-LABEL: v_fneg_fold_f16: | |
| ; GFX11-FAKE16: ; %bb.0: | |
| ; GFX11-FAKE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-FAKE16-NEXT: v_mul_f16_e64 v0, -v0, v0 | |
| ; GFX11-FAKE16-NEXT: s_setpc_b64 s[30:31] | |
| %fsub = fsub half -0.0, %in | |
| %fmul = fmul half %fsub, %in | |
| ret half %fmul | |
| } | |
| define amdgpu_kernel void @s_fneg_v2f16(ptr addrspace(1) %out, <2 x half> %in) #0 { | |
| ; CI-LABEL: s_fneg_v2f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dword s2, s[8:9], 0x2 | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; CI-NEXT: v_mov_b32_e32 v0, s0 | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_mov_b32_e32 v2, s2 | |
| ; CI-NEXT: flat_store_dword v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: s_fneg_v2f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX8-NEXT: v_mov_b32_e32 v0, s0 | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_mov_b32_e32 v2, s2 | |
| ; GFX8-NEXT: flat_store_dword v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: s_fneg_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX9-NEXT: v_mov_b32_e32 v0, 0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX9-NEXT: v_mov_b32_e32 v1, s2 | |
| ; GFX9-NEXT: global_store_dword v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-LABEL: s_fneg_v2f16: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_clause 0x1 | |
| ; GFX11-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 | |
| ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1] | |
| ; GFX11-NEXT: s_endpgm | |
| %fneg = fsub <2 x half> <half -0.0, half -0.0>, %in | |
| store <2 x half> %fneg, ptr addrspace(1) %out | |
| ret void | |
| } | |
| define <2 x half> @s_fneg_v2f16_nonload() #0 { | |
| ; CIVI-LABEL: s_fneg_v2f16_nonload: | |
| ; CIVI: ; %bb.0: | |
| ; CIVI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; CIVI-NEXT: ;;#ASMSTART | |
| ; CIVI-NEXT: ; def s4 | |
| ; CIVI-NEXT: ;;#ASMEND | |
| ; CIVI-NEXT: s_xor_b32 s4, s4, 0x80008000 | |
| ; CIVI-NEXT: v_mov_b32_e32 v0, s4 | |
| ; CIVI-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX9-LABEL: s_fneg_v2f16_nonload: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX9-NEXT: ;;#ASMSTART | |
| ; GFX9-NEXT: ; def s4 | |
| ; GFX9-NEXT: ;;#ASMEND | |
| ; GFX9-NEXT: s_xor_b32 s4, s4, 0x80008000 | |
| ; GFX9-NEXT: v_mov_b32_e32 v0, s4 | |
| ; GFX9-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-LABEL: s_fneg_v2f16_nonload: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-NEXT: ;;#ASMSTART | |
| ; GFX11-NEXT: ; def s0 | |
| ; GFX11-NEXT: ;;#ASMEND | |
| ; GFX11-NEXT: s_xor_b32 s0, s0, 0x80008000 | |
| ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-NEXT: v_mov_b32_e32 v0, s0 | |
| ; GFX11-NEXT: s_setpc_b64 s[30:31] | |
| %in = call i32 asm sideeffect "; def $0", "=s"() | |
| %in.bc = bitcast i32 %in to <2 x half> | |
| %fneg = fsub <2 x half> <half -0.0, half -0.0>, %in.bc | |
| ret <2 x half> %fneg | |
| } | |
| define amdgpu_kernel void @v_fneg_v2f16(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 { | |
| ; CI-LABEL: v_fneg_v2f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x2 | |
| ; CI-NEXT: v_lshlrev_b32_e32 v0, 2, v0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_add_i32_e32 v0, vcc, s0, v0 | |
| ; CI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc | |
| ; CI-NEXT: flat_load_dword v2, v[0:1] | |
| ; CI-NEXT: s_waitcnt vmcnt(0) | |
| ; CI-NEXT: v_xor_b32_e32 v2, 0x80008000, v2 | |
| ; CI-NEXT: flat_store_dword v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: v_fneg_v2f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x8 | |
| ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 2, v0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0 | |
| ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc | |
| ; GFX8-NEXT: flat_load_dword v2, v[0:1] | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX8-NEXT: v_xor_b32_e32 v2, 0x80008000, v2 | |
| ; GFX8-NEXT: flat_store_dword v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: v_fneg_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x8 | |
| ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 2, v0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: global_load_dword v1, v0, s[0:1] | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: v_xor_b32_e32 v1, 0x80008000, v1 | |
| ; GFX9-NEXT: global_store_dword v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-LABEL: v_fneg_v2f16: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_load_b64 s[0:1], s[4:5], 0x8 | |
| ; GFX11-NEXT: v_and_b32_e32 v0, 0x3ff, v0 | |
| ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | |
| ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 2, v0 | |
| ; GFX11-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-NEXT: global_load_b32 v1, v0, s[0:1] | |
| ; GFX11-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX11-NEXT: v_xor_b32_e32 v1, 0x80008000, v1 | |
| ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1] | |
| ; GFX11-NEXT: s_endpgm | |
| %tid = call i32 @llvm.amdgcn.workitem.id.x() | |
| %gep.in = getelementptr inbounds <2 x half>, ptr addrspace(1) %in, i32 %tid | |
| %gep.out = getelementptr inbounds <2 x half>, ptr addrspace(1) %in, i32 %tid | |
| %val = load <2 x half>, ptr addrspace(1) %gep.in, align 2 | |
| %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val | |
| store <2 x half> %fneg, ptr addrspace(1) %gep.out | |
| ret void | |
| } | |
| define amdgpu_kernel void @fneg_free_v2f16(ptr addrspace(1) %out, i32 %in) #0 { | |
| ; CI-LABEL: fneg_free_v2f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_load_dword s2, s[8:9], 0x2 | |
| ; CI-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; CI-NEXT: s_add_i32 s12, s12, s17 | |
| ; CI-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; CI-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; CI-NEXT: s_waitcnt lgkmcnt(0) | |
| ; CI-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; CI-NEXT: v_mov_b32_e32 v0, s0 | |
| ; CI-NEXT: v_mov_b32_e32 v1, s1 | |
| ; CI-NEXT: v_mov_b32_e32 v2, s2 | |
| ; CI-NEXT: flat_store_dword v[0:1], v2 | |
| ; CI-NEXT: s_endpgm | |
| ; | |
| ; GFX8-LABEL: fneg_free_v2f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX8-NEXT: s_add_i32 s12, s12, s17 | |
| ; GFX8-NEXT: s_mov_b32 flat_scratch_lo, s13 | |
| ; GFX8-NEXT: s_lshr_b32 flat_scratch_hi, s12, 8 | |
| ; GFX8-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX8-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX8-NEXT: v_mov_b32_e32 v0, s0 | |
| ; GFX8-NEXT: v_mov_b32_e32 v1, s1 | |
| ; GFX8-NEXT: v_mov_b32_e32 v2, s2 | |
| ; GFX8-NEXT: flat_store_dword v[0:1], v2 | |
| ; GFX8-NEXT: s_endpgm | |
| ; | |
| ; GFX9-LABEL: fneg_free_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_load_dword s2, s[8:9], 0x8 | |
| ; GFX9-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 | |
| ; GFX9-NEXT: v_mov_b32_e32 v0, 0 | |
| ; GFX9-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX9-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX9-NEXT: v_mov_b32_e32 v1, s2 | |
| ; GFX9-NEXT: global_store_dword v0, v1, s[0:1] | |
| ; GFX9-NEXT: s_endpgm | |
| ; | |
| ; GFX11-LABEL: fneg_free_v2f16: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_clause 0x1 | |
| ; GFX11-NEXT: s_load_b32 s2, s[4:5], 0x8 | |
| ; GFX11-NEXT: s_load_b64 s[0:1], s[4:5], 0x0 | |
| ; GFX11-NEXT: s_waitcnt lgkmcnt(0) | |
| ; GFX11-NEXT: s_xor_b32 s2, s2, 0x80008000 | |
| ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | |
| ; GFX11-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2 | |
| ; GFX11-NEXT: global_store_b32 v0, v1, s[0:1] | |
| ; GFX11-NEXT: s_endpgm | |
| %bc = bitcast i32 %in to <2 x half> | |
| %fsub = fsub <2 x half> <half -0.0, half -0.0>, %bc | |
| store <2 x half> %fsub, ptr addrspace(1) %out | |
| ret void | |
| } | |
| define <2 x half> @v_fneg_fold_v2f16(<2 x half> %in) #0 { | |
| ; CI-LABEL: v_fneg_fold_v2f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; CI-NEXT: v_xor_b32_e32 v2, 0x80008000, v0 | |
| ; CI-NEXT: v_lshrrev_b32_e32 v1, 16, v0 | |
| ; CI-NEXT: v_lshrrev_b32_e32 v3, 16, v2 | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v1, v1 | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v3, v3 | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v2, v2 | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v0, v0 | |
| ; CI-NEXT: v_mul_f32_e32 v1, v3, v1 | |
| ; CI-NEXT: v_cvt_f16_f32_e32 v1, v1 | |
| ; CI-NEXT: v_mul_f32_e32 v0, v2, v0 | |
| ; CI-NEXT: v_cvt_f16_f32_e32 v0, v0 | |
| ; CI-NEXT: v_lshlrev_b32_e32 v1, 16, v1 | |
| ; CI-NEXT: v_or_b32_e32 v0, v0, v1 | |
| ; CI-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX8-LABEL: v_fneg_fold_v2f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX8-NEXT: v_mul_f16_sdwa v1, -v0, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 | |
| ; GFX8-NEXT: v_mul_f16_e64 v0, -v0, v0 | |
| ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1 | |
| ; GFX8-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX9-LABEL: v_fneg_fold_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX9-NEXT: v_pk_mul_f16 v0, v0, v0 neg_lo:[1,0] neg_hi:[1,0] | |
| ; GFX9-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-LABEL: v_fneg_fold_v2f16: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-NEXT: v_pk_mul_f16 v0, v0, v0 neg_lo:[1,0] neg_hi:[1,0] | |
| ; GFX11-NEXT: s_setpc_b64 s[30:31] | |
| %fsub = fsub <2 x half> <half -0.0, half -0.0>, %in | |
| %fmul = fmul <2 x half> %fsub, %in | |
| ret <2 x half> %fmul | |
| } | |
| define void @v_extract_fneg_fold_v2f16(<2 x half> %val) #0 { | |
| ; CI-LABEL: v_extract_fneg_fold_v2f16: | |
| ; CI: ; %bb.0: | |
| ; CI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v1, v0 | |
| ; CI-NEXT: v_lshrrev_b32_e32 v0, 16, v0 | |
| ; CI-NEXT: v_cvt_f32_f16_e32 v0, v0 | |
| ; CI-NEXT: v_mul_f32_e32 v1, -4.0, v1 | |
| ; CI-NEXT: v_cvt_f16_f32_e32 v1, v1 | |
| ; CI-NEXT: v_sub_f32_e32 v0, 2.0, v0 | |
| ; CI-NEXT: v_cvt_f16_f32_e32 v0, v0 | |
| ; CI-NEXT: flat_store_short v[0:1], v1 | |
| ; CI-NEXT: s_waitcnt vmcnt(0) | |
| ; CI-NEXT: flat_store_short v[0:1], v0 | |
| ; CI-NEXT: s_waitcnt vmcnt(0) | |
| ; CI-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX8-LABEL: v_extract_fneg_fold_v2f16: | |
| ; GFX8: ; %bb.0: | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX8-NEXT: v_mov_b32_e32 v2, 0x4000 | |
| ; GFX8-NEXT: v_mul_f16_e32 v1, -4.0, v0 | |
| ; GFX8-NEXT: v_sub_f16_sdwa v0, v2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1 | |
| ; GFX8-NEXT: flat_store_short v[0:1], v1 | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX8-NEXT: flat_store_short v[0:1], v0 | |
| ; GFX8-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX8-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX9-LABEL: v_extract_fneg_fold_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX9-NEXT: v_mov_b32_e32 v2, 0x4000 | |
| ; GFX9-NEXT: v_mul_f16_e32 v1, -4.0, v0 | |
| ; GFX9-NEXT: v_sub_f16_sdwa v0, v2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1 | |
| ; GFX9-NEXT: global_store_short v[0:1], v1, off | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: global_store_short v[0:1], v0, off | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-TRUE16-LABEL: v_extract_fneg_fold_v2f16: | |
| ; GFX11-TRUE16: ; %bb.0: | |
| ; GFX11-TRUE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-TRUE16-NEXT: v_mul_f16_e32 v0.l, -4.0, v0.l | |
| ; GFX11-TRUE16-NEXT: v_sub_f16_e32 v0.h, 2.0, v0.h | |
| ; GFX11-TRUE16-NEXT: global_store_b16 v[0:1], v0, off dlc | |
| ; GFX11-TRUE16-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-TRUE16-NEXT: global_store_d16_hi_b16 v[0:1], v0, off dlc | |
| ; GFX11-TRUE16-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-TRUE16-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-FAKE16-LABEL: v_extract_fneg_fold_v2f16: | |
| ; GFX11-FAKE16: ; %bb.0: | |
| ; GFX11-FAKE16-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-FAKE16-NEXT: v_lshrrev_b32_e32 v1, 16, v0 | |
| ; GFX11-FAKE16-NEXT: v_mul_f16_e32 v0, -4.0, v0 | |
| ; GFX11-FAKE16-NEXT: s_delay_alu instid0(VALU_DEP_2) | |
| ; GFX11-FAKE16-NEXT: v_sub_f16_e32 v1, 2.0, v1 | |
| ; GFX11-FAKE16-NEXT: global_store_b16 v[0:1], v0, off dlc | |
| ; GFX11-FAKE16-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-FAKE16-NEXT: global_store_b16 v[0:1], v1, off dlc | |
| ; GFX11-FAKE16-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-FAKE16-NEXT: s_setpc_b64 s[30:31] | |
| %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val | |
| %elt0 = extractelement <2 x half> %fneg, i32 0 | |
| %elt1 = extractelement <2 x half> %fneg, i32 1 | |
| %fmul0 = fmul half %elt0, 4.0 | |
| %fadd1 = fadd half %elt1, 2.0 | |
| store volatile half %fmul0, ptr addrspace(1) poison | |
| store volatile half %fadd1, ptr addrspace(1) poison | |
| ret void | |
| } | |
| define void @v_extract_fneg_no_fold_v2f16(<2 x half> %val) #0 { | |
| ; CIVI-LABEL: v_extract_fneg_no_fold_v2f16: | |
| ; CIVI: ; %bb.0: | |
| ; CIVI-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; CIVI-NEXT: v_xor_b32_e32 v0, 0x80008000, v0 | |
| ; CIVI-NEXT: v_lshrrev_b32_e32 v1, 16, v0 | |
| ; CIVI-NEXT: flat_store_short v[0:1], v0 | |
| ; CIVI-NEXT: s_waitcnt vmcnt(0) | |
| ; CIVI-NEXT: flat_store_short v[0:1], v1 | |
| ; CIVI-NEXT: s_waitcnt vmcnt(0) | |
| ; CIVI-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX9-LABEL: v_extract_fneg_no_fold_v2f16: | |
| ; GFX9: ; %bb.0: | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX9-NEXT: v_xor_b32_e32 v0, 0x80008000, v0 | |
| ; GFX9-NEXT: global_store_short v[0:1], v0, off | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: global_store_short_d16_hi v[0:1], v0, off | |
| ; GFX9-NEXT: s_waitcnt vmcnt(0) | |
| ; GFX9-NEXT: s_setpc_b64 s[30:31] | |
| ; | |
| ; GFX11-LABEL: v_extract_fneg_no_fold_v2f16: | |
| ; GFX11: ; %bb.0: | |
| ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | |
| ; GFX11-NEXT: v_xor_b32_e32 v0, 0x80008000, v0 | |
| ; GFX11-NEXT: global_store_b16 v[0:1], v0, off dlc | |
| ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-NEXT: global_store_d16_hi_b16 v[0:1], v0, off dlc | |
| ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0 | |
| ; GFX11-NEXT: s_setpc_b64 s[30:31] | |
| %fneg = fsub <2 x half> <half -0.0, half -0.0>, %val | |
| %elt0 = extractelement <2 x half> %fneg, i32 0 | |
| %elt1 = extractelement <2 x half> %fneg, i32 1 | |
| store volatile half %elt0, ptr addrspace(1) poison | |
| store volatile half %elt1, ptr addrspace(1) poison | |
| ret void | |
| } | |
| declare i32 @llvm.amdgcn.workitem.id.x() #1 | |
| attributes #0 = { nounwind } | |
| attributes #1 = { nounwind readnone } |