[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:23:55 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;
----------------
hidekisaito wrote:

Yes, but since I still need to check It != end(), that doesn't make it any cleaner in my opinion. I don't care enough to go against your suggestion, though.

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


More information about the llvm-commits mailing list