LLVM 24.0.0git
VPlanTransforms.cpp File Reference

This file implements a set of utility VPlan to VPlan transformations. More...

Go to the source code of this file.

Classes

class  SinkStoreInfo
 Helper for extra no-alias checks via known-safe recipe and SCEV. More...
struct  EarlyExitInfo

Functions

static std::optional< int64_t > getConstantStride (VPValue *Addr, Type *AccessTy, PredicatedScalarEvolution &PSE, const Loop *L)
 If the pointer operand Addr of a memory access is an affine AddRec w.r.t.
static bool canHoistOrSinkWithNoAliasCheck (const MemoryLocation &MemLoc, VPBasicBlock *FirstBB, VPBasicBlock *LastBB, std::optional< SinkStoreInfo > SinkInfo={})
 Check if a memory operation doesn't alias with memory operations using scoped noalias metadata, in blocks in the single-successor chain between FirstBB and LastBB.
static TypegetLoadStoreValueType (VPReplicateRecipe *R, bool IsLoad)
 Get the value type of the replicate load or store.
template<unsigned Opcode>
static SmallVector< SmallVector< VPReplicateRecipe *, 4 > > collectGroupedReplicateMemOps (VPlan &Plan, PredicatedScalarEvolution &PSE, const Loop *L, function_ref< bool(VPReplicateRecipe *)> FilterFn)
 Collect either replicated Loads or Stores grouped by their address SCEV and their load-store type, in a deep-traversal of the vector loop region in Plan.
static bool sinkScalarOperands (VPlan &Plan)
static VPBasicBlockgetPredicatedThenBlock (VPRegionBlock *R)
 If R is a triangle region, return the 'then' block of the triangle.
static bool mergeReplicateRegionsIntoSuccessors (VPlan &Plan)
static VPRegionBlockcreateReplicateRegion (VPReplicateRecipe *PredRecipe, VPRegionBlock *ParentRegion, VPlan &Plan)
static void addReplicateRegions (VPlan &Plan)
static void removeRedundantInductionCasts (VPlan &Plan)
 Remove redundant casts of inductions.
static void legalizeAndOptimizeInductions (VPlan &Plan)
 Legalize VPWidenPointerInductionRecipe, by replacing it with a PtrAdd (IndStart, ScalarIVSteps (0, Step)) if only its scalar values are used, as VPWidenPointerInductionRecipe will generate vectors only.
static VPWidenInductionRecipegetOptimizableIVOf (VPValue *VPV, PredicatedScalarEvolution &PSE)
 Check if VPV is an untruncated wide induction, either before or after the increment.
static VPValueoptimizeEarlyExitInductionUser (VPlan &Plan, VPValue *Op, PredicatedScalarEvolution &PSE)
 Attempts to optimize the induction variable exit values for users in the early exit block.
static VPValuetryToComputeEndValueForInduction (VPWidenInductionRecipe *WideIV, VPBuilder &VectorPHBuilder, VPValue *VectorTC)
 Compute the end value for WideIV, unless it is truncated.
static VPValueoptimizeLatchExitInductionUser (VPlan &Plan, VPValue *Op, DenseMap< VPValue *, VPValue * > &EndValues, PredicatedScalarEvolution &PSE)
 Attempts to optimize the induction variable exit values for users in the exit block coming from the latch in the original scalar loop.
static VPValueoptimizeLatchExitIVUserViaSCEV (VPlan &Plan, VPValue *Op, PredicatedScalarEvolution &PSE, VPValue *ResumeTC, const Loop *L)
static void removeRedundantExpandSCEVRecipes (VPlan &Plan)
 Remove redundant ExpandSCEVRecipes in Plan's entry block by replacing them with already existing recipes expanding the same SCEV expression.
static bool simplifyLogicalRecipe (VPSingleDefRecipe *Def, VPBuilder &Builder, bool CanCreateNewRecipe)
 Try to simplify logical and bitwise recipes in Def.
static void simplifyRecipe (VPSingleDefRecipe *Def)
 Try to simplify VPSingleDefRecipe Def.
