[llvm] [SLP] Bail out on store-to-load forwarding hazards (PR #199606)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 01:27:40 PDT 2026


================
@@ -234,6 +234,25 @@ class MemoryDepChecker {
            std::numeric_limits<uint64_t>::max();
   }
 
+  /// Returns true if a memory dependence at byte distance \p Distance between
+  /// a store and load (both with element size \p TypeByteSize bytes) would
+  /// prevent store-to-load forwarding when the store is widened to
+  /// \p VectorStoreSize bytes.
+  ///
+  /// The predicate fires when (a) the load is misaligned w.r.t. the widened
+  /// store window (\c Distance is not a multiple of \p VectorStoreSize), and
+  /// (b) the conflicting store is still likely to be in the store buffer
+  /// (\c Distance / VectorStoreSize is below 8 * TypeByteSize iterations).
+  /// Both couldPreventStoreLoadForward and SLPVectorizer use this as their
+  /// core STLF cost-model gate.
+  static bool isStoreLoadForwardingConflict(uint64_t Distance,
+                                            uint64_t VectorStoreSize,
+                                            uint64_t TypeByteSize) {
+    const uint64_t NumItersForStoreLoadThroughMemory = 8 * TypeByteSize;
----------------
mbhade-amd wrote:

This isn't a new constant — NumItersForStoreLoadThroughMemory = 8 * TypeByteSize already exists in MemoryDepChecker::couldPreventStoreLoadForward. I only factored the inner predicate out into isStoreLoadForwardingConflict so LAA and SLP share one definition;

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


More information about the llvm-commits mailing list