[llvm] 73d90ec - [SLP][NFC]Consider non-profitable trees with only phis, gathers, splits and small nodes with reuses

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 28 03:56:17 PDT 2025


Author: Alexey Bataev
Date: 2025-04-28T03:56:08-07:00
New Revision: 73d90ec8257488deaf6cc9b00dc778b109d5dfc0

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

LOG: [SLP][NFC]Consider non-profitable trees with only phis, gathers, splits and small nodes with reuses

Improves compile time for non-profitable cases.
Fixes #135965

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4f6db05d18c2a..26b5982f5bb18 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13949,6 +13949,19 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
       }))
     return true;
 
+  // If the tree contains only phis, buildvectors, split nodes and
+  // small nodes with reuses, we can skip it.
+  if (!ForReduction && !SLPCostThreshold.getNumOccurrences() &&
+      all_of(VectorizableTree, [](const std::unique_ptr<TreeEntry> &TE) {
+        return TE->State == TreeEntry::SplitVectorize ||
+               (TE->isGather() &&
+                none_of(TE->Scalars, IsaPred<ExtractElementInst>)) ||
+               (TE->hasState() && (TE->getOpcode() == Instruction::PHI ||
+                                   (!TE->ReuseShuffleIndices.empty() &&
+                                    TE->Scalars.size() == 2)));
+      }))
+    return true;
+
   // We can vectorize the tree if its size is greater than or equal to the
   // minimum size specified by the MinTreeSize command line option.
   if (VectorizableTree.size() >= MinTreeSize)


        


More information about the llvm-commits mailing list