[llvm] [SLP][NFC]Skip large mostly-trivial trees with up to one vector compute node (PR #194703)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 11:46:56 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Alexey Bataev (alexey-bataev)
<details>
<summary>Changes</summary>
Track non-load/store, non-PHI, non-split vector compute nodes separately
in isTreeTinyAndNotFullyVectorizable. Allow skipping a tree when it
contains at most one such vector node and at most one load/store node,
provided the tree is large enough relative to their combined count
(VectorizableTree.size() > LimitTreeSize * (StoreLoadNodes.size() +
VectorNodes.size())).
---
Full diff: https://github.com/llvm/llvm-project/pull/194703.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+21-3)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index c18ebe3e23cc5..072d1d75bbda0 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -17662,9 +17662,11 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
// If the tree contains only phis, buildvectors, split nodes and
// small nodes with reuses, we can skip it.
SmallVector<const TreeEntry *> StoreLoadNodes;
+ SmallVector<const TreeEntry *> VectorNodes;
unsigned NumGathers = 0;
- constexpr int LimitTreeSize = 36;
+ constexpr unsigned LimitTreeSize = 36;
if (!ForReduction && !SLPCostThreshold.getNumOccurrences() &&
+ VectorizableTree.size() > LimitTreeSize &&
all_of(VectorizableTree,
[&](const std::unique_ptr<TreeEntry> &TE) {
if (!TE->isGather() && TE->hasState() &&
@@ -17673,6 +17675,12 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
StoreLoadNodes.push_back(TE.get());
return true;
}
+ if (!TE->isGather() && TE->hasState() &&
+ TE->State != TreeEntry::SplitVectorize &&
+ TE->getOpcode() != Instruction::PHI) {
+ VectorNodes.push_back(TE.get());
+ return true;
+ }
if (TE->isGather())
++NumGathers;
return TE->State == TreeEntry::SplitVectorize ||
@@ -17691,8 +17699,18 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
!TE->ReorderIndices.empty() || TE->isAltShuffle()) &&
TE->Scalars.size() == 2)));
}) &&
- (StoreLoadNodes.empty() ||
- (VectorizableTree.size() > LimitTreeSize * StoreLoadNodes.size() &&
+ ((StoreLoadNodes.empty() && VectorNodes.empty()) ||
+ (VectorNodes.size() <= 1 && StoreLoadNodes.size() <= 1 &&
+ (VectorizableTree.size() >
+ LimitTreeSize * (StoreLoadNodes.size() + VectorNodes.size()) ||
+ (StoreLoadNodes.empty() &&
+ (VectorNodes.empty() ||
+ (VectorNodes.size() == 1 &&
+ VectorNodes.front()->getOpcode() == Instruction::GetElementPtr)) &&
+ VectorizableTree.size() >
+ LimitTreeSize * (StoreLoadNodes.size() + VectorNodes.size())))) ||
+ (VectorNodes.empty() &&
+ VectorizableTree.size() > LimitTreeSize * StoreLoadNodes.size() &&
(NumGathers > 0 || none_of(StoreLoadNodes, [&](const TreeEntry *TE) {
return TE->getOpcode() == Instruction::Store ||
all_of(TE->Scalars, [&](Value *V) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/194703
More information about the llvm-commits
mailing list