LLVM 18.0.0git
|
VPTransformState holds information passed down when "executing" a VPlan, needed for generating the output IR. More...
#include "Transforms/Vectorize/VPlan.h"
Classes | |
struct | CFGState |
Hold state information used when constructing the CFG of the output IR, traversing the VPBasicBlocks and generating corresponding IR BasicBlocks. More... | |
struct | DataState |
Public Member Functions | |
VPTransformState (ElementCount VF, unsigned UF, LoopInfo *LI, DominatorTree *DT, IRBuilderBase &Builder, InnerLoopVectorizer *ILV, VPlan *Plan, LLVMContext &Ctx) | |
Value * | get (VPValue *Def, unsigned Part) |
Get the generated Value for a given VPValue and a given Part. | |
Value * | get (VPValue *Def, const VPIteration &Instance) |
Get the generated Value for a given VPValue and given Part and Lane. | |
bool | hasVectorValue (VPValue *Def, unsigned Part) |
bool | hasScalarValue (VPValue *Def, VPIteration Instance) |
void | set (VPValue *Def, Value *V, unsigned Part) |
Set the generated Value for a given VPValue and a given Part. | |
void | reset (VPValue *Def, Value *V, unsigned Part) |
Reset an existing vector value for Def and a given Part . | |
void | set (VPValue *Def, Value *V, const VPIteration &Instance) |
Set the generated scalar V for Def and the given Instance . | |
void | reset (VPValue *Def, Value *V, const VPIteration &Instance) |
Reset an existing scalar value for Def and a given Instance . | |
void | addNewMetadata (Instruction *To, const Instruction *Orig) |
Add additional metadata to To that was not present on Orig . | |
void | addMetadata (Instruction *To, Instruction *From) |
Add metadata from one instruction to another. | |
void | addMetadata (ArrayRef< Value * > To, Instruction *From) |
Similar to the previous function but it adds the metadata to a vector of instructions. | |
void | setDebugLocFrom (DebugLoc DL) |
Set the debug location in the builder using the debug location DL . | |
void | packScalarIntoVectorValue (VPValue *Def, const VPIteration &Instance) |
Construct the vector value of a scalarized value V one lane at a time. | |
Public Attributes | |
ElementCount | VF |
The chosen Vectorization and Unroll Factors of the loop being vectorized. | |
unsigned | UF |
std::optional< VPIteration > | Instance |
Hold the indices to generate specific scalar instructions. | |
struct llvm::VPTransformState::DataState | Data |
struct llvm::VPTransformState::CFGState | CFG |
LoopInfo * | LI |
Hold a pointer to LoopInfo to register new basic blocks in the loop. | |
DominatorTree * | DT |
Hold a pointer to Dominator Tree to register new basic blocks in the loop. | |
IRBuilderBase & | Builder |
Hold a reference to the IRBuilder used to generate output IR code. | |
VPValue2ValueTy | VPValue2Value |
Value * | CanonicalIV = nullptr |
Hold the canonical scalar IV of the vector loop (start=0, step=VF*UF). | |
InnerLoopVectorizer * | ILV |
Hold a pointer to InnerLoopVectorizer to reuse its IR generation methods. | |
VPlan * | Plan |
Pointer to the VPlan code is generated for. | |
Loop * | CurrentVectorLoop = nullptr |
The loop object for the current parent region, or nullptr. | |
LoopVersioning * | LVer = nullptr |
LoopVersioning. | |
DenseMap< const SCEV *, Value * > | ExpandedSCEVs |
Map SCEVs to their expanded values. | |
VPTypeAnalysis | TypeAnalysis |
VPlan-based type analysis. | |
VPTransformState holds information passed down when "executing" a VPlan, needed for generating the output IR.
|
inline |
void VPTransformState::addMetadata | ( | ArrayRef< Value * > | To, |
Instruction * | From | ||
) |
Similar to the previous function but it adds the metadata to a vector of instructions.
Definition at line 351 of file VPlan.cpp.
References addMetadata(), From, and I.
void VPTransformState::addMetadata | ( | Instruction * | To, |
Instruction * | From | ||
) |
Add metadata from one instruction to another.
This includes both the original MDs from From
and additional ones (
Definition at line 342 of file VPlan.cpp.
References addNewMetadata(), From, and llvm::propagateMetadata().
Referenced by addMetadata(), llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), and llvm::VPWidenMemoryInstructionRecipe::execute().
void VPTransformState::addNewMetadata | ( | Instruction * | To, |
const Instruction * | Orig | ||
) |
Add additional metadata to To
that was not present on Orig
.
Currently this is used to add the noalias annotations based on the inserted memchecks. Use this for instructions that are cloned into the vector loop.
Definition at line 334 of file VPlan.cpp.
References llvm::LoopVersioning::annotateInstWithNoAlias(), and LVer.
Referenced by addMetadata(), and llvm::InnerLoopVectorizer::scalarizeInstruction().
Value * VPTransformState::get | ( | VPValue * | Def, |
const VPIteration & | Instance | ||
) |
Get the generated Value for a given VPValue and given Part and Lane.
Definition at line 215 of file VPlan.cpp.
References assert(), Builder, llvm::IRBuilderBase::CreateExtractElement(), Data, hasScalarValue(), hasVectorValue(), Instance, llvm::VPTransformState::DataState::PerPartOutput, llvm::VPTransformState::DataState::PerPartScalars, and VF.
Get the generated Value for a given VPValue and a given Part.
Note that as some Defs are still created by ILV and managed in its ValueMap, this method will delegate the call to ILV in such cases in order to provide callers a consistent API.
Definition at line 237 of file VPlan.cpp.
References assert(), B, Builder, CFG, llvm::IRBuilderBase::CreateVectorSplat(), Data, llvm::VectorType::get(), llvm::PoisonValue::get(), get(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::VPBlockBase::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::VPlan::getVectorLoopRegion(), hasScalarValue(), hasVectorValue(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::ElementCount::isScalar(), llvm::vputils::isUniformAfterVectorization(), packScalarIntoVectorValue(), llvm::VPTransformState::DataState::PerPartOutput, Plan, llvm::IRBuilderBase::restoreIP(), llvm::IRBuilderBase::saveIP(), set(), llvm::IRBuilderBase::SetInsertPoint(), VF, and llvm::VPTransformState::CFGState::VPBB2IRBB.
Referenced by llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPWidenPHIRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPBlendRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPReplicateRecipe::execute(), llvm::VPBranchOnMaskRecipe::execute(), llvm::VPPredInstPHIRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::VPActiveLaneMaskPHIRecipe::execute(), llvm::VPWidenCanonicalIVRecipe::execute(), llvm::VPDerivedIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), llvm::VPlan::execute(), llvm::LoopVectorizationPlanner::executePlan(), llvm::InnerLoopVectorizer::fixFixedOrderRecurrence(), llvm::InnerLoopVectorizer::fixNonInductionPHIs(), llvm::VPLiveOut::fixPhi(), llvm::InnerLoopVectorizer::fixReduction(), llvm::InnerLoopVectorizer::fixupIVUsers(), get(), packScalarIntoVectorValue(), llvm::InnerLoopVectorizer::scalarizeInstruction(), and llvm::InnerLoopVectorizer::vectorizeInterleaveGroup().
|
inline |
Definition at line 278 of file VPlan.h.
References Data, I, Instance, llvm::VPTransformState::DataState::PerPartScalars, and VF.
Referenced by llvm::VPPredInstPHIRecipe::execute(), and get().
Definition at line 272 of file VPlan.h.
References Data, I, and llvm::VPTransformState::DataState::PerPartOutput.
Referenced by llvm::VPPredInstPHIRecipe::execute(), and get().
void VPTransformState::packScalarIntoVectorValue | ( | VPValue * | Def, |
const VPIteration & | Instance | ||
) |
Construct the vector value of a scalarized value V
one lane at a time.
Definition at line 383 of file VPlan.cpp.
References Builder, llvm::IRBuilderBase::CreateInsertElement(), get(), Instance, set(), and VF.
Referenced by llvm::VPReplicateRecipe::execute(), and get().
|
inline |
Reset an existing vector value for Def
and a given Part
.
Definition at line 297 of file VPlan.h.
References assert(), Data, and llvm::VPTransformState::DataState::PerPartOutput.
Referenced by llvm::VPPredInstPHIRecipe::execute().
|
inline |
Set the generated Value for a given VPValue and a given Part.
Definition at line 289 of file VPlan.h.
References Data, llvm::VPTransformState::DataState::PerPartOutput, and UF.
Referenced by llvm::VPInstruction::execute(), llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPWidenPHIRecipe::execute(), llvm::VPFirstOrderRecurrencePHIRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPBlendRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPReplicateRecipe::execute(), llvm::VPPredInstPHIRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::VPCanonicalIVPHIRecipe::execute(), llvm::VPActiveLaneMaskPHIRecipe::execute(), llvm::VPWidenCanonicalIVRecipe::execute(), llvm::VPDerivedIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), get(), packScalarIntoVectorValue(), llvm::VPlan::prepareToExecute(), llvm::InnerLoopVectorizer::scalarizeInstruction(), and llvm::InnerLoopVectorizer::vectorizeInterleaveGroup().
void VPTransformState::setDebugLocFrom | ( | DebugLoc | DL | ) |
Set the debug location in the builder using the debug location DL
.
Definition at line 362 of file VPlan.cpp.
References Builder, llvm::DILocation::cloneByMultiplyingDuplicationFactor(), llvm::dbgs(), DL, llvm::EnableFSDiscriminator, llvm::IRBuilderBase::GetInsertBlock(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::BasicBlock::getParent(), LLVM_DEBUG, llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::Function::shouldEmitDebugInfoForProfiling(), UF, and VF.
Referenced by llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPBlendRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::InnerLoopVectorizer::fixReduction(), llvm::InnerLoopVectorizer::scalarizeInstruction(), and llvm::InnerLoopVectorizer::vectorizeInterleaveGroup().
IRBuilderBase& llvm::VPTransformState::Builder |
Hold a reference to the IRBuilder used to generate output IR code.
Definition at line 387 of file VPlan.h.
Referenced by llvm::VPInstruction::execute(), llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPWidenPHIRecipe::execute(), llvm::VPFirstOrderRecurrencePHIRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPBlendRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPBranchOnMaskRecipe::execute(), llvm::VPPredInstPHIRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::VPActiveLaneMaskPHIRecipe::execute(), llvm::VPDerivedIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), llvm::VPlan::execute(), llvm::VPBasicBlock::execute(), llvm::LoopVectorizationPlanner::executePlan(), llvm::InnerLoopVectorizer::fixVectorizedLoop(), get(), packScalarIntoVectorValue(), llvm::VPlan::prepareToExecute(), llvm::InnerLoopVectorizer::scalarizeInstruction(), and setDebugLocFrom().
Value* llvm::VPTransformState::CanonicalIV = nullptr |
struct llvm::VPTransformState::CFGState llvm::VPTransformState::CFG |
Referenced by llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPFirstOrderRecurrencePHIRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPBranchOnMaskRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::VPCanonicalIVPHIRecipe::execute(), llvm::VPActiveLaneMaskPHIRecipe::execute(), llvm::VPWidenCanonicalIVRecipe::execute(), llvm::VPlan::execute(), llvm::VPBasicBlock::execute(), llvm::VPRegionBlock::execute(), llvm::LoopVectorizationPlanner::executePlan(), llvm::InnerLoopVectorizer::fixNonInductionPHIs(), llvm::VPLiveOut::fixPhi(), llvm::InnerLoopVectorizer::fixVectorizedLoop(), get(), and llvm::VPlan::prepareToExecute().
Loop* llvm::VPTransformState::CurrentVectorLoop = nullptr |
The loop object for the current parent region, or nullptr.
Definition at line 401 of file VPlan.h.
Referenced by llvm::VPReductionPHIRecipe::execute(), llvm::VPBasicBlock::execute(), and llvm::VPRegionBlock::execute().
struct llvm::VPTransformState::DataState llvm::VPTransformState::Data |
Referenced by get(), hasScalarValue(), hasVectorValue(), reset(), and set().
DominatorTree* llvm::VPTransformState::DT |
Hold a pointer to Dominator Tree to register new basic blocks in the loop.
Definition at line 384 of file VPlan.h.
Referenced by llvm::VPlan::execute().
Map SCEVs to their expanded values.
Populated when executing VPExpandSCEVRecipes.
Definition at line 412 of file VPlan.h.
Referenced by llvm::VPExpandSCEVRecipe::execute(), and llvm::LoopVectorizationPlanner::executePlan().
InnerLoopVectorizer* llvm::VPTransformState::ILV |
Hold a pointer to InnerLoopVectorizer to reuse its IR generation methods.
Definition at line 395 of file VPlan.h.
Referenced by llvm::VPInterleaveRecipe::execute(), llvm::VPReductionRecipe::execute(), and llvm::VPReplicateRecipe::execute().
std::optional<VPIteration> llvm::VPTransformState::Instance |
Hold the indices to generate specific scalar instructions.
Null indicates that all instances are to be generated, using either scalar or vector instructions.
Definition at line 248 of file VPlan.h.
Referenced by llvm::VPInstruction::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPInterleaveRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPReplicateRecipe::execute(), llvm::VPBranchOnMaskRecipe::execute(), llvm::VPPredInstPHIRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::VPDerivedIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), llvm::VPBasicBlock::execute(), llvm::VPRegionBlock::execute(), get(), hasScalarValue(), packScalarIntoVectorValue(), reset(), and set().
LoopInfo* llvm::VPTransformState::LI |
Hold a pointer to LoopInfo to register new basic blocks in the loop.
Definition at line 381 of file VPlan.h.
Referenced by llvm::VPBasicBlock::execute(), and llvm::VPRegionBlock::execute().
LoopVersioning* llvm::VPTransformState::LVer = nullptr |
It's only set up (non-null) if memchecks were used.
This is currently only used to add no-alias metadata based on the memchecks. The actually versioning is performed manually.
Definition at line 408 of file VPlan.h.
Referenced by addNewMetadata(), and llvm::LoopVectorizationPlanner::executePlan().
VPlan* llvm::VPTransformState::Plan |
Pointer to the VPlan code is generated for.
Definition at line 398 of file VPlan.h.
Referenced by llvm::VPlan::createInitialVPlan(), llvm::VPlanPrinter::dump(), llvm::InnerLoopVectorizer::fixCrossIterationPHIs(), llvm::InnerLoopVectorizer::fixFixedOrderRecurrence(), llvm::InnerLoopVectorizer::fixReduction(), get(), llvm::vputils::getOrCreateVPValueForSCEVExpr(), and llvm::VPInterleavedAccessInfo::VPInterleavedAccessInfo().
VPTypeAnalysis llvm::VPTransformState::TypeAnalysis |
VPlan-based type analysis.
Definition at line 415 of file VPlan.h.
Referenced by llvm::VPWidenRecipe::execute(), and llvm::InnerLoopVectorizer::scalarizeInstruction().
unsigned llvm::VPTransformState::UF |
Definition at line 243 of file VPlan.h.
Referenced by llvm::VPInstruction::execute(), llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenSelectRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPBlendRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPReplicateRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::VPExpandSCEVRecipe::execute(), llvm::VPCanonicalIVPHIRecipe::execute(), llvm::VPActiveLaneMaskPHIRecipe::execute(), llvm::VPWidenCanonicalIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), llvm::VPlan::execute(), llvm::VPRegionBlock::execute(), llvm::VPLiveOut::fixPhi(), llvm::VPlan::getName(), llvm::VPlan::prepareToExecute(), set(), and setDebugLocFrom().
ElementCount llvm::VPTransformState::VF |
The chosen Vectorization and Unroll Factors of the loop being vectorized.
Definition at line 242 of file VPlan.h.
Referenced by llvm::VPWidenRecipe::execute(), llvm::VPWidenCastRecipe::execute(), llvm::VPWidenCallRecipe::execute(), llvm::VPWidenGEPRecipe::execute(), llvm::VPWidenIntOrFpInductionRecipe::execute(), llvm::VPWidenPointerInductionRecipe::execute(), llvm::VPFirstOrderRecurrencePHIRecipe::execute(), llvm::VPReductionPHIRecipe::execute(), llvm::VPReductionRecipe::execute(), llvm::VPReplicateRecipe::execute(), llvm::VPWidenMemoryInstructionRecipe::execute(), llvm::VPWidenCanonicalIVRecipe::execute(), llvm::VPScalarIVStepsRecipe::execute(), llvm::VPlan::execute(), llvm::VPRegionBlock::execute(), llvm::VPLiveOut::fixPhi(), get(), llvm::VPlan::getName(), hasScalarValue(), packScalarIntoVectorValue(), llvm::VPlan::prepareToExecute(), reset(), set(), and setDebugLocFrom().
VPValue2ValueTy llvm::VPTransformState::VPValue2Value |
Definition at line 389 of file VPlan.h.
Referenced by llvm::VPlan::execute().