[llvm] [SLP] Add store-to-load forwarding conflict cost for widened store chains (PR #199606)

Milin Bhade via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 12 09:59:37 PDT 2026


================
@@ -18049,6 +18085,18 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
               BaseSI->getPointerAddressSpace(), CostKind, OpInfo);
         }
       }
+      // Widening this store chain can break store-to-load forwarding for a
+      // nearby loop-carried load. Rather than reject the tree outright, add
+      // the target's modeled STLF penalty so a chain that is still profitable
+      // after paying it can vectorize. The penalty is a throughput/latency
+      // hazard, so only account for it under those cost kinds.
+      if (EnableSLPStoreLoadForwardCheck && E->State == TreeEntry::Vectorize &&
+          (CostKind == TTI::TCK_RecipThroughput ||
+           CostKind == TTI::TCK_Latency) &&
+          findStoreLoadForwardingConflict(
+              BaseSI,
+              E->getVectorFactor() * std::max(1u, E->getInterleaveFactor())))
----------------
mbhade-amd wrote:

Done.

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


More information about the llvm-commits mailing list