llvm-project/llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit-clustering.ll
Lucas Ramirez e377dc4d38
[AMDGPU] Max. WG size-induced occupancy limits max. waves/EU (#137807)
The default maximum waves/EU returned by the family of
`AMDGPUSubtarget::getWavesPerEU` is currently the maximum number of
waves/EU supported by the subtarget (only a valid occupancy range in
"amdgpu-waves-per-eu" may lower that maximum). This ignores maximum
achievable occupancy imposed by flat workgroup size and LDS usage,
resulting in situations where `AMDGPUSubtarget::getWavesPerEU` produces
a maximum higher than the one from
`AMDGPUSubtarget::getOccupancyWithWorkGroupSizes`.

This limits the waves/EU range's maximum to the maximum achievable
occupancy derived from flat workgroup sizes and LDS usage. This only has
an impact on functions which restrict flat workgroup size with
"amdgpu-flat-work-group-size", since the default range of flat workgroup
sizes achieves the maximum number of waves/EU supported by the
subtarget.

Improvements to the handling of "amdgpu-waves-per-eu" are left for a
follow up PR (e.g., I think the attribute should be able to lower the
full range of waves/EU produced by these methods).
2025-05-01 13:22:23 +02:00

46 lines
1.7 KiB
LLVM

; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; Interleave loads and stores to fit into 9 VGPR limit.
; This requires to avoid load/store clustering.
; Reschedule the second scheduling region without clustering while
; the first region is skipped.
; GCN: global_load_dwordx4
; GCN: global_store_dwordx4
; GCN: global_load_dwordx4
; GCN: global_store_dwordx4
; GCN: global_load_dwordx4
; GCN: global_store_dwordx4
; GCN: NumVgprs: {{[0-9]$}}
; GCN: ScratchSize: 0{{$}}
define amdgpu_kernel void @load_store_max_9vgprs(ptr addrspace(1) nocapture noalias readonly %arg, ptr addrspace(1) nocapture noalias %arg1, i1 %cnd) #1 {
bb:
%id = call i32 @llvm.amdgcn.workitem.id.x()
%base = getelementptr inbounds <4 x i32>, ptr addrspace(1) %arg, i32 %id
br i1 %cnd, label %bb1, label %bb2
bb1:
%tmp = getelementptr inbounds <4 x i32>, ptr addrspace(1) %base, i32 1
%tmp2 = load <4 x i32>, ptr addrspace(1) %tmp, align 4
%tmp3 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %base, i32 3
%tmp4 = load <4 x i32>, ptr addrspace(1) %tmp3, align 4
%tmp5 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %base, i32 5
%tmp6 = load <4 x i32>, ptr addrspace(1) %tmp5, align 4
store <4 x i32> %tmp2, ptr addrspace(1) %arg1, align 4
%tmp7 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %arg1, i64 3
store <4 x i32> %tmp4, ptr addrspace(1) %tmp7, align 4
%tmp8 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %arg1, i64 5
store <4 x i32> %tmp6, ptr addrspace(1) %tmp8, align 4
br label %bb2
bb2:
ret void
}
declare i32 @llvm.amdgcn.workitem.id.x() #0
attributes #0 = { nounwind readnone }
attributes #1 = { "amdgpu-num-vgpr"="9" }