LLVM 22.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::InnerLoopVectorizer Class Reference

InnerLoopVectorizer vectorizes loops which contain only one basic block to a specified vectorization factor (VF). More...

Inheritance diagram for llvm::InnerLoopVectorizer:
[legend]

Public Member Functions

 InnerLoopVectorizer (Loop *OrigLoop, PredicatedScalarEvolution &PSE, LoopInfo *LI, DominatorTree *DT, const TargetTransformInfo *TTI, AssumptionCache *AC, ElementCount VecWidth, unsigned UnrollFactor, LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, GeneratedRTChecks &RTChecks, VPlan &Plan)
 
virtual ~InnerLoopVectorizer ()=default
 
virtual BasicBlockcreateVectorizedLoopSkeleton ()
 Creates a basic block for the scalar preheader.
 
void fixVectorizedLoop (VPTransformState &State)
 Fix the vectorized code, taking care of header phi's, and more.
 
void fixNonInductionPHIs (VPTransformState &State)
 Fix the non-induction PHIs in Plan.
 
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.
 
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

BasicBlockcreateScalarPreheader (StringRef Prefix)
 Create and return a new IR basic block for the scalar preheader whose name is prefixed with Prefix.
 
virtual void printDebugTracesAtStart ()
 Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested.
 
virtual void printDebugTracesAtEnd ()
 

Protected Attributes

LoopOrigLoop
 The original loop.
 
PredicatedScalarEvolutionPSE
 A wrapper around ScalarEvolution used to add runtime SCEV checks.
 
LoopInfoLI
 Loop Info.
 
DominatorTreeDT
 Dominator Tree.
 
const TargetTransformInfoTTI
 Target Transform Info.
 
AssumptionCacheAC
 Assumption Cache.
 
ElementCount VF
 The vectorization SIMD factor to use.
 
unsigned UF
 The vectorization unroll factor to use.
 
IRBuilder Builder
 The builder that we use.
 
BasicBlockLoopVectorPreHeader = nullptr
 The vector-loop preheader.
 
ValueTripCount = nullptr
 Trip count of the original loop.
 
LoopVectorizationCostModelCost
 The profitablity analysis.
 
BlockFrequencyInfoBFI
 BFI and PSI are used to check for profile guided size optimizations.
 
ProfileSummaryInfoPSI
 
GeneratedRTChecks & RTChecks
 Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable.
 
BasicBlockAdditionalBypassBlock = nullptr
 The additional bypass block which conditionally skips over the epilogue loop after executing the main loop.
 
VPlanPlan
 
VPBasicBlockVectorPHVPBB
 The vector preheader block of Plan, used as target for check blocks introduced during skeleton creation.
 

Friends

class LoopVectorizationPlanner
 

Detailed Description

InnerLoopVectorizer vectorizes loops which contain only one basic block to a specified vectorization factor (VF).

This class performs the widening of scalars into vectors, or multiple scalars. This class also implements the following features:

Definition at line 498 of file LoopVectorize.cpp.

Constructor & Destructor Documentation

◆ InnerLoopVectorizer()

llvm::InnerLoopVectorizer::InnerLoopVectorizer ( Loop OrigLoop,
PredicatedScalarEvolution PSE,
LoopInfo LI,
DominatorTree DT,
const TargetTransformInfo TTI,
AssumptionCache AC,
ElementCount  VecWidth,
unsigned  UnrollFactor,
LoopVectorizationCostModel CM,
BlockFrequencyInfo BFI,
ProfileSummaryInfo PSI,
GeneratedRTChecks &  RTChecks,
VPlan Plan 
)
inline

Definition at line 500 of file LoopVectorize.cpp.

◆ ~InnerLoopVectorizer()

virtual llvm::InnerLoopVectorizer::~InnerLoopVectorizer ( )
virtualdefault

Member Function Documentation

◆ createScalarPreheader()

BasicBlock * InnerLoopVectorizer::createScalarPreheader ( StringRef  Prefix)
protected

◆ createVectorizedLoopSkeleton()

BasicBlock * InnerLoopVectorizer::createVectorizedLoopSkeleton ( )
virtual