static void reassociateHeaderMask (VPlan &Plan)
 Reassociate (headermask && x) && y -> headermask && (x && y) to allow the header mask to be simplified further when tail folding, e.g.
static std::optional< Instruction::BinaryOpsgetUnmaskedDivRemOpcode (Intrinsic::ID ID)
static void narrowToSingleScalarRecipes (VPlan &Plan)
static void removeCommonBlendMask (VPBlendRecipe *Blend)
 Try to see if all of Blend's masks share a common value logically and'ed and remove it from the masks.
static void simplifyBlends (VPlan &Plan)
 Normalize and simplify VPBlendRecipes.
static bool optimizeVectorInductionWidthForTCAndVFUF (VPlan &Plan, ElementCount BestVF, unsigned BestUF)
 Optimize the width of vector induction variables in Plan based on a known constant Trip Count, BestVF and BestUF.
static bool isConditionTrueViaVFAndUF (VPValue *Cond, VPlan &Plan, ElementCount BestVF, unsigned BestUF, PredicatedScalarEvolution &PSE)
 Return true if Cond is known to be true for given BestVF and BestUF.
static bool tryToReplaceALMWithWideALM (VPlan &Plan, ElementCount VF, unsigned UF)
 Try to replace multiple active lane masks used for control flow with a single, wide active lane mask instruction followed by multiple extract subvector intrinsics.
static bool simplifyBranchConditionForVFAndUF (VPlan &Plan, ElementCount BestVF, unsigned BestUF, PredicatedScalarEvolution &PSE)
 Try to simplify the branch condition of Plan.
static bool cannotHoistOrSinkRecipe (VPRecipeBase &R, VPBasicBlock *FirstBB, VPBasicBlock *LastBB, bool Sinking=false)
 Return true if we do not know how to (mechanically) hoist or sink a non-memory or memory recipe R out of a loop region.
static void licm (VPlan &Plan)
 Move loop-invariant recipes out of the vector loop region in Plan.
static std::optional< VPValue * > getRecipesForUncountableExit (SmallVectorImpl< VPInstruction * > &Recipes, VPBasicBlock *LatchVPBB)
 Returns the VPValue representing the uncountable exit comparison used by AnyOf if the recipes it depends on can be traced back to live-ins and the addresses (in GEP/PtrAdd form) of any (non-masked) load used in generating the values for the comparison.
static bool handleUncountableExitsWithSideEffects (VPlan &Plan, SmallVectorImpl< EarlyExitInfo > &Exits, VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, VPBasicBlock *MiddleVPBB, Loop *TheLoop, PredicatedScalarEvolution &PSE, DominatorTree &DT, AssumptionCache *AC)
 Update Plan to mask memory operations in the loop based on whether the early exit is taken or not.
static VPExpressionRecipetryToMatchAndCreateExtendedReduction (VPReductionRecipe *Red, VPCostContext &Ctx, VFRange &Range)
 This function tries convert extended in-loop reductions to VPExpressionRecipe and clamp the Range if it is beneficial and valid.
static VPExpressionRecipetryToMatchAndCreateMulAccumulateReduction (VPReductionRecipe *Red, VPCostContext &Ctx, VFRange &Range)
 This function tries convert extended in-loop reductions to VPExpressionRecipe and clamp the Range if it is beneficial and valid.
static void tryToCreateAbstractReductionRecipe (VPReductionRecipe *Red, VPCostContext &Ctx, VFRange &Range)
 This function tries to create abstract recipes from the reduction recipe for following optimizations and cost estimation.
static VPIRMetadata getCommonMetadata (ArrayRef< VPReplicateRecipe * > Recipes)
template<unsigned Opcode>
static SmallVector< SmallVector< VPReplicateRecipe *, 4 > > collectComplementaryPredicatedMemOps (VPlan &Plan, PredicatedScalarEvolution &PSE, const Loop *L)
template<typename InstType>
static VPReplicateRecipefindRecipeWithMinAlign (ArrayRef< VPReplicateRecipe * > Group)
static bool canSinkStoreWithNoAliasCheck (ArrayRef< VPReplicateRecipe * > StoresToSink, PredicatedScalarEvolution &PSE, const Loop &L)
static bool canNarrowLoad (VPSingleDefRecipe *WideMember0, unsigned OpIdx, VPValue *OpV, unsigned Idx, bool IsScalable)
 Returns true if V is VPWidenLoadRecipe or VPInterleaveRecipe that can be converted to a narrower recipe.
