LLVM 20.0.0git
Public Member Functions | Protected Member Functions | List of all members
llvm::EpilogueVectorizerEpilogueLoop Class Reference
Inheritance diagram for llvm::EpilogueVectorizerEpilogueLoop:
Inheritance graph
[legend]

Public Member Functions

 EpilogueVectorizerEpilogueLoop (Loop *OrigLoop, PredicatedScalarEvolution &PSE, LoopInfo *LI, DominatorTree *DT, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, AssumptionCache *AC, OptimizationRemarkEmitter *ORE, EpilogueLoopVectorizationInfo &EPI, LoopVectorizationLegality *LVL, llvm::LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, GeneratedRTChecks &Checks, VPlan &Plan)
 
BasicBlockcreateEpilogueVectorizedLoopSkeleton (const SCEV2ValueTy &ExpandedSCEVs) final
 Implements the interface for creating a vectorized skeleton using the epilogue loop strategy (ie the second pass of vplan execution).
 
- Public Member Functions inherited from llvm::InnerLoopAndEpilogueVectorizer
 InnerLoopAndEpilogueVectorizer (Loop *OrigLoop, PredicatedScalarEvolution &PSE, LoopInfo *LI, DominatorTree *DT, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, AssumptionCache *AC, OptimizationRemarkEmitter *ORE, EpilogueLoopVectorizationInfo &EPI, LoopVectorizationLegality *LVL, llvm::LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, GeneratedRTChecks &Checks, VPlan &Plan)
 
BasicBlockcreateVectorizedLoopSkeleton (const SCEV2ValueTy &ExpandedSCEVs) final
 Create a new empty loop that will contain vectorized instructions later on, while the old loop will be used as the scalar remainder.
 
virtual BasicBlockcreateEpilogueVectorizedLoopSkeleton (const SCEV2ValueTy &ExpandedSCEVs)=0
 The interface for creating a vectorized skeleton using one of two different strategies, each corresponding to one execution of the vplan as described above.
 
- Public Member Functions inherited from llvm::InnerLoopVectorizer
 InnerLoopVectorizer (Loop *OrigLoop, PredicatedScalarEvolution &PSE, LoopInfo *LI, DominatorTree *DT, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, AssumptionCache *AC, OptimizationRemarkEmitter *ORE, ElementCount VecWidth, ElementCount MinProfitableTripCount, unsigned UnrollFactor, LoopVectorizationLegality *LVL, LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, GeneratedRTChecks &RTChecks, VPlan &Plan)
 
virtual ~InnerLoopVectorizer ()=default
 
virtual BasicBlockcreateVectorizedLoopSkeleton (const SCEV2ValueTy &ExpandedSCEVs)
 Create a new empty loop that will contain vectorized instructions later on, while the old loop will be used as the scalar remainder.
 
void fixVectorizedLoop (VPTransformState &State)
 Fix the vectorized code, taking care of header phi's, and more.
 
bool areSafetyChecksAdded ()
 
void scalarizeInstruction (const Instruction *Instr, VPReplicateRecipe *RepRecipe, const VPLane &Lane, VPTransformState &State)
 A helper function to scalarize a single Instruction in the innermost loop.
 
void fixNonInductionPHIs (VPTransformState &State)
 Fix the non-induction PHIs in Plan.
 
void createInductionResumeVPValue (VPIRInstruction *InductionPhiIRI, const InductionDescriptor &ID, Value *Step, ArrayRef< BasicBlock * > BypassBlocks, VPBuilder &ScalarPHBuilder, Value *MainVectorTripCount=nullptr)
 Create a ResumePHI VPInstruction for the induction InductionPhiIRI to resume iteration count in the scalar epilogue from where the vectorized loop left off, and add it to the scalar preheader of VPlan.
 
ValuegetTripCount () const
 Returns the original loop trip count.
 
void setTripCount (Value *TC)
 Used to set the trip count after ILV's construction and after the preheader block has been executed.
 
ValuegetInductionAdditionalBypassValue (PHINode *OrigPhi) const
 induction header phi.
 
BasicBlockgetAdditionalBypassBlock () const
 Return the additional bypass block which targets the scalar loop by skipping the epilogue loop after completing the main loop.
 

Protected Member Functions

BasicBlockemitMinimumVectorEpilogueIterCountCheck (BasicBlock *Bypass, BasicBlock *Insert)
 Emits an iteration count bypass check after the main vector loop has finished to see if there are any iterations left to execute by either the vector epilogue or the scalar epilogue.
 
void printDebugTracesAtStart () override
 Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested.
 
void printDebugTracesAtEnd () override
 
