|
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, 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 | isLegalMaskedStore (Type *DataType, Value *Ptr, Align Alignment, unsigned AddressSpace) const |
Returns true if the target machine supports masked store operation for the given DataType and kind of access to Ptr. | |
| bool | isLegalMaskedLoad (Type *DataType, Value *Ptr, Align Alignment, unsigned AddressSpace) const |
Returns true if the target machine supports masked load operation for the given DataType and kind of access to Ptr. | |
| 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. | |
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 517 of file LoopVectorizationPlanner.h.
|
inline |
Definition at line 597 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 464 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().
Referenced by processLoopInVPlanNativePath().
| 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 566 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 322 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().
|
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 685 of file LoopVectorizationPlanner.h.
References I.
|
inline |
Returns the set of in-loop reduction PHIs.
Definition at line 679 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 645 of file LoopVectorizationPlanner.h.
Definition at line 435 of file LoopVectorizationPlanner.cpp.
Referenced by computeFeasibleMaxVF(), and determineVPlanVF().
|
inline |
Definition at line 611 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 674 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 78 of file LoopVectorizationPlanner.cpp.
References llvm::VectorType::get(), llvm::getLoadStoreAlignment(), llvm::getLoadStoreType(), llvm::isa(), and llvm::ElementCount::isVector().
| bool VFSelectionContext::isLegalMaskedLoad | ( | Type * | DataType, |
| Value * | Ptr, | ||
| Align | Alignment, | ||
| unsigned | AddressSpace ) const |
Returns true if the target machine supports masked load operation for the given DataType and kind of access to Ptr.
Definition at line 70 of file LoopVectorizationPlanner.cpp.
References ForceTargetSupportsMaskedMemoryOps.
| bool VFSelectionContext::isLegalMaskedStore | ( | Type * | DataType, |
| Value * | Ptr, | ||
| Align | Alignment, | ||
| unsigned | AddressSpace ) const |
Returns true if the target machine supports masked store operation for the given DataType and kind of access to Ptr.
Definition at line 62 of file LoopVectorizationPlanner.cpp.
References ForceTargetSupportsMaskedMemoryOps.
| bool VFSelectionContext::runtimeChecksRequired | ( | ) |
Check whether vectorization would require runtime checks.
When optimizing for size, returning true here aborts vectorization.
Definition at line 529 of file LoopVectorizationPlanner.cpp.
References llvm::dbgs(), LLVM_DEBUG, and llvm::reportVectorizationFailure().
| bool VFSelectionContext::shouldConsiderRegPressureForVF | ( | ElementCount | VF | ) | const |
Definition at line 106 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 92 of file LoopVectorizationPlanner.cpp.
References ForceTargetSupportsScalableVectors.
Referenced by computeFeasibleMaxVF().
| 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 524 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 591 of file LoopVectorizationPlanner.h.
Referenced by llvm::LoopVectorizePass::processLoop(), processLoopInVPlanNativePath(), and VFSelectionContext().
Whether this loop should be optimized for size based on function attribute or profile information.
Definition at line 595 of file LoopVectorizationPlanner.h.
Referenced by VFSelectionContext().