static bool canNarrowOps (ArrayRef< VPValue * > Ops, bool IsScalable)
static std::optional< ElementCountisConsecutiveInterleaveGroup (VPInterleaveRecipe *InterleaveR, ArrayRef< ElementCount > VFs, const TargetTransformInfo &TTI)
 Returns VF from VFs if IR is a full interleave group with factor and number of members both equal to VF.
static bool isAlreadyNarrow (VPValue *VPV)
 Returns true if VPValue is a narrow VPValue.
static VPValuenarrowInterleaveGroupOp (ArrayRef< VPValue * > Members, SmallPtrSetImpl< VPValue * > &NarrowedOps, VPBasicBlock *Preheader)
static VPWidenIntOrFpInductionRecipegetExpressionIV (VPValue *V)
 Check if V is a binary expression of a widened IV and a loop-invariant value.
static VPValuecloneBinOpForScalarIV (VPWidenRecipe *BinOp, VPValue *ScalarIV, VPWidenIntOrFpInductionRecipe *WidenIV)
 Create a scalar version of BinOp, with its WidenIV operand replaced by ScalarIV, and place it after ScalarIV's defining recipe.
static bool areVFParamsOk (const VFInfo &Info, ArrayRef< VPValue * > Args, PredicatedScalarEvolution &PSE, const Loop *L)
 Returns true if Info's parameter kinds are compatible with Args.
static FunctionfindVectorVariant (CallInst *CI, ArrayRef< VPValue * > Args, ElementCount VF, bool MaskRequired, PredicatedScalarEvolution &PSE, const Loop *L)
 Find a vector variant of CI for VF, respecting MaskRequired.
static CallWideningDecision decideCallWidening (VPInstruction &VPI, ArrayRef< VPValue * > Ops, ElementCount VF, VPCostContext &CostCtx)
 Pick the cheapest widening for the call VPI at VF among scalarization, vector intrinsic, and vector library variant.

Detailed Description

This file implements a set of utility VPlan to VPlan transformations.

Definition in file VPlanTransforms.cpp.

Function Documentation

◆ addReplicateRegions()

◆ areVFParamsOk()

bool areVFParamsOk ( const VFInfo & Info,
ArrayRef< VPValue * > Args,
PredicatedScalarEvolution & PSE,
const Loop * L )
static

Returns true if Info's parameter kinds are compatible with Args.

Definition at line 5575 of file VPlanTransforms.cpp.

References llvm::all_of(), and llvm::PredicatedScalarEvolution::getSE().

Referenced by findVectorVariant().

◆ canHoistOrSinkWithNoAliasCheck()

bool canHoistOrSinkWithNoAliasCheck ( const MemoryLocation & MemLoc,
VPBasicBlock * FirstBB,
VPBasicBlock * LastBB,
std::optional< SinkStoreInfo > SinkInfo = {} )
static

Check if a memory operation doesn't alias with memory operations using scoped noalias metadata, in blocks in the single-successor chain between FirstBB and LastBB.

If SinkInfo is std::nullopt, only recipes that may write to memory are checked (for load hoisting). Otherwise recipes that both read and write memory are checked, and SCEV is used to prove no-alias between the group leader and other replicate recipes (for store sinking).

Definition at line 250 of file VPlanTransforms.cpp.

Referenced by cannotHoistOrSinkRecipe(), canSinkStoreWithNoAliasCheck(), and llvm::VPlanTransforms::hoistPredicatedLoads().

◆ canNarrowLoad()

bool canNarrowLoad ( VPSingleDefRecipe * WideMember0,
unsigned OpIdx,
VPValue * OpV,
unsigned Idx,
bool IsScalable )
static

Returns true if V is VPWidenLoadRecipe or VPInterleaveRecipe that can be converted to a narrower recipe.

