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

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 08:12:15 PDT 2026


================
@@ -28257,6 +28285,109 @@ bool SLPVectorizerPass::runImpl(Function &F, ScalarEvolution *SE_,
   return Changed;
 }
 
+bool BoUpSLP::findStoreLoadForwardingConflict(StoreInst *BaseStore,
+                                              unsigned VF) {
+  if (!BaseStore)
+    return false;
+
+  StoreInst *FirstStore = BaseStore;
+
+  // Memoize per (store, VF); the entry is re-costed repeatedly.
+  auto Key = std::make_pair(FirstStore, VF);
+  auto CacheIt = StlfConflictCache.find(Key);
+  if (CacheIt != StlfConflictCache.end())
+    return CacheIt->second;
+
+  auto CacheAndReturn = [&](bool Result) -> bool {
+    StlfConflictCache[Key] = Result;
+    // No conflict at VF implies none at any smaller power-of-2 VF, so seed
+    // those entries too. Conflicts do not propagate downward.
+    if (!Result && isPowerOf2_32(VF))
+      for (unsigned V = VF / 2; V >= 2; V /= 2)
+        StlfConflictCache.try_emplace(std::make_pair(FirstStore, V), false);
+    return Result;
----------------
alexey-bataev wrote:

Better to extend it for non-power-of-2 case too

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


More information about the llvm-commits mailing list