LLVM 20.0.0git
|
Utility class for getting and setting loop vectorizer hints in the form of loop metadata. More...
#include "llvm/Transforms/Vectorize/LoopVectorizationLegality.h"
Public Types | |
enum | ForceKind { FK_Undefined = -1 , FK_Disabled = 0 , FK_Enabled = 1 } |
enum | ScalableForceKind { SK_Unspecified = -1 , SK_FixedWidthOnly = 0 , SK_PreferScalable = 1 } |
Public Member Functions | |
LoopVectorizeHints (const Loop *L, bool InterleaveOnlyWhenForced, OptimizationRemarkEmitter &ORE, const TargetTransformInfo *TTI=nullptr) | |
void | setAlreadyVectorized () |
Mark the loop L as already vectorized by setting the width to 1. | |
bool | allowVectorization (Function *F, Loop *L, bool VectorizeOnlyWhenForced) const |
void | emitRemarkWithHints () const |
Dumps all the hint information. | |
ElementCount | getWidth () const |
unsigned | getInterleave () const |
unsigned | getIsVectorized () const |
unsigned | getPredicate () const |
enum ForceKind | getForce () const |
bool | isScalableVectorizationDisabled () const |
const char * | vectorizeAnalysisPassName () const |
If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend to print the diagnostic. | |
bool | allowReordering () const |
When enabling loop hints are provided we allow the vectorizer to change the order of operations that is given by the scalar loop. | |
bool | isPotentiallyUnsafe () const |
void | setPotentiallyUnsafe () |
Utility class for getting and setting loop vectorizer hints in the form of loop metadata.
This class keeps a number of loop annotations locally (as member variables) and can, upon request, write them back as metadata on the loop. It will initially scan the loop for existing metadata, and will update the local values based on information in the loop. We cannot write all values to metadata, as the mere presence of some info, for example 'force', means a decision has been made. So, we need to be careful NOT to add them if the user hasn't specifically asked so.
Definition at line 60 of file LoopVectorizationLegality.h.
Enumerator | |
---|---|
FK_Undefined | Not selected. |
FK_Disabled | Forcing disabled. |
FK_Enabled | Forcing enabled. |
Definition at line 107 of file LoopVectorizationLegality.h.
Definition at line 113 of file LoopVectorizationLegality.h.
llvm::LoopVectorizeHints::LoopVectorizeHints | ( | const Loop * | L, |
bool | InterleaveOnlyWhenForced, | ||
OptimizationRemarkEmitter & | ORE, | ||
const TargetTransformInfo * | TTI = nullptr |
||
) |
Definition at line 107 of file LoopVectorizationLegality.cpp.
References llvm::dbgs(), llvm::TargetTransformInfo::enableScalableVectorization(), ForceScalableVectorization, llvm::ElementCount::getFixed(), getInterleave(), getWidth(), llvm::VectorizerParams::isInterleaveForced(), LLVM_DEBUG, SK_FixedWidthOnly, SK_PreferScalable, SK_Unspecified, and llvm::VectorizerParams::VectorizationInterleave.
bool llvm::LoopVectorizeHints::allowReordering | ( | ) | const |
When enabling loop hints are provided we allow the vectorizer to change the order of operations that is given by the scalar loop.
This is not enabled by default because can be unsafe or inefficient. For example, reordering floating-point operations will change the way round-off error accumulates in the loop.
Definition at line 250 of file LoopVectorizationLegality.cpp.
References FK_Enabled, getForce(), getWidth(), and llvm::HintsAllowReordering.
Referenced by llvm::LoopVectorizationCostModel::useOrderedReductions().
bool llvm::LoopVectorizeHints::allowVectorization | ( | Function * | F, |
Loop * | L, | ||
bool | VectorizeOnlyWhenForced | ||
) | const |
Definition at line 182 of file LoopVectorizationLegality.cpp.
References llvm::dbgs(), llvm::OptimizationRemarkEmitter::emit(), emitRemarkWithHints(), FK_Disabled, FK_Enabled, getForce(), getIsVectorized(), LLVM_DEBUG, and vectorizeAnalysisPassName().
Referenced by isExplicitVecOuterLoop(), and llvm::LoopVectorizePass::processLoop().
void llvm::LoopVectorizeHints::emitRemarkWithHints | ( | ) | const |
Dumps all the hint information.
Definition at line 215 of file LoopVectorizationLegality.cpp.
References llvm::OptimizationRemarkEmitter::emit(), FK_Disabled, FK_Enabled, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::Loop::getStartLoc(), if(), and LV_NAME.
Referenced by allowVectorization(), isExplicitVecOuterLoop(), and llvm::LoopVectorizePass::processLoop().
|
inline |
Definition at line 153 of file LoopVectorizationLegality.h.
References FK_Disabled, FK_Undefined, and llvm::hasDisableAllTransformsHint().
Referenced by allowReordering(), allowVectorization(), llvm::LoopVectorizationPlanner::computeBestVF(), getScalarEpilogueLowering(), isExplicitVecOuterLoop(), isPotentiallyUnsafe(), llvm::LoopVectorizePass::processLoop(), and vectorizeAnalysisPassName().
|
inline |
Definition at line 142 of file LoopVectorizationLegality.h.
References llvm::hasUnrollTransformation(), and llvm::TM_Disable.
Referenced by isExplicitVecOuterLoop(), LoopVectorizeHints(), and llvm::LoopVectorizePass::processLoop().
|
inline |
Definition at line 151 of file LoopVectorizationLegality.h.
Referenced by allowVectorization().
|
inline |
Definition at line 152 of file LoopVectorizationLegality.h.
Referenced by getScalarEpilogueLowering().
|
inline |
Definition at line 137 of file LoopVectorizationLegality.h.
References llvm::ElementCount::get(), and SK_PreferScalable.
Referenced by allowReordering(), LoopVectorizeHints(), llvm::LoopVectorizePass::processLoop(), processLoopInVPlanNativePath(), and vectorizeAnalysisPassName().
|
inline |
Definition at line 176 of file LoopVectorizationLegality.h.
References FK_Enabled, and getForce().
Referenced by llvm::LoopVectorizePass::processLoop().
|
inline |
Definition at line 161 of file LoopVectorizationLegality.h.
References SK_FixedWidthOnly.
void llvm::LoopVectorizeHints::setAlreadyVectorized | ( | ) |
Mark the loop L as already vectorized by setting the width to 1.
Definition at line 163 of file LoopVectorizationLegality.cpp.
References llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::MDString::get(), llvm::BasicBlock::getContext(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::Loop::getLoopID(), llvm::makePostTransformationMetadata(), llvm::Loop::setLoopID(), and llvm::Twine::str().
Referenced by llvm::LoopVectorizationPlanner::executePlan(), llvm::LoopVectorizePass::processLoop(), and processLoopInVPlanNativePath().
|
inline |
Definition at line 185 of file LoopVectorizationLegality.h.
If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend to print the diagnostic.
Definition at line 240 of file LoopVectorizationLegality.cpp.
References llvm::OptimizationRemarkAnalysis::AlwaysPrint, FK_Disabled, FK_Undefined, llvm::ElementCount::getFixed(), getForce(), getWidth(), isZero(), and LV_NAME.
Referenced by allowVectorization(), llvm::LoopVectorizePass::processLoop(), and llvm::reportVectorizationFailure().