V is used by a wide recipe that feeds a store interleave group at index Idx, WideMember0 is the recipe feeding the same interleave group at index 0. A VPWidenLoadRecipe can be narrowed to an index-independent load if it feeds all wide ops at all indices (OpV must be the operand at index OpIdx for both the recipe at lane 0, WideMember0). A VPInterleaveRecipe can be narrowed to a wide load, if V is defined at Idx of a load interleave group. A live-in or recipe defined outside the loop region can be converted, if it is the same across all lanes, or we can create a BuildVector for it.

Definition at line 3929 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), llvm::VPValue::getDefiningRecipe(), llvm::VPUser::getOperand(), llvm::VPValue::getScalarType(), IR, llvm::VPValue::isDefinedOutsideLoopRegions(), and OpIdx.

Referenced by canNarrowOps().

◆ canNarrowOps()

◆ cannotHoistOrSinkRecipe()

bool cannotHoistOrSinkRecipe ( VPRecipeBase & R,
VPBasicBlock * FirstBB,
VPBasicBlock * LastBB,
bool Sinking = false )
static

Return true if we do not know how to (mechanically) hoist or sink a non-memory or memory recipe R out of a loop region.

When sinking, passing Sinking = true ensures that assumes aren't sunk.

Definition at line 2342 of file VPlanTransforms.cpp.

References canHoistOrSinkWithNoAliasCheck(), llvm::vputils::cannotHoistOrSinkRecipe(), llvm::cast(), llvm::vputils::getMemoryLocation(), llvm::isa(), llvm::PatternMatch::m_Intrinsic(), and llvm::SCEVPatternMatch::match().

Referenced by licm().

◆ canSinkStoreWithNoAliasCheck()

◆ cloneBinOpForScalarIV()

VPValue * cloneBinOpForScalarIV ( VPWidenRecipe * BinOp,
VPValue * ScalarIV,
VPWidenIntOrFpInductionRecipe * WidenIV )
static

Create a scalar version of BinOp, with its WidenIV operand replaced by ScalarIV, and place it after ScalarIV's defining recipe.

Definition at line 4432 of file VPlanTransforms.cpp.

References assert(), llvm::VPWidenRecipe::clone(), llvm::VPValue::getDefiningRecipe(), llvm::VPUser::getNumOperands(), llvm::VPWidenRecipe::getOpcode(), llvm::VPRecipeBase::insertAfter(), and llvm::Instruction::isBinaryOp().

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

◆ collectComplementaryPredicatedMemOps()

◆ collectGroupedReplicateMemOps()

◆ createReplicateRegion()

◆ decideCallWidening()

◆ findRecipeWithMinAlign()

template<typename InstType>
VPReplicateRecipe * findRecipeWithMinAlign ( ArrayRef< VPReplicateRecipe * > Group)
static

◆ findVectorVariant()

Function * findVectorVariant ( CallInst * CI,
ArrayRef< VPValue * > Args,
ElementCount VF,
bool MaskRequired,
PredicatedScalarEvolution & PSE,
const Loop * L )
static

Find a vector variant of CI for VF, respecting MaskRequired.

Returns the variant function, or nullptr. Masked variants are assumed to take the mask as a trailing parameter.

Definition at line 5602 of file VPlanTransforms.cpp.

References areVFParamsOk(), llvm::find_if(), llvm::Module::getFunction(), llvm::VFDatabase::getMappings(), llvm::Instruction::getModule(), and llvm::CallBase::isNoBuiltin().

Referenced by decideCallWidening().

◆ getCommonMetadata()

◆ getConstantStride()

std::optional< int64_t > getConstantStride ( VPValue * Addr,
Type * AccessTy,
PredicatedScalarEvolution & PSE,
const Loop * L )
static

If the pointer operand Addr of a memory access is an affine AddRec w.r.t.

L with a constant stride, return the stride in units of AccessTy. Otherwise return std::nullopt.

Definition at line 49 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), llvm::vputils::getSCEVExprForVPValue(), and llvm::getStrideFromAddRec().

Referenced by llvm::VPlanTransforms::makeMemOpWideningDecisions(), and llvm::VPlanTransforms::tryToConvertVPInstructionsToVPRecipes().

◆ getExpressionIV()