- Protected Member Functions inherited from llvm::InnerLoopVectorizer
virtual void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II, Value *VectorTripCount, BasicBlock *MiddleBlock, VPTransformState &State)
 Set up the values of the IVs correctly when exiting the vector loop.
 
void sinkScalarOperands (Instruction *PredInst)
 Iteratively sink the scalarized operands of a predicated instruction into the block that was created for it.
 
ValuegetOrCreateVectorTripCount (BasicBlock *InsertBlock)
 Returns (and creates if needed) the trip count of the widened loop.
 
void emitIterationCountCheck (BasicBlock *Bypass)
 Emit a bypass check to see if the vector trip count is zero, including if it overflows.
 
BasicBlockemitSCEVChecks (BasicBlock *Bypass)
 Emit a bypass check to see if all of the SCEV assumptions we've had to make are correct.
 
BasicBlockemitMemRuntimeChecks (BasicBlock *Bypass)
 Emit bypass checks to check any memory assumptions we may have made.
 
void createVectorLoopSkeleton (StringRef Prefix)
 Emit basic blocks (prefixed with Prefix) for the iteration check, vector loop preheader, middle block and scalar preheader.
 
void createInductionResumeVPValues (const SCEV2ValueTy &ExpandedSCEVs, Value *MainVectorTripCount=nullptr, SmallPtrSetImpl< PHINode * > *IVSubset=nullptr)
 Create new phi nodes for the induction variables to resume iteration count in the scalar epilogue, from where the vectorized loop left off.
 
virtual void printDebugTracesAtStart ()
 Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested.
 
virtual void printDebugTracesAtEnd ()
 

Additional Inherited Members

- Public Attributes inherited from llvm::InnerLoopAndEpilogueVectorizer
EpilogueLoopVectorizationInfoEPI
 Holds and updates state information required to vectorize the main loop and its epilogue in two separate passes.
 
- Protected Attributes inherited from llvm::InnerLoopVectorizer
LoopOrigLoop
 The original loop.
 
PredicatedScalarEvolutionPSE
 A wrapper around ScalarEvolution used to add runtime SCEV checks.
 
LoopInfoLI
 Loop Info.
 
DominatorTreeDT
 Dominator Tree.
 
const TargetLibraryInfoTLI
 Target Library Info.
 
const TargetTransformInfoTTI
 Target Transform Info.
 
AssumptionCacheAC
 Assumption Cache.
 
OptimizationRemarkEmitterORE
 Interface to emit optimization remarks.
 
ElementCount VF
 The vectorization SIMD factor to use.
 
ElementCount MinProfitableTripCount
 
unsigned UF
 The vectorization unroll factor to use.
 
IRBuilder Builder
 The builder that we use.
 
BasicBlockLoopVectorPreHeader
 The vector-loop preheader.
 
BasicBlockLoopScalarPreHeader
 The scalar-loop preheader.
 
BasicBlockLoopMiddleBlock
 Middle Block between the vector and the scalar.
 
SmallVector< BasicBlock *, 4 > LoopBypassBlocks
 A list of all bypass blocks. The first block is the entry of the loop.
 
SmallVector< Instruction *, 4 > PredicatedInstructions
 Store instructions that were predicated.
 
ValueTripCount = nullptr
 Trip count of the original loop.
 
ValueVectorTripCount = nullptr
 Trip count of the widened loop (TripCount - TripCount % (VF*UF))
 
LoopVectorizationLegalityLegal
 The legality analysis.
 
LoopVectorizationCostModelCost
 The profitablity analysis.
 
bool AddedSafetyChecks = false
 
BlockFrequencyInfoBFI
 BFI and PSI are used to check for profile guided size optimizations.
 
ProfileSummaryInfoPSI
 
bool OptForSizeBasedOnProfile
 
GeneratedRTChecks & RTChecks
 Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable.
 
DenseMap< PHINode *, Value * > Induction2AdditionalBypassValue
 Mapping of induction phis to their additional bypass values.
 
BasicBlockAdditionalBypassBlock = nullptr
 The additional bypass block which conditionally skips over the epilogue loop after executing the main loop.
 
VPlanPlan
 

Detailed Description

Definition at line 810 of file LoopVectorize.cpp.

Constructor & Destructor Documentation

◆ EpilogueVectorizerEpilogueLoop()

llvm::EpilogueVectorizerEpilogueLoop::EpilogueVectorizerEpilogueLoop ( Loop OrigLoop,
PredicatedScalarEvolution PSE,
LoopInfo LI,
DominatorTree DT,
const TargetLibraryInfo TLI,
const TargetTransformInfo TTI,
AssumptionCache AC,
OptimizationRemarkEmitter ORE,
EpilogueLoopVectorizationInfo EPI,
LoopVectorizationLegality LVL,
llvm::LoopVectorizationCostModel CM,
BlockFrequencyInfo BFI,
ProfileSummaryInfo PSI,
GeneratedRTChecks &  Checks,
VPlan Plan 
)
inline

