Skip to content

Commit 12fda30

Browse files
committed
[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.
1 parent 8d7ca08 commit 12fda30

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7327,6 +7327,15 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
73277327
return VecBase;
73287328
}
73297329
void add(const TreeEntry *E1, const TreeEntry *E2, ArrayRef<int> Mask) {
7330+
if (E1 == E2) {
7331+
assert(all_of(Mask,
7332+
[=](int Idx) {
7333+
return Idx < static_cast<int>(E1->getVectorFactor());
7334+
}) &&
7335+
"Expected single vector shuffle mask.");
7336+
add(E1, Mask);
7337+
return;
7338+
}
73307339
CommonMask.assign(Mask.begin(), Mask.end());
73317340
InVectors.assign({E1, E2});
73327341
}
@@ -7525,10 +7534,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
75257534
LLVM_DEBUG(dbgs() << "SLP: shuffled " << Entries.size()
75267535
<< " entries for bundle "
75277536
<< shortBundleName(VL) << ".\n");
7528-
if (Entries.size() == 1)
7529-
Estimator.add(Entries.front(), Mask);
7530-
else
7531-
Estimator.add(Entries.front(), Entries.back(), Mask);
7537+
Estimator.add(Entries.front(), Entries.back(), Mask);
75327538
if (all_of(GatheredScalars, PoisonValue ::classof))
75337539
return Estimator.finalize(E->ReuseShuffleIndices);
75347540
return Estimator.finalize(

0 commit comments

Comments
 (0)