LLVM 23.0.0git
VPlanConstruction.cpp File Reference

This file implements transforms for initial VPlan construction. More...

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "vplan"

Functions

static bool isHeaderBB (BasicBlock *BB, Loop *L)
static bool canonicalHeaderAndLatch (VPBlockBase *HeaderVPB, const VPDominatorTree &VPDT)
 Checks if HeaderVPB is a loop header block in the plain CFG; that is, it has exactly 2 predecessors (preheader and latch), where the block dominates the latch and the preheader dominates the block.
static void createLoopRegion (VPlan &Plan, VPBlockBase *HeaderVPB)
 Create a new VPRegionBlock for the loop starting at HeaderVPB.
static void addCanonicalIVRecipes (VPlan &Plan, VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, Type *IdxTy, DebugLoc DL)
static void createExtractsForLiveOuts (VPlan &Plan, VPBasicBlock *MiddleVPBB)
 Creates extracts for values in Plan defined in a loop region and used outside a loop region.
static void addInitialSkeleton (VPlan &Plan, Type *InductionTy, DebugLoc IVDL, PredicatedScalarEvolution &PSE, Loop *TheLoop)
static void simplifyLiveInsWithSCEV (VPlan &Plan, PredicatedScalarEvolution &PSE)
 Check Plan's live-in and replace them with constants, if they can be simplified via SCEV.
static void printAfterInitialConstruction (VPlan &)
 To make RUN_VPLAN_PASS print initial VPlan.
static VPHeaderPHIRecipecreateWidenInductionRecipe (PHINode *Phi, VPPhi *PhiR, VPIRValue *Start, const InductionDescriptor &IndDesc, VPlan &Plan, PredicatedScalarEvolution &PSE, Loop &OrigLoop, DebugLoc DL)
 Creates a VPWidenIntOrFpInductionRecipe or VPWidenPointerInductionRecipe for Phi based on IndDesc.
static void insertCheckBlockBeforeVectorLoop (VPlan &Plan, VPBasicBlock *CheckBlockVPBB)
 Insert CheckBlockVPBB on the edge leading to the vector preheader, connecting it to both vector and scalar preheaders.
static void addBypassBranch (VPlan &Plan, VPBasicBlock *CheckBlockVPBB, VPValue *Cond, bool AddBranchWeights)
 Create a BranchOnCond terminator in CheckBlockVPBB.
static VPInstructionfindFindIVSelect (VPValue *BackedgeVal)
 Find and return the final select instruction of the FindIV result pattern for the given BackedgeVal: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel), ComputeReductionResult(ReducedIV), Start.

Variables

static constexpr uint32_t CheckBypassWeights [] = {1, 127}

Detailed Description

This file implements transforms for initial VPlan construction.

Definition in file VPlanConstruction.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "vplan"

Definition at line 33 of file VPlanConstruction.cpp.

Function Documentation

◆ addBypassBranch()

void addBypassBranch ( VPlan & Plan,
VPBasicBlock * CheckBlockVPBB,
VPValue * Cond,
bool AddBranchWeights )
static

◆ addCanonicalIVRecipes()

◆ addInitialSkeleton()

◆ canonicalHeaderAndLatch()

bool canonicalHeaderAndLatch ( VPBlockBase * HeaderVPB,
const VPDominatorTree & VPDT )
static

Checks if HeaderVPB is a loop header block in the plain CFG; that is, it has exactly 2 predecessors (preheader and latch), where the block dominates the latch and the preheader dominates the block.

If it is a header block return true and canonicalize the predecessors of the header (making sure the preheader appears first and the latch second) and the successors of the latch (making sure the loop exit comes first). Otherwise return false.

Definition at line 382 of file VPlanConstruction.cpp.

References assert(), llvm::VPInstruction::BranchOnCond, llvm::cast(), llvm::DominatorTreeBase< NodeT, IsPostDom >::dominates(), getOpcode(), llvm::VPBlockBase::getPredecessors(), llvm::VPInstruction::Not, llvm::ArrayRef< T >::size(), std::swap(), and llvm::VPBlockBase::swapPredecessors().

Referenced by addInitialSkeleton(), and llvm::VPlanTransforms::createLoopRegions().

◆ createExtractsForLiveOuts()

void createExtractsForLiveOuts ( VPlan & Plan,
VPBasicBlock * MiddleVPBB )
static

Creates extracts for values in Plan defined in a loop region and used outside a loop region.

Definition at line 492 of file VPlanConstruction.cpp.

References assert(), B(), llvm::cast(), llvm::VPlan::getExitBlocks(), and llvm::VPBasicBlock::getFirstNonPhi().

Referenced by addInitialSkeleton().

◆ createLoopRegion()

◆ createWidenInductionRecipe()

◆ findFindIVSelect()

VPInstruction * findFindIVSelect ( VPValue * BackedgeVal)
static

Find and return the final select instruction of the FindIV result pattern for the given BackedgeVal: select(icmp ne ComputeReductionResult(ReducedIV), Sentinel), ComputeReductionResult(ReducedIV), Start.

Definition at line 1145 of file VPlanConstruction.cpp.

References llvm::cast(), llvm::dyn_cast(), llvm::vputils::findRecipe(), llvm::PatternMatch::m_Specific(), llvm::VPlanPatternMatch::m_VPValue(), and llvm::VPlanPatternMatch::matchFindIVResult().

Referenced by llvm::VPlanTransforms::handleMultiUseReductions().

◆ insertCheckBlockBeforeVectorLoop()

void insertCheckBlockBeforeVectorLoop ( VPlan & Plan,
VPBasicBlock * CheckBlockVPBB )
static

Insert CheckBlockVPBB on the edge leading to the vector preheader, connecting it to both vector and scalar preheaders.

Updates scalar preheader phis to account for the new predecessor.

Definition at line 972 of file VPlanConstruction.cpp.

References assert(), llvm::cast(), llvm::VPBlockUtils::connectBlocks(), llvm::VPlan::getScalarPreheader(), llvm::VPBlockBase::getSinglePredecessor(), llvm::VPlan::getVectorPreheader(), llvm::VPBlockUtils::insertOnEdge(), and llvm::VPBlockBase::swapSuccessors().

Referenced by llvm::VPlanTransforms::attachCheckBlock().

◆ isHeaderBB()

bool isHeaderBB ( BasicBlock * BB,
Loop * L )
static

Definition at line 96 of file VPlanConstruction.cpp.

◆ printAfterInitialConstruction()

void printAfterInitialConstruction ( VPlan & )
static

To make RUN_VPLAN_PASS print initial VPlan.

Definition at line 593 of file VPlanConstruction.cpp.

Referenced by llvm::VPlanTransforms::buildVPlan0().

◆ simplifyLiveInsWithSCEV()

void simplifyLiveInsWithSCEV ( VPlan & Plan,
PredicatedScalarEvolution & PSE )
static

Check Plan's live-in and replace them with constants, if they can be simplified via SCEV.

Definition at line 577 of file VPlanConstruction.cpp.

References llvm::CallingConv::C, llvm::dyn_cast(), llvm::VPlan::getLiveIns(), llvm::VPlan::getOrAddLiveIn(), llvm::vputils::getSCEVExprForVPValue(), and llvm::to_vector().

Referenced by llvm::VPlanTransforms::buildVPlan0().

Variable Documentation

◆ CheckBypassWeights

uint32_t CheckBypassWeights[] = {1, 127}
staticconstexpr

Definition at line 991 of file VPlanConstruction.cpp.

Referenced by addBypassBranch().