@@ -2433,7 +2433,8 @@ class BoUpSLP {
2433
2433
2434
2434
/// \returns the cost of the vectorizable entry.
2435
2435
InstructionCost getEntryCost(const TreeEntry *E,
2436
- ArrayRef<Value *> VectorizedVals);
2436
+ ArrayRef<Value *> VectorizedVals,
2437
+ SmallPtrSetImpl<Value *> &CheckedExtracts);
2437
2438
2438
2439
/// This is the recursive part of buildTree.
2439
2440
void buildTree_rec(ArrayRef<Value *> Roots, unsigned Depth,
@@ -6731,6 +6732,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
6731
6732
InstructionCost Cost = 0;
6732
6733
ArrayRef<Value *> VectorizedVals;
6733
6734
BoUpSLP &R;
6735
+ SmallPtrSetImpl<Value *> &CheckedExtracts;
6734
6736
constexpr static TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
6735
6737
6736
6738
InstructionCost getBuildVectorCost(ArrayRef<Value *> VL, Value *Root) {
@@ -6923,8 +6925,10 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
6923
6925
6924
6926
public:
6925
6927
ShuffleCostEstimator(TargetTransformInfo &TTI,
6926
- ArrayRef<Value *> VectorizedVals, BoUpSLP &R)
6927
- : TTI(TTI), VectorizedVals(VectorizedVals), R(R) {}
6928
+ ArrayRef<Value *> VectorizedVals, BoUpSLP &R,
6929
+ SmallPtrSetImpl<Value *> &CheckedExtracts)
6930
+ : TTI(TTI), VectorizedVals(VectorizedVals), R(R),
6931
+ CheckedExtracts(CheckedExtracts) {}
6928
6932
Value *adjustExtracts(const TreeEntry *E, ArrayRef<int> Mask,
6929
6933
TTI::ShuffleKind ShuffleKind) {
6930
6934
if (Mask.empty())
@@ -6939,7 +6943,6 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
6939
6943
return nullptr;
6940
6944
}
6941
6945
DenseMap<Value *, int> ExtractVectorsTys;
6942
- SmallPtrSet<Value *, 4> CheckedExtracts;
6943
6946
for (auto [I, V] : enumerate(VL)) {
6944
6947
// Ignore non-extractelement scalars.
6945
6948
if (isa<UndefValue>(V) || (!Mask.empty() && Mask[I] == UndefMaskElem))
@@ -7070,8 +7073,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
7070
7073
}
7071
7074
};
7072
7075
7073
- InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
7074
- ArrayRef<Value *> VectorizedVals) {
7076
+ InstructionCost
7077
+ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
7078
+ SmallPtrSetImpl<Value *> &CheckedExtracts) {
7075
7079
ArrayRef<Value *> VL = E->Scalars;
7076
7080
7077
7081
Type *ScalarTy = VL[0]->getType();
@@ -7098,7 +7102,8 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
7098
7102
return 0;
7099
7103
if (isa<InsertElementInst>(VL[0]))
7100
7104
return InstructionCost::getInvalid();
7101
- ShuffleCostEstimator Estimator(*TTI, VectorizedVals, *this);
7105
+ ShuffleCostEstimator Estimator(*TTI, VectorizedVals, *this,
7106
+ CheckedExtracts);
7102
7107
unsigned VF = E->getVectorFactor();
7103
7108
SmallVector<int> ReuseShuffleIndicies(E->ReuseShuffleIndices.begin(),
7104
7109
E->ReuseShuffleIndices.end());
@@ -8224,6 +8229,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
8224
8229
8225
8230
unsigned BundleWidth = VectorizableTree[0]->Scalars.size();
8226
8231
8232
+ SmallPtrSet<Value *, 4> CheckedExtracts;
8227
8233
for (unsigned I = 0, E = VectorizableTree.size(); I < E; ++I) {
8228
8234
TreeEntry &TE = *VectorizableTree[I];
8229
8235
if (TE.State == TreeEntry::NeedToGather) {
@@ -8239,7 +8245,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
8239
8245
}
8240
8246
}
8241
8247
8242
- InstructionCost C = getEntryCost(&TE, VectorizedVals);
8248
+ InstructionCost C = getEntryCost(&TE, VectorizedVals, CheckedExtracts );
8243
8249
Cost += C;
8244
8250
LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C
8245
8251
<< " for bundle that starts with " << *TE.Scalars[0]
0 commit comments