VPWidenIntOrFpInductionRecipe * getExpressionIV ( VPValue * V)
static

Check if V is a binary expression of a widened IV and a loop-invariant value.

Returns the widened IV if found, nullptr otherwise.

Definition at line 4413 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), llvm::isa(), llvm::Instruction::isBinaryOp(), llvm::VPValue::isDefinedOutsideLoopRegions(), llvm::Instruction::isIntDivRem(), and std::swap().

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

◆ getLoadStoreValueType()

Type * getLoadStoreValueType ( VPReplicateRecipe * R,
bool IsLoad )
static

Get the value type of the replicate load or store.

IsLoad indicates whether it is a load.

Definition at line 279 of file VPlanTransforms.cpp.

References llvm::Type::getScalarType().

Referenced by collectGroupedReplicateMemOps().

◆ getOptimizableIVOf()

◆ getPredicatedThenBlock()

VPBasicBlock * getPredicatedThenBlock ( VPRegionBlock * R)
static

If R is a triangle region, return the 'then' block of the triangle.

Definition at line 416 of file VPlanTransforms.cpp.

References llvm::cast(), and llvm::dyn_cast().

Referenced by mergeReplicateRegionsIntoSuccessors().

◆ getRecipesForUncountableExit()

std::optional< VPValue * > getRecipesForUncountableExit ( SmallVectorImpl< VPInstruction * > & Recipes,
VPBasicBlock * LatchVPBB )
static

◆ getUnmaskedDivRemOpcode()

std::optional< Instruction::BinaryOps > getUnmaskedDivRemOpcode ( Intrinsic::ID ID)
static

Definition at line 1714 of file VPlanTransforms.cpp.

Referenced by narrowToSingleScalarRecipes().

◆ handleUncountableExitsWithSideEffects()

bool handleUncountableExitsWithSideEffects ( VPlan & Plan,
SmallVectorImpl< EarlyExitInfo > & Exits,
VPBasicBlock * HeaderVPBB,
VPBasicBlock * LatchVPBB,
VPBasicBlock * MiddleVPBB,
Loop * TheLoop,
PredicatedScalarEvolution & PSE,
DominatorTree & DT,
AssumptionCache * AC )
static

Update Plan to mask memory operations in the loop based on whether the early exit is taken or not.

We're currently expecting to find a loop with properties similar to the following:

for.body: ir<indvars.iv> = WIDEN-INDUCTION nuw nsw ir<0>, ir<1>, vp<%0> EMIT ir<arrayidx> = getelementptr inbounds nuw ir< >, ir<indvars.iv> EMIT-SCALAR ir<%0> = load ir<arrayidx> EMIT ir<cmp1> = icmp sgt ir<%0>, ir<5> EMIT vp<%1> = masked-cond ir<cmp1> Successor(s): if.end

if.end: EMIT ir<arrayidx3> = getelementptr inbounds nuw ir<@src>, ir<indvars.iv> EMIT-SCALAR ir<%2> = load ir<arrayidx3> EMIT ir<add> = add nsw ir<%2>, ir<42> EMIT ir<arrayidx5> = getelementptr inbounds nuw ir<@dst>, ir<indvars.iv> EMIT store ir<add>, ir<arrayidx5> EMIT ir<indvars.iv.next> = add nuw nsw ir<indvars.iv>, ir<1> EMIT vp<%3> = any-of ir<%1> EMIT ir<exitcond.not> = icmp eq ir<indvars.iv.next>, ir<10000> EMIT branch-on-two-conds vp<%3>, ir<exitcond.not> Successor(s): middle.block, middle.block, for.body

We currently expect LoopVectorizationLegality to ensure that:

  • There must also be a counted exit. We will need to support speculative or first-faulting loads before we can remove this restriction.
  • Any stores within the loop must not alias with the load used for the uncountable exit. We can relax this a bit with runtime aliasing checks.
  • Other memory operations in the loop can take place before or after the uncountable exit, but must also be unconditional. We need to support combining the conditions in VPlanPredicator.
  • The loop must have a single unconditional load contributing to the uncountable exit comparison, and the other term must be loop-invariant. Improving upon this requires work in getRecipesForUncountableExit to handle more complex recipe graphs.

