forked from OSchip/llvm-project
[AMDGPU] Allow narrowing muti-dword loads
Currently BE allows only a little load narrowing because of the fear it will produce sub-dword ext loads. However, we can always allow narrowing if we are shrinking one multi-dword load to another multi-dword load. In particular we were unable to reduce s_load_dwordx8 into s_load_dwordx4 if identity shuffle was used to extract low 4 dwords. Differential Revision: https://reviews.llvm.org/D73133
This commit is contained in:
parent
7a94d4f4ee
commit
44b865fa7f
|
@ -641,8 +641,9 @@ bool AMDGPUTargetLowering::shouldReduceLoadWidth(SDNode *N,
|
|||
|
||||
unsigned NewSize = NewVT.getStoreSizeInBits();
|
||||
|
||||
// If we are reducing to a 32-bit load, this is always better.
|
||||
if (NewSize == 32)
|
||||
// If we are reducing to a 32-bit load or a smaller multi-dword load,
|
||||
// this is always better.
|
||||
if (NewSize >= 32)
|
||||
return true;
|
||||
|
||||
EVT OldVT = N->getValueType(0);
|
||||
|
|
|
@ -629,7 +629,7 @@ define <4 x half> @shuffle_v8f16_0123(<8 x half> addrspace(1)* %arg0, <8 x half>
|
|||
; GFX9-LABEL: shuffle_v8f16_0123:
|
||||
; GFX9: ; %bb.0:
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
||||
; GFX9-NEXT: global_load_dwordx4 v[0:3], v[0:1], off
|
||||
; GFX9-NEXT: global_load_dwordx2 v[0:1], v[0:1], off
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0)
|
||||
; GFX9-NEXT: s_setpc_b64 s[30:31]
|
||||
%val0 = load <8 x half>, <8 x half> addrspace(1)* %arg0
|
||||
|
@ -656,8 +656,10 @@ define <4 x half> @shuffle_v8f16_10_11_2_3(<8 x half> addrspace(1)* %arg0, <8 x
|
|||
; GFX9-LABEL: shuffle_v8f16_10_11_2_3:
|
||||
; GFX9: ; %bb.0:
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
||||
; GFX9-NEXT: global_load_dword v2, v[2:3], off offset:4
|
||||
; GFX9-NEXT: global_load_dword v1, v[0:1], off offset:4
|
||||
; GFX9-NEXT: global_load_dword v0, v[2:3], off offset:4
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(1)
|
||||
; GFX9-NEXT: v_mov_b32_e32 v0, v2
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0)
|
||||
; GFX9-NEXT: s_setpc_b64 s[30:31]
|
||||
%val0 = load <8 x half>, <8 x half> addrspace(1)* %arg0
|
||||
|
@ -670,12 +672,12 @@ define <4 x half> @shuffle_v8f16_13_14_2_3(<8 x half> addrspace(1)* %arg0, <8 x
|
|||
; GFX9-LABEL: shuffle_v8f16_13_14_2_3:
|
||||
; GFX9: ; %bb.0:
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
||||
; GFX9-NEXT: global_load_dwordx4 v[2:5], v[2:3], off
|
||||
; GFX9-NEXT: global_load_dwordx2 v[2:3], v[2:3], off offset:8
|
||||
; GFX9-NEXT: global_load_dword v1, v[0:1], off offset:4
|
||||
; GFX9-NEXT: v_mov_b32_e32 v0, 0xffff
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(1)
|
||||
; GFX9-NEXT: v_and_b32_sdwa v0, v0, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
||||
; GFX9-NEXT: v_lshl_or_b32 v0, v5, 16, v0
|
||||
; GFX9-NEXT: v_and_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
|
||||
; GFX9-NEXT: v_lshl_or_b32 v0, v3, 16, v0
|
||||
; GFX9-NEXT: s_waitcnt vmcnt(0)
|
||||
; GFX9-NEXT: s_setpc_b64 s[30:31]
|
||||
%val0 = load <8 x half>, <8 x half> addrspace(1)* %arg0
|
||||
|
@ -809,6 +811,27 @@ define <4 x half> @shuffle_v4f16_0456(<4 x half> addrspace(1)* %arg0, <4 x half>
|
|||
ret <4 x half> %shuffle
|
||||
}
|
||||
|
||||
define amdgpu_kernel void @shuffle_scalar_load_v8i32_0123(<8 x i32> addrspace(4)* %in, <4 x i32> addrspace(1)* %out) {
|
||||
; GFX9-LABEL: shuffle_scalar_load_v8i32_0123:
|
||||
; GFX9: ; %bb.0:
|
||||
; GFX9-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
|
||||
; GFX9-NEXT: s_waitcnt lgkmcnt(0)
|
||||
; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x0
|
||||
; GFX9-NEXT: v_mov_b32_e32 v4, s2
|
||||
; GFX9-NEXT: v_mov_b32_e32 v5, s3
|
||||
; GFX9-NEXT: s_waitcnt lgkmcnt(0)
|
||||
; GFX9-NEXT: v_mov_b32_e32 v0, s4
|
||||
; GFX9-NEXT: v_mov_b32_e32 v1, s5
|
||||
; GFX9-NEXT: v_mov_b32_e32 v2, s6
|
||||
; GFX9-NEXT: v_mov_b32_e32 v3, s7
|
||||
; GFX9-NEXT: global_store_dwordx4 v[4:5], v[0:3], off
|
||||
; GFX9-NEXT: s_endpgm
|
||||
%ld8 = load <8 x i32>, <8 x i32> addrspace(4)* %in, align 16
|
||||
%id = shufflevector <8 x i32> %ld8, <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
||||
store <4 x i32> %id, <4 x i32> addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
declare <2 x half> @llvm.fma.v2f16(<2 x half>, <2 x half>, <2 x half>) #0
|
||||
declare i32 @llvm.amdgcn.workitem.id.x() #0
|
||||
|
||||
|
|
Loading…
Reference in New Issue