class LoopVectorizeHints

Declaration

class LoopVectorizeHints { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:61

Member Variables

private llvm::LoopVectorizeHints::Hint Width
Vectorization width.
private llvm::LoopVectorizeHints::Hint Interleave
Vectorization interleave factor.
private llvm::LoopVectorizeHints::Hint Force
Vectorization forced
private llvm::LoopVectorizeHints::Hint IsVectorized
Already Vectorized
private llvm::LoopVectorizeHints::Hint Predicate
Vector Predicate
private llvm::LoopVectorizeHints::Hint Scalable
Says whether we should use fixed width or scalable vectorization.
private bool PotentiallyUnsafe = false
True if there is any unsafe math in the loop.
private const llvm::Loop* TheLoop
The loop these hints belong to.
private llvm::OptimizationRemarkEmitter& ORE
Interface to emit optimization remarks.

Method Overview

Methods

LoopVectorizeHints(
    const llvm::Loop* L,
    bool InterleaveOnlyWhenForced,
    llvm::OptimizationRemarkEmitter& ORE,
    const llvm::TargetTransformInfo* TTI =
        nullptr)

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:125

Parameters

const llvm::Loop* L
bool InterleaveOnlyWhenForced
llvm::OptimizationRemarkEmitter& ORE
const llvm::TargetTransformInfo* TTI = nullptr

static llvm::StringRef Prefix()

Description

Return the loop metadata prefix.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:102

bool allowReordering() const

Description

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.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:175

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

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:132

Parameters

llvm::Function* F
llvm::Loop* L
bool VectorizeOnlyWhenForced

void emitRemarkWithHints() const

Description

Dumps all the hint information.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:136

enum ForceKind getForce() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:154

void getHintsFromMetadata()

Description

Find hints specified in the loop metadata and update local values.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:190

unsigned int getInterleave() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:143

unsigned int getIsVectorized() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:152

unsigned int getPredicate() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:153

llvm::ElementCount getWidth() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:138

bool isPotentiallyUnsafe() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:177

bool isScalableVectorizationDisabled() const

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:162

Returns

true if scalable vectorization has been explicitly disabled.

void setAlreadyVectorized()

Description

Mark the loop L as already vectorized by setting the width to 1.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:130

void setHint(llvm::StringRef Name,
             llvm::Metadata* Arg)

Description

Checks string hint with one operand and set value if valid.

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:193

Parameters

llvm::StringRef Name
llvm::Metadata* Arg

void setPotentiallyUnsafe()

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:186

const char* vectorizeAnalysisPassName() const

Description

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

Declared at: llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h:168