LLVM  14.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::LoopVectorizationPlanner Class Reference

Planner drives the vectorization process after having passed Legality checks. More...

#include "Transforms/Vectorize/LoopVectorizationPlanner.h"

Public Member Functions

 LoopVectorizationPlanner (Loop *L, LoopInfo *LI, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, LoopVectorizationLegality *Legal, LoopVectorizationCostModel &CM, InterleavedAccessInfo &IAI, PredicatedScalarEvolution &PSE, const LoopVectorizeHints &Hints, LoopVectorizationRequirements &Requirements, OptimizationRemarkEmitter *ORE)
 
Optional< VectorizationFactorplan (ElementCount UserVF, unsigned UserIC)
 Plan how to best vectorize, return the best VF and its cost, or None if vectorization and interleaving should be avoided up front. More...
 
VectorizationFactor planInVPlanNativePath (ElementCount UserVF)
 Use the VPlan-native path to plan how to best vectorize, return the best VF and its cost. More...
 
void setBestPlan (ElementCount VF, unsigned UF)
 Finalize the best decision and dispose of all other VPlans. More...
 
void executePlan (InnerLoopVectorizer &LB, DominatorTree *DT)
 Generate the IR code for the body of the vectorized loop according to the best selected VPlan. More...
 
void printPlans (raw_ostream &O)
 
bool hasPlanWithVFs (const ArrayRef< ElementCount > VFs) const
 Look through the existing plans and return true if we have one with all the vectorization factors in question. More...
 

Static Public Member Functions

static bool getDecisionAndClampRange (const std::function< bool(ElementCount)> &Predicate, VFRange &Range)
 Test a Predicate on a Range of VF's. More...
 

Protected Member Functions

void collectTriviallyDeadInstructions (SmallPtrSetImpl< Instruction * > &DeadInstructions)
 Collect the instructions from the original loop that would be trivially dead in the vectorized loop if generated. More...
 
void buildVPlans (ElementCount MinVF, ElementCount MaxVF)
 Build VPlans for power-of-2 VF's between MinVF and MaxVF inclusive, according to the information gathered by Legal when it checked if it is legal to vectorize the loop. More...
 

Detailed Description

Planner drives the vectorization process after having passed Legality checks.

Definition at line 236 of file LoopVectorizationPlanner.h.

Constructor & Destructor Documentation

◆ LoopVectorizationPlanner()

llvm::LoopVectorizationPlanner::LoopVectorizationPlanner ( Loop L,
LoopInfo LI,
const TargetLibraryInfo TLI,
const TargetTransformInfo TTI,
LoopVectorizationLegality Legal,
LoopVectorizationCostModel CM,
InterleavedAccessInfo IAI,
PredicatedScalarEvolution PSE,
const LoopVectorizeHints Hints,
LoopVectorizationRequirements Requirements,
OptimizationRemarkEmitter ORE 
)
inline

Definition at line 278 of file LoopVectorizationPlanner.h.

References llvm::IRSimilarity::Legal.

Member Function Documentation

◆ buildVPlans()

void LoopVectorizationPlanner::buildVPlans ( ElementCount  MinVF,
ElementCount  MaxVF 
)
protected

Build VPlans for power-of-2 VF's between MinVF and MaxVF inclusive, according to the information gathered by Legal when it checked if it is legal to vectorize the loop.

Build VPlans for the full range of feasible VF's = {MinVF, 2 * MinVF, 4 * MinVF, ..., MaxVF} by repeatedly building a VPlan for a sub-range of VF's starting at a given VF and extending it as much as possible.

Each vectorization decision can potentially shorten this sub-range during buildVPlan().

Definition at line 8646 of file LoopVectorize.cpp.

References llvm::VFRange::End, llvm::UnivariateLinearPolyBase< LeafTy >::getWithIncrement(), llvm::LinearPolySize< ElementCount >::isKnownLT(), and llvm::InnerLoopVectorizer::VF.

◆ collectTriviallyDeadInstructions()

void LoopVectorizationPlanner::collectTriviallyDeadInstructions ( SmallPtrSetImpl< Instruction * > &  DeadInstructions)
protected

◆ executePlan()

void LoopVectorizationPlanner::executePlan ( InnerLoopVectorizer LB,
DominatorTree DT 
)

◆ getDecisionAndClampRange()

bool LoopVectorizationPlanner::getDecisionAndClampRange ( const std::function< bool(ElementCount)> &  Predicate,
VFRange Range 
)
static

Test a Predicate on a Range of VF's.

Return the value of applying Predicate on Range.Start, possibly decreasing Range.End such that the returned value holds for the entire Range.

Definition at line 8626 of file LoopVectorize.cpp.

References assert(), llvm::VFRange::End, llvm::VFRange::isEmpty(), llvm::LinearPolySize< ElementCount >::isKnownLT(), and llvm::VFRange::Start.

Referenced by llvm::VPRecipeBuilder::handleReplication().

◆ hasPlanWithVFs()

bool llvm::LoopVectorizationPlanner::hasPlanWithVFs ( const ArrayRef< ElementCount VFs) const
inline

Look through the existing plans and return true if we have one with all the vectorization factors in question.

Definition at line 311 of file LoopVectorizationPlanner.h.

References llvm::all_of(), and llvm::any_of().

Referenced by llvm::LoopVectorizationCostModel::selectEpilogueVectorizationFactor().

◆ plan()

Optional< VectorizationFactor > LoopVectorizationPlanner::plan ( ElementCount  UserVF,
unsigned  UserIC 
)

◆ planInVPlanNativePath()

VectorizationFactor LoopVectorizationPlanner::planInVPlanNativePath ( ElementCount  UserVF)

◆ printPlans()

void LoopVectorizationPlanner::printPlans ( raw_ostream O)

Definition at line 8239 of file LoopVectorize.cpp.

References llvm::RISCVFenceField::O, and PrintVPlansInDotFormat.

◆ setBestPlan()

void LoopVectorizationPlanner::setBestPlan ( ElementCount  VF,
unsigned  UF 
)

Finalize the best decision and dispose of all other VPlans.

Definition at line 8192 of file LoopVectorize.cpp.

References assert(), llvm::dbgs(), llvm::erase_if(), LLVM_DEBUG, llvm::InnerLoopVectorizer::UF, and llvm::InnerLoopVectorizer::VF.

Referenced by llvm::LoopVectorizePass::processLoop(), and processLoopInVPlanNativePath().


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