Member Function Documentation

◆ createEpilogueVectorizedLoopSkeleton()

BasicBlock * EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton ( const SCEV2ValueTy &  ExpandedSCEVs)
finalvirtual

Implements the interface for creating a vectorized skeleton using the epilogue loop strategy (ie the second pass of vplan execution).

This function is partially responsible for generating the control flow depicted in https://llvm.org/docs/Vectorizers.html#epilogue-vectorization.

Implements llvm::InnerLoopAndEpilogueVectorizer.

Definition at line 8062 of file LoopVectorize.cpp.

References llvm::InnerLoopVectorizer::AdditionalBypassBlock, assert(), llvm::BasicBlock::begin(), llvm::DominatorTreeBase< NodeT, IsPostDom >::changeImmediateDominator(), llvm::InnerLoopVectorizer::createInductionResumeVPValues(), llvm::InnerLoopVectorizer::createVectorLoopSkeleton(), llvm::InnerLoopVectorizer::DT, emitMinimumVectorEpilogueIterCountCheck(), llvm::InnerLoopAndEpilogueVectorizer::EPI, llvm::EpilogueLoopVectorizationInfo::EpilogueIterationCountCheck, llvm::BasicBlock::getFirstNonPHI(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::InnerLoopVectorizer::LI, llvm::InnerLoopVectorizer::LoopBypassBlocks, llvm::InnerLoopVectorizer::LoopScalarPreHeader, llvm::InnerLoopVectorizer::LoopVectorPreHeader, llvm::EpilogueLoopVectorizationInfo::MainLoopIterationCountCheck, llvm::EpilogueLoopVectorizationInfo::MemSafetyCheck, llvm::none_of(), llvm::BasicBlock::phis(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::User::replaceUsesOfWith(), llvm::EpilogueLoopVectorizationInfo::SCEVSafetyCheck, llvm::Value::setName(), llvm::SplitBlock(), and llvm::EpilogueLoopVectorizationInfo::VectorTripCount.

◆ emitMinimumVectorEpilogueIterCountCheck()

BasicBlock * EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck ( BasicBlock Bypass,
BasicBlock Insert 
)
protected

Emits an iteration count bypass check after the main vector loop has finished to see if there are any iterations left to execute by either the vector epilogue or the scalar epilogue.

Definition at line 8143 of file LoopVectorize.cpp.

References assert(), llvm::InnerLoopVectorizer::Builder, llvm::BranchInst::Create(), llvm::IRBuilderBase::CreateICmp(), llvm::createStepForVF(), llvm::IRBuilderBase::CreateSub(), llvm::DominatorTree::dominates(), llvm::InnerLoopVectorizer::DT, llvm::InnerLoopAndEpilogueVectorizer::EPI, llvm::EpilogueLoopVectorizationInfo::EpilogueUF, llvm::EpilogueLoopVectorizationInfo::EpilogueVF, llvm::VPIRBasicBlock::fromBasicBlock(), llvm::VPlan::getEntry(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::hasBranchWeightMD(), llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, introduceCheckBlockInVPlan(), llvm::ElementCount::isVector(), llvm::InnerLoopVectorizer::LoopBypassBlocks, llvm::InnerLoopVectorizer::LoopVectorPreHeader, llvm::InnerLoopVectorizer::OrigLoop, P, llvm::InnerLoopVectorizer::Plan, llvm::VPBlockUtils::reassociateBlocks(), llvm::ReplaceInstWithInst(), llvm::setBranchWeights(), llvm::VPlan::setEntry(), llvm::EpilogueLoopVectorizationInfo::TripCount, llvm::InnerLoopVectorizer::UF, llvm::EpilogueLoopVectorizationInfo::VectorTripCount, and llvm::InnerLoopVectorizer::VF.

Referenced by createEpilogueVectorizedLoopSkeleton().

◆ printDebugTracesAtEnd()

void EpilogueVectorizerEpilogueLoop::printDebugTracesAtEnd ( )
overrideprotectedvirtual

◆ printDebugTracesAtStart()

void EpilogueVectorizerEpilogueLoop::printDebugTracesAtStart ( )
overrideprotectedvirtual

Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested.

Reimplemented from llvm::InnerLoopVectorizer.

Definition at line 8198 of file LoopVectorize.cpp.

References llvm::dbgs(), llvm::InnerLoopAndEpilogueVectorizer::EPI, llvm::EpilogueLoopVectorizationInfo::EpilogueUF, llvm::EpilogueLoopVectorizationInfo::EpilogueVF, and LLVM_DEBUG.


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