LLVM 22.0.0git
|
Bottom Up SLP Vectorizer. More...
Classes | |
struct | EdgeInfo |
This structure holds any data we need about the edges being traversed during buildTreeRec(). More... | |
class | LookAheadHeuristics |
A helper class used for scoring candidates for two consecutive lanes. More... | |
class | ShuffleCostEstimator |
Merges shuffle masks and emits final shuffle instruction, if required. More... | |
class | ShuffleInstructionBuilder |
Merges shuffle masks and emits final shuffle instruction, if required. More... | |
class | VLOperands |
A helper data structure to hold the operands of a vector of instructions. More... |
Public Types | |
enum class | LoadsState { Gather , Vectorize , ScatterVectorize , StridedVectorize , CompressVectorize } |
Tracks the state we can represent the loads in the given sequence. More... | |
using | ValueList = SmallVector<Value *, 8> |
using | InstrList = SmallVector<Instruction *, 16> |
using | ValueSet = SmallPtrSet<Value *, 16> |
using | StoreList = SmallVector<StoreInst *, 8> |
using | ExtraValueToDebugLocsMap = SmallDenseSet<Value *, 4> |
using | OrdersType = SmallVector<unsigned, 4> |
Public Member Functions | |
BoUpSLP (Function *Func, ScalarEvolution *Se, TargetTransformInfo *Tti, TargetLibraryInfo *TLi, AAResults *Aa, LoopInfo *Li, DominatorTree *Dt, AssumptionCache *AC, DemandedBits *DB, const DataLayout *DL, OptimizationRemarkEmitter *ORE) | |
Value * | vectorizeTree () |
Vectorize the tree that starts with the elements in VL . | |
Value * | vectorizeTree (const ExtraValueToDebugLocsMap &ExternallyUsedValues, Instruction *ReductionRoot=nullptr, ArrayRef< std::tuple< Value *, unsigned, bool > > VectorValuesAndScales={}) |
Vectorize the tree but with the list of externally used values ExternallyUsedValues . | |
InstructionCost | getSpillCost () |
InstructionCost | getTreeCost (ArrayRef< Value * > VectorizedVals={}, InstructionCost ReductionCost=TTI::TCC_Free) |
void | buildTree (ArrayRef< Value * > Roots, const SmallDenseSet< Value * > &UserIgnoreLst) |
Construct a vectorizable tree that starts at Roots , ignoring users for the purpose of scheduling and extraction in the UserIgnoreLst . | |
void | buildTree (ArrayRef< Value * > Roots) |
Construct a vectorizable tree that starts at Roots . | |
ArrayRef< Value * > | getRootNodeScalars () const |
Return the scalars of the root node. | |
std::optional< std::pair< Type *, bool > > | getRootNodeTypeWithNoCast () const |
Returns the type/is-signed info for the root node in the graph without casting. | |
bool | isSignedMinBitwidthRootNode () const |
Checks if the root graph node can be emitted with narrower bitwidth at codegen and returns it signedness, if so. | |
FixedVectorType * | getReductionType () const |
Returns reduction type after minbitdth analysis. | |
void | buildExternalUses (const ExtraValueToDebugLocsMap &ExternallyUsedValues={}) |
Builds external uses of the vectorized scalars, i.e. | |
void | transformNodes () |
Transforms graph nodes to target specific representations, if profitable. | |
void | deleteTree () |
Clear the internal data structures that are created by 'buildTree'. | |
unsigned | getTreeSize () const |
unsigned | getCanonicalGraphSize () const |
Returns the base graph size, before any transformations. | |
void | optimizeGatherSequence () |
Perform LICM and CSE on the newly generated gather sequences. | |
std::optional< OrdersType > | findReusedOrderedScalars (const TreeEntry &TE, bool TopToBottom, bool IgnoreReorder) |
Checks if the specified gather tree entry TE can be represented as a shuffled vector entry + (possibly) permutation with other gathers. | |
std::optional< OrdersType > | findPartiallyOrderedLoads (const TreeEntry &TE) |
Sort loads into increasing pointers offsets to allow greater clustering. | |
std::optional< OrdersType > | getReorderingData (const TreeEntry &TE, bool TopToBottom, bool IgnoreReorder) |
Gets reordering data for the given tree entry. | |
bool | isProfitableToReorder () const |
Checks if it is profitable to reorder the current tree. | |
void | reorderTopToBottom () |
Reorders the current graph to the most profitable order starting from the root node to the leaf nodes. | |
void | reorderBottomToTop (bool IgnoreReorder=false) |
Reorders the current graph to the most profitable order starting from leaves to the root. | |
unsigned | getVectorElementSize (Value *V) |
void | computeMinimumValueSizes () |
Compute the minimum type sizes required to represent the entries in a vectorizable tree. | |
unsigned | getMaxVecRegSize () const |
unsigned | getMinVecRegSize () const |
unsigned | getMinVF (unsigned Sz) const |
unsigned | getMaximumVF (unsigned ElemWidth, unsigned Opcode) const |
unsigned | canMapToVector (Type *T) const |
Check if homogeneous aggregate is isomorphic to some VectorType. | |
bool | isTreeTinyAndNotFullyVectorizable (bool ForReduction=false) const |
bool | isTreeNotExtendable () const |
Checks if the graph and all its subgraphs cannot be better vectorized. | |
bool | isLoadCombineReductionCandidate (RecurKind RdxKind) const |
Assume that a legal-sized 'or'-reduction of shifted/zexted loaded values can be load combined in the backend. | |
bool | isLoadCombineCandidate (ArrayRef< Value * > Stores) const |
Assume that a vector of stores of bitwise-or/shifted/zexted loaded values can be load combined in the backend. | |
bool | isStridedLoad (ArrayRef< Value * > VL, ArrayRef< Value * > PointerOps, ArrayRef< unsigned > Order, const TargetTransformInfo &TTI, const DataLayout &DL, ScalarEvolution &SE, const bool IsAnyPointerUsedOutGraph, const int64_t Diff, StridedPtrInfo &SPtrInfo) const |
Checks if strided loads can be generated out of VL loads with pointers PointerOps: | |
LoadsState | canVectorizeLoads (ArrayRef< Value * > VL, const Value *VL0, SmallVectorImpl< unsigned > &Order, SmallVectorImpl< Value * > &PointerOps, StridedPtrInfo &SPtrInfo, unsigned *BestVF=nullptr, bool TryRecursiveCheck=true) const |
Checks if the given array of loads can be represented as a vectorized, scatter or just simple gather. | |
template<typename T> | |
void | registerNonVectorizableLoads (ArrayRef< T * > VL) |
Registers non-vectorizable sequence of loads. | |
template<typename T> | |
bool | areKnownNonVectorizableLoads (ArrayRef< T * > VL) const |
Checks if the given loads sequence is known as not vectorizable. | |
OptimizationRemarkEmitter * | getORE () |
std::optional< int > | findBestRootPair (ArrayRef< std::pair< Value *, Value * > > Candidates, int Limit=LookAheadHeuristics::ScoreFail) const |
Evaluate each pair in Candidates and return index into Candidates for a pair which have highest score deemed to have best chance to form root of profitable tree to vectorize. | |
bool | isDeleted (Instruction *I) const |
Checks if the instruction is marked for deletion. | |
void | eraseInstruction (Instruction *I) |
Removes an instruction from its block and eventually deletes it. | |
template<typename T> | |
void | removeInstructionsAndOperands (ArrayRef< T * > DeadVals, ArrayRef< std::tuple< Value *, unsigned, bool > > VectorValuesAndScales) |
Remove instructions from the parent function and clear the operands of DeadVals instructions, marking for deletion trivially dead operands. | |
bool | isAnalyzedReductionRoot (Instruction *I) const |
Checks if the instruction was already analyzed for being possible reduction root. | |
void | analyzedReductionRoot (Instruction *I) |
Register given instruction as already analyzed for being possible reduction root. | |
bool | areAnalyzedReductionVals (ArrayRef< Value * > VL) const |
Checks if the provided list of reduced values was checked already for vectorization. | |
void | analyzedReductionVals (ArrayRef< Value * > VL) |
Adds the list of reduced values to list of already checked values for the vectorization. | |
void | clearReductionData () |
Clear the list of the analyzed reduction root instructions. | |
bool | isAnyGathered (const SmallDenseSet< Value * > &Vals) const |
Checks if the given value is gathered in one of the nodes. | |
bool | isGathered (const Value *V) const |
Checks if the given value is gathered in one of the nodes. | |
bool | isNotScheduled (const Value *V) const |
Checks if the specified value was not schedule. | |
bool | isVectorized (const Value *V) const |
Check if the value is vectorized in the tree. | |
~BoUpSLP () |
Static Public Member Functions | |
static bool | isIdentityOrder (ArrayRef< unsigned > Order) |
Does this non-empty order represent an identity order? |
Friends | |
struct | DenseMapInfo< EdgeInfo > |
struct | GraphTraits< BoUpSLP * > |
struct | DOTGraphTraits< BoUpSLP * > |
raw_ostream & | operator<< (raw_ostream &OS, const BoUpSLP::ScheduleEntity &SE) |
raw_ostream & | operator<< (raw_ostream &OS, const BoUpSLP::ScheduleData &SD) |
raw_ostream & | operator<< (raw_ostream &OS, const BoUpSLP::ScheduleBundle &Bundle) |
raw_ostream & | operator<< (raw_ostream &OS, const BoUpSLP::ScheduleCopyableData &SD) |
Bottom Up SLP Vectorizer.
Definition at line 1920 of file SLPVectorizer.cpp.
Definition at line 1956 of file SLPVectorizer.cpp.
using llvm::slpvectorizer::BoUpSLP::InstrList = SmallVector<Instruction *, 16> |
Definition at line 1953 of file SLPVectorizer.cpp.
Definition at line 1957 of file SLPVectorizer.cpp.
using llvm::slpvectorizer::BoUpSLP::StoreList = SmallVector<StoreInst *, 8> |
Definition at line 1955 of file SLPVectorizer.cpp.
using llvm::slpvectorizer::BoUpSLP::ValueList = SmallVector<Value *, 8> |
Definition at line 1952 of file SLPVectorizer.cpp.
using llvm::slpvectorizer::BoUpSLP::ValueSet = SmallPtrSet<Value *, 16> |
Definition at line 1954 of file SLPVectorizer.cpp.
|
strong |
Tracks the state we can represent the loads in the given sequence.
Enumerator | |
---|---|
Gather | |
Vectorize | |
ScatterVectorize | |
StridedVectorize | |
CompressVectorize |
Definition at line 1944 of file SLPVectorizer.cpp.
|
inline |
Definition at line 1959 of file SLPVectorizer.cpp.
References llvm::CodeMetrics::collectEphemeralValues(), MaxVectorRegSizeOption, MinVectorRegSizeOption, and llvm::TargetTransformInfo::RGK_FixedWidthVector.
Referenced by llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::LookAheadHeuristics(), llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::ShuffleCostEstimator(), llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleInstructionBuilder(), and llvm::slpvectorizer::BoUpSLP::VLOperands::VLOperands().
BoUpSLP::~BoUpSLP | ( | ) |
Definition at line 6049 of file SLPVectorizer.cpp.
References assert(), llvm::dbgs(), llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), I, llvm::isa(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::verifyFunction(), and llvm::wouldInstructionBeTriviallyDead().
|
inline |
Register given instruction as already analyzed for being possible reduction root.
Definition at line 3562 of file SLPVectorizer.cpp.
References I.
Adds the list of reduced values to list of already checked values for the vectorization.
Definition at line 3572 of file SLPVectorizer.cpp.
References llvm::hash_value().
Checks if the provided list of reduced values was checked already for vectorization.
Definition at line 3567 of file SLPVectorizer.cpp.
References llvm::hash_value().
|
inline |
Checks if the given loads sequence is known as not vectorizable.
Definition at line 2267 of file SLPVectorizer.cpp.
References llvm::hash_value().
Referenced by canVectorizeLoads().
void BoUpSLP::buildExternalUses | ( | const ExtraValueToDebugLocsMap & | ExternallyUsedValues = {} | ) |
Builds external uses of the vectorized scalars, i.e.
the list of vectorized scalars to be extracted, their lanes and their scalar users. ExternallyUsedValues
contains additional list of external uses to handle vectorization of reductions.
Definition at line 8698 of file SLPVectorizer.cpp.
References llvm::all_of(), assert(), llvm::dbgs(), doesInTreeUserNeedToExtract(), llvm::dyn_cast(), llvm::ArrayRef< T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::find(), llvm::isa(), isDeleted(), LLVM_DEBUG, llvm::none_of(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace(), llvm::Value::users(), and UsesLimit.
Construct a vectorizable tree that starts at Roots
.
Definition at line 8954 of file SLPVectorizer.cpp.
References allSameType(), and deleteTree().
void BoUpSLP::buildTree | ( | ArrayRef< Value * > | Roots, |
const SmallDenseSet< Value * > & | UserIgnoreLst ) |
Construct a vectorizable tree that starts at Roots
, ignoring users for the purpose of scheduling and extraction in the UserIgnoreLst
.
Definition at line 8945 of file SLPVectorizer.cpp.
References allSameType(), and deleteTree().
Check if homogeneous aggregate is isomorphic to some VectorType.
Accepts homogeneous multidimensional aggregate of scalars/vectors like {[4 x i16], [4 x i16]}, { <2 x float>, <2 x float> }, {{{i16, i16}, {i16, i16}}, {{i16, i16}, {i16, i16}}} and so on.
Definition at line 11864 of file SLPVectorizer.cpp.
References llvm::cast(), llvm::dyn_cast(), getWidenedType(), llvm::isa(), llvm::Type::isEmptyTy(), isValidElementType(), N, and T.
BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads | ( | ArrayRef< Value * > | VL, |
const Value * | VL0, | ||
SmallVectorImpl< unsigned > & | Order, | ||
SmallVectorImpl< Value * > & | PointerOps, | ||
StridedPtrInfo & | SPtrInfo, | ||
unsigned * | BestVF = nullptr, | ||
bool | TryRecursiveCheck = true ) const |
Checks if the given array of loads can be represented as a vectorized, scatter or just simple gather.
VL | list of loads. |
VL0 | main load value. |
Order | returned order of load instructions. |
PointerOps | returned list of pointer operands. |
BestVF | return best vector factor, if recursive check found better vectorization sequences rather than masked gather. |
TryRecursiveCheck | used to check if long masked gather can be represented as a serie of loads/insert subvector, if profitable. |
Definition at line 6879 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), areKnownNonVectorizableLoads(), arePointersCompatible(), llvm::ArrayRef(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::ArrayRef< T >::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::CallingConv::C, calculateRtStride(), canVectorizeLoads(), llvm::cast(), llvm::SmallVectorImpl< T >::clear(), llvm::APInt::clearAllBits(), CompressVectorize, computeCommonAlignment(), CostKind, llvm::count_if(), llvm::doesNotNeedToBeScheduled(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::ArrayRef< T >::end(), llvm::enumerate(), llvm::SmallVectorTemplateCommon< T, typename >::front(), Gather, GEP, llvm::APInt::getAllOnes(), getFloorFullVectorNumberOfElements(), getGEPCosts(), getMinVF(), llvm::APInt::getOneBitSet(), getParent(), llvm::getPointerOperand(), llvm::getPointersDiff(), getScalarizationOverhead(), getShuffleCost(), llvm::Value::getType(), llvm::getUnderlyingObject(), getWidenedType(), llvm::hasFullVectorsOrPowerOf2(), I, llvm::isa(), llvm::APInt::isAllOnes(), llvm::IsaPred, isMaskedLoadCompress(), isReverseOrder(), isStridedLoad(), llvm::APInt::isZero(), MinProfitableStridedLoads, P, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::resize(), ScatterVectorize, llvm::seq(), llvm::APInt::setAllBits(), llvm::APInt::setBits(), llvm::ArrayRef< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::TargetTransformInfo::SK_Broadcast, llvm::TargetTransformInfo::SK_InsertSubvector, llvm::TargetTransformInfo::SK_PermuteSingleSrc, llvm::ArrayRef< T >::slice(), SLPCostThreshold, llvm::sortPtrAccesses(), StridedVectorize, llvm::TargetTransformInfo::TCK_RecipThroughput, and Vectorize.
Referenced by canVectorizeLoads(), and getReorderingData().
|
inline |
Clear the list of the analyzed reduction root instructions.
Definition at line 3576 of file SLPVectorizer.cpp.
void BoUpSLP::computeMinimumValueSizes | ( | ) |
Compute the minimum type sizes required to represent the entries in a vectorizable tree.
Definition at line 22182 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), assert(), llvm::bit_ceil(), llvm::SmallVectorImpl< T >::clear(), llvm::ComputeNumSignBits(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::dyn_cast(), llvm::IntegerType::get(), llvm::getNumberOfParts(), getNumElements(), getOpcode(), llvm::Type::getScalarType(), llvm::Value::getType(), getWidenedType(), I, llvm::isa(), llvm::isGather(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
inline |
Clear the internal data structures that are created by 'buildTree'.
Definition at line 2074 of file SLPVectorizer.cpp.
Referenced by buildTree(), and buildTree().
|
inline |
Removes an instruction from its block and eventually deletes it.
It's like Instruction::eraseFromParent() except that the actual deletion is delayed until BoUpSLP is destructed.
Definition at line 3465 of file SLPVectorizer.cpp.
References I.
Referenced by optimizeGatherSequence(), removeInstructionsAndOperands(), and vectorizeTree().
|
inline |
Evaluate each pair in Candidates
and return index into Candidates
for a pair which have highest score deemed to have best chance to form root of profitable tree to vectorize.
Return std::nullopt if no candidate scored above the LookAheadHeuristics::ScoreFail.
Limit | Lower limit of the cost, considered to be good enough score. |
Definition at line 3440 of file SLPVectorizer.cpp.
References llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getScoreAtLevelRec(), I, RootLookAheadMaxDepth, llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::ScoreFail, and llvm::seq().
Referenced by transformNodes().
std::optional< BoUpSLP::OrdersType > BoUpSLP::findPartiallyOrderedLoads | ( | const TreeEntry & | TE | ) |
Sort loads into increasing pointers offsets to allow greater clustering.
Definition at line 7306 of file SLPVectorizer.cpp.
References assert(), clusterSortPtrAccesses(), llvm::dyn_cast(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorImpl< T >::reserve().
Referenced by getReorderingData().
std::optional< BoUpSLP::OrdersType > BoUpSLP::findReusedOrderedScalars | ( | const TreeEntry & | TE, |
bool | TopToBottom, | ||
bool | IgnoreReorder ) |
Checks if the specified gather tree entry TE
can be represented as a shuffled vector entry + (possibly) permutation with other gathers.
It implements the checks only for possibly ordered scalars (Loads, ExtractElement, ExtractValue), which can be part of the graph.
TopToBottom | If true, used for the whole tree rotation, false - for sub-tree rotations. |
IgnoreReorder | true, if the order of the root node might be ignored. |
Definition at line 6149 of file SLPVectorizer.cpp.
References llvm::SmallBitVector::all(), llvm::all_of(), llvm::SmallBitVector::any(), llvm::any_of(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::cast(), llvm::count(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::enumerate(), llvm::fill(), llvm::find(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::getNumberOfParts(), getNumElems(), getPartNumElems(), getWidenedType(), I, llvm::isa(), isConstant(), isValidElementType(), P, llvm::PoisonMaskElem, llvm::seq(), llvm::SmallBitVector::set(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::TargetTransformInfo::SK_PermuteSingleSrc, and llvm::SmallBitVector::test().
Referenced by getReorderingData().
|
inline |
Returns the base graph size, before any transformations.
Definition at line 2107 of file SLPVectorizer.cpp.
Referenced by isTreeNotExtendable().
|
inline |
Definition at line 2196 of file SLPVectorizer.cpp.
References MaxVFOption.
|
inline |
Definition at line 2183 of file SLPVectorizer.cpp.
|
inline |
Definition at line 2188 of file SLPVectorizer.cpp.
Referenced by getMinVF().
Definition at line 2192 of file SLPVectorizer.cpp.
References getMinVecRegSize().
Referenced by canVectorizeLoads().
|
inline |
Definition at line 2271 of file SLPVectorizer.cpp.
|
inline |
Returns reduction type after minbitdth analysis.
Definition at line 2047 of file SLPVectorizer.cpp.
References llvm::IntegerType::get(), and getWidenedType().
std::optional< BoUpSLP::OrdersType > BoUpSLP::getReorderingData | ( | const TreeEntry & | TE, |
bool | TopToBottom, | ||
bool | IgnoreReorder ) |
Gets reordering data for the given tree entry.
If the entry is vectorized
TopToBottom | If true, include the order of vectorized stores and insertelement nodes, otherwise skip them. |
IgnoreReorder | true, if the root node order can be ignored. |
Definition at line 7388 of file SLPVectorizer.cpp.
References addMask(), llvm::all_of(), allConstant(), allSameType(), llvm::any_of(), llvm::ArrayRef(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), canVectorizeLoads(), llvm::cast(), llvm::Instruction::comesBefore(), CompressVectorize, llvm::count_if(), llvm::Data, llvm::divideCeil(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::enumerate(), llvm::find(), llvm::find_if_not(), findPartiallyOrderedLoads(), findReusedOrderedScalars(), fixupOrderingIndices(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::PoisonValue::get(), getElementIndex(), getExtractIndex(), llvm::getNumberOfParts(), llvm::Value::getNumUses(), getParent(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), getShuffleCost(), getWidenedType(), I, II, llvm::inversePermutation(), llvm::isa(), isAlternateInstruction(), llvm::IsaPred, llvm::Instruction::isBinaryOp(), isConstant(), isIdentityOrder(), llvm::ShuffleVectorInst::isOneUseSingleSourceMask(), isReverseOrder(), isSplat(), llvm::PoisonMaskElem, reorderOrder(), llvm::seq(), llvm::SmallBitVector::set(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::TargetTransformInfo::SK_PermuteSingleSrc, llvm::stable_sort(), StridedVectorize, llvm::TargetTransformInfo::TCK_RecipThroughput, llvm::SmallBitVector::test(), llvm::transform(), llvm::Value::use_empty(), llvm::Value::user_begin(), Vectorize, VectorizeNonPowerOf2, and llvm::zip().
Referenced by reorderBottomToTop(), and reorderTopToBottom().
Return the scalars of the root node.
Definition at line 2016 of file SLPVectorizer.cpp.
References assert().
|
inline |
Returns the type/is-signed info for the root node in the graph without casting.
Definition at line 2023 of file SLPVectorizer.cpp.
References llvm::cast(), llvm::SmallVectorTemplateCommon< T, typename >::front(), and llvm::IntegerType::get().
InstructionCost BoUpSLP::getSpillCost | ( | ) |
Definition at line 15517 of file SLPVectorizer.cpp.
References allConstant(), llvm::SmallVectorImpl< T >::append(), assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::at(), BlockSize, llvm::cast(), Cleanup, llvm::Instruction::comesBefore(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::contains(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::First, llvm::IntegerType::get(), llvm::IntrinsicCostAttributes::getArgTypes(), llvm::Type::getContext(), llvm::BasicBlock::getFirstNonPHIOrDbgOrAlloca(), llvm::BasicBlock::getParent(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), getWidenedType(), I, II, llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), isVectorized(), llvm::Type::isVectorTy(), llvm::Last, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::make_scope_exit(), Operands, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::pred_begin(), llvm::pred_end(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), ScheduleRegionSizeBudget, llvm::BasicBlock::size(), llvm::TargetTransformInfo::TCK_RecipThroughput, and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().
Referenced by getTreeCost().
InstructionCost BoUpSLP::getTreeCost | ( | ArrayRef< Value * > | VectorizedVals = {}, |
InstructionCost | ReductionCost = TTI::TCC_Free ) |
VL
. A negative number means that this is profitable. Definition at line 15910 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), areTwoInsertFromSameBuildVector(), assert(), llvm::sampleprof::Base, llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::CallingConv::C, llvm::cast(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), CostKind, llvm::count_if(), llvm::Data, llvm::dbgs(), llvm::dump(), llvm::dyn_cast(), llvm::dyn_cast_if_present(), llvm::dyn_cast_or_null(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::ArrayRef< T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::enumerate(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::find_if(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::IntegerType::get(), llvm::Type::getContext(), getElementIndex(), getExtractWithExtendCost(), llvm::User::getOperand(), llvm::Type::getScalarType(), getShuffleCost(), getSpillCost(), llvm::InsertElementInst::getType(), getVectorInstrCost(), getWidenedType(), llvm::APInt::getZero(), llvm::has_single_bit(), I, II, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), llvm::isa(), llvm::isa_and_nonnull(), llvm::isa_and_present(), isFirstInsertElement(), llvm::ShuffleVectorInst::isIdentityMask(), llvm::isKnownNonNegative(), isVectorized(), LLVM_DEBUG, llvm::MutableArrayRef(), llvm::TargetTransformInfo::None, llvm::none_of(), P, performExtractsShuffleAction(), llvm::PoisonMaskElem, llvm::SmallVectorTemplateBase< T, bool >::push_back(), shortBundleName(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::TargetTransformInfo::SK_PermuteSingleSrc, llvm::TargetTransformInfo::SK_PermuteTwoSrc, SLPCostThreshold, SLPReVec, llvm::TargetTransformInfo::TCC_Basic, llvm::TargetTransformInfo::TCC_Free, llvm::TargetTransformInfo::TCK_RecipThroughput, UsesLimit, llvm::Vector, llvm::ViewGraph(), and ViewSLPTree.
|
inline |
Definition at line 2104 of file SLPVectorizer.cpp.
Referenced by isTreeNotExtendable().
V
. If V is a store, the size is the width of the stored value. Otherwise, the size is the width of the largest loaded value reaching V. This method is used by the vectorizer to calculate vectorization factors. Definition at line 21681 of file SLPVectorizer.cpp.
References llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::Type::getInt1Ty(), llvm::Value::getType(), getVectorElementSize(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::SmallVectorImpl< T >::pop_back_val(), and RecursionMaxDepth.
Referenced by getVectorElementSize().
|
inline |
Checks if the instruction was already analyzed for being possible reduction root.
Definition at line 3557 of file SLPVectorizer.cpp.
References I.
|
inline |
Checks if the given value is gathered in one of the nodes.
Definition at line 3582 of file SLPVectorizer.cpp.
References llvm::any_of(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains().
|
inline |
Checks if the instruction is marked for deletion.
Definition at line 3460 of file SLPVectorizer.cpp.
References I.
Referenced by buildExternalUses(), and optimizeGatherSequence().
Checks if the given value is gathered in one of the nodes.
Definition at line 3586 of file SLPVectorizer.cpp.
Does this non-empty order represent an identity order?
Identity should be represented as an empty order, so this is used to decide if we can canonicalize a computed order. Undef elements (represented as size) are ignored.
Definition at line 2116 of file SLPVectorizer.cpp.
References llvm::all_of(), assert(), llvm::ArrayRef< T >::empty(), llvm::enumerate(), P, and llvm::ArrayRef< T >::size().
Referenced by getReorderingData(), reorderBottomToTop(), and reorderTopToBottom().
Assume that a vector of stores of bitwise-or/shifted/zexted loaded values can be load combined in the backend.
Load combining may not be allowed in the IR optimizer, so we do not want to alter the pattern. For example, partially transforming a scalar bswap() pattern into vector code is effectively impossible for the backend to undo. TODO: If load combining is allowed in the IR optimizer, this analysis may not be necessary.
Definition at line 15294 of file SLPVectorizer.cpp.
References isLoadCombineCandidateImpl(), llvm::PatternMatch::m_Store(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::ArrayRef< T >::size(), and X.
Assume that a legal-sized 'or'-reduction of shifted/zexted loaded values can be load combined in the backend.
Load combining may not be allowed in the IR optimizer, so we do not want to alter the pattern. For example, partially transforming a scalar bswap() pattern into vector code is effectively impossible for the backend to undo. TODO: If load combining is allowed in the IR optimizer, this analysis may not be necessary.
Definition at line 15284 of file SLPVectorizer.cpp.
References isLoadCombineCandidateImpl(), and llvm::Or.
Checks if the specified value was not schedule.
Definition at line 3590 of file SLPVectorizer.cpp.
bool BoUpSLP::isProfitableToReorder | ( | ) | const |
Checks if it is profitable to reorder the current tree.
If the tree does not contain many profitable reordable nodes, better to skip it to save compile time.
Definition at line 7810 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), llvm::ArrayRef(), llvm::count_if(), DisableTreeReorder, llvm::IsaPred, llvm::Instruction::isBinaryOp(), isCommutative(), and llvm::none_of().
|
inline |
Checks if the root graph node can be emitted with narrower bitwidth at codegen and returns it signedness, if so.
Definition at line 2042 of file SLPVectorizer.cpp.
bool BoUpSLP::isStridedLoad | ( | ArrayRef< Value * > | VL, |
ArrayRef< Value * > | PointerOps, | ||
ArrayRef< unsigned > | Order, | ||
const TargetTransformInfo & | TTI, | ||
const DataLayout & | DL, | ||
ScalarEvolution & | SE, | ||
const bool | IsAnyPointerUsedOutGraph, | ||
const int64_t | Diff, | ||
StridedPtrInfo & | SPtrInfo ) const |
Checks if strided loads can be generated out of VL
loads with pointers PointerOps:
Definition at line 6821 of file SLPVectorizer.cpp.
References llvm::ArrayRef< T >::back(), llvm::cast(), llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::front(), llvm::getPointersDiff(), llvm::Value::getType(), getWidenedType(), llvm::has_single_bit(), llvm::SmallSet< T, N, C >::insert(), MaxProfitableLoadStride, MinProfitableStridedLoads, Ptr, llvm::ArrayRef< T >::size(), and llvm::SmallSet< T, N, C >::size().
Referenced by canVectorizeLoads().
bool BoUpSLP::isTreeNotExtendable | ( | ) | const |
Checks if the graph and all its subgraphs cannot be better vectorized.
It may happen, if all gather nodes are loads and they cannot be "clusterized". In this case even subgraphs cannot be vectorized more effectively than the base graph.
Definition at line 15483 of file SLPVectorizer.cpp.
References llvm::all_of(), allConstant(), allSameBlock(), llvm::ArrayRef(), llvm::count_if(), getCanonicalGraphSize(), getSameOpcode(), getTreeSize(), llvm::isa(), llvm::IsaPred, isSplat(), and llvm::seq().
Definition at line 15307 of file SLPVectorizer.cpp.
References llvm::all_of(), allConstant(), allSameBlock(), llvm::any_of(), llvm::ArrayRef(), assert(), llvm::count_if(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::APInt::getAllOnes(), getWidenedType(), llvm::isa(), llvm::IsaPred, isSplat(), MinTreeSize, llvm::none_of(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::DebugCounter::shouldExecute(), llvm::SmallVectorTemplateCommon< T, typename >::size(), SLPCostThreshold, and llvm::TargetTransformInfo::TCK_RecipThroughput.
Check if the value is vectorized in the tree.
Definition at line 3595 of file SLPVectorizer.cpp.
References assert().
Referenced by getSpillCost(), getTreeCost(), and vectorizeTree().
void BoUpSLP::optimizeGatherSequence | ( | ) |
Perform LICM and CSE on the newly generated gather sequences.
Definition at line 20621 of file SLPVectorizer.cpp.
References A(), llvm::any_of(), assert(), llvm::SmallVectorImpl< T >::assign(), B(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallPtrSetImplBase::clear(), llvm::dbgs(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), eraseInstruction(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::getNumberOfParts(), llvm::BasicBlock::getTerminator(), getWidenedType(), I, llvm::is_contained(), llvm::isa(), isDeleted(), LLVM_DEBUG, llvm::make_early_inc_range(), N, llvm::PoisonMaskElem, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::ArrayRef< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::sort().
|
inline |
Registers non-vectorizable sequence of loads.
Definition at line 2261 of file SLPVectorizer.cpp.
References llvm::hash_value().
|
inline |
Remove instructions from the parent function and clear the operands of DeadVals
instructions, marking for deletion trivially dead operands.
Definition at line 3472 of file SLPVectorizer.cpp.
References llvm::all_of(), assert(), llvm::cast(), llvm::cast_or_null(), llvm::dyn_cast(), llvm::dyn_cast_if_present(), llvm::ArrayRef< T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), eraseInstruction(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::isInstructionTriviallyDead(), llvm::none_of(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::salvageDebugInfo(), T, llvm::Value::use_empty(), and llvm::wouldInstructionBeTriviallyDead().
void BoUpSLP::reorderBottomToTop | ( | bool | IgnoreReorder = false | ) |
Reorders the current graph to the most profitable order starting from leaves to the root.
It allows to rotate small subgraphs and reduce the number of reshuffles if the leaf nodes use the same order. In this case we can merge the orders and just shuffle user node instead of shuffling its operands. Plus, even the leaf nodes have different orders, it allows to sink reordering in the graph closer to the root node and merge it later during analysis.
Definition at line 8280 of file SLPVectorizer.cpp.
References AbstractManglingParser< Derived, Alloc >::NumOps, AbstractManglingParser< Derived, Alloc >::Ops, llvm::all_of(), llvm::any_of(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallPtrSetImplBase::clear(), combineOrders(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::count_if(), llvm::Data, llvm::dyn_cast(), llvm::ArrayRef< T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallPtrSetImpl< PtrType >::erase(), llvm::find_if_not(), fixupOrderingIndices(), Gather, getReorderingData(), llvm::getVectorIntrinsicIDForCall(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::SetVector< T, Vector, Set, N >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert_range(), llvm::inversePermutation(), llvm::isa(), isConstant(), isIdentityOrder(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::make_second_range(), llvm::Intrinsic::not_intrinsic, P, llvm::PoisonMaskElem, llvm::SmallVectorTemplateBase< T, bool >::push_back(), reorderOrder(), reorderReuses(), llvm::reorderScalars(), llvm::seq(), llvm::ArrayRef< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SetVector< T, Vector, Set, N >::takeVector(), llvm::transform(), and Users.
void BoUpSLP::reorderTopToBottom | ( | ) |
Reorders the current graph to the most profitable order starting from the root node to the leaf nodes.
The best order is chosen only from the nodes of the same size (vectorization factor). Smaller nodes are considered parts of subgraph with smaller VF and they are reordered independently. We can make it because we still need to extend smaller nodes to the wider VF and we can merge reordering shuffles with the widening shuffles.
Definition at line 7938 of file SLPVectorizer.cpp.
References addMask(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), Cleanup, combineOrders(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::ArrayRef< T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), fixupOrderingIndices(), llvm::for_each(), getAltInstrMask(), getOpcode(), getReorderingData(), getWidenedType(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::inversePermutation(), llvm::isa(), isIdentityOrder(), llvm::make_scope_exit(), llvm::PoisonMaskElem, RecursionMaxDepth, reorderOrder(), llvm::reorderScalars(), llvm::ArrayRef< T >::size(), SLPReVec, llvm::transform(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().
void BoUpSLP::transformNodes | ( | ) |
Transforms graph nodes to target specific representations, if profitable.
Definition at line 12780 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), CostKind, llvm::count_if(), llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::ArrayRef< T >::empty(), findBestRootPair(), I, llvm::is_contained(), llvm::isa(), P, llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::ScoreSplatLoads, llvm::seq(), and llvm::TargetTransformInfo::TCK_RecipThroughput.
Value * BoUpSLP::vectorizeTree | ( | ) |
Vectorize the tree that starts with the elements in VL
.
Returns the vectorized root.
Definition at line 19948 of file SLPVectorizer.cpp.
References vectorizeTree().
Referenced by vectorizeTree(), and vectorizeTree().
Value * BoUpSLP::vectorizeTree | ( | const ExtraValueToDebugLocsMap & | ExternallyUsedValues, |
Instruction * | ReductionRoot = nullptr, | ||
ArrayRef< std::tuple< Value *, unsigned, bool > > | VectorValuesAndScales = {} ) |
Vectorize the tree but with the list of externally used values ExternallyUsedValues
.
Values in this MapVector can be replaced but the generated extractvalue instructions.
Definition at line 19953 of file SLPVectorizer.cpp.
References llvm::all_of(), llvm::any_of(), areTwoInsertFromSameBuildVector(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::cast(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), createExtractVector(), llvm::Data, llvm::dbgs(), llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::ArrayRef< T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), eraseInstruction(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::find_if(), llvm::get(), getElementIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::InsertElementInst::getType(), llvm::Value::getType(), getWidenedType(), I, II, llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::is_contained(), llvm::isa(), llvm::Type::isIntOrIntVectorTy(), llvm::isKnownNonNegative(), isVectorized(), IV, LLVM_DEBUG, llvm::mayHaveNonDefUseDependency(), llvm::Instruction::moveAfter(), PHI, llvm::PoisonMaskElem, llvm::User::replaceUsesOfWith(), llvm::seq(), llvm::SmallVectorTemplateCommon< T, typename >::size(), SLPReVec, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace(), llvm::User::User(), llvm::Value::users(), and vectorizeTree().
|
friend |
Definition at line 2271 of file SLPVectorizer.cpp.
|
friend |
Definition at line 5137 of file SLPVectorizer.cpp.
|
friend |
Definition at line 5137 of file SLPVectorizer.cpp.
|
friend |
Definition at line 5014 of file SLPVectorizer.cpp.
|
friend |
Definition at line 5137 of file SLPVectorizer.cpp.
|
friend |
Definition at line 4907 of file SLPVectorizer.cpp.
|
friend |
Definition at line 4746 of file SLPVectorizer.cpp.