|
LLVM 23.0.0git
|
Holds state needed to make cost decisions before computing costs per-VF, including the maximum VFs. More...
#include "Transforms/Vectorize/LoopVectorizationPlanner.h"
Public Member Functions | |
| VFSelectionContext (const TargetTransformInfo &TTI, const LoopVectorizationLegality *Legal, const Loop *TheLoop, const Function &F, PredicatedScalarEvolution &PSE, DemandedBits *DB, OptimizationRemarkEmitter *ORE, const LoopVectorizeHints *Hints, bool OptForSize) | |
| std::optional< unsigned > | getVScaleForTuning () const |
| bool | shouldConsiderRegPressureForVF (ElementCount VF) const |
| bool | supportsScalableVectors () const |
| void | collectElementTypesForWidening (const SmallPtrSetImpl< const Value * > *ValuesToIgnore=nullptr) |
| Collect element types in the loop that need widening. | |
| std::pair< unsigned, unsigned > | getSmallestAndWidestTypes () const |
| FixedScalableVFPair | computeFeasibleMaxVF (unsigned MaxTripCount, ElementCount UserVF, unsigned UserIC, bool FoldTailByMasking, bool RequiresScalarEpilogue) |
| std::optional< unsigned > | getMaxSafeElements () const |
| Return maximum safe number of elements to be processed per vector iteration, which do not prevent store-load forwarding and are safe with regard to the memory dependencies. | |
| bool | useOrderedReductions (const RecurrenceDescriptor &RdxDesc) const |
| Returns true if we should use strict in-order reductions for the given RdxDesc. | |
| bool | isLegalMaskedLoadOrStore (Instruction *I, ElementCount VF) const |
Returns true if the target machine supports masked loads or stores for I's data type and alignment. | |
| bool | isLegalGatherOrScatter (Value *V, ElementCount VF) const |
Returns true if the target machine can represent V as a masked gather or scatter operation. | |
| void | collectInLoopReductions () |
| Split reductions into those that happen in the loop, and those that happen outside. | |
| bool | isInLoopReduction (PHINode *Phi) const |
| Returns true if the Phi is part of an inloop reduction. | |
| const SmallPtrSetImpl< PHINode * > & | getInLoopReductions () const |
| Returns the set of in-loop reduction PHIs. | |
| Instruction * | getInLoopReductionImmediateChain (Instruction *I) const |
Returns the immediate chain operand of in-loop reduction operation I, or nullptr if I is not an in-loop reduction operation. | |
| bool | runtimeChecksRequired () |
| Check whether vectorization would require runtime checks. | |
| FixedScalableVFPair | computeVPlanOuterloopVF (ElementCount UserVF) |
| Returns a scalable VF to use for outer-loop vectorization if the target supports it and a fixed VF otherwise. | |
| void | computeMinimalBitwidths () |
| Compute smallest bitwidth each instruction can be represented with. | |
| const MapVector< Instruction *, uint64_t > & | getMinimalBitwidths () const |
Public Attributes | |
| const TTI::TargetCostKind | CostKind |
| The kind of cost that we are calculating. | |
| const bool | OptForSize |
| Whether this loop should be optimized for size based on function attribute or profile information. | |
Holds state needed to make cost decisions before computing costs per-VF, including the maximum VFs.
Definition at line 530 of file LoopVectorizationPlanner.h.
|
inline |
Definition at line 616 of file LoopVectorizationPlanner.h.
References CostKind, and OptForSize.
| void VFSelectionContext::collectElementTypesForWidening | ( | const SmallPtrSetImpl< const Value * > * | ValuesToIgnore = nullptr | ) |
Collect element types in the loop that need widening.
Definition at line 462 of file LoopVectorizationPlanner.cpp.
References assert(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::dyn_cast(), llvm::RecurrenceDescriptor::getRecurrenceKind(), llvm::RecurrenceDescriptor::getRecurrenceType(), I, llvm::isa(), llvm::PreferInLoopReductions, T, and useOrderedReductions().
| void VFSelectionContext::collectInLoopReductions | ( | ) |
Split reductions into those that happen in the loop, and those that happen outside.
In-loop reductions are collected into InLoopReductions. InLoopReductionImmediateChains is filled with each in-loop reduction operation and its immediate chain operand for use during cost modelling.
Definition at line 568 of file LoopVectorizationPlanner.cpp.
References llvm::dbgs(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::RecurrenceDescriptor::getRecurrenceKind(), llvm::RecurrenceDescriptor::getRecurrenceType(), llvm::RecurrenceDescriptor::getReductionOpChain(), llvm::RecurrenceDescriptor::hasUsesOutsideReductionChain(), I, llvm::RecurrenceDescriptor::isAnyOfRecurrenceKind(), llvm::RecurrenceDescriptor::isFindIVRecurrenceKind(), llvm::RecurrenceDescriptor::isFindLastRecurrenceKind(), LLVM_DEBUG, llvm::PreferInLoopReductions, and useOrderedReductions().
| FixedScalableVFPair VFSelectionContext::computeFeasibleMaxVF | ( | unsigned | MaxTripCount, |
| ElementCount | UserVF, | ||
| unsigned | UserIC, | ||
| bool | FoldTailByMasking, | ||
| bool | RequiresScalarEpilogue ) |
Definition at line 320 of file LoopVectorizationPlanner.cpp.
References assert(), llvm::bit_floor(), llvm::dbgs(), DEBUG_TYPE, llvm::ElementCount::getFixed(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::ElementCount::getScalable(), getSmallestAndWidestTypes(), llvm::details::FixedOrScalableQuantity< ElementCount, unsigned >::isKnownGT(), llvm::details::FixedOrScalableQuantity< ElementCount, unsigned >::isKnownLE(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), LLVM_DEBUG, and supportsScalableVectors().
| void VFSelectionContext::computeMinimalBitwidths | ( | ) |
Compute smallest bitwidth each instruction can be represented with.
The vector equivalents of these instructions should be truncated to this type.
Definition at line 564 of file LoopVectorizationPlanner.cpp.
References llvm::computeMinimumValueSizes().
| FixedScalableVFPair VFSelectionContext::computeVPlanOuterloopVF | ( | ElementCount | UserVF | ) |
Returns a scalable VF to use for outer-loop vectorization if the target supports it and a fixed VF otherwise.
Definition at line 626 of file LoopVectorizationPlanner.cpp.
References _, assert(), llvm::dbgs(), llvm::ElementCount::get(), llvm::ElementCount::getFixed(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::FixedScalableVFPair::getNone(), getSmallestAndWidestTypes(), llvm::isPowerOf2_32(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::ElementCount::isScalar(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isZero(), LLVM_DEBUG, N, RegSize, llvm::reportVectorizationFailure(), llvm::TargetTransformInfo::RGK_FixedWidthVector, llvm::TargetTransformInfo::RGK_ScalableVector, supportsScalableVectors(), and VPlanBuildOuterloopStressTest.
|
inline |
Returns the immediate chain operand of in-loop reduction operation I, or nullptr if I is not an in-loop reduction operation.
Definition at line 699 of file LoopVectorizationPlanner.h.
References I.
|
inline |
Returns the set of in-loop reduction PHIs.
Definition at line 693 of file LoopVectorizationPlanner.h.
|
inline |
Return maximum safe number of elements to be processed per vector iteration, which do not prevent store-load forwarding and are safe with regard to the memory dependencies.
Required for EVL-based VPlans to correctly calculate AVL (application vector length) as min(remaining AVL, MaxSafeElements). Set by computeFeasibleMaxVF. TODO: need to consider adjusting cost model to use this value as a vectorization factor for EVL-based vectorization.
Definition at line 664 of file LoopVectorizationPlanner.h.
|
inline |
Definition at line 717 of file LoopVectorizationPlanner.h.
Definition at line 433 of file LoopVectorizationPlanner.cpp.
Referenced by computeFeasibleMaxVF(), and computeVPlanOuterloopVF().
|
inline |
Definition at line 630 of file LoopVectorizationPlanner.h.
Referenced by preparePlanForEpilogueVectorLoop(), and llvm::LoopVectorizePass::processLoop().
Returns true if the Phi is part of an inloop reduction.
Definition at line 688 of file LoopVectorizationPlanner.h.
| bool VFSelectionContext::isLegalGatherOrScatter | ( | Value * | V, |
| ElementCount | VF ) const |
Returns true if the target machine can represent V as a masked gather or scatter operation.
Definition at line 76 of file LoopVectorizationPlanner.cpp.
References llvm::VectorType::get(), llvm::getLoadStoreAlignment(), llvm::getLoadStoreType(), llvm::isa(), and llvm::ElementCount::isVector().
| bool VFSelectionContext::isLegalMaskedLoadOrStore | ( | Instruction * | I, |
| ElementCount | VF ) const |
Returns true if the target machine supports masked loads or stores for I's data type and alignment.
The caller must ensure the access is consecutive or part of an interleave group.
Definition at line 64 of file LoopVectorizationPlanner.cpp.
References assert(), ForceTargetSupportsMaskedMemoryOps, llvm::getLoadStoreAddressSpace(), llvm::getLoadStoreAlignment(), llvm::getLoadStoreType(), I, and llvm::isa().
| bool VFSelectionContext::runtimeChecksRequired | ( | ) |
Check whether vectorization would require runtime checks.
When optimizing for size, returning true here aborts vectorization.
Definition at line 527 of file LoopVectorizationPlanner.cpp.
References llvm::dbgs(), LLVM_DEBUG, and llvm::reportVectorizationFailure().
| bool VFSelectionContext::shouldConsiderRegPressureForVF | ( | ElementCount | VF | ) | const |
Definition at line 104 of file LoopVectorizationPlanner.cpp.
References ConsiderRegPressure, llvm::details::FixedOrScalableQuantity< ElementCount, unsigned >::isKnownGT(), and llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable().
| bool VFSelectionContext::supportsScalableVectors | ( | ) | const |
Definition at line 90 of file LoopVectorizationPlanner.cpp.
References ForceTargetSupportsScalableVectors.
Referenced by computeFeasibleMaxVF(), and computeVPlanOuterloopVF().
| bool VFSelectionContext::useOrderedReductions | ( | const RecurrenceDescriptor & | RdxDesc | ) | const |
Returns true if we should use strict in-order reductions for the given RdxDesc.
This is true if the -enable-strict-reductions flag is passed, the IsOrdered flag of RdxDesc is set and we do not allow reordering of FP operations.
Definition at line 522 of file LoopVectorizationPlanner.cpp.
References llvm::RecurrenceDescriptor::isOrdered().
Referenced by collectElementTypesForWidening(), and collectInLoopReductions().
| const TTI::TargetCostKind llvm::VFSelectionContext::CostKind |
The kind of cost that we are calculating.
Definition at line 610 of file LoopVectorizationPlanner.h.
Referenced by llvm::LoopVectorizePass::processLoop(), and VFSelectionContext().
Whether this loop should be optimized for size based on function attribute or profile information.
Definition at line 614 of file LoopVectorizationPlanner.h.
Referenced by VFSelectionContext().