[llvm] c601928 - [SLP][NFC]Improve compile time by storing all nodes for the given
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 07:30:00 PDT 2023
Author: Alexey Bataev
Date: 2023-09-21T07:24:31-07:00
New Revision: c601928cb9c3c886eb4c2e744906ab7a9eb2e41d
URL: https://github.com/llvm/llvm-project/commit/c601928cb9c3c886eb4c2e744906ab7a9eb2e41d
DIFF: https://github.com/llvm/llvm-project/commit/c601928cb9c3c886eb4c2e744906ab7a9eb2e41d.diff
LOG: [SLP][NFC]Improve compile time by storing all nodes for the given
scalar.
No need to scan the whole graph when trying to find matching node for
the scalar, vectorized in several nodes, better to store corresponding
nodes along and scan just this small list.
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 b5860e34251d12b..11294047209c9e7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2918,7 +2918,7 @@ class BoUpSLP {
"Scalar already in tree!");
if (TE) {
if (TE != Last)
- MultiNodeScalars.insert(V);
+ MultiNodeScalars.try_emplace(V).first->getSecond().push_back(Last);
continue;
}
ScalarToTreeEntry[V] = Last;
@@ -2979,8 +2979,9 @@ class BoUpSLP {
/// Maps a specific scalar to its tree entry.
SmallDenseMap<Value *, TreeEntry *> ScalarToTreeEntry;
- /// List of scalars, used in several vectorize nodes.
- SmallDenseSet<Value *> MultiNodeScalars;
+ /// List of scalars, used in several vectorize nodes, and the list of the
+ /// nodes.
+ SmallDenseMap<Value *, SmallVector<TreeEntry *>> MultiNodeScalars;
/// Maps a value to the proposed vectorizable size.
SmallDenseMap<Value *, unsigned> InstrElementSize;
@@ -9866,15 +9867,16 @@ Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx) {
};
TreeEntry *VE = getTreeEntry(S.OpValue);
bool IsSameVE = VE && CheckSameVE(VE);
- if (!IsSameVE && MultiNodeScalars.contains(S.OpValue)) {
- auto *I =
- find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
- return TE->State != TreeEntry::NeedToGather && TE.get() != VE &&
- CheckSameVE(TE.get());
- });
- if (I != VectorizableTree.end()) {
- VE = I->get();
- IsSameVE = true;
+ if (!IsSameVE) {
+ auto It = MultiNodeScalars.find(S.OpValue);
+ if (It != MultiNodeScalars.end()) {
+ auto *I = find_if(It->getSecond(), [&](const TreeEntry *TE) {
+ return TE != VE && CheckSameVE(TE);
+ });
+ if (I != It->getSecond().end()) {
+ VE = *I;
+ IsSameVE = true;
+ }
}
}
if (IsSameVE) {
More information about the llvm-commits
mailing list