Definition at line 3097 of file VPlanTransforms.cpp.

References _, llvm::VPInstruction::ActiveLaneMask, assert(), llvm::cast(), Cond, llvm::VPBuilder::createAdd(), llvm::VPBuilder::createFirstActiveLane(), llvm::VPBuilder::createICmp(), llvm::VPBuilder::createNaryOp(), llvm::VPBuilder::createScalarZExtOrTrunc(), llvm::dwarf_linker::DebugLoc, llvm::VPBlockUtils::disconnectBlocks(), DL, llvm::DominatorTreeBase< NodeT, IsPostDom >::dominates(), llvm::VPBasicBlock::end(), llvm::erase(), llvm::VPInstruction::ExtractLane, llvm::find_singleton(), llvm::VPBasicBlock::front(), llvm::ScalarEvolution::getConstant(), llvm::VPlan::getConstantInt(), llvm::VPlan::getDataLayout(), llvm::VPBasicBlock::getFirstNonPhi(), llvm::VPUser::getOperand(), getRecipesForUncountableExit(), llvm::VPlan::getScalarPreheader(), llvm::VPRecipeValue::getScalarType(), llvm::vputils::getSCEVExprForVPValue(), llvm::PredicatedScalarEvolution::getSE(), llvm::VPBasicBlock::getTerminator(), llvm::VPlan::getTripCount(), llvm::VPlan::getZero(), I, llvm::CmpInst::ICMP_EQ, llvm::is_contained(), llvm::isDereferenceableAndAlignedInLoop(), IV, llvm::Load, llvm::VPlanPatternMatch::m_BranchOnCond(), llvm::VPlanPatternMatch::m_LiveIn(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::VPlanPatternMatch::m_VPInstruction(), llvm::VPlanPatternMatch::m_VPValue(), llvm::PatternMatch::match(), llvm::VPBasicBlock::phis(), llvm::range_size(), llvm::reverse(), llvm::VPUser::setOperand(), and llvm::vp_rpo_plain_cfg_loop_body().

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

◆ isAlreadyNarrow()

bool isAlreadyNarrow ( VPValue * VPV)
static

Returns true if VPValue is a narrow VPValue.

Definition at line 4035 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), and llvm::isa().

Referenced by narrowInterleaveGroupOp(), and llvm::VPlanTransforms::narrowInterleaveGroups().

◆ isConditionTrueViaVFAndUF()

◆ isConsecutiveInterleaveGroup()

std::optional< ElementCount > isConsecutiveInterleaveGroup ( VPInterleaveRecipe * InterleaveR,
ArrayRef< ElementCount > VFs,
const TargetTransformInfo & TTI )
static

◆ legalizeAndOptimizeInductions()

void legalizeAndOptimizeInductions ( VPlan & Plan)
static

Legalize VPWidenPointerInductionRecipe, by replacing it with a PtrAdd (IndStart, ScalarIVSteps (0, Step)) if only its scalar values are used, as VPWidenPointerInductionRecipe will generate vectors only.

If some users require vectors while other require scalars, the scalar uses need to extract the scalars from the generated vectors (Note that this is different to how int/fp inductions are handled). Legalize extract-from-ends using uniform VPReplicateRecipe of wide inductions to use regular VPReplicateRecipe, so the correct end value is available. Also optimize VPWidenIntOrFpInductionRecipe, if any of its users needs scalar values, by providing them scalar steps built on the canonical scalar IV and update the original IV's users. This is an optional optimization to reduce the needs of vector extracts.

Definition at line 725 of file VPlanTransforms.cpp.

References assert(), llvm::cast(), llvm::vputils::collectUsersRecursively(), llvm::vputils::createScalarIVSteps(), llvm::VPBuilder::createSingleScalarOp(), llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::VPBlockBase::getEntryBasicBlock(), llvm::VPBasicBlock::getFirstNonPhi(), llvm::DebugLoc::getUnknown(), llvm::VPlan::getVectorLoopRegion(), llvm::VPlan::hasScalableVF(), llvm::VPlan::hasScalarVFOnly(), llvm::isa(), llvm::APInt::isNonNegative(), llvm::vputils::isSingleScalar(), llvm::PatternMatch::m_APInt(), llvm::VPlanPatternMatch::m_Binary(), llvm::VPlanPatternMatch::m_VPValue(), llvm::PatternMatch::match(), llvm::none_of(), llvm::vputils::onlyFirstLaneUsed(), llvm::VPBasicBlock::phis(), llvm::reverse(), llvm::vputils::scalarizeVPWidenPointerInduction(), and Users.

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

