[llvm] [AMDGPU][Scheduler] Refactor VGPR rematerialization during scheduling (PR #118722)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 10:56:23 PST 2025


================
@@ -1185,6 +1185,28 @@ unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
   return std::min(std::max(TotalNumVGPRs / RoundedRegs, 1u), MaxWaves);
 }
 
+unsigned getVGPRReductionToIncreaseWavesPerEU(const MCSubtargetInfo *STI,
+                                              unsigned NumVGPRs) {
+  unsigned Granule = getVGPRAllocGranule(STI);
+  unsigned MaxWaves = getMaxWavesPerEU(STI);
+  unsigned TotalNumVGPRs = getTotalNumVGPRs(STI);
+
+  unsigned NumWaves =
+      getNumWavesPerEUWithNumVGPRs(NumVGPRs, Granule, MaxWaves, TotalNumVGPRs);
+  if (NumWaves == MaxWaves)
+    return 0;
+  return NumVGPRs - alignDown(TotalNumVGPRs / (NumWaves + 1), Granule);
+}
+
+unsigned getVGPRReductionToEliminateSpilling(const MCSubtargetInfo *STI,
+                                             unsigned NumVGPRs) {
+  unsigned Granule = getVGPRAllocGranule(STI);
+  unsigned TotalNumVGPRs = getTotalNumVGPRs(STI);
----------------
jrbyrnes wrote:

This returns 512 for the unified register file case when we actually want 256 since we only care about the arch VGPR pressure

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


More information about the llvm-commits mailing list