LLVM  16.0.0git
Public Member Functions | Friends | List of all members
llvm::VPlan Class Reference

VPlan models a candidate for vectorization, encoding various decisions take to produce efficient output IR, including which branches, basic-blocks and output IR instructions to generate, and their cost. More...

#include "Transforms/Vectorize/VPlan.h"

Public Member Functions

 VPlan (VPBlockBase *Entry=nullptr)
 
 ~VPlan ()
 
void prepareToExecute (Value *TripCount, Value *VectorTripCount, Value *CanonicalIVStartValue, VPTransformState &State, bool IsEpilogueVectorization)
 Prepare the plan for execution, setting up the required live-in values. More...
 
void execute (VPTransformState *State)
 Generate the IR code for this VPlan. More...
 
VPBlockBasegetEntry ()
 
const VPBlockBasegetEntry () const
 
VPBlockBasesetEntry (VPBlockBase *Block)
 
VPValuegetOrCreateTripCount ()
 The trip count of the original loop. More...
 
VPValuegetOrCreateBackedgeTakenCount ()
 The backedge taken count of the original loop. More...
 
VPValuegetVectorTripCount ()
 The vector trip count. More...
 
void disableValue2VPValue ()
 Mark the plan to indicate that using Value2VPValue is not safe any longer, because it may be stale. More...
 
void addVF (ElementCount VF)
 
bool hasVF (ElementCount VF)
 
const std::string & getName () const
 
void setName (const Twine &newName)
 
VPValuegetOrAddExternalDef (Value *V)
 Get the existing or add a new external definition for V. More...
 
void addVPValue (Value *V)
 
void addVPValue (Value *V, VPValue *VPV)
 
VPValuegetVPValue (Value *V, bool OverrideAllowed=false)
 Returns the VPValue for V. More...
 
VPValuegetOrAddVPValue (Value *V, bool OverrideAllowed=false)
 Gets the VPValue or adds a new one (if none exists yet) for V. More...
 
void removeVPValueFor (Value *V)
 
void print (raw_ostream &O) const
 Print this VPlan to O. More...
 
void printDOT (raw_ostream &O) const
 Print this VPlan in DOT format to O. More...
 
LLVM_DUMP_METHOD void dump () const
 Dump the plan to stderr (for debugging). More...
 
iterator_range< mapped_iterator< Use *, std::function< VPValue *(Value *)> > > mapToVPValues (User::op_range Operands)
 Returns a range mapping the values the range Operands to their corresponding VPValues. More...
 
VPRegionBlockgetVectorLoopRegion ()
 Returns the VPRegionBlock of the vector loop. More...
 
const VPRegionBlockgetVectorLoopRegion () const
 
VPCanonicalIVPHIRecipegetCanonicalIV ()
 Returns the canonical induction recipe of the vector loop. More...
 
VPActiveLaneMaskPHIRecipegetActiveLaneMaskPhi ()
 Find and return the VPActiveLaneMaskPHIRecipe from the header - there be only one at most. More...
 
void addLiveOut (PHINode *PN, VPValue *V)
 
void clearLiveOuts ()
 
void removeLiveOut (PHINode *PN)
 
const MapVector< PHINode *, VPLiveOut * > & getLiveOuts () const
 

Friends

class VPlanPrinter
 
class VPSlotTracker
 

Detailed Description

VPlan models a candidate for vectorization, encoding various decisions take to produce efficient output IR, including which branches, basic-blocks and output IR instructions to generate, and their cost.

VPlan holds a Hierarchical-CFG of VPBasicBlocks and VPRegionBlocks rooted at an Entry VPBlock.

Definition at line 2492 of file VPlan.h.

Constructor & Destructor Documentation

◆ VPlan()

llvm::VPlan::VPlan ( VPBlockBase Entry = nullptr)
inline

Definition at line 2536 of file VPlan.h.

◆ ~VPlan()

llvm::VPlan::~VPlan ( )
inline

Definition at line 2541 of file VPlan.h.

References clearLiveOuts().

Member Function Documentation

◆ addLiveOut()

void VPlan::addLiveOut ( PHINode PN,
VPValue V 
)

Definition at line 792 of file VPlan.cpp.

References assert().

Referenced by addUsersInExitBlock().

◆ addVF()

void llvm::VPlan::addVF ( ElementCount  VF)
inline

◆ addVPValue() [1/2]

void llvm::VPlan::addVPValue ( Value V)
inline

◆ addVPValue() [2/2]

void llvm::VPlan::addVPValue ( Value V,
VPValue VPV 
)
inline

◆ clearLiveOuts()

void llvm::VPlan::clearLiveOuts ( )
inline

Definition at line 2705 of file VPlan.h.

Referenced by llvm::InnerLoopVectorizer::fixVectorizedLoop(), and ~VPlan().

◆ disableValue2VPValue()

void llvm::VPlan::disableValue2VPValue ( )
inline

Mark the plan to indicate that using Value2VPValue is not safe any longer, because it may be stale.

Definition at line 2597 of file VPlan.h.

◆ dump()

LLVM_DUMP_METHOD void VPlan::dump ( ) const

Dump the plan to stderr (for debugging).

Definition at line 789 of file VPlan.cpp.

References llvm::dbgs(), and print().

◆ execute()

void VPlan::execute ( VPTransformState State)

Generate the IR code for this VPlan.

Generate the code inside the preheader and body of the vectorized loop.

Assumes a single pre-header basic-block was created for this. Introduce additional basic-blocks as needed, and fill them all.

Definition at line 666 of file VPlan.cpp.

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

◆ getActiveLaneMaskPhi()

