[llvm] 12fda30 - [SLP][NFC]Unify add() member function in CostEstimator, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 08:02:39 PDT 2023
Author: Alexey Bataev
Date: 2023-09-21T07:59:37-07:00
New Revision: 12fda304ccf3e853e90708567f87d12c56ef4aa3
URL: https://github.com/llvm/llvm-project/commit/12fda304ccf3e853e90708567f87d12c56ef4aa3
DIFF: https://github.com/llvm/llvm-project/commit/12fda304ccf3e853e90708567f87d12c56ef4aa3.diff
LOG: [SLP][NFC]Unify add() member function in CostEstimator, NFC.
Make add() function smart enough to understand that the shuffle of
a single entry is requested, if it sees that the second node is the same
as the first.
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 11294047209c9e7..e3a1c0b54995ad1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7327,6 +7327,15 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return VecBase;
}
void add(const TreeEntry *E1, const TreeEntry *E2, ArrayRef<int> Mask) {
+ if (E1 == E2) {
+ assert(all_of(Mask,
+ [=](int Idx) {
+ return Idx < static_cast<int>(E1->getVectorFactor());
+ }) &&
+ "Expected single vector shuffle mask.");
+ add(E1, Mask);
+ return;
+ }
CommonMask.assign(Mask.begin(), Mask.end());
InVectors.assign({E1, E2});
}
@@ -7525,10 +7534,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
LLVM_DEBUG(dbgs() << "SLP: shuffled " << Entries.size()
<< " entries for bundle "
<< shortBundleName(VL) << ".\n");
- if (Entries.size() == 1)
- Estimator.add(Entries.front(), Mask);
- else
- Estimator.add(Entries.front(), Entries.back(), Mask);
+ Estimator.add(Entries.front(), Entries.back(), Mask);
if (all_of(GatheredScalars, PoisonValue ::classof))
return Estimator.finalize(E->ReuseShuffleIndices);
return Estimator.finalize(
More information about the llvm-commits
mailing list