[llvm] [AMDGPU] Reset minOccupancy if unclustered schedule was not run for any region. (PR #162025)

Dhruva Chakrabarti via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 18:09:42 PDT 2025


================
@@ -1134,21 +1136,28 @@ bool PreRARematStage::initGCNSchedStage() {
   return true;
 }
 
-void GCNSchedStage::finalizeGCNSchedStage() {
+void GCNSchedStage::finalizeGCNSchedStage(bool IsAnyRegionScheduled) {
   DAG.finishBlock();
   LLVM_DEBUG(dbgs() << "Ending scheduling stage: " << StageID << "\n");
 }
 
-void UnclusteredHighRPStage::finalizeGCNSchedStage() {
+void UnclusteredHighRPStage::finalizeGCNSchedStage(bool IsAnyRegionScheduled) {
   SavedMutations.swap(DAG.Mutations);
   S.SGPRLimitBias = S.VGPRLimitBias = 0;
   if (DAG.MinOccupancy > InitialOccupancy) {
-    LLVM_DEBUG(dbgs() << StageID
-                      << " stage successfully increased occupancy to "
-                      << DAG.MinOccupancy << '\n');
+    if (IsAnyRegionScheduled) {
+      LLVM_DEBUG(dbgs() << StageID
+                        << " stage successfully increased occupancy to "
+                        << DAG.MinOccupancy << '\n');
+    } else {
+      DAG.MinOccupancy = InitialOccupancy;
----------------
dhruvachak wrote:

> Instead of roll-back, can you avoid modifying the real occupancy until the scheduling change is performed?

Thanks for the suggestion. I updated the patch with this change. While doing that, I realized that MFI occupancy should not be updated either unless at least one region is scheduled. That has been fixed now as well.

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


More information about the llvm-commits mailing list