[llvm] [Draft][AMDGPU] Take into account amdgpu-waves-per-eu in getRegPressureLimit (PR #173992)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 5 04:02:40 PST 2026


Juan Manuel Martinez =?utf-8?q?CaamaƱo?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/173992 at github.com>


================
@@ -3783,7 +3783,13 @@ bool SIRegisterInfo::isAGPR(const MachineRegisterInfo &MRI,
 
 unsigned SIRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
                                              MachineFunction &MF) const {
-  unsigned MinOcc = ST.getOccupancyWithWorkGroupSizes(MF).first;
+  unsigned MinWGSizeOcc = ST.getOccupancyWithWorkGroupSizes(MF).first;
+  unsigned MaxWavesPerEU = ST.getWavesPerEU(MF.getFunction()).second;
+  // The occupancy is bound by the amdgpu-waves-per-eu value specified by the
+  // user. Using a small value for amdgpu-waves-per-eu, should yield bigger
+  // register pressure limits (if resources allow it).
+  unsigned MinOcc = std::min(MinWGSizeOcc, MaxWavesPerEU);
----------------
lucas-rami wrote:

I am not sure I understand the rationale for combining the minimum occupancy w.r.t. workgroup size with the maximum target occupancy.

AFAIU the method should produce the maximum number of registers of `RC` we can use if we want to achieve the minimum target occupancy. If that is correct I think we should just have

```cpp
unsigned MinOcc = ST.getWavesPerEU(MF.getFunction()).first;
```

which (even before #168358) is itself based on/constrained by the workgroup size range.

https://github.com/llvm/llvm-project/pull/173992


More information about the llvm-commits mailing list