Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | class LoopVectorizeHints { | ||||
/// Vectorization width. | /// Vectorization width. | ||||
Hint Width; | Hint Width; | ||||
/// Vectorization interleave factor. | /// Vectorization interleave factor. | ||||
Hint Interleave; | Hint Interleave; | ||||
/// Vectorization forced | /// Vectorization forced | ||||
Hint Force; | Hint VectorizationForce; | ||||
/// Interleave forced | |||||
Hint InterleaveForce; | |||||
/// Already Vectorized | /// Already Vectorized | ||||
Hint IsVectorized; | Hint IsVectorized; | ||||
/// Vector Predicate | /// Vector Predicate | ||||
Hint Predicate; | Hint Predicate; | ||||
/// Says whether we should use fixed width or scalable vectorization. | /// Says whether we should use fixed width or scalable vectorization. | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | unsigned getInterleave() const { | ||||
// If interleaving is not explicitly set, assume that if we do not want | // If interleaving is not explicitly set, assume that if we do not want | ||||
// unrolling, we also don't want any interleaving. | // unrolling, we also don't want any interleaving. | ||||
if (llvm::hasUnrollTransformation(TheLoop) & TM_Disable) | if (llvm::hasUnrollTransformation(TheLoop) & TM_Disable) | ||||
return 1; | return 1; | ||||
return 0; | return 0; | ||||
} | } | ||||
unsigned getIsVectorized() const { return IsVectorized.Value; } | unsigned getIsVectorized() const { return IsVectorized.Value; } | ||||
unsigned getPredicate() const { return Predicate.Value; } | unsigned getPredicate() const { return Predicate.Value; } | ||||
enum ForceKind getForce() const { | enum ForceKind getVectorizationForce() const { | ||||
if ((ForceKind)Force.Value == FK_Undefined && | if ((ForceKind)VectorizationForce.Value == FK_Undefined && | ||||
hasDisableAllTransformsHint(TheLoop)) | |||||
return FK_Disabled; | |||||
return (ForceKind)VectorizationForce.Value; | |||||
} | |||||
enum ForceKind getInterleaveForce() const { | |||||
if ((ForceKind)InterleaveForce.Value == FK_Undefined && | |||||
hasDisableAllTransformsHint(TheLoop)) | hasDisableAllTransformsHint(TheLoop)) | ||||
return FK_Disabled; | return FK_Disabled; | ||||
return (ForceKind)Force.Value; | return (ForceKind)InterleaveForce.Value; | ||||
} | } | ||||
/// \return true if scalable vectorization has been explicitly disabled. | /// \return true if scalable vectorization has been explicitly disabled. | ||||
bool isScalableVectorizationDisabled() const { | bool isScalableVectorizationDisabled() const { | ||||
return (ScalableForceKind)Scalable.Value == SK_FixedWidthOnly; | return (ScalableForceKind)Scalable.Value == SK_FixedWidthOnly; | ||||
} | } | ||||
/// If hints are provided that force vectorization, use the AlwaysPrint | /// If hints are provided that force vectorization, use the AlwaysPrint | ||||
/// pass name to force the frontend to print the diagnostic. | /// pass name to force the frontend to print the diagnostic. | ||||
const char *vectorizeAnalysisPassName() const; | const char *vectorizeAnalysisPassName() const; | ||||
/// When enabling loop hints are provided we allow the vectorizer to change | /// 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 | /// 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, | /// enabled by default because can be unsafe or inefficient. For example, | ||||
/// reordering floating-point operations will change the way round-off | /// reordering floating-point operations will change the way round-off | ||||
/// error accumulates in the loop. | /// error accumulates in the loop. | ||||
bool allowReordering() const; | bool allowReordering() const; | ||||
bool isPotentiallyUnsafe() const { | bool isPotentiallyUnsafe() const { | ||||
// Avoid FP vectorization if the target is unsure about proper support. | // Avoid FP vectorization if the target is unsure about proper support. | ||||
// This may be related to the SIMD unit in the target not handling | // This may be related to the SIMD unit in the target not handling | ||||
// IEEE 754 FP ops properly, or bad single-to-double promotions. | // IEEE 754 FP ops properly, or bad single-to-double promotions. | ||||
// Otherwise, a sequence of vectorized loops, even without reduction, | // Otherwise, a sequence of vectorized loops, even without reduction, | ||||
// could lead to different end results on the destination vectors. | // could lead to different end results on the destination vectors. | ||||
return getForce() != LoopVectorizeHints::FK_Enabled && PotentiallyUnsafe; | return getVectorizationForce() != LoopVectorizeHints::FK_Enabled && | ||||
PotentiallyUnsafe; | |||||
} | } | ||||
void setPotentiallyUnsafe() { PotentiallyUnsafe = true; } | void setPotentiallyUnsafe() { PotentiallyUnsafe = true; } | ||||
private: | private: | ||||
/// Find hints specified in the loop metadata and update local values. | /// Find hints specified in the loop metadata and update local values. | ||||
void getHintsFromMetadata(); | void getHintsFromMetadata(); | ||||
▲ Show 20 Lines • Show All 370 Lines • Show Last 20 Lines |