[llvm-branch-commits] [llvm] [AMDGPU][Scheduler] Prepare remat stage for rematerializer integration (NFC) (PR #189489)

Quentin Colombet via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 3 14:06:11 PDT 2026


================
@@ -1637,24 +1632,37 @@ bool PreRARematStage::initGCNSchedStage() {
         DAG.deleteMI(Remat.DefRegion, Remat.DefMI);
       }
 
-      unsetSatisfiedRPTargets(Remat.Live);
-    }
-
-    REMAT_DEBUG({
+      // Adjust RP targets. The save is guaranteed in regions in which the
+      // register is live-through and unused but optimistic in all other regions
+      // where the register is live.
+      updateRPTargets(Cand.Live, Cand.RPSave);
+      RecomputeRP |= Cand.UnpredictableRPSave;
+      RescheduleRegions |= Cand.Live;
       if (!TargetRegions.any()) {
-        dbgs() << "** Interrupt round on all targets achieved\n";
-      } else if (RematIdx) {
-        dbgs() << "** Interrupt round on stale score for "
-               << *ScoredRemats[RematIdx - 1].Remat->DefMI;
-      } else {
-        dbgs() << "** Stop on exhausted rematerialization candidates\n";
+        REMAT_DEBUG(dbgs() << "All targets cleared, verifying...\n");
+        break;
       }
-    });
+    }
+
+    if (!updateAndVerifyRPTargets(RecomputeRP) && !TargetRegions.any()) {
+      REMAT_DEBUG(dbgs() << "Objectives achieved!\n");
+      break;
+    }
+
+    // Update the score of remaining candidates.
+    NewCandidateOrder.clear();
----------------
qcolombet wrote:

Could we declare `NewCandidateOrder` only here?
Like do we save anything by doing the declaration outside.

Also, by construction this should be empty already no?

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


More information about the llvm-branch-commits mailing list