LLVM 22.0.0git
|
InnerLoopVectorizer vectorizes loops which contain only one basic block to a specified vectorization factor (VF). More...
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 BasicBlock * | createVectorizedLoopSkeleton () |
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 . | |
Value * | getTripCount () 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. | |
Protected Member Functions | |
BasicBlock * | createScalarPreheader (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 | |
Loop * | OrigLoop |
The original loop. | |
PredicatedScalarEvolution & | PSE |
A wrapper around ScalarEvolution used to add runtime SCEV checks. | |
LoopInfo * | LI |
Loop Info. | |
DominatorTree * | DT |
Dominator Tree. | |
const TargetTransformInfo * | TTI |
Target Transform Info. | |
AssumptionCache * | AC |
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. | |
BasicBlock * | LoopVectorPreHeader = nullptr |
The vector-loop preheader. | |
Value * | TripCount = nullptr |
Trip count of the original loop. | |
LoopVectorizationCostModel * | Cost |
The profitablity analysis. | |
BlockFrequencyInfo * | BFI |
BFI and PSI are used to check for profile guided size optimizations. | |
ProfileSummaryInfo * | PSI |
GeneratedRTChecks & | RTChecks |
Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable. | |
VPlan & | Plan |
VPBasicBlock * | VectorPHVPBB |
The vector preheader block of Plan , used as target for check blocks introduced during skeleton creation. | |
Friends | |
class | LoopVectorizationPlanner |
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.
|
inline |
Definition at line 500 of file LoopVectorize.cpp.
|
virtualdefault |
|
protected |
Create and return a new IR basic block for the scalar preheader whose name is prefixed with Prefix
.
Definition at line 2376 of file LoopVectorize.cpp.
References assert(), DT, llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getTerminator(), llvm::LoopBase< BlockT, LoopT >::getUniqueLatchExitBlock(), llvm::ElementCount::isVector(), LI, LoopVectorPreHeader, OrigLoop, llvm::SplitBlock(), and VF.
Referenced by createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::createVectorizedLoopSkeleton(), and llvm::EpilogueVectorizerEpilogueLoop::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 2428 of file LoopVectorize.cpp.
References createScalarPreheader(), and llvm::BasicBlock::getSinglePredecessor().
Referenced by llvm::LoopVectorizationPlanner::executePlan().
void InnerLoopVectorizer::fixNonInductionPHIs | ( | VPTransformState & | State | ) |
Fix the non-induction PHIs in Plan
.
Definition at line 2592 of file LoopVectorize.cpp.
References llvm::PHINode::addIncoming(), Builder, llvm::VPTransformState::CFG, llvm::VPTransformState::get(), llvm::VPlan::getEntry(), llvm::VPPhiAccessors::incoming_values_and_blocks(), P, Plan, llvm::IRBuilderBase::SetInsertPoint(), llvm::vp_depth_first_shallow(), and llvm::VPTransformState::CFGState::VPBB2IRBB.
Referenced by fixVectorizedLoop().
void InnerLoopVectorizer::fixVectorizedLoop | ( | VPTransformState & | State | ) |
Fix the vectorized code, taking care of header phi's, and more.
Definition at line 2557 of file LoopVectorize.cpp.
References llvm::VPTransformState::CFG, cse(), estimateElementCount(), fixNonInductionPHIs(), llvm::vputils::getFirstLoopHeader(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), LI, OrigLoop, llvm::VPTransformState::Plan, llvm::setProfileInfoAfterUnrolling(), UF, VF, llvm::VPTransformState::CFGState::VPBB2IRBB, and llvm::VPTransformState::VPDT.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
inline |
Returns the original loop trip count.
Definition at line 528 of file LoopVectorize.cpp.
References TripCount.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::LoopVectorizationPlanner::executePlan(), and llvm::LoopVectorizePass::processLoop().
|
inlineprotectedvirtual |
Reimplemented in llvm::EpilogueVectorizerMainLoop, and llvm::EpilogueVectorizerEpilogueLoop.
Definition at line 545 of file LoopVectorize.cpp.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
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 544 of file LoopVectorize.cpp.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
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().
|
friend |
Definition at line 536 of file LoopVectorize.cpp.
|
protected |
Assumption Cache.
Definition at line 565 of file LoopVectorize.cpp.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
protected |
BFI and PSI are used to check for profile guided size optimizations.
Definition at line 590 of file LoopVectorize.cpp.
|
protected |
The builder that we use.
Definition at line 576 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), llvm::LoopVectorizationPlanner::executePlan(), and fixNonInductionPHIs().
|
protected |
The profitablity analysis.
Definition at line 587 of file LoopVectorize.cpp.
|
protected |
Dominator Tree.
Definition at line 559 of file LoopVectorize.cpp.
Referenced by createScalarPreheader(), and llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton().
|
protected |
Loop Info.
Definition at line 556 of file LoopVectorize.cpp.
Referenced by createScalarPreheader(), llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), and fixVectorizedLoop().
|
protected |
The vector-loop preheader.
Definition at line 581 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), createScalarPreheader(), llvm::EpilogueVectorizerMainLoop::createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), and llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck().
|
protected |
The original loop.
Definition at line 548 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), createScalarPreheader(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), fixVectorizedLoop(), llvm::EpilogueVectorizerMainLoop::printDebugTracesAtEnd(), and llvm::EpilogueVectorizerEpilogueLoop::printDebugTracesAtEnd().
|
protected |
Definition at line 597 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), fixNonInductionPHIs(), and llvm::EpilogueVectorizerMainLoop::introduceCheckBlockInVPlan().
|
protected |
A wrapper around ScalarEvolution used to add runtime SCEV checks.
Applies dynamic knowledge to simplify SCEV expressions and converts them to a more usable form.
Definition at line 553 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck().
|
protected |
Definition at line 591 of file LoopVectorize.cpp.
|
protected |
Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable.
Definition at line 595 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), and llvm::LoopVectorizationPlanner::executePlan().
|
protected |
Trip count of the original loop.
Definition at line 584 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::EpilogueVectorizerEpilogueLoop(), getTripCount(), and setTripCount().
|
protected |
Target Transform Info.
Definition at line 562 of file LoopVectorize.cpp.
|
protected |
The vectorization unroll factor to use.
Each scalar is vectorized to this many different vector instructions.
Definition at line 573 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), and fixVectorizedLoop().
|
protected |
The vector preheader block of Plan
, used as target for check blocks introduced during skeleton creation.
Definition at line 601 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createVectorizedLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), and llvm::EpilogueVectorizerMainLoop::introduceCheckBlockInVPlan().
|
protected |
The vectorization SIMD factor to use.
Each vector will have this many vector elements.
Definition at line 569 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createIterationCountCheck(), createScalarPreheader(), and fixVectorizedLoop().