LLVM  14.0.0git
Classes | Public Types | Public Member Functions | List of all members
llvm::LoopVectorizeHints Class Reference

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, SK_PreferFixedWidth = 2 }
 

Public Member Functions

 LoopVectorizeHints (const Loop *L, bool InterleaveOnlyWhenForced, OptimizationRemarkEmitter &ORE)
 
void setAlreadyVectorized ()
 Mark the loop L as already vectorized by setting the width to 1. More...
 
bool allowVectorization (Function *F, Loop *L, bool VectorizeOnlyWhenForced) const
 
void emitRemarkWithHints () const
 Dumps all the hint information. More...
 
ElementCount getWidth () const
 
unsigned getInterleave () const
 
unsigned getIsVectorized () const
 
unsigned getPredicate () const
 
enum ForceKind getForce () const
 
bool isScalableVectorizationPreferred () const
 
bool isScalableVectorizationExplicitlyEnabled () 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. More...
 
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. More...
 
bool isPotentiallyUnsafe () const
 
void setPotentiallyUnsafe ()
 

Detailed Description

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 46 of file LoopVectorizationLegality.h.

Member Enumeration Documentation

◆ ForceKind

Enumerator
FK_Undefined 

Not selected.

FK_Disabled 

Forcing disabled.

FK_Enabled 

Forcing enabled.

Definition at line 93 of file LoopVectorizationLegality.h.

◆ ScalableForceKind

Enumerator
SK_Unspecified 

Not selected.

SK_FixedWidthOnly 

Disables vectorization with scalable vectors.

SK_PreferScalable 

Vectorize loops using scalable vectors or fixed-width vectors, but favor scalable vectors when the cost-model is inconclusive.

This is the default when the scalable.enable hint is enabled through a pragma.

SK_PreferFixedWidth 

Vectorize loops using scalable vectors or fixed-width vectors, but favor fixed-width vectors when the cost is inconclusive.

Definition at line 99 of file LoopVectorizationLegality.h.

Constructor & Destructor Documentation

◆ LoopVectorizeHints()

llvm::LoopVectorizeHints::LoopVectorizeHints ( const Loop L,
bool  InterleaveOnlyWhenForced,
OptimizationRemarkEmitter ORE 
)

Member Function Documentation

◆ allowReordering()

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 221 of file LoopVectorizationLegality.cpp.

References FK_Enabled, getForce(), getWidth(), and llvm::HintsAllowReordering.

◆ allowVectorization()

bool llvm::LoopVectorizeHints::allowVectorization ( Function F,
Loop L,
bool  VectorizeOnlyWhenForced 
) const

◆ emitRemarkWithHints()

void llvm::LoopVectorizeHints::emitRemarkWithHints ( ) const

Dumps all the hint information.

Definition at line 185 of file LoopVectorizationLegality.cpp.

References FK_Disabled, and LV_NAME.

Referenced by allowVectorization(), isExplicitVecOuterLoop(), and llvm::LoopVectorizePass::processLoop().

◆ getForce()

enum ForceKind llvm::LoopVectorizeHints::getForce ( ) const
inline

◆ getInterleave()

unsigned llvm::LoopVectorizeHints::getInterleave ( ) const
inline

◆ getIsVectorized()

unsigned llvm::LoopVectorizeHints::getIsVectorized ( ) const
inline

Definition at line 138 of file LoopVectorizationLegality.h.

Referenced by allowVectorization().

◆ getPredicate()

unsigned llvm::LoopVectorizeHints::getPredicate ( ) const
inline

Definition at line 139 of file LoopVectorizationLegality.h.

Referenced by getScalarEpilogueLowering().

◆ getWidth()

ElementCount llvm::LoopVectorizeHints::getWidth ( ) const
inline

◆ isPotentiallyUnsafe()

bool llvm::LoopVectorizeHints::isPotentiallyUnsafe ( ) const
inline

Definition at line 176 of file LoopVectorizationLegality.h.

References FK_Enabled, and getForce().

Referenced by llvm::LoopVectorizePass::processLoop().

◆ isScalableVectorizationDisabled()

bool llvm::LoopVectorizeHints::isScalableVectorizationDisabled ( ) const
inline
Returns
true if scalable vectorization has been explicitly disabled.

Definition at line 161 of file LoopVectorizationLegality.h.

References SK_FixedWidthOnly.

◆ isScalableVectorizationExplicitlyEnabled()

bool llvm::LoopVectorizeHints::isScalableVectorizationExplicitlyEnabled ( ) const
inline
Returns
true if scalable vectorization has been explicitly enabled.

Definition at line 155 of file LoopVectorizationLegality.h.

References SK_PreferFixedWidth, and SK_PreferScalable.

Referenced by getWidth().

◆ isScalableVectorizationPreferred()

bool llvm::LoopVectorizeHints::isScalableVectorizationPreferred ( ) const
inline
Returns
true if the cost-model for scalable vectorization should favor vectorization with scalable vectors over fixed-width vectors when the cost-model is inconclusive.

Definition at line 150 of file LoopVectorizationLegality.h.

References SK_PreferScalable.

◆ setAlreadyVectorized()

void llvm::LoopVectorizeHints::setAlreadyVectorized ( )

◆ setPotentiallyUnsafe()

void llvm::LoopVectorizeHints::setPotentiallyUnsafe ( )
inline

Definition at line 185 of file LoopVectorizationLegality.h.

◆ vectorizeAnalysisPassName()

const char * llvm::LoopVectorizeHints::vectorizeAnalysisPassName ( ) const

If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend to print the diagnostic.

Definition at line 211 of file LoopVectorizationLegality.cpp.

References llvm::OptimizationRemarkAnalysis::AlwaysPrint, FK_Disabled, FK_Undefined, llvm::LinearPolySize< ElementCount >::getFixed(), getForce(), getWidth(), isZero(), and LV_NAME.

Referenced by allowVectorization(), llvm::LoopVectorizePass::processLoop(), llvm::reportVectorizationFailure(), and llvm::reportVectorizationInfo().


The documentation for this class was generated from the following files: