[llvm] [AMDGPU] Model ordered XDL writes in expert scheduling (PR #218326)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 06:34:43 PDT 2026


================
@@ -884,14 +903,26 @@ void WaitcntBrackets::updateByEvent(HWEvents E, MachineInstr &Inst) {
     Increment = 2;
   }
   unsigned CurrScore = UB + Increment;
-  if (CurrScore == 0)
+  // Increment can be two, so unsigned overflow may wrap to one instead of zero.
+  if (CurrScore <= UB)
     report_fatal_error("InsertWaitcnt score wraparound");
   // PendingEvents and ScoreUB need to be update regardless if this event
   // changes the score of a register or not.
   // Examples including vm_cnt when buffer-store or lgkm_cnt when send-message.
   PendingEvents |= E;
   setScoreUB(T, CurrScore);
 
+  if (E == HWEvents::VGPR_XDL_WRITE && Context->TII.isVAVDSTOrderedXDL(Inst)) {
+    // While an earlier write is pending, every later ordered XDL write must
+    // also be pending. Count those writes as a per-dependency wait bound.
+    for (auto &Entry : VMem) {
+      auto &Info = Entry.second;
+      if (Info.Scores[AMDGPU::VA_VDST_WR] > getScoreLB(AMDGPU::VA_VDST_WR) &&
+          Info.NumOrderedXDLsAfterWrite < getLimit(AMDGPU::VA_VDST_WR) - 1)
----------------
jayfoad wrote:

`- 1` looks suspicious here. `getLimit(AMDGPU::VA_VDST_WR)` is 15 so this means `NumOrderedXDLsAfterWrite` will never exceed 14. Is that really what you want?

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


More information about the llvm-commits mailing list