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

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 20 10:50:03 PST 2026


================
@@ -3411,10 +3425,17 @@ SIInsertWaitcnts::getPreheaderFlushFlags(MachineLoop *ML,
           if (VgprDefDS.contains(RU))
             DSInvalidated = true;
 
-          // Early exit if both optimizations are invalidated
-          if (VMemInvalidated && DSInvalidated)
+          // Early exit if all optimizations are invalidated
+          if (VMemInvalidated && DSInvalidated && FlushPointTrackingInvalid)
             return Flags;
 
+          // Check for flush points (DS load used in same iteration)
+          if (!FlushPointTrackingInvalid) {
+            auto It = DSLoadPosition.find(RU);
+            if (It != DSLoadPosition.end() && It->second > LastFlushedPosition)
+              LastFlushedPosition = It->second;
----------------
vporpo wrote:

I usually prefer std::max() because it expresses the intend a bit more clearly, but I agree it shouldn't make too much of a difference here.

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


More information about the llvm-commits mailing list