[llvm] [AMDGPU] Prefer lower total register usage in regions with spilling (PR #71882)
Valery Pykhtin via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 07:43:55 PST 2023
================
@@ -104,18 +105,82 @@ bool GCNRegPressure::less(const GCNSubtarget &ST,
const auto Occ = std::min(SGPROcc, VGPROcc);
const auto OtherOcc = std::min(OtherSGPROcc, OtherVGPROcc);
+
+ // Give first precedence to the better occupancy.
if (Occ != OtherOcc)
return Occ > OtherOcc;
+ unsigned MaxVGPRs = ST.getMaxNumVGPRs(MF);
+ unsigned MaxSGPRs = ST.getMaxNumSGPRs(MF);
+
+ // SGPR excess pressure conditions
+ unsigned ExcessSGPR = std::max(static_cast<int>(getSGPRNum() - MaxSGPRs), 0);
+ unsigned OtherExcessSGPR =
+ std::max(static_cast<int>(O.getSGPRNum() - MaxSGPRs), 0);
+
+ auto WaveSize = ST.getWavefrontSize();
+ // The number of virtual VGPRs required to handle excess SGPR
+ unsigned SGPRSpills = (ExcessSGPR + (WaveSize - 1)) / WaveSize;
----------------
vpykhtin wrote:
`SGPRSpills` name is a bit misleading, better to have a name reflecting that it's a number of VGPRs.
https://github.com/llvm/llvm-project/pull/71882
More information about the llvm-commits
mailing list