[llvm] 8d933ea - [SLP][NFC]Use SmallDensetSet for lookup instead of ArrayRef, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 13:17:42 PDT 2023
Author: Alexey Bataev
Date: 2023-09-06T13:17:30-07:00
New Revision: 8d933ea5ac12cf706ebf818e8720f34660c79797
URL: https://github.com/llvm/llvm-project/commit/8d933ea5ac12cf706ebf818e8720f34660c79797
DIFF: https://github.com/llvm/llvm-project/commit/8d933ea5ac12cf706ebf818e8720f34660c79797.diff
LOG: [SLP][NFC]Use SmallDensetSet for lookup instead of ArrayRef, NFC.
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 0e8ff61ed7f119..d2570fdea4216b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1766,7 +1766,7 @@ class BoUpSLP {
auto *IdxLaneI = dyn_cast<Instruction>(IdxLaneV);
if (!IdxLaneI || !isa<Instruction>(OpIdxLaneV))
return 0;
- return R.areAllUsersVectorized(IdxLaneI, std::nullopt)
+ return R.areAllUsersVectorized(IdxLaneI)
? LookAheadHeuristics::ScoreAllUserVectorized
: 0;
}
@@ -2430,8 +2430,9 @@ class BoUpSLP {
}
/// Checks if all users of \p I are the part of the vectorization tree.
- bool areAllUsersVectorized(Instruction *I,
- ArrayRef<Value *> VectorizedVals) const;
+ bool areAllUsersVectorized(
+ Instruction *I,
+ const SmallDenseSet<Value *> *VectorizedVals = nullptr) const;
/// Return information about the vector formed for the specified index
/// of a vector of (the same) instruction.
@@ -6431,9 +6432,9 @@ bool BoUpSLP::canReuseExtract(ArrayRef<Value *> VL, Value *OpValue,
return ShouldKeepOrder;
}
-bool BoUpSLP::areAllUsersVectorized(Instruction *I,
- ArrayRef<Value *> VectorizedVals) const {
- return (I->hasOneUse() && is_contained(VectorizedVals, I)) ||
+bool BoUpSLP::areAllUsersVectorized(
+ Instruction *I, const SmallDenseSet<Value *> *VectorizedVals) const {
+ return (I->hasOneUse() && (!VectorizedVals || VectorizedVals->contains(I))) ||
all_of(I->users(), [this](User *U) {
return ScalarToTreeEntry.count(U) > 0 ||
isVectorLikeInstWithConstOps(U) ||
@@ -6888,7 +6889,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
SmallVector<PointerUnion<Value *, const TreeEntry *>, 2> InVectors;
const TargetTransformInfo &TTI;
InstructionCost Cost = 0;
- ArrayRef<Value *> VectorizedVals;
+ SmallDenseSet<Value *> VectorizedVals;
BoUpSLP &R;
SmallPtrSetImpl<Value *> &CheckedExtracts;
constexpr static TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
@@ -7181,8 +7182,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
ShuffleCostEstimator(TargetTransformInfo &TTI,
ArrayRef<Value *> VectorizedVals, BoUpSLP &R,
SmallPtrSetImpl<Value *> &CheckedExtracts)
- : TTI(TTI), VectorizedVals(VectorizedVals), R(R),
- CheckedExtracts(CheckedExtracts) {}
+ : TTI(TTI), VectorizedVals(VectorizedVals.begin(), VectorizedVals.end()),
+ R(R), CheckedExtracts(CheckedExtracts) {}
Value *adjustExtracts(const TreeEntry *E, ArrayRef<int> Mask,
TTI::ShuffleKind ShuffleKind) {
if (Mask.empty())
@@ -7207,7 +7208,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
// in
diff erent graph entries.
const TreeEntry *VE = R.getTreeEntry(V);
if (!CheckedExtracts.insert(V).second ||
- !R.areAllUsersVectorized(cast<Instruction>(V), VectorizedVals) ||
+ !R.areAllUsersVectorized(cast<Instruction>(V), &VectorizedVals) ||
(VE && VE != E))
continue;
auto *EE = cast<ExtractElementInst>(V);
@@ -9050,12 +9051,9 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, ArrayRef<Value *> VL,
// by extractelements processing) or may form vector node in future.
auto MightBeIgnored = [=](Value *V) {
auto *I = dyn_cast<Instruction>(V);
- SmallVector<Value *> IgnoredVals;
- if (UserIgnoreList)
- IgnoredVals.assign(UserIgnoreList->begin(), UserIgnoreList->end());
return I && !IsSplatOrUndefs && !ScalarToTreeEntry.count(I) &&
!isVectorLikeInstWithConstOps(I) &&
- !areAllUsersVectorized(I, IgnoredVals) && isSimple(I);
+ !areAllUsersVectorized(I, UserIgnoreList) && isSimple(I);
};
// Check that the neighbor instruction may form a full vector node with the
// current instruction V. It is possible, if they have same/alternate opcode
More information about the llvm-commits
mailing list