LLVM 23.0.0git
llvm::VPCostContext Struct Reference

Struct to hold various analysis needed for cost computations. More...

#include "Transforms/Vectorize/VPlanHelpers.h"

Public Types

enum class  CallWideningKind { Scalarize , Intrinsic , VectorVariant }
 Choice for how to widen a call at a given VF. More...

Public Member Functions

 VPCostContext (const TargetTransformInfo &TTI, const TargetLibraryInfo &TLI, const VPlan &Plan, LoopVectorizationCostModel &CM, TargetTransformInfo::TargetCostKind CostKind, PredicatedScalarEvolution &PSE, const Loop *L)
InstructionCost getLegacyCost (Instruction *UI, ElementCount VF) const
 Return the cost for UI with VF using the legacy cost model as fallback until computing the cost of all recipes migrates to VPlan.
bool skipCostComputation (Instruction *UI, bool IsVector) const
 Return true if the cost for UI shouldn't be computed, e.g.
uint64_t getPredBlockCostDivisor (BasicBlock *BB) const
bool willBeScalarized (Instruction *I, ElementCount VF) const
 Returns true if I is known to be scalarized at VF.
bool isMaskRequired (Instruction *I) const
 Forwards to LoopVectorizationCostModel::isMaskRequired.
std::optional< CallWideningKindgetLegacyCallKind (CallInst *CI, ElementCount VF) const
 Returns the legacy call widening decision for CI at VF, or std::nullopt if none was recorded.
TargetTransformInfo::OperandValueInfo getOperandInfo (VPValue *V) const
 Returns the OperandInfo for V, if it is a live-in.
InstructionCost getScalarizationOverhead (Type *ResultTy, ArrayRef< const VPValue * > Operands, ElementCount VF, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None, bool AlwaysIncludeReplicatingR=false)
 Estimate the overhead of scalarizing a recipe with result type ResultTy and Operands with VF.
bool useEmulatedMaskMemRefHack (const VPReplicateRecipe *R, ElementCount VF)
 Returns true if an artificially high cost for emulated masked memrefs should be used.

Static Public Member Functions

static bool isFreeScalarIntrinsic (Intrinsic::ID ID)
 Returns true if ID is a pseudo intrinsic that is dropped via scalarization rather than widened.

Public Attributes

const TargetTransformInfoTTI
const TargetLibraryInfoTLI
VPTypeAnalysis Types
LLVMContextLLVMCtx
LoopVectorizationCostModelCM
SmallPtrSet< Instruction *, 8 > SkipCostComputation
TargetTransformInfo::TargetCostKind CostKind
PredicatedScalarEvolutionPSE
const LoopL
std::optional< unsignedNumPredStores
 Number of predicated stores in the VPlan, computed on demand.

Detailed Description

Struct to hold various analysis needed for cost computations.

Definition at line 325 of file VPlanHelpers.h.

Member Enumeration Documentation

◆ CallWideningKind

Choice for how to widen a call at a given VF.

Enumerator
Scalarize 
Intrinsic 
VectorVariant 

Definition at line 327 of file VPlanHelpers.h.

Constructor & Destructor Documentation

◆ VPCostContext()

llvm::VPCostContext::VPCostContext ( const TargetTransformInfo & TTI,
const TargetLibraryInfo & TLI,
const VPlan & Plan,
LoopVectorizationCostModel & CM,
TargetTransformInfo::TargetCostKind CostKind,
PredicatedScalarEvolution & PSE,
const Loop * L )
inline

Definition at line 342 of file VPlanHelpers.h.

References CM, CostKind, L, LLVMCtx, PSE, TLI, TTI, and Types.

Member Function Documentation

◆ getLegacyCallKind()

std::optional< VPCostContext::CallWideningKind > VPCostContext::getLegacyCallKind ( CallInst * CI,
ElementCount VF ) const

Returns the legacy call widening decision for CI at VF, or std::nullopt if none was recorded.

Used only in asserts.

Definition at line 5811 of file LoopVectorize.cpp.

References CM, llvm::LoopVectorizationCostModel::CM_IntrinsicCall, llvm::LoopVectorizationCostModel::CM_Scalarize, llvm::LoopVectorizationCostModel::CM_VectorCall, Intrinsic, llvm::ElementCount::isScalar(), Scalarize, and VectorVariant.

Referenced by llvm::VPlanTransforms::makeCallWideningDecisions().

◆ getLegacyCost()

InstructionCost VPCostContext::getLegacyCost ( Instruction * UI,
ElementCount VF ) const

Return the cost for UI with VF using the legacy cost model as fallback until computing the cost of all recipes migrates to VPlan.

Definition at line 5782 of file LoopVectorize.cpp.

