[llvm] [AMDGPU] Extend DS loop wait optimization with flush point tracking (PR #175658)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 17:53:03 PST 2026


================
@@ -3196,8 +3243,29 @@ SIInsertWaitcnts::getPreheaderFlushFlags(MachineLoop *ML,
       // Only invalidate when DEF comes before USE (same-iteration consumption,
       // checked above when processing uses).
       if (isDSRead(MI)) {
+        // Track position for flush point detection
+        bool TrackPosition =
+            !FlushPointTrackingInvalid && InLatchBlock && AfterBarrier;
+        if (TrackPosition)
+          ++DSLoadCount;
+
         for (const MachineOperand &Op : MI.all_defs()) {
           for (MCRegUnit RU : TRI->regunits(Op.getReg().asMCReg())) {
+            // Check for overwrite of pending DS load (flush point)
+            // and record new position if tracking
+            if (!FlushPointTrackingInvalid) {
+              unsigned Key = static_cast<unsigned>(RU);
----------------
hidekisaito wrote:

done

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


More information about the llvm-commits mailing list