LLVM 20.0.0git |
#include "llvm/Transforms/Vectorize/SLPVectorizer.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PriorityQueue.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/DemandedBits.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/IVDescriptors.h"
#include "llvm/Analysis/LoopAccessAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugCounter.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/InstructionCost.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/InjectTLIMappings.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <tuple>
#include <utility>
Go to the source code of this file.
Classes | |
class | llvm::slpvectorizer::BoUpSLP |
Bottom Up SLP Vectorizer.More... | |
struct | llvm::slpvectorizer::BoUpSLP::EdgeInfo |
This structure holds any data we need about the edges being traversed during buildTree_rec().More... | |
class | llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics |
A helper class used for scoring candidates for two consecutive lanes.More... | |
class | llvm::slpvectorizer::BoUpSLP::VLOperands |
A helper data structure to hold the operands of a vector of instructions.More... | |
struct | llvm::GraphTraits< BoUpSLP * > |
struct | llvm::GraphTraits< BoUpSLP * >::ChildIteratorType |
Add the VectorizableTree to the index iterator to be able to return TreeEntry pointers.More... | |
class | llvm::GraphTraits< BoUpSLP * >::nodes_iterator |
For the node iterator we just need to turn the TreeEntry iterator into a TreeEntry* iterator so that it dereferences to NodeRef.More... | |
struct | llvm::DOTGraphTraits< BoUpSLP * > |
class | llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator |
Merges shuffle masks and emits final shuffle instruction, if required.More... | |
class | llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder |
Merges shuffle masks and emits final shuffle instruction, if required.More... | |
Namespaces | |
namespace | llvm |
This is an optimization pass for GlobalISel generic memory operations. | |
namespace | llvm::slpvectorizer |
A private "module" namespace for types and utilities used by this pass. | |
Macros | |
#define | SV_NAME "slp-vectorizer" |
#define | DEBUG_TYPE "SLP" |
Functions | |
STATISTIC (NumVectorInstructions, "Number ofvectorinstructions generated") | |
DEBUG_COUNTER (VectorizedGraphs, "slp-vectorized", "Controls which SLP graphs should be vectorized.") | |
staticbool | isValidElementType (Type *Ty) |
Predicate for the element types that the SLP vectorizer supports. | |
staticType * | getValueType (Value *V) |
Returns the type of the given value/instructionV . | |
staticunsigned | getNumElements (Type *Ty) |
staticFixedVectorType * | getWidenedType (Type *ScalarTy,unsigned VF) |
staticunsigned | getFullVectorNumberOfElements (constTargetTransformInfo &TTI,Type *Ty,unsigned Sz) |
Returns the number of elements of the given typeTy , not less thanSz , which forms type, which splits byTTI into whole vector types during legalization. | |
staticunsigned | getFloorFullVectorNumberOfElements (constTargetTransformInfo &TTI,Type *Ty,unsigned Sz) |
Returns the number of elements of the given typeTy , not greater thanSz , which forms type, which splits byTTI into whole vector types during legalization. | |
static void | transformScalarShuffleIndiciesToVector (unsigned VecTyNumElements,SmallVectorImpl< int > &Mask) |
staticunsigned | getShufflevectorNumGroups (ArrayRef<Value * > VL) |
staticSmallVector< int > | calculateShufflevectorMask (ArrayRef<Value * > VL) |
staticbool | isConstant (Value *V) |
staticbool | isVectorLikeInstWithConstOps (Value *V) |
Checks ifV is one of vector-like instructions, i.e. | |
staticunsigned | getPartNumElems (unsignedSize,unsigned NumParts) |
Returns power-of-2 number of elements in a single register (part), given the total number of elementsSize and number of registers (parts)NumParts . | |
staticunsigned | getNumElems (unsignedSize,unsigned PartNumElems,unsigned Part) |
Returns correct remaining number of elements, considering total amountSize , (power-of-2 number) of elements in a single registerPartNumElems and current register (part)Part . | |
static std::string | shortBundleName (ArrayRef<Value * > VL, intIdx=-1) |
Print a short descriptor of the instruction bundle suitable for debug output. | |
staticbool | allSameBlock (ArrayRef<Value * > VL) |
staticbool | allConstant (ArrayRef<Value * > VL) |
staticbool | isSplat (ArrayRef<Value * > VL) |
staticbool | isCommutative (Instruction *I) |
template<typenameT > | |
static std::optional<unsigned > | getInsertExtractIndex (constValue *Inst,unsignedOffset) |
static std::optional<unsigned > | getElementIndex (constValue *Inst,unsignedOffset=0) |
staticSmallBitVector | buildUseMask (int VF,ArrayRef< int > Mask, UseMask MaskArg) |
Prepares a use bitset for the given mask either for the first argument or for the second. | |
template<bool IsPoisonOnly = false> | |
staticSmallBitVector | isUndefVector (constValue *V,constSmallBitVector &UseMask={}) |
Checks if the given value is actually an undefined constant vector. | |
static std::optional<TargetTransformInfo::ShuffleKind > | isFixedVectorShuffle (ArrayRef<Value * > VL,SmallVectorImpl< int > &Mask,AssumptionCache *AC) |
Checks if the vector of instructions can be represented as a shuffle, like: x0 = extractelement <4 x i8> x, i32 0 x3 = extractelement <4 x i8> x, i32 3 y1 = extractelement <4 x i8> y, i32 1 y2 = extractelement <4 x i8> y, i32 2 x0x0 = mul i8 x0, x0 x3x3 = mul i8 x3, x3 y1y1 = mul i8 y1, y1 y2y2 = mul i8 y2, y2 ins1 = insertelement <4 x i8> poison, i8 x0x0, i32 0 ins2 = insertelement <4 x i8> ins1, i8 x3x3, i32 1 ins3 = insertelement <4 x i8> ins2, i8 y1y1, i32 2 ins4 = insertelement <4 x i8> ins3, i8 y2y2, i32 3 ret <4 x i8> ins4 can be transformed into: %1 = shufflevector <4 x i8> x, <4 x i8> y, <4 x i32> <i32 0, i32 3, i32 5, i32 6> %2 = mul <4 x i8> %1, %1 ret <4 x i8> %2 Mask will return the Shuffle Mask equivalent to the extracted elements. | |
static std::optional<unsigned > | getExtractIndex (Instruction *E) |
staticbool | isValidForAlternation (unsigned Opcode) |
static InstructionsState | getSameOpcode (ArrayRef<Value * > VL,constTargetLibraryInfo &TLI) |
staticbool | areCompatibleCmpOps (Value *BaseOp0,Value *BaseOp1,Value *Op0,Value *Op1,constTargetLibraryInfo &TLI) |
Checks if the provided operands of 2 cmp instructions are compatible, i.e. | |
staticbool | isCmpSameOrSwapped (constCmpInst *BaseCI,constCmpInst *CI,constTargetLibraryInfo &TLI) |
staticbool | allSameType (ArrayRef<Value * > VL) |
staticbool | doesInTreeUserNeedToExtract (Value *Scalar,Instruction *UserInst,TargetLibraryInfo *TLI,constTargetTransformInfo *TTI) |
staticMemoryLocation | getLocation (Instruction *I) |
staticbool | isSimple (Instruction *I) |
static void | addMask (SmallVectorImpl< int > &Mask,ArrayRef< int > SubMask,bool ExtendingManyInputs=false) |
ShufflesMask in accordance with the givenSubMask . | |
static void | fixupOrderingIndices (MutableArrayRef<unsigned > Order) |
Order may have elements assigned special value (size) which is out of bounds. | |
staticSmallBitVector | getAltInstrMask (ArrayRef<Value * > VL,unsigned Opcode0,unsigned Opcode1) |
static void | llvm::inversePermutation (ArrayRef<unsigned > Indices,SmallVectorImpl< int > &Mask) |
static void | llvm::reorderScalars (SmallVectorImpl<Value * > &Scalars,ArrayRef< int > Mask) |
Reorders the list of scalars in accordance with the givenMask . | |
staticbool | llvm::areAllOperandsNonInsts (Value *V) |
Checks if the provided value does not require scheduling. | |
staticbool | llvm::isUsedOutsideBlock (Value *V) |
Checks if the provided value does not require scheduling. | |
staticbool | llvm::doesNotNeedToBeScheduled (Value *V) |
Checks if the specified value does not require scheduling. | |
staticbool | llvm::doesNotNeedToSchedule (ArrayRef<Value * > VL) |
Checks if the specified array of instructions does not require scheduling. | |
staticbool | llvm::hasFullVectorsOrPowerOf2 (constTargetTransformInfo &TTI,Type *Ty,unsigned Sz) |
Returns true if widened type ofTy elements with sizeSz represents full vector type, i.e. | |
staticunsigned | llvm::getNumberOfParts (constTargetTransformInfo &TTI,VectorType *VecTy,constunsigned Limit=std::numeric_limits<unsigned >::max()) |
Returns number of parts, the typeVecTy will be split at the codegen phase. | |
static void | reorderReuses (SmallVectorImpl< int > &Reuses,ArrayRef< int > Mask) |
Reorders the givenReuses mask according to the givenMask . | |
static void | reorderOrder (SmallVectorImpl<unsigned > &Order,ArrayRef< int > Mask,bool BottomOrder=false) |
Reorders the givenOrder according to the givenMask . | |
staticbool | arePointersCompatible (Value *Ptr1,Value *Ptr2,constTargetLibraryInfo &TLI,bool CompareOpcodes=true) |
template<typenameT > | |
staticAlign | computeCommonAlignment (ArrayRef<Value * > VL) |
Calculates minimal alignment as a common alignment. | |
staticbool | isReverseOrder (ArrayRef<unsigned > Order) |
Check ifOrder represents reverse order. | |
static std::optional<Value * > | calculateRtStride (ArrayRef<Value * > PointerOps,Type *ElemTy,constDataLayout &DL,ScalarEvolution &SE,SmallVectorImpl<unsigned > &SortedIndices,Instruction *Inst=nullptr) |
Checks if the provided list of pointersPointers represents the strided pointers for type ElemTy. | |
static std::pair<InstructionCost,InstructionCost > | getGEPCosts (constTargetTransformInfo &TTI,ArrayRef<Value * > Ptrs,Value *BasePtr,unsigned Opcode,TTI::TargetCostKindCostKind,Type *ScalarTy,VectorType *VecTy) |
Calculate the scalar and the vector costs from vectorizing set of GEPs. | |
staticInstructionCost | getShuffleCost (constTargetTransformInfo &TTI,TTI::ShuffleKind Kind,VectorType *Tp,ArrayRef< int > Mask={},TTI::TargetCostKindCostKind=TTI::TCK_RecipThroughput, intIndex=0,VectorType *SubTp=nullptr,ArrayRef<constValue * > Args={}) |
Returns the cost of the shuffle instructions with the givenKind , vector typeTp and optionalMask . | |
staticValue * | createInsertVector (IRBuilderBase &Builder,Value *Vec,Value *V,unsignedIndex,function_ref<Value *(Value *,Value *,ArrayRef< int >)> Generator={}) |
Correctly creates insert_subvector, checking that the index is multiple of the subvectors length. | |
staticValue * | createExtractVector (IRBuilderBase &Builder,Value *Vec,unsigned SubVecVF,unsignedIndex) |
Correctly creates extract_subvector, checking that the index is multiple of the subvectors length. | |
staticbool | clusterSortPtrAccesses (ArrayRef<Value * > VL,ArrayRef<BasicBlock * > BBs,Type *ElemTy,constDataLayout &DL,ScalarEvolution &SE,SmallVectorImpl<unsigned > &SortedIndices) |
staticbool | areTwoInsertFromSameBuildVector (InsertElementInst *VU,InsertElementInst *V,function_ref<Value *(InsertElementInst *)> GetBaseOperand) |
Check if two insertelement instructions are from the same buildvector. | |
staticbool | isRepeatedNonIdentityClusteredMask (ArrayRef< int > Mask,unsigned Sz) |
Checks if the given mask is a "clustered" mask with the same clusters of sizeSz , which are not identity submasks. | |
static void | combineOrders (MutableArrayRef<unsigned > Order,ArrayRef<unsigned > SecondaryOrder) |
staticLLVM_DUMP_METHOD void | dumpOrder (constBoUpSLP::OrdersType &Order) |
static void | gatherPossiblyVectorizableLoads (constBoUpSLP &R,ArrayRef<Value * > VL,constDataLayout &DL,ScalarEvolution &SE,constTargetTransformInfo &TTI,SmallVectorImpl<SmallVector< std::pair<LoadInst *, int > > > &GatheredLoads,bool AddNew=true) |
Tries to find subvector of loads and builds new vector of only loads if can be profitable. | |
staticbool | needToScheduleSingleInstruction (ArrayRef<Value * > VL) |
static std::pair< size_t, size_t > | generateKeySubkey (Value *V,constTargetLibraryInfo *TLI,function_ref<hash_code(size_t,LoadInst *)> LoadsSubkeyGenerator,bool AllowAlternate) |
Generates key/subkey pair for the given value to provide effective sorting of the values and better detection of the vectorizable values sequences. | |
staticbool | isAlternateInstruction (constInstruction *I,constInstruction *MainOp,constInstruction *AltOp,constTargetLibraryInfo &TLI) |
Checks if the specified instructionI is an alternate operation for the givenMainOp andAltOp instructions. | |
static std::pair<InstructionCost,InstructionCost > | getVectorCallCosts (CallInst *CI,FixedVectorType *VecTy,TargetTransformInfo *TTI,TargetLibraryInfo *TLI,ArrayRef<Type * > ArgTys) |
staticSmallVector<Type * > | buildIntrinsicArgTypes (constCallInst *CI,constIntrinsic::IDID,constunsigned VF,unsigned MinBW,constTargetTransformInfo *TTI) |
Builds the arguments types vector for the given call instruction with the givenID for the specified vector factor. | |
staticbool | isLoadCombineCandidateImpl (Value *Root,unsigned NumElts,TargetTransformInfo *TTI,bool MustMatchOrInst) |
staticbool | isFirstInsertElement (constInsertElementInst *IE1,constInsertElementInst *IE2) |
Checks if theIE1 instructions is followed byIE2 instruction in the buildvector sequence. | |
template<typenameT > | |
staticT * | performExtractsShuffleAction (MutableArrayRef< std::pair<T *,SmallVector< int > > > ShuffleMask,Value *Base,function_ref<unsigned(T *)> GetVF,function_ref< std::pair<T *,bool >(T *,ArrayRef< int >,bool)> ResizeAction,function_ref<T *(ArrayRef< int >,ArrayRef<T * >)> Action) |
Does the analysis of the provided shuffle masks and performs the requested actions on the vectors with the given shuffle masks. | |
staticInstruction * | propagateMetadata (Instruction *Inst,ArrayRef<Value * > VL) |
staticRecurKind | getRdxKind (Value *V) |
Gets recurrence kind from the specified value. | |
staticbool | checkTreeSizes (ArrayRef< std::pair<unsigned,unsigned > > Sizes,bool First) |
Checks if the quadratic mean deviation is less than 90% of the mean size. | |
static std::optional<unsigned > | getAggregateSize (Instruction *InsertInst) |
static void | findBuildAggregate_rec (Instruction *LastInsertInst,TargetTransformInfo *TTI,SmallVectorImpl<Value * > &BuildVectorOpds,SmallVectorImpl<Value * > &InsertElts,unsigned OperandOffset,constBoUpSLP &R) |
staticbool | findBuildAggregate (Instruction *LastInsertInst,TargetTransformInfo *TTI,SmallVectorImpl<Value * > &BuildVectorOpds,SmallVectorImpl<Value * > &InsertElts,constBoUpSLP &R) |
Recognize construction of vectors like ra = insertelement <4 x float> poison, float s0, i32 0 rb = insertelement <4 x float> ra, float s1, i32 1 rc = insertelement <4 x float> rb, float s2, i32 2 rd = insertelement <4 x float> rc, float s3, i32 3 starting from the last insertelement or insertvalue instruction. | |
staticInstruction * | getReductionInstr (constDominatorTree *DT,PHINode *P,BasicBlock *ParentBB,LoopInfo *LI) |
Try and get a reduction instruction from a phi node. | |
staticbool | matchRdxBop (Instruction *I,Value *&V0,Value *&V1) |
staticInstruction * | tryGetSecondaryReductionRoot (PHINode *Phi,Instruction *Root) |
We could have an initial reduction that is not an add. | |
staticInstruction * | getNonPhiOperand (Instruction *I,PHINode *Phi) |
Returns the first operand ofI that does not matchPhi . | |
staticbool | isReductionCandidate (Instruction *I) |
\Returns true ifI is a candidate instruction for reduction vectorization. | |
template<typenameT > | |
staticbool | tryToVectorizeSequence (SmallVectorImpl<T * > &Incoming,function_ref<bool(T *,T *)> Comparator,function_ref<bool(T *,T *)> AreCompatible,function_ref<bool(ArrayRef<T * >,bool)> TryToVectorizeHelper,bool MaxVFOnly,BoUpSLP &R) |
template<bool IsCompatibility> | |
staticbool | compareCmp (Value *V,Value *V2,TargetLibraryInfo &TLI,constDominatorTree &DT) |
Compare two cmp instructions. | |
Variables | |
staticcl::opt<bool > | RunSLPVectorization ("vectorize-slp", cl::init(true), cl::Hidden,cl::desc("Run the SLP vectorization passes")) |
staticcl::opt<bool > | SLPReVec ("slp-revec", cl::init(false), cl::Hidden,cl::desc("Enable vectorizationfor widervector utilization")) |
staticcl::opt< int > | SLPCostThreshold ("slp-threshold", cl::init(0), cl::Hidden,cl::desc("Only vectorizeif you gain more than this " "number ")) |
staticcl::opt<bool > | SLPSkipEarlyProfitabilityCheck ("slp-skip-early-profitability-check", cl::init(false), cl::Hidden,cl::desc("Whentrue, SLP vectorizer bypasses profitabilitychecks based on " "heuristics and makes vectorization decision via cost modeling.")) |
staticcl::opt<bool > | ShouldVectorizeHor ("slp-vectorize-hor", cl::init(true), cl::Hidden,cl::desc("Attempt to vectorize horizontal reductions")) |
staticcl::opt<bool > | ShouldStartVectorizeHorAtStore ("slp-vectorize-hor-store", cl::init(false), cl::Hidden,cl::desc("Attempt to vectorize horizontalreductions feeding into a store")) |
staticcl::opt< int > | MaxVectorRegSizeOption ("slp-max-reg-size", cl::init(128), cl::Hidden,cl::desc("Attempt to vectorizefor this register size in bits")) |
staticcl::opt<unsigned > | MaxVFOption ("slp-max-vf", cl::init(0), cl::Hidden,cl::desc("Maximum SLP vectorization factor (0=unlimited)")) |
staticcl::opt< int > | ScheduleRegionSizeBudget ("slp-schedule-budget", cl::init(100000), cl::Hidden,cl::desc("Limit the size of the SLP schedulingregion per block")) |
Limits the size of scheduling regions in a block. | |
staticcl::opt< int > | MinVectorRegSizeOption ("slp-min-reg-size", cl::init(128), cl::Hidden,cl::desc("Attempt to vectorizefor this register size in bits")) |
staticcl::opt<unsigned > | RecursionMaxDepth ("slp-recursion-max-depth", cl::init(12), cl::Hidden,cl::desc("Limit therecursion depth when building a vectorizable tree")) |
staticcl::opt<unsigned > | MinTreeSize ("slp-min-tree-size", cl::init(3), cl::Hidden,cl::desc("Only vectorize small treesif they are fully vectorizable")) |
staticcl::opt< int > | LookAheadMaxDepth ("slp-max-look-ahead-depth", cl::init(2), cl::Hidden,cl::desc("The maximum look-ahead depthfor operand reordering scores")) |
staticcl::opt< int > | RootLookAheadMaxDepth ("slp-max-root-look-ahead-depth", cl::init(2), cl::Hidden,cl::desc("The maximum look-ahead depthfor searching best rooting option")) |
staticcl::opt<unsigned > | MinProfitableStridedLoads ("slp-min-strided-loads", cl::init(2), cl::Hidden,cl::desc("The minimum number ofloads, which should be considered strided, " "if the stride is > 1 or is runtime value")) |
staticcl::opt<unsigned > | MaxProfitableLoadStride ("slp-max-stride", cl::init(8), cl::Hidden,cl::desc("The maximum stride, considered to be profitable.")) |
staticcl::opt<bool > | ViewSLPTree ("view-slp-tree", cl::Hidden,cl::desc("Display the SLP trees with Graphviz")) |
staticcl::opt<bool > | VectorizeNonPowerOf2 ("slp-vectorize-non-power-of-2", cl::init(false), cl::Hidden,cl::desc("Try to vectorize with non-power-of-2 number of elements.")) |
staticconstunsigned | AliasedCheckLimit = 10 |
static constexpr int | UsesLimit = 64 |
staticconstunsigned | MaxMemDepDistance = 160 |
staticconst int | MinScheduleRegionSize = 16 |
If the ScheduleRegionSizeBudget is exhausted, we allow small scheduling regions to be handled. | |
staticconstunsigned | MaxPHINumOperands = 128 |
Maximum allowed number of operands in the PHI nodes. | |
#define DEBUG_TYPE "SLP" |
Definition at line110 of fileSLPVectorizer.cpp.
#define SV_NAME "slp-vectorizer" |
Definition at line109 of fileSLPVectorizer.cpp.
| static |
ShufflesMask
in accordance with the givenSubMask
.
ExtendingManyInputs | Supports reshuffling of the mask with not only one but two input vectors. |
Definition at line1151 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::ArrayRef< T >::begin(),llvm::ArrayRef< T >::empty(),llvm::ArrayRef< T >::end(),I,llvm::PoisonMaskElem, andllvm::ArrayRef< T >::size().
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData(), andllvm::slpvectorizer::BoUpSLP::reorderTopToBottom().
VL
are constants (but not globals/constant expressions).Definition at line485 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(), andisConstant().
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData(),llvm::slpvectorizer::BoUpSLP::isTreeNotExtendable(),llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
VL
are in the same block or false otherwise.Definition at line461 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),llvm::ArrayRef< T >::end(),llvm::find_if(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),II, andisVectorLikeInstWithConstOps().
Referenced byllvm::slpvectorizer::BoUpSLP::isTreeNotExtendable(),llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
VL
have the same type or false otherwise.Definition at line1093 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),llvm::ArrayRef< T >::drop_front(), andllvm::ArrayRef< T >::front().
Referenced byllvm::slpvectorizer::BoUpSLP::buildTree(), andllvm::slpvectorizer::BoUpSLP::getReorderingData().
| static |
Checks if the provided operands of 2 cmp instructions are compatible, i.e.
compatible instructions or constants, or just some other regular values.
Definition at line873 of fileSLPVectorizer.cpp.
ReferencesgetSameOpcode(), andisConstant().
Referenced byisCmpSameOrSwapped().
| static |
Definition at line4790 of fileSLPVectorizer.cpp.
ReferencesgetSameOpcode(),llvm::getUnderlyingObject(),isConstant(), andRecursionMaxDepth.
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads().
| static |
Check if two insertelement instructions are from the same buildvector.
Definition at line5500 of fileSLPVectorizer.cpp.
ReferencesgetElementIndex(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),llvm::InsertElementInst::getType(),llvm::Value::hasOneUse(),llvm::SmallBitVector::set(), andllvm::SmallBitVector::test().
Referenced byllvm::slpvectorizer::BoUpSLP::getTreeCost(), andllvm::slpvectorizer::BoUpSLP::vectorizeTree().
| static |
Builds the arguments types vector for the given call instruction with the givenID
for the specified vector factor.
Definition at line11077 of fileSLPVectorizer.cpp.
Referencesllvm::CallBase::args(),llvm::enumerate(),llvm::IntegerType::get(),llvm::Value::getContext(),getWidenedType(),Idx,llvm::isVectorIntrinsicWithScalarOpAtArg(),llvm::Intrinsic::not_intrinsic, andllvm::SmallVectorTemplateBase< T, bool >::push_back().
| static |
Prepares a use bitset for the given mask either for the first argument or for the second.
Definition at line616 of fileSLPVectorizer.cpp.
Referencesllvm::enumerate(),Idx, andllvm::PoisonMaskElem.
Referenced byperformExtractsShuffleAction().
| static |
Checks if the provided list of pointersPointers
represents the strided pointers for type ElemTy.
If they are not, std::nullopt is returned. Otherwise, ifInst
is not specified, just initialized optional value is returned to show that the pointers represent strided pointers. IfInst
specified, the runtime stride is materialized before the givenInst
.
Definition at line4834 of fileSLPVectorizer.cpp.
Referencesllvm::SmallVectorImpl< T >::clear(),DL,llvm::SCEVExpander::expandCodeFor(),llvm::ScalarEvolution::getAddExpr(),llvm::ScalarEvolution::getConstant(),llvm::ScalarEvolution::getMinusSCEV(),llvm::ScalarEvolution::getMulExpr(),llvm::ScalarEvolution::getSCEV(),llvm::SCEV::getType(),llvm::ScalarEvolution::getUDivExactExpr(),llvm::SCEV::isNonConstantNegative(),llvm::SCEV::isZero(),Ptr,llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::SmallVectorImpl< T >::resize(),llvm::ArrayRef< T >::size(),llvm::SmallVectorBase< Size_T >::size(), andSize.
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads().
| static |
Definition at line391 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::ArrayRef< T >::front(),getShufflevectorNumGroups(), andllvm::PoisonMaskElem.
Checks if the quadratic mean deviation is less than 90% of the mean size.
Definition at line18678 of fileSLPVectorizer.cpp.
| static |
Definition at line5369 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),llvm::any_of(),assert(),llvm::sampleprof::Base,llvm::SmallVectorImpl< T >::clear(),llvm::SmallPtrSetImpl< PtrType >::contains(),llvm::Depth,llvm::ArrayRef< T >::drop_front(),llvm::enumerate(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::find(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::front(),llvm::ArrayRef< T >::front(),llvm::getUnderlyingObject(),llvm::SmallPtrSetImpl< PtrType >::insert(),llvm::isPointerTy(),P,Ptr,llvm::SmallVectorTemplateBase< T, bool >::push_back(),RecursionMaxDepth,llvm::ArrayRef< T >::size(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::size(),llvm::SmallVectorBase< Size_T >::size(),llvm::stable_sort(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::try_emplace(),X, andY.
Referenced byllvm::slpvectorizer::BoUpSLP::findPartiallyOrderedLoads().
| static |
Definition at line5916 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::ArrayRef< T >::empty(),Idx,llvm::SmallBitVector::set(),llvm::ArrayRef< T >::size(), andllvm::SmallBitVector::test().
Referenced byllvm::slpvectorizer::BoUpSLP::reorderBottomToTop(), andllvm::slpvectorizer::BoUpSLP::reorderTopToBottom().
| static |
Compare two cmp instructions.
If IsCompatibility is true, function returns true if 2 cmps have same/swapped predicates and mos compatible corresponding operands. If IsCompatibility is false, function implements strict weak ordering relation between two cmp instructions, returning true if the first instruction is "less" than the second, i.e. its predicate is less than the predicate of the second or the operands IDs are less than the operands IDs of the second cmp instruction.
Definition at line21313 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::DomTreeNodeBase< NodeT >::getDFSNumIn(),llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(),llvm::User::getOperand(),getSameOpcode(),llvm::Type::getScalarSizeInBits(),llvm::CmpInst::getSwappedPredicate(),llvm::Value::getType(),llvm::Type::getTypeID(),llvm::Value::getValueID(),I, andisValidElementType().
Calculates minimal alignment as a common alignment.
Definition at line4809 of fileSLPVectorizer.cpp.
Referencesllvm::ArrayRef< T >::drop_front(),llvm::ArrayRef< T >::front(), andllvm::getAlign().
| static |
Correctly creates extract_subvector, checking that the index is multiple of the subvectors length.
Otherwise, generates shuffle usingGenerator
or using default shuffle.
Definition at line5010 of fileSLPVectorizer.cpp.
Referencesllvm::IRBuilderBase::CreateExtractVector(),llvm::IRBuilderBase::CreateShuffleVector(),llvm::IRBuilderBase::getInt64(),llvm::Type::getScalarType(),llvm::Value::getType(),getWidenedType(),Index, andllvm::PoisonMaskElem.
Referenced byllvm::slpvectorizer::BoUpSLP::vectorizeTree().
| static |
Correctly creates insert_subvector, checking that the index is multiple of the subvectors length.
Otherwise, generates shuffle usingGenerator
or using default shuffle.
Definition at line4979 of fileSLPVectorizer.cpp.
DEBUG_COUNTER | ( | VectorizedGraphs | , |
"slp-vectorized" | , | ||
"Controls which SLP graphs should be vectorized." | |||
) |
| static |
Definition at line1100 of fileSLPVectorizer.cpp.
Referencesllvm::any_of(),llvm::CallBase::args(),llvm::enumerate(),llvm::Instruction::getOpcode(),llvm::LoadInst::getPointerOperand(), andllvm::getVectorIntrinsicIDForCall().
Referenced byllvm::slpvectorizer::BoUpSLP::buildExternalUses().
| static |
Definition at line6734 of fileSLPVectorizer.cpp.
Referencesllvm::dbgs(), andIdx.
| static |
Recognize construction of vectors like ra = insertelement <4 x float> poison, float s0, i32 0 rb = insertelement <4 x float> ra, float s1, i32 1 rc = insertelement <4 x float> rb, float s2, i32 2 rd = insertelement <4 x float> rc, float s3, i32 3 starting from the last insertelement or insertvalue instruction.
Also recognize homogeneous aggregates like {<2 x float>, <2 x float>}, {{float, float}, {float, float}}, [2 x {float, float}] and so on. See llvm/test/Transforms/SLPVectorizer/X86/pr42022.ll for examples.
Assume LastInsertInst is of InsertElementInst or InsertValueInst type.
Definition at line20889 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::SmallVectorBase< Size_T >::empty(),llvm::erase(),findBuildAggregate_rec(),getAggregateSize(),llvm::SmallVectorImpl< T >::resize(), andllvm::SmallVectorBase< Size_T >::size().
| static |
Definition at line20850 of fileSLPVectorizer.cpp.
ReferencesfindBuildAggregate_rec(),getElementIndex(),llvm::User::getOperand(), andllvm::Value::hasOneUse().
Referenced byfindBuildAggregate(), andfindBuildAggregate_rec().
| static |
Order may have elements assigned special value (size) which is out of bounds.
Such indices only appear on places which correspond to undef values (see canReuseExtract for details) and used in order to avoid undef values have effect on operands ordering. The first loop below simply finds all unused indices and then the next loop nest assigns these indices for undef values positions. As an example below Order has two undef positions and they have assigned values 3 and 7 respectively: before: 6 9 5 4 9 2 1 0 after: 6 3 5 4 7 2 1 0
Definition at line1186 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::SmallBitVector::count(),llvm::SmallBitVector::find_first(),llvm::SmallBitVector::find_next(),I,Idx,llvm::SmallBitVector::none(),llvm::SmallBitVector::reset(),llvm::SmallBitVector::set(), andllvm::ArrayRef< T >::size().
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData(),llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(),reorderOrder(), andllvm::slpvectorizer::BoUpSLP::reorderTopToBottom().
| static |
Tries to find subvector of loads and builds new vector of only loads if can be profitable.
Definition at line6789 of fileSLPVectorizer.cpp.
Referencesllvm::any_of(),assert(),llvm::ArrayRef< T >::begin(),llvm::bit_ceil(),llvm::SetVector< T, Vector, Set, N >::contains(),llvm::SmallSet< T, N, C >::contains(),llvm::SmallPtrSetImpl< PtrType >::contains(),llvm::Data,DL,llvm::SmallVectorImpl< T >::emplace_back(),llvm::ArrayRef< T >::empty(),llvm::SetVector< T, Vector, Set, N >::empty(),llvm::ArrayRef< T >::end(),llvm::enumerate(),llvm::find_if(),llvm::ArrayRef< T >::front(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),llvm::LoadInst::getPointerOperand(),llvm::getPointersDiff(),llvm::Value::getType(),llvm::getUnderlyingObject(),getValueType(),llvm::has_single_bit(),Idx,llvm::SmallSet< T, N, C >::insert(),llvm::SetVector< T, Vector, Set, N >::insert(),llvm::SmallPtrSetImpl< PtrType >::insert(),isValidElementType(),llvm::Offset,P,RecursionMaxDepth,llvm::ArrayRef< T >::size(), andllvm::zip().
Referenced byllvm::slpvectorizer::BoUpSLP::transformNodes().
| static |
Generates key/subkey pair for the given value to provide effective sorting of the values and better detection of the vectorizable values sequences.
The keys/subkeys can be used for better sorting of the values themselves (keys) and in values subgroups (subkeys).
Definition at line7417 of fileSLPVectorizer.cpp.
Referencesllvm::SmallBitVector::all(),generateKeySubkey(),llvm::CmpInst::getInversePredicate(),llvm::VFDatabase::getMappings(),llvm::CmpInst::getSwappedPredicate(),llvm::getVectorIntrinsicIDForCall(),llvm::hash_combine(),llvm::hash_value(),I,llvm::Instruction::isIntDivRem(),llvm::isTriviallyVectorizable(),isUndefVector(),isValidForAlternation(), andisVectorLikeInstWithConstOps().
Referenced bygenerateKeySubkey().
| static |
Definition at line20822 of fileSLPVectorizer.cpp.
Referencesllvm::Type::isSingleValueType(), andIV.
Referenced byfindBuildAggregate().
| static |
Definition at line1212 of fileSLPVectorizer.cpp.
ReferencesgetNumElements(),getOpcode(),llvm::SmallBitVector::set(), andllvm::ArrayRef< T >::size().
Referenced byllvm::slpvectorizer::BoUpSLP::reorderTopToBottom().
Definition at line568 of fileSLPVectorizer.cpp.
ReferencesI,IV, andllvm::Offset.
| static |
Definition at line794 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::Instruction::getOpcode(), andllvm::User::getOperand().
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData().
| static |
Returns the number of elements of the given typeTy
, not greater thanSz
, which forms type, which splits byTTI
into whole vector types during legalization.
Definition at line286 of fileSLPVectorizer.cpp.
Referencesllvm::bit_ceil(),llvm::bit_floor(),llvm::divideCeil(),llvm::TargetTransformInfo::getNumberOfParts(),getWidenedType(), andisValidElementType().
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
| static |
Returns the number of elements of the given typeTy
, not less thanSz
, which forms type, which splits byTTI
into whole vector types during legalization.
Definition at line271 of fileSLPVectorizer.cpp.
Referencesllvm::bit_ceil(),llvm::divideCeil(),llvm::TargetTransformInfo::getNumberOfParts(),getWidenedType(), andisValidElementType().
| static |
Calculate the scalar and the vector costs from vectorizing set of GEPs.
Definition at line9521 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),CostKind,llvm::ArrayRef< T >::end(),llvm::find_if(),llvm::TargetTransformInfo::getGEPCost(),llvm::TargetTransformInfo::getPointersChainCost(),Ptr,llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::SmallVectorBase< Size_T >::size(), andllvm::TargetTransformInfo::TCC_Free.
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads().
| static |
Definition at line543 of fileSLPVectorizer.cpp.
Referencesllvm::Offset.
| static |
Definition at line1129 of fileSLPVectorizer.cpp.
Referencesllvm::MemoryLocation::get(), andI.
| static |
Returns
the first operand ofI
that does not matchPhi
.
If operand is not an instruction it returns nullptr.
Definition at line21013 of fileSLPVectorizer.cpp.
ReferencesI, andmatchRdxBop().
Definition at line254 of fileSLPVectorizer.cpp.
Referencesassert().
Referenced byllvm::MachineIRBuilder::buildSplatBuildVector(),cacheDIVar(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes(),containsUndefinedElement(),CreateGCRelocates(),expandAbs(),expandCrossIntrinsic(),expandExpIntrinsic(),expandLogIntrinsic(),extractVector(),getAltInstrMask(),llvm::getNumberOfParts(),llvm::X86TTIImpl::getScalarizationOverhead(),llvm::BasicTTIImplBase< T >::getTypeBasedIntrinsicInstrCost(),llvm::SystemZTTIImpl::getVectorTruncCost(),getWidenedType(),insertVector(),llvm::X86TTIImpl::isLegalMaskedExpandLoad(),llvm::X86TTIImpl::isLegalMaskedLoad(),llvm::ShuffleVectorInst::isValidOperands(),isVectorPromotionViableForSlice(),isZero(),llvm::RewriteStatepointsForGC::runOnFunction(),llvm::InstCombinerImpl::SimplifyDemandedVectorElts(),simplifyX86pack(), andupgradeX86IntrinsicCall().
Returns correct remaining number of elements, considering total amountSize
, (power-of-2 number) of elements in a single registerPartNumElems
and current register (part)Part
.
Definition at line442 of fileSLPVectorizer.cpp.
ReferencesSize.
Referenced byllvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars().
Returns power-of-2 number of elements in a single register (part), given the total number of elementsSize
and number of registers (parts)NumParts
.
Definition at line435 of fileSLPVectorizer.cpp.
Referencesllvm::bit_ceil(),llvm::divideCeil(), andSize.
Referenced byllvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), andllvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars().
Gets recurrence kind from the specified value.
Definition at line20819 of fileSLPVectorizer.cpp.
Referenced byllvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes().
| static |
Try and get a reduction instruction from a phi node.
Given a phi nodeP
in a blockParentBB
, consider possible reductions if they come from eitherParentBB
or a containing loop latch.
Definition at line20925 of fileSLPVectorizer.cpp.
Referencesllvm::DominatorTree::dominates(),llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(),llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), andP.
| static |
VL
described in InstructionsState, the Opcode that we suppose the whole list could be vectorized even if its structure is diverse.Definition at line909 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),assert(),llvm::CmpInst::BAD_ICMP_PREDICATE,llvm::SetVector< T, Vector, Set, N >::contains(),llvm::SmallVectorBase< Size_T >::empty(),llvm::ArrayRef< T >::end(),llvm::find_if(),llvm::SmallVectorTemplateCommon< T, typename >::front(),llvm::CallBase::getBundleOperandsStartIndex(),llvm::CallBase::getCalledFunction(),llvm::VFDatabase::getMappings(),llvm::Instruction::getOpcode(),llvm::User::getOperand(),llvm::CmpInst::getSwappedPredicate(),llvm::Value::getType(),llvm::getVectorIntrinsicIDForCall(),llvm::CallBase::hasOperandBundles(),I,llvm::SetVector< T, Vector, Set, N >::insert(),isCmpSameOrSwapped(),llvm::isTriviallyVectorizable(),isValidForAlternation(),isVectorLikeInstWithConstOps(),llvm::User::op_begin(),llvm::ArrayRef< T >::size(),llvm::SetVector< T, Vector, Set, N >::size(), andllvm::SmallVectorBase< Size_T >::size().
Referenced byareCompatibleCmpOps(),arePointersCompatible(),compareCmp(),llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(),llvm::slpvectorizer::BoUpSLP::VLOperands::reorder(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
| static |
Returns the cost of the shuffle instructions with the givenKind
, vector typeTp
and optionalMask
.
Adds SLP-specifc cost estimation for insert subvector pattern.
Definition at line4955 of fileSLPVectorizer.cpp.
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),llvm::slpvectorizer::BoUpSLP::getReorderingData(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
Definition at line339 of fileSLPVectorizer.cpp.
Referencesllvm::SmallBitVector::all(),llvm::all_of(),assert(),llvm::ArrayRef< T >::empty(),llvm::ArrayRef< T >::front(),I,llvm::SmallBitVector::set(),llvm::ArrayRef< T >::size(), andllvm::ArrayRef< T >::slice().
Referenced bycalculateShufflevectorMask().
Returns the type of the given value/instructionV
.
If it is store, returns the type of its value operand, for Cmp - the types of the compare operands and for insertelement - the type os the inserted operand. Otherwise, just the type of the value is returned.
Definition at line243 of fileSLPVectorizer.cpp.
Referenced byCollectOpsToWiden(),combineArithReduction(),combineConcatVectorOps(),combineMulToPMULDQ(),combineTargetShuffle(),combineToHorizontalAddSub(),CompactSwizzlableVector(),detectPMADDUBSW(),FoldBUILD_VECTOR(),foldCONCAT_VECTORS(),gatherPossiblyVectorizableLoads(),llvm::Function::getFunctionType(),llvm::RISCVTTIImpl::getIntImmCostInst(),getTestBitOperand(),LLVMGlobalGetValueType(),matchPMADDWD(),matchPMADDWD_2(),narrowVectorSelect(),performCONCAT_VECTORSCombine(), andllvm::SelectionDAGISel::SelectInlineAsmMemoryOperands().
| static |
Definition at line9039 of fileSLPVectorizer.cpp.
Referencesllvm::VFShape::get(),llvm::TargetTransformInfo::getCallInstrCost(),llvm::ElementCount::getFixed(),llvm::CallBase::getFunctionType(),llvm::TargetTransformInfo::getIntrinsicInstrCost(),llvm::FixedVectorType::getNumElements(),llvm::getVectorIntrinsicIDForCall(),llvm::VFDatabase::getVectorizedFunction(),llvm::CallBase::isNoBuiltin(), andllvm::TargetTransformInfo::TCK_RecipThroughput.
| static |
Definition at line263 of fileSLPVectorizer.cpp.
Referencesllvm::FixedVectorType::get(),getNumElements(), andllvm::Type::getScalarType().
Referenced byllvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(),buildIntrinsicArgTypes(),llvm::slpvectorizer::BoUpSLP::canMapToVector(),llvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes(),createExtractVector(),llvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars(),getFloorFullVectorNumberOfElements(),getFullVectorNumberOfElements(),llvm::slpvectorizer::BoUpSLP::getReductionType(),llvm::slpvectorizer::BoUpSLP::getReorderingData(),llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(),llvm::slpvectorizer::BoUpSLP::getSpillCost(),llvm::slpvectorizer::BoUpSLP::getTreeCost(),llvm::hasFullVectorsOrPowerOf2(),llvm::slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable(),llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::needToDelay(),llvm::slpvectorizer::BoUpSLP::optimizeGatherSequence(),llvm::slpvectorizer::BoUpSLP::reorderTopToBottom(),llvm::slpvectorizer::BoUpSLP::transformNodes(), andllvm::slpvectorizer::BoUpSLP::vectorizeTree().
| static |
Checks if the specified instructionI
is an alternate operation for the givenMainOp
andAltOp
instructions.
Definition at line9101 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::Instruction::getOpcode(),llvm::CmpInst::getSwappedPredicate(),I,isCmpSameOrSwapped(), andP.
| static |
CI
has similar "look" and same predicate asBaseCI
, "as is" or with its operands and predicate swapped, false otherwise.Definition at line887 of fileSLPVectorizer.cpp.
ReferencesareCompatibleCmpOps(),assert(),llvm::User::getOperand(),llvm::CmpInst::getPredicate(),llvm::CmpInst::getSwappedPredicate(), andllvm::Value::getType().
Referenced bygetSameOpcode(), andisAlternateInstruction().
| static |
I
is commutative, handles CmpInst and BinaryOperator.Definition at line509 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),I, andUsesLimit.
Referenced byllvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getScoreAtLevelRec(), andllvm::FastISel::selectBinaryOp().
Definition at line410 of fileSLPVectorizer.cpp.
Referenced byallConstant(),areCompatibleCmpOps(), andisVectorLikeInstWithConstOps().
| static |
Checks if theIE1
instructions is followed byIE2
instruction in the buildvector sequence.
Definition at line12300 of fileSLPVectorizer.cpp.
ReferencesgetElementIndex(),llvm::Value::hasOneUse(), andllvm_unreachable.
Referenced byllvm::slpvectorizer::BoUpSLP::getTreeCost(), andllvm::slpvectorizer::BoUpSLP::vectorizeTree().
| static |
Checks if the vector of instructions can be represented as a shuffle, like: x0 = extractelement <4 x i8> x, i32 0 x3 = extractelement <4 x i8> x, i32 3 y1 = extractelement <4 x i8> y, i32 1 y2 = extractelement <4 x i8> y, i32 2 x0x0 = mul i8 x0, x0 x3x3 = mul i8 x3, x3 y1y1 = mul i8 y1, y1 y2y2 = mul i8 y2, y2 ins1 = insertelement <4 x i8> poison, i8 x0x0, i32 0 ins2 = insertelement <4 x i8> ins1, i8 x3x3, i32 1 ins3 = insertelement <4 x i8> ins2, i8 y1y1, i32 2 ins4 = insertelement <4 x i8> ins3, i8 y2y2, i32 3 ret <4 x i8> ins4 can be transformed into: %1 = shufflevector <4 x i8> x, <4 x i8> y, <4 x i32> <i32 0, i32 3, i32 5, i32 6> %2 = mul <4 x i8> %1, %1 ret <4 x i8> %2 Mask will return the Shuffle Mask equivalent to the extracted elements.
TODO: Can we split off and reuse the shuffle mask detection from ShuffleVectorInst/getShuffleCost?
Definition at line706 of fileSLPVectorizer.cpp.
Referencesllvm::any_of(),llvm::ArrayRef< T >::begin(),llvm::ArrayRef< T >::end(),llvm::find_if(),I,Idx,llvm::isGuaranteedNotToBePoison(),isUndefVector(),llvm::PoisonMaskElem,Select,llvm::ArrayRef< T >::size(),Size,llvm::TargetTransformInfo::SK_PermuteSingleSrc,llvm::TargetTransformInfo::SK_PermuteTwoSrc,llvm::TargetTransformInfo::SK_Select, andUnknown.
| static |
Definition at line12012 of fileSLPVectorizer.cpp.
Referencesllvm::dbgs(),llvm::IntegerType::get(),llvm::Value::getContext(),llvm::Type::getIntegerBitWidth(),llvm::TargetTransformInfo::isTypeLegal(),LLVM_DEBUG,llvm::PatternMatch::m_APInt(),llvm::PatternMatch::m_Or(),llvm::PatternMatch::m_Shl(),llvm::PatternMatch::m_Value(),llvm::PatternMatch::m_ZExt(),llvm::PatternMatch::match(), andllvm::APInt::urem().
Referenced byllvm::slpvectorizer::BoUpSLP::isLoadCombineCandidate(), andllvm::slpvectorizer::BoUpSLP::isLoadCombineReductionCandidate().
| static |
\Returns true ifI
is a candidate instruction for reduction vectorization.
Definition at line21022 of fileSLPVectorizer.cpp.
ReferencesI,IsSelect(),llvm::PatternMatch::m_Select(),llvm::PatternMatch::m_Value(),llvm::PatternMatch::match(), andmatchRdxBop().
Checks if the given mask is a "clustered" mask with the same clusters of sizeSz
, which are not identity submasks.
Definition at line5876 of fileSLPVectorizer.cpp.
ReferencesE,I, andllvm::ShuffleVectorInst::isIdentityMask().
Check ifOrder
represents reverse order.
Definition at line4817 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),assert(),llvm::ArrayRef< T >::empty(),llvm::enumerate(), andllvm::ArrayRef< T >::size().
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads(),llvm::slpvectorizer::BoUpSLP::getReorderingData(), andllvm::slpvectorizer::BoUpSLP::transformNodes().
| static |
Definition at line1138 of fileSLPVectorizer.cpp.
Referenced byllvm::DOTGraphTraits< DOTFuncInfo * >::getNodeLabel(),llvm::DOTGraphTraits< MachineBlockFrequencyInfo * >::getNodeLabel(),llvm::DOTGraphTraits< const MachineFunction * >::getNodeLabel(),llvm::DOTGraphTraits< DOTMachineFuncInfo * >::getNodeLabel(),llvm::DOTGraphTraits< DomTreeNode * >::getNodeLabel(),llvm::DOTGraphTraits< RegionNode * >::getNodeLabel(),llvm::X86TargetLowering::shouldReduceLoadWidth(),tryToFoldExtOfMaskedLoad(),llvm::MBFIWrapper::view(), andllvm::MachineBlockFrequencyInfo::view().
VL
are identical or some of them are UndefValue.Definition at line493 of fileSLPVectorizer.cpp.
| static |
Checks if the given value is actually an undefined constant vector.
Also, if theUseMask
is not empty, tries to check if the non-masked elements actually mask the insertelement buildvector, if any.
Definition at line637 of fileSLPVectorizer.cpp.
Referenced bygenerateKeySubkey(),llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(),isFixedVectorShuffle(), andperformExtractsShuffleAction().
Predicate for the element types that the SLP vectorizer supports.
The most important thing to filter here are types which are invalid in LLVM vectors. We also filter target specific types which have absolutely no meaningful vectorization path such as x86_fp80 and ppc_f128. This just avoids spending time checking the cost model and realizing that they will be inevitably scalarized.
Definition at line231 of fileSLPVectorizer.cpp.
Referencesllvm::Type::getScalarType(),llvm::Type::isPPC_FP128Ty(),llvm::Type::isX86_FP80Ty(), andSLPReVec.
Referenced byllvm::slpvectorizer::BoUpSLP::canMapToVector(),compareCmp(),llvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars(),gatherPossiblyVectorizableLoads(),getFloorFullVectorNumberOfElements(),getFullVectorNumberOfElements(),llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(), andllvm::hasFullVectorsOrPowerOf2().
Opcode
is allowed as part of the main/alternate instruction for SLP vectorization.Example of unsupported opcode is SDIV that can potentially cause UB if the "shuffled out" lane would result in division by zero.
Definition at line861 of fileSLPVectorizer.cpp.
Referencesllvm::Instruction::isIntDivRem().
Referenced bygenerateKeySubkey(), andgetSameOpcode().
Checks ifV
is one of vector-like instructions, i.e.
undef, insertelement/extractelement with constant indices for fixed vector type or extractvalue instruction.
Definition at line417 of fileSLPVectorizer.cpp.
Referencesassert(),I, andisConstant().
Referenced byallSameBlock(),generateKeySubkey(), andgetSameOpcode().
| static |
Definition at line20969 of fileSLPVectorizer.cpp.
ReferencesI,llvm::PatternMatch::m_BinOp(),llvm::PatternMatch::m_Value(), andllvm::PatternMatch::match().
Referenced bygetNonPhiOperand(), andisReductionCandidate().
Definition at line7398 of fileSLPVectorizer.cpp.
Referencesllvm::doesNotNeedToBeScheduled().
| static |
Does the analysis of the provided shuffle masks and performs the requested actions on the vectors with the given shuffle masks.
It tries to do it in several steps.
Definition at line12355 of fileSLPVectorizer.cpp.
Referencesllvm::SmallBitVector::all(),assert(),llvm::sampleprof::Base,buildUseMask(),I,Idx,isUndefVector(),llvm::PoisonMaskElem, andllvm::SmallBitVector::test().
| static |
I
after propagating metadata fromVL
only for instructions inVL
.Definition at line15260 of fileSLPVectorizer.cpp.
Referencesllvm::propagateMetadata(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().
| static |
Reorders the givenOrder
according to the givenMask
.
Order
- is the original order of the scalars. Procedure transforms the provided order in accordance with the givenMask
. If the resultingOrder
is just an identity order,Order
is cleared.
Definition at line4582 of fileSLPVectorizer.cpp.
Referencesllvm::all_of(),assert(),llvm::SmallVectorImpl< T >::assign(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::SmallVectorImpl< T >::clear(),llvm::Data,llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorTemplateCommon< T, typename >::end(),llvm::enumerate(),fixupOrderingIndices(),I,llvm::inversePermutation(),llvm::ShuffleVectorInst::isIdentityMask(),llvm::PoisonMaskElem,reorderReuses(),llvm::SmallVectorImpl< T >::resize(), andllvm::SmallVectorImpl< T >::swap().
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData(),llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(), andllvm::slpvectorizer::BoUpSLP::reorderTopToBottom().
| static |
Reorders the givenReuses
mask according to the givenMask
.
Reuses
contains original mask for the scalars reused in the node. Procedure transform this mask in accordance with the givenMask
.
Definition at line4568 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),E,llvm::SmallVectorTemplateCommon< T, typename >::end(),I,llvm::PoisonMaskElem,llvm::SmallVectorBase< Size_T >::size(), andllvm::SmallVectorImpl< T >::swap().
Referenced byllvm::slpvectorizer::BoUpSLP::reorderBottomToTop(), andreorderOrder().
Print a short descriptor of the instruction bundle suitable for debug output.
Definition at line449 of fileSLPVectorizer.cpp.
Referencesllvm::ArrayRef< T >::front(),Idx,OS, andllvm::ArrayRef< T >::size().
Referenced byllvm::slpvectorizer::BoUpSLP::getTreeCost().
STATISTIC | ( | NumVectorInstructions | , |
"Number ofvectorinstructions generated" | |||
) |
| static |
Definition at line300 of fileSLPVectorizer.cpp.
Referencesllvm::enumerate(),I, andllvm::PoisonMaskElem.
| static |
We could have an initial reduction that is not an add.
r *= v1 + v2 + v3 + v4 In such a case start looking for a tree rooted in the first '+'. \Returns the new root if found, which may be nullptr if not an instruction.
Definition at line20995 of fileSLPVectorizer.cpp.
Referencesassert(),llvm::User::getOperand(),LHS, andRHS.
| static |
\Returns the minimum number of elements that we will attempt to vectorize.
Definition at line21194 of fileSLPVectorizer.cpp.
Referencesllvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::SmallVectorImpl< T >::clear(),llvm::dbgs(),llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorTemplateCommon< T, typename >::end(),End,llvm::SmallVectorTemplateCommon< T, typename >::front(),I,LLVM_DEBUG,llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::SmallVectorBase< Size_T >::size(),llvm::stable_sort(), andllvm::SmallVectorImpl< T >::swap().
Definition at line206 of fileSLPVectorizer.cpp.
Definition at line215 of fileSLPVectorizer.cpp.
Maximum allowed number of operands in the PHI nodes.
Definition at line222 of fileSLPVectorizer.cpp.
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads().
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::BoUpSLP().
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::getMaximumVF().
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::canVectorizeLoads().
| static |
If the ScheduleRegionSizeBudget is exhausted, we allow small scheduling regions to be handled.
Definition at line219 of fileSLPVectorizer.cpp.
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::BoUpSLP().
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::findBestRootPair().
| static |
Referenced byllvm::SLPVectorizerPass::runImpl().
| static |
Limits the size of scheduling regions in a block.
It avoid long compile times forvery large blocks where vector instructions are spread over a wide range. This limit is way higher than needed by real-world functions.
| static |
| static |
| staticconstexpr |
Definition at line210 of fileSLPVectorizer.cpp.
Referenced byllvm::slpvectorizer::BoUpSLP::buildExternalUses(),llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes(),llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(),llvm::slpvectorizer::BoUpSLP::getTreeCost(),isCommutative(),llvm::isUsedOutsideBlock(), andllvm::slpvectorizer::BoUpSLP::vectorizeTree().
| static |
Referenced byllvm::slpvectorizer::BoUpSLP::getReorderingData().