Creates a basic block for the scalar preheader.

Both EpilogueVectorizerMainLoop and EpilogueVectorizerEpilogueLoop overwrite the method to create additional blocks and checks needed for epilogue vectorization.

Reimplemented in llvm::EpilogueVectorizerMainLoop, and llvm::EpilogueVectorizerEpilogueLoop.

Definition at line 2423 of file LoopVectorize.cpp.

References createScalarPreheader(), and llvm::BasicBlock::getSinglePredecessor().

Referenced by llvm::LoopVectorizationPlanner::executePlan().

◆ fixNonInductionPHIs()

void InnerLoopVectorizer::fixNonInductionPHIs ( VPTransformState State)

◆ fixVectorizedLoop()

void InnerLoopVectorizer::fixVectorizedLoop ( VPTransformState State)

◆ getAdditionalBypassBlock()

BasicBlock * llvm::InnerLoopVectorizer::getAdditionalBypassBlock ( ) const
inline

Return the additional bypass block which targets the scalar loop by skipping the epilogue loop after completing the main loop.

Definition at line 537 of file LoopVectorize.cpp.

References AdditionalBypassBlock, and assert().

Referenced by llvm::LoopVectorizationPlanner::executePlan(), and llvm::LoopVectorizePass::processLoop().

◆ getTripCount()

Value * llvm::InnerLoopVectorizer::getTripCount ( ) const
inline

◆ printDebugTracesAtEnd()

virtual void llvm::InnerLoopVectorizer::printDebugTracesAtEnd ( )
inlineprotectedvirtual

◆ printDebugTracesAtStart()

virtual void llvm::InnerLoopVectorizer::printDebugTracesAtStart ( )
inlineprotectedvirtual

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

Reimplemented in llvm::EpilogueVectorizerMainLoop, and llvm::EpilogueVectorizerEpilogueLoop.

Definition at line 552 of file LoopVectorize.cpp.

Referenced by llvm::LoopVectorizationPlanner::executePlan().

◆ setTripCount()

void llvm::InnerLoopVectorizer::setTripCount ( Value TC)
inline

Used to set the trip count after ILV's construction and after the preheader block has been executed.

Note that this always holds the trip count of the original loop for both main loop and epilogue vectorization.

Definition at line 533 of file LoopVectorize.cpp.

References TripCount.

Referenced by llvm::LoopVectorizationPlanner::executePlan(), and llvm::LoopVectorizePass::processLoop().

Friends And Related Function Documentation

◆ LoopVectorizationPlanner

friend class LoopVectorizationPlanner
friend

Definition at line 544 of file LoopVectorize.cpp.

Member Data Documentation

◆ AC

AssumptionCache* llvm::InnerLoopVectorizer::AC
protected

◆ AdditionalBypassBlock

BasicBlock* llvm::InnerLoopVectorizer::AdditionalBypassBlock = nullptr
protected

The additional bypass block which conditionally skips over the epilogue loop after executing the main loop.

Needed to resume inductions and reductions during epilogue vectorization.

Definition at line 608 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), and getAdditionalBypassBlock().

◆ BFI

BlockFrequencyInfo* llvm::InnerLoopVectorizer::BFI
protected

BFI and PSI are used to check for profile guided size optimizations.

Definition at line 598 of file LoopVectorize.cpp.

Referenced by getScalarEpilogueLowering(), and processLoopInVPlanNativePath().

◆ Builder

IRBuilder llvm::InnerLoopVectorizer::Builder
protected

◆ Cost

LoopVectorizationCostModel* llvm::InnerLoopVectorizer::Cost
protected

The profitablity analysis.

Definition at line 595 of file LoopVectorize.cpp.

◆ DT

DominatorTree* llvm::InnerLoopVectorizer::DT
protected

◆ LI

LoopInfo* llvm::InnerLoopVectorizer::LI
protected

◆ LoopVectorPreHeader

BasicBlock* llvm::InnerLoopVectorizer::LoopVectorPreHeader = nullptr
protected

◆ OrigLoop

Loop* llvm::InnerLoopVectorizer::OrigLoop
protected

◆ Plan

