[llvm] [AMDGPU] Restrict pending resource preferences near unified VGPR occupancy boundaries (PR #220975)

Yoonseo Choi via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 20:22:06 PDT 2026


================
@@ -1832,6 +1837,32 @@ bool GCNSchedStage::initGCNRegion() {
 
   PressureBefore = DAG.Pressure[RegionIdx];
 
+  S.AllowPendingCandidates = true;
+
+  // Only adjust the initial max-occupancy schedule, and do not override the
+  // explicit scheduling policy of an IGLP region.
+  if (StageID == GCNSchedStageID::OccInitialSchedule && ST.hasGFX90AInsts() &&
+      !DAG.RegionsWithIGLPInstrs[RegionIdx]) {
+    unsigned DynamicVGPRBlockSize = MFI.getDynamicVGPRBlockSize();
+    unsigned RegionOccupancy =
+        std::min(DAG.MinOccupancy,
+                 PressureBefore.getOccupancy(ST, DynamicVGPRBlockSize));
+
+    // Pending candidates may extend live ranges. Round the estimate to the
+    // hardware allocation granule and keep the final block for the current
+    // occupancy in reserve. At one wave there is no lower occupancy to protect.
+    if (RegionOccupancy > 1) {
+      unsigned UnifiedVGPRPressure =
+          PressureBefore.getVGPRNum(/*UnifiedVGPRFile=*/true);
+      unsigned EstimatedUnifiedVGPRPressure =
+          alignTo(UnifiedVGPRPressure + MaxVGPRPressureInc + S.ErrorMargin,
+                  ST.getVGPRAllocGranule(DynamicVGPRBlockSize));
+      unsigned MaxVGPRs =
+          ST.getMaxNumVGPRs(RegionOccupancy, DynamicVGPRBlockSize);
+      S.AllowPendingCandidates = EstimatedUnifiedVGPRPressure < MaxVGPRs;
----------------
yoonseoch wrote:

I think the new push is a good improvement: now the guard is in the tryPendingCandidate() and pending node still can win based on reg pressure and only avoided on resource pressure. Without changing VGPR limits, under current implementation it might be the right scope to change. I'd still like someone with more scheduler experience to sign off. 

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


More information about the llvm-commits mailing list