VPActiveLaneMaskPHIRecipe * VPlan::getActiveLaneMaskPhi ( )

Find and return the VPActiveLaneMaskPHIRecipe from the header - there be only one at most.

If there isn't one, then return nullptr.

Definition at line 571 of file VPlan.cpp.

References llvm::VPBlockBase::getEntryBasicBlock(), and llvm::VPBasicBlock::phis().

◆ getCanonicalIV()

VPCanonicalIVPHIRecipe* llvm::VPlan::getCanonicalIV ( )
inline

◆ getEntry() [1/2]

VPBlockBase* llvm::VPlan::getEntry ( )
inline

◆ getEntry() [2/2]

const VPBlockBase* llvm::VPlan::getEntry ( ) const
inline

Definition at line 2570 of file VPlan.h.

◆ getLiveOuts()

const MapVector<PHINode *, VPLiveOut *>& llvm::VPlan::getLiveOuts ( ) const
inline

Definition at line 2716 of file VPlan.h.

◆ getName()

const std::string& llvm::VPlan::getName ( ) const
inline

Definition at line 2603 of file VPlan.h.

Referenced by llvm::VPlanPrinter::dump().

◆ getOrAddExternalDef()

VPValue* llvm::VPlan::getOrAddExternalDef ( Value V)
inline

Get the existing or add a new external definition for V.

Definition at line 2608 of file VPlan.h.

References I, and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().

Referenced by llvm::vputils::getOrCreateVPValueForSCEVExpr(), and llvm::LoopVectorizePass::processLoop().

◆ getOrAddVPValue()

VPValue* llvm::VPlan::getOrAddVPValue ( Value V,
bool  OverrideAllowed = false 
)
inline

Gets the VPValue or adds a new one (if none exists yet) for V.

OverrideAllowed can be used to disable checking whether it is safe to query VPValues using IR Values.

Definition at line 2645 of file VPlan.h.

References addVPValue(), assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), and getVPValue().

Referenced by addCanonicalIVRecipes(), addUsersInExitBlock(), and mapToVPValues().

◆ getOrCreateBackedgeTakenCount()

VPValue* llvm::VPlan::getOrCreateBackedgeTakenCount ( )
inline

The backedge taken count of the original loop.

Definition at line 2586 of file VPlan.h.

◆ getOrCreateTripCount()

VPValue* llvm::VPlan::getOrCreateTripCount ( )
inline

The trip count of the original loop.

Definition at line 2579 of file VPlan.h.

Referenced by addCanonicalIVRecipes().

◆ getVectorLoopRegion() [1/2]

VPRegionBlock* llvm::VPlan::getVectorLoopRegion ( )
inline

◆ getVectorLoopRegion() [2/2]

const VPRegionBlock* llvm::VPlan::getVectorLoopRegion ( ) const
inline

Definition at line 2685 of file VPlan.h.

References getEntry().

◆ getVectorTripCount()

VPValue& llvm::VPlan::getVectorTripCount ( )
inline

The vector trip count.

Definition at line 2593 of file VPlan.h.

Referenced by addCanonicalIVRecipes().

◆ getVPValue()

VPValue* llvm::VPlan::getVPValue ( Value V,
bool  OverrideAllowed = false 
)
inline

Returns the VPValue for V.

OverrideAllowed can be used to disable checking whether it is safe to query VPValues using IR Values.

Definition at line 2634 of file VPlan.h.

References assert(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count().

Referenced by getOrAddVPValue(), and llvm::InnerLoopVectorizer::truncateToMinimalBitwidths().

◆ hasVF()

bool llvm::VPlan::hasVF ( ElementCount  VF)
inline

◆ mapToVPValues()

iterator_range<mapped_iterator<Use *, std::function<VPValue *(Value *)> > > llvm::VPlan::mapToVPValues ( User::op_range  Operands)
inline

Returns a range mapping the values the range Operands to their corresponding VPValues.

Definition at line 2674 of file VPlan.h.

References function, getOrAddVPValue(), llvm::map_range(), and Operands.

◆ prepareToExecute()

void VPlan::prepareToExecute ( Value TripCount,
Value VectorTripCount,
Value CanonicalIVStartValue,
VPTransformState State,
bool  IsEpilogueVectorization 
)

◆ print()

LLVM_DUMP_METHOD void VPlan::print ( raw_ostream O) const

Print this VPlan to O.

Definition at line 747 of file VPlan.cpp.

References llvm::depth_first(), and llvm::RISCVFenceField::O.

Referenced by llvm::operator<<().

◆ printDOT()

LLVM_DUMP_METHOD void VPlan::printDOT ( raw_ostream O) const

Print this VPlan in DOT format to O.

Definition at line 783 of file VPlan.cpp.

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

◆ removeLiveOut()

void llvm::VPlan::removeLiveOut ( PHINode PN)
inline

◆ removeVPValueFor()

void llvm::VPlan::removeVPValueFor ( Value V)
inline

◆ setEntry()

VPBlockBase* llvm::VPlan::setEntry ( VPBlockBase Block)
inline

Definition at line 2572 of file VPlan.h.

Referenced by llvm::VPlanHCFGBuilder::buildHierarchicalCFG().

◆ setName()

void llvm::VPlan::setName ( const Twine newName)
inline

Definition at line 2605 of file VPlan.h.

References llvm::Twine::str().

Referenced by llvm::VPlanHCFGBuilder::buildHierarchicalCFG().

Friends And Related Function Documentation

◆ VPlanPrinter

friend class VPlanPrinter
friend

Definition at line 2493 of file VPlan.h.

◆ VPSlotTracker

friend class VPSlotTracker
friend

Definition at line 2494 of file VPlan.h.


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