VPlan& llvm::InnerLoopVectorizer::Plan
protected

◆ PSE

PredicatedScalarEvolution& llvm::InnerLoopVectorizer::PSE
protected

◆ PSI

ProfileSummaryInfo* llvm::InnerLoopVectorizer::PSI
protected

Definition at line 599 of file LoopVectorize.cpp.

Referenced by getScalarEpilogueLowering(), and processLoopInVPlanNativePath().

◆ RTChecks

GeneratedRTChecks& llvm::InnerLoopVectorizer::RTChecks
protected

Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable.

Definition at line 603 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), and llvm::LoopVectorizationPlanner::executePlan().

◆ TripCount

Value* llvm::InnerLoopVectorizer::TripCount = nullptr
protected

Trip count of the original loop.

Definition at line 592 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::EpilogueVectorizerEpilogueLoop(), getTripCount(), and setTripCount().

◆ TTI

const TargetTransformInfo* llvm::InnerLoopVectorizer::TTI
protected

Target Transform Info.

Definition at line 570 of file LoopVectorize.cpp.

◆ UF

unsigned llvm::InnerLoopVectorizer::UF
protected

The vectorization unroll factor to use.

Each scalar is vectorized to this many different vector instructions.

Definition at line 581 of file LoopVectorize.cpp.

Referenced by llvm::LoopVectorizationPlanner::addMinimumIterationCheck(), llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), fixVectorizedLoop(), and isIndvarOverflowCheckKnownFalse().

◆ VectorPHVPBB

VPBasicBlock* llvm::InnerLoopVectorizer::VectorPHVPBB
protected

The vector preheader block of Plan, used as target for check blocks introduced during skeleton creation.

Definition at line 614 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), and llvm::EpilogueVectorizerMainLoop::introduceCheckBlockInVPlan().

◆ VF

ElementCount llvm::InnerLoopVectorizer::VF
protected

The vectorization SIMD factor to use.

Each vector will have this many vector elements.

Definition at line 577 of file LoopVectorize.cpp.

Referenced by addExitUsersForFirstOrderRecurrences(), llvm::LoopVectorizationPlanner::addMinimumIterationCheck(), calculateEarlyExitCost(), llvm::LoopVectorizationCostModel::collectInstsToScalarize(), llvm::LoopVectorizationPlanner::computeBestVF(), llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), createScalarPreheader(), llvm::LoopVectorizationPlanner::emitInvalidCostRemarks(), estimateElementCount(), llvm::LoopVectorizationCostModel::expectedCost(), fixVectorizedLoop(), llvm::LoopVectorizationCostModel::getDivRemSpeculationCost(), llvm::LoopVectorizationCostModel::getInstructionCost(), llvm::VPCostContext::getLegacyCost(), llvm::LoopVectorizationCostModel::getReductionPatternCost(), llvm::LoopVectorizationCostModel::getVectorCallCost(), llvm::LoopVectorizationCostModel::getVectorIntrinsicCost(), llvm::VPRecipeBuilder::handleReplication(), llvm::LoopVectorizationCostModel::interleavedAccessCanBeWidened(), llvm::LoopVectorizationCostModel::isEpilogueVectorizationProfitable(), isIndvarOverflowCheckKnownFalse(), llvm::VPCostContext::isLegacyUniformAfterVectorization(), isOutsideLoopWorkProfitable(), llvm::LoopVectorizationCostModel::isScalarWithPredication(), maybeVectorizeType(), llvm::LoopVectorizationCostModel::memoryInstructionCanBeWidened(), llvm::LoopVectorizationPlanner::plan(), planContainsAdditionalSimplifications(), llvm::LoopVectorizationPlanner::planInVPlanNativePath(), processLoopInVPlanNativePath(), llvm::LoopVectorizationPlanner::selectInterleaveCount(), llvm::LoopVectorizationCostModel::setCostBasedWideningDecision(), llvm::LoopVectorizationCostModel::setVectorizedCallDecision(), llvm::LoopVectorizationCostModel::shouldCalculateRegPressureForVF(), llvm::VPRecipeBuilder::tryToCreateWidenRecipe(), and willGenerateVectors().


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