[llvm] [SLP] Use named structs in vectorizeStores() (NFC) (PR #132781)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 2 02:02:29 PDT 2025


================
@@ -20279,56 +20306,51 @@ bool SLPVectorizerPass::vectorizeStores(
   // dependencies and no need to waste compile time to try to vectorize them.
   // - Try to vectorize the sequence {1, {1, 0}, {3, 2}}.
   auto FillStoresSet = [&](unsigned Idx, StoreInst *SI) {
-    for (std::pair<unsigned, StoreIndexToDistSet> &Set : SortedStores) {
+    for (RelatedStoreInsts &StoreSeq : SortedStores) {
       std::optional<int> Diff = getPointersDiff(
-          Stores[Set.first]->getValueOperand()->getType(),
-          Stores[Set.first]->getPointerOperand(),
+          Stores[StoreSeq.BaseInstrIdx]->getValueOperand()->getType(),
+          Stores[StoreSeq.BaseInstrIdx]->getPointerOperand(),
           SI->getValueOperand()->getType(), SI->getPointerOperand(), *DL, *SE,
           /*StrictCheck=*/true);
       if (!Diff)
         continue;
-      auto It = Set.second.find(std::make_pair(Idx, *Diff));
-      if (It == Set.second.end()) {
-        Set.second.emplace(Idx, *Diff);
+      std::optional<unsigned> PrevInst = StoreSeq.getInstIdx(/*PtrDist=*/*Diff);
+      if (!PrevInst) {
+        StoreSeq.insert(Idx, *Diff);
         return;
       }
----------------
gbossu wrote:

Updated to have a single lookup, I'm hoping this can be committed now

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


More information about the llvm-commits mailing list