[llvm] [AMDGPU] Examine instructions in pending queues during scheduling (PR #147653)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 23:20:43 PDT 2025


================
@@ -319,17 +327,45 @@ void GCNSchedStrategy::initCandidate(SchedCandidate &Cand, SUnit *SU,
   }
 }
 
+static bool shouldCheckPending(SchedBoundary &Zone,
+                               const TargetSchedModel *SchedModel) {
+  const unsigned ReadyListLimit = 256;
+  bool HasBufferedModel =
+      SchedModel->hasInstrSchedModel() && SchedModel->getMicroOpBufferSize();
+  return ExaminePendingQueue &&
+         Zone.Available.size() + Zone.Pending.size() <= ReadyListLimit &&
+         HasBufferedModel;
+}
+
+static SUnit *pickOnlyChoice(SchedBoundary &Zone,
+                             const TargetSchedModel *SchedModel) {
+  if (!shouldCheckPending(Zone, SchedModel) || Zone.Pending.empty())
+    return Zone.pickOnlyChoice();
+  return nullptr;
+}
+
+#ifndef NDEBUG
+void GCNSchedStrategy::printCandidateDecision(const SchedCandidate &Current,
+                                              const SchedCandidate &Preferred) {
+  LLVM_DEBUG(dbgs() << "Prefer:\t\t"; DAG->dumpNode(*Preferred.SU));
+  if (Current.SU)
+    LLVM_DEBUG(dbgs() << "Not:\t"; DAG->dumpNode(*Current.SU));
+  LLVM_DEBUG(dbgs() << "Reason:\t\t"; traceCandidate(Preferred));
----------------
arsenm wrote:

Use one debug LLVM_DEBUG({})

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


More information about the llvm-commits mailing list