References CM, llvm::ForceTargetInstructionCost, and InstructionCost.

◆ getOperandInfo()

TargetTransformInfo::OperandValueInfo VPCostContext::getOperandInfo ( VPValue * V) const

Returns the OperandInfo for V, if it is a live-in.

Definition at line 1860 of file VPlan.cpp.

References llvm::dyn_cast(), and llvm::TargetTransformInfo::getOperandInfo().

◆ getPredBlockCostDivisor()

uint64_t VPCostContext::getPredBlockCostDivisor ( BasicBlock * BB) const
Returns
how much the cost of a predicated block should be divided by. Forwards to LoopVectorizationCostModel::getPredBlockCostDivisor.

Definition at line 5796 of file LoopVectorize.cpp.

References CM, and CostKind.

◆ getScalarizationOverhead()

InstructionCost VPCostContext::getScalarizationOverhead ( Type * ResultTy,
ArrayRef< const VPValue * > Operands,
ElementCount VF,
TTI::VectorInstrContext VIC = TTI::VectorInstrContext::None,
bool AlwaysIncludeReplicatingR = false )

Estimate the overhead of scalarizing a recipe with result type ResultTy and Operands with VF.

This is a convenience wrapper for the type-based getScalarizationOverhead API. VIC provides context about whether the scalarization is for a load/store operation. If AlwaysIncludeReplicatingR is true, always compute the cost of scalarizing replicating operands.

Definition at line 1867 of file VPlan.cpp.

References assert(), llvm::cast(), CostKind, llvm::APInt::getAllOnes(), llvm::getContainedTypes(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::ElementCount::isScalar(), llvm::Type::isVoidTy(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::to_vector(), llvm::toVectorizedTy(), TTI, and Types.

◆ isFreeScalarIntrinsic()

bool VPCostContext::isFreeScalarIntrinsic ( Intrinsic::ID ID)
static

Returns true if ID is a pseudo intrinsic that is dropped via scalarization rather than widened.

Definition at line 1945 of file VPlan.cpp.

References llvm::is_contained().

Referenced by llvm::VPReplicateRecipe::computeCallCost(), decideCallWidening(), and llvm::VPlanTransforms::makeCallWideningDecisions().

◆ isMaskRequired()

bool VPCostContext::isMaskRequired ( Instruction * I) const

Forwards to LoopVectorizationCostModel::isMaskRequired.

Definition at line 5806 of file LoopVectorize.cpp.

References CM, and I.

Referenced by decideCallWidening().

◆ skipCostComputation()

bool VPCostContext::skipCostComputation ( Instruction * UI,
bool IsVector ) const

Return true if the cost for UI shouldn't be computed, e.g.

because it has already been pre-computed.

Definition at line 5790 of file LoopVectorize.cpp.

References CM, and SkipCostComputation.

◆ useEmulatedMaskMemRefHack()

bool VPCostContext::useEmulatedMaskMemRefHack ( const VPReplicateRecipe * R,
ElementCount VF )

◆ willBeScalarized()

bool VPCostContext::willBeScalarized ( Instruction * I,
ElementCount VF ) const

Returns true if I is known to be scalarized at VF.

Definition at line 5800 of file LoopVectorize.cpp.

References CM, I, and llvm::ElementCount::isVector().

Referenced by decideCallWidening().

Member Data Documentation

◆ CM

◆ CostKind

TargetTransformInfo::TargetCostKind llvm::VPCostContext::CostKind

◆ L

const Loop* llvm::VPCostContext::L

Definition at line 337 of file VPlanHelpers.h.

Referenced by decideCallWidening(), and VPCostContext().

◆ LLVMCtx

LLVMContext& llvm::VPCostContext::LLVMCtx

Definition at line 332 of file VPlanHelpers.h.

Referenced by VPCostContext().

◆ NumPredStores

std::optional<unsigned> llvm::VPCostContext::NumPredStores

Number of predicated stores in the VPlan, computed on demand.

Definition at line 340 of file VPlanHelpers.h.

Referenced by useEmulatedMaskMemRefHack().

◆ PSE

PredicatedScalarEvolution& llvm::VPCostContext::PSE

Definition at line 336 of file VPlanHelpers.h.

Referenced by decideCallWidening(), and VPCostContext().

◆ SkipCostComputation

SmallPtrSet<Instruction *, 8> llvm::VPCostContext::SkipCostComputation

Definition at line 334 of file VPlanHelpers.h.

Referenced by skipCostComputation().

◆ TLI

const TargetLibraryInfo& llvm::VPCostContext::TLI

◆ TTI

const TargetTransformInfo& llvm::VPCostContext::TTI

◆ Types


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