[llvm] af5dd51 - [SLP][NFC]Move poor throughput insts logic into a helper function, NFC

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 15:20:03 PDT 2026


Author: Alexey Bataev
Date: 2026-10-11T18:19:58-04:00
New Revision: af5dd5175f15ea24f36d6f95e6c218671b8f07a0

URL: https://github.com/llvm/llvm-project/commit/af5dd5175f15ea24f36d6f95e6c218671b8f07a0
DIFF: https://github.com/llvm/llvm-project/commit/af5dd5175f15ea24f36d6f95e6c218671b8f07a0.diff

LOG: [SLP][NFC]Move poor throughput insts logic into a helper function, NFC



Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/231042

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h b/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
index 3d8ab0d1b7573..74a94fa229ec7 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h
@@ -114,6 +114,11 @@ struct SLPVectorizerPass : public OptionalPassInfoMixin<SLPVectorizerPass> {
   /// Vectorize the store instructions collected in Stores.
   bool vectorizeStoreChains(slpvectorizer::BoUpSLP &R);
 
+  /// Try to vectorize the poor-throughput instructions \p Candidates as the
+  /// standalone seeds.
+  bool vectorizePoorThroughputSeeds(ArrayRef<Instruction *> Candidates,
+                                    slpvectorizer::BoUpSLP &R);
+
   /// Try to vectorize the standalone seeds \p Seeds in the groups of the
   /// compatible instructions, \p IsLessGroup orders the groups.
   bool vectorizeSeeds(SmallVectorImpl<Value *> &Seeds,

diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 1b881e2f05b64..a1b95c6750b8d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -36753,29 +36753,33 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(
     }
   }
 
-  if (PoorThroughputSeeds.size() >= 2) {
-    SmallVector<Value *> Seeds;
-    SmallDenseMap<Value *, SeedGroupKey> SeedKeys;
-    for (Instruction *I :
-         make_filter_range(PoorThroughputSeeds, [&](Instruction *I) {
-           return !R.isDeleted(I) &&
-                  isValidElementType(getValueType(I, SLPReVec), SLPReVec) &&
-                  !R.hasResolvedUser(I);
-         })) {
-      SeedKeys.try_emplace(I, getSeedGroupKey(I, *TLI));
-      Seeds.push_back(I);
-    }
-    Changed |= vectorizeSeeds(
-        Seeds,
-        [&](Value *V1, Value *V2) {
-          return SeedKeys.at(V1).less(SeedKeys.at(V2));
-        },
-        R);
-  }
+  Changed |= vectorizePoorThroughputSeeds(PoorThroughputSeeds.getArrayRef(), R);
 
   return Changed;
 }
 
+bool SLPVectorizerPass::vectorizePoorThroughputSeeds(
+    ArrayRef<Instruction *> Candidates, BoUpSLP &R) {
+  if (Candidates.size() < 2)
+    return false;
+  SmallVector<Value *> Seeds;
+  SmallDenseMap<Value *, SeedGroupKey> SeedKeys;
+  for (Instruction *I : make_filter_range(Candidates, [&](Instruction *I) {
+         return !R.isDeleted(I) &&
+                isValidElementType(getValueType(I, SLPReVec), SLPReVec) &&
+                !R.hasResolvedUser(I);
+       })) {
+    SeedKeys.try_emplace(I, getSeedGroupKey(I, *TLI));
+    Seeds.push_back(I);
+  }
+  return vectorizeSeeds(
+      Seeds,
+      [&](Value *V1, Value *V2) {
+        return SeedKeys.at(V1).less(SeedKeys.at(V2));
+      },
+      R);
+}
+
 bool SLPVectorizerPass::vectorizeSeeds(
     SmallVectorImpl<Value *> &Seeds,
     function_ref<bool(Value *, Value *)> IsLessGroup, BoUpSLP &R) {


        


More information about the llvm-commits mailing list