◆ licm()

◆ mergeReplicateRegionsIntoSuccessors()

◆ narrowInterleaveGroupOp()

◆ narrowToSingleScalarRecipes()

◆ optimizeEarlyExitInductionUser()

◆ optimizeLatchExitInductionUser()

◆ optimizeLatchExitIVUserViaSCEV()

◆ optimizeVectorInductionWidthForTCAndVFUF()

bool optimizeVectorInductionWidthForTCAndVFUF ( VPlan & Plan,
ElementCount BestVF,
unsigned BestUF )
static

Optimize the width of vector induction variables in Plan based on a known constant Trip Count, BestVF and BestUF.

Definition at line 1927 of file VPlanTransforms.cpp.

References llvm::VPBasicBlock::appendRecipe(), assert(), llvm::cast(), llvm::IntegerType::get(), llvm::APInt::getActiveBits(), llvm::VPlan::getBackedgeTakenCount(), llvm::APInt::getBitWidth(), llvm::VPlan::getConstantInt(), llvm::VPlan::getContext(), llvm::VPRecipeBase::getDebugLoc(), llvm::VPIRFlags::getDefaultFlags(), llvm::VPBlockBase::getEntryBasicBlock(), llvm::VPWidenInductionRecipe::getInductionDescriptor(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::VPlan::getOrCreateBackedgeTakenCount(), llvm::VPWidenInductionRecipe::getPHINode(), llvm::VPRecipeValue::getScalarType(), llvm::VPValue::getSingleUser(), llvm::VPlan::getTripCount(), llvm::VPWidenIntOrFpInductionRecipe::getTruncInst(), llvm::VPlan::getVectorLoopRegion(), llvm::VPlan::getVectorPreheader(), llvm::VPWidenInductionRecipe::getVFValue(), llvm::VPlan::getZero(), llvm::VPValue::hasMoreThanOneUniqueUser(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isFixed(), llvm::PatternMatch::m_APInt(), llvm::VPlanPatternMatch::m_Broadcast(), llvm::VPlanPatternMatch::m_CanonicalWidenIV(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), llvm::SCEVPatternMatch::match(), llvm::VPBasicBlock::phis(), llvm::PowerOf2Ceil(), llvm::APIntOps::RoundingUDiv(), and llvm::APInt::UP.

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

◆ reassociateHeaderMask()

void reassociateHeaderMask ( VPlan & Plan)
static

◆ removeCommonBlendMask()

◆ removeRedundantExpandSCEVRecipes()

void removeRedundantExpandSCEVRecipes ( VPlan & Plan)
static

Remove redundant ExpandSCEVRecipes in Plan's entry block by replacing them with already existing recipes expanding the same SCEV expression.

Definition at line 1100 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), llvm::VPlan::getEntry(), llvm::VPBlockBase::getEntryBasicBlock(), llvm::VPlan::getTripCount(), llvm::make_early_inc_range(), llvm::VPlan::resetTripCount(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().

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

◆ removeRedundantInductionCasts()

void removeRedundantInductionCasts ( VPlan & Plan)
static

Remove redundant casts of inductions.

Such redundant casts are casts of induction variables that can be ignored, because we already proved that the casted phi is equal to the uncasted phi in the vectorized loop. There is no need to vectorize the cast - the same value can be used for both the phi and casts in the vector loop.

Definition at line 648 of file VPlanTransforms.cpp.

References llvm::dyn_cast(), llvm::VPBlockBase::getEntryBasicBlock(), llvm::VPlan::getVectorLoopRegion(), IV, llvm::VPBasicBlock::phis(), llvm::VPValue::replaceAllUsesWith(), llvm::reverse(), and llvm::VPValue::users().

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

◆ simplifyBlends()

◆ simplifyBranchConditionForVFAndUF()

◆ simplifyLogicalRecipe()

◆ simplifyRecipe()

void simplifyRecipe ( VPSingleDefRecipe * Def)
static

Try to simplify VPSingleDefRecipe Def.

Definition at line 1264 of file VPlanTransforms.cpp.

References A(), llvm::all_equal(), llvm::all_of(), llvm::VPInstruction::AnyOf, assert(), llvm::VPInstruction::Broadcast, llvm::CallingConv::C, llvm::cast(), DL, llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::APInt::exactLogBase2(), llvm::CmpInst::FCMP_UNO, llvm::VPlanPatternMatch::findUserOf(), llvm::APInt::getBitWidth(), llvm::VPlan::getConcreteUF(), llvm::VPlan::getDataLayout(), llvm::CmpInst::getInversePredicate(), llvm::VPUser::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::VPDef::getVPSingleValue(), llvm::VPlan::getZero(), llvm::VPlan::hasScalarVFOnly(), llvm::isa(), llvm::APInt::isPowerOf2(), llvm::vputils::isSingleScalar(), llvm::vputils::isUniformAcrossVFsAndUFs(), llvm::VPlan::isUnrolled(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::VPlanPatternMatch::m_AnyOf(), llvm::PatternMatch::m_APInt(), llvm::VPlanPatternMatch::m_BinaryOr(), llvm::VPlanPatternMatch::m_Broadcast(), llvm::VPlanPatternMatch::m_BuildVector(), llvm::PatternMatch::m_c_Add(), llvm::VPlanPatternMatch::m_c_BinaryOr(), llvm::PatternMatch::m_c_Mul(), llvm::VPlanPatternMatch::m_CanonicalWidenIV(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::VPlanPatternMatch::m_ComputeReductionResult(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Deferred(), llvm::VPlanPatternMatch::m_DerivedIV(), llvm::VPlanPatternMatch::m_ExtractElement(), llvm::VPlanPatternMatch::m_ExtractLane(), llvm::VPlanPatternMatch::m_ExtractLastLane(), llvm::VPlanPatternMatch::m_ExtractLastPart(), llvm::VPlanPatternMatch::m_ExtractPenultimateElement(), llvm::VPlanPatternMatch::m_HeaderMask(), llvm::PatternMatch::m_Intrinsic(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificCmp(), llvm::PatternMatch::m_Sub(), llvm::VPlanPatternMatch::m_True(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_UDiv(), llvm::VPlanPatternMatch::m_VPInstruction(), llvm::VPlanPatternMatch::m_VPIRValue(), llvm::VPlanPatternMatch::m_VPPhi(), llvm::VPlanPatternMatch::m_VPValue(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::SCEVPatternMatch::match(), llvm::PatternMatch::match_fn(), llvm::vputils::onlyFirstLaneUsed(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::VPValue::replaceAllUsesWith(), simplifyLogicalRecipe(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::to_vector(), llvm::vputils::tryToFoldLiveIns(), X, and Y.

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

◆ sinkScalarOperands()

◆ tryToComputeEndValueForInduction()

◆ tryToCreateAbstractReductionRecipe()

void tryToCreateAbstractReductionRecipe ( VPReductionRecipe * Red,
VPCostContext & Ctx,
VFRange & Range )
static

This function tries to create abstract recipes from the reduction recipe for following optimizations and cost estimation.

Definition at line 3695 of file VPlanTransforms.cpp.

References assert(), llvm::VPRecipeBase::insertBefore(), Range, tryToMatchAndCreateExtendedReduction(), and tryToMatchAndCreateMulAccumulateReduction().

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

◆ tryToMatchAndCreateExtendedReduction()

◆ tryToMatchAndCreateMulAccumulateReduction()

VPExpressionRecipe * tryToMatchAndCreateMulAccumulateReduction ( VPReductionRecipe * Red,
VPCostContext & Ctx,
VFRange & Range )
static

◆ tryToReplaceALMWithWideALM()

bool tryToReplaceALMWithWideALM ( VPlan & Plan,
ElementCount VF,
unsigned UF )
static