LLVM 19.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 TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, AssumptionCache *AC, OptimizationRemarkEmitter *ORE, ElementCount VecWidth, ElementCount MinProfitableTripCount, unsigned UnrollFactor, LoopVectorizationLegality *LVL, LoopVectorizationCostModel *CM, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, GeneratedRTChecks &RTChecks) | |
virtual | ~InnerLoopVectorizer ()=default |
virtual std::pair< BasicBlock *, Value * > | createVectorizedLoopSkeleton (const SCEV2ValueTy &ExpandedSCEVs) |
Create a new empty loop that will contain vectorized instructions later on, while the old loop will be used as the scalar remainder. | |
void | fixVectorizedLoop (VPTransformState &State, VPlan &Plan) |
Fix the vectorized code, taking care of header phi's, live-outs, and more. | |
bool | areSafetyChecksAdded () |
void | scalarizeInstruction (const Instruction *Instr, VPReplicateRecipe *RepRecipe, const VPIteration &Instance, VPTransformState &State) |
A helper function to scalarize a single Instruction in the innermost loop. | |
void | vectorizeInterleaveGroup (const InterleaveGroup< Instruction > *Group, ArrayRef< VPValue * > VPDefs, VPTransformState &State, VPValue *Addr, ArrayRef< VPValue * > StoredValues, VPValue *BlockInMask, bool NeedsMaskForGaps) |
Try to vectorize interleaved access group Group with the base address given in Addr , optionally masking the vector operations if BlockInMask is non-null. | |
void | fixNonInductionPHIs (VPlan &Plan, VPTransformState &State) |
Fix the non-induction PHIs in Plan . | |
PHINode * | createInductionResumeValue (PHINode *OrigPhi, const InductionDescriptor &ID, Value *Step, ArrayRef< BasicBlock * > BypassBlocks, std::pair< BasicBlock *, Value * > AdditionalBypass={nullptr, nullptr}) |
Create a new phi node for the induction variable OrigPhi to resume iteration count in the scalar epilogue, from where the vectorized loop left off. | |
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 Types | |
using | PhiVector = SmallVector< PHINode *, 4 > |
A small list of PHINodes. | |
using | ScalarParts = SmallVector< SmallVector< Value *, 4 >, 2 > |
A type for scalarized values in the new loop. | |
Protected Member Functions | |
void | fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II, Value *VectorTripCount, Value *EndValue, BasicBlock *MiddleBlock, BasicBlock *VectorHeader, VPlan &Plan, VPTransformState &State) |
Set up the values of the IVs correctly when exiting the vector loop. | |
void | fixFixedOrderRecurrence (VPFirstOrderRecurrencePHIRecipe *PhiR, VPTransformState &State) |
Create the exit value of first order recurrences in the middle block and update their users. | |
void | sinkScalarOperands (Instruction *PredInst) |
Iteratively sink the scalarized operands of a predicated instruction into the block that was created for it. | |
Value * | getOrCreateVectorTripCount (BasicBlock *InsertBlock) |
Returns (and creates if needed) the trip count of the widened loop. | |
Value * | createBitOrPointerCast (Value *V, VectorType *DstVTy, const DataLayout &DL) |
Returns a bitcasted value to the requested vector type. | |
void | emitIterationCountCheck (BasicBlock *Bypass) |
Emit a bypass check to see if the vector trip count is zero, including if it overflows. | |
BasicBlock * | emitSCEVChecks (BasicBlock *Bypass) |
Emit a bypass check to see if all of the SCEV assumptions we've had to make are correct. | |
BasicBlock * | emitMemRuntimeChecks (BasicBlock *Bypass) |
Emit bypass checks to check any memory assumptions we may have made. | |
void | createVectorLoopSkeleton (StringRef Prefix) |
Emit basic blocks (prefixed with Prefix ) for the iteration check, vector loop preheader, middle block and scalar preheader. | |
void | createInductionResumeValues (const SCEV2ValueTy &ExpandedSCEVs, std::pair< BasicBlock *, Value * > AdditionalBypass={nullptr, nullptr}) |
Create new phi nodes for the induction variables to resume iteration count in the scalar epilogue, from where the vectorized loop left off. | |
BasicBlock * | completeLoopSkeleton () |
Complete the loop skeleton by adding debug MDs, creating appropriate conditional branches in the middle block, preparing the builder and running the verifier. | |
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 TargetLibraryInfo * | TLI |
Target Library Info. | |
const TargetTransformInfo * | TTI |
Target Transform Info. | |
AssumptionCache * | AC |
Assumption Cache. | |
OptimizationRemarkEmitter * | ORE |
Interface to emit optimization remarks. | |
ElementCount | VF |
The vectorization SIMD factor to use. | |
ElementCount | MinProfitableTripCount |
unsigned | UF |
The vectorization unroll factor to use. | |
IRBuilder | Builder |
The builder that we use. | |
BasicBlock * | LoopVectorPreHeader |
The vector-loop preheader. | |
BasicBlock * | LoopScalarPreHeader |
The scalar-loop preheader. | |
BasicBlock * | LoopMiddleBlock |
Middle Block between the vector and the scalar. | |
BasicBlock * | LoopExitBlock |
The unique ExitBlock of the scalar loop if one exists. | |
BasicBlock * | LoopScalarBody |
The scalar loop body. | |
SmallVector< BasicBlock *, 4 > | LoopBypassBlocks |
A list of all bypass blocks. The first block is the entry of the loop. | |
SmallVector< Instruction *, 4 > | PredicatedInstructions |
Store instructions that were predicated. | |
Value * | TripCount = nullptr |
Trip count of the original loop. | |
Value * | VectorTripCount = nullptr |
Trip count of the widened loop (TripCount - TripCount % (VF*UF)) | |
LoopVectorizationLegality * | Legal |
The legality analysis. | |
LoopVectorizationCostModel * | Cost |
The profitablity analysis. | |
bool | AddedSafetyChecks = false |
DenseMap< PHINode *, Value * > | IVEndValues |
BlockFrequencyInfo * | BFI |
BFI and PSI are used to check for profile guided size optimizations. | |
ProfileSummaryInfo * | PSI |
bool | OptForSizeBasedOnProfile |
GeneratedRTChecks & | RTChecks |
Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable. | |
SmallMapVector< const RecurrenceDescriptor *, PHINode *, 4 > | ReductionResumeValues |
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 502 of file LoopVectorize.cpp.
|
protected |
A small list of PHINodes.
Definition at line 595 of file LoopVectorize.cpp.
|
protected |
A type for scalarized values in the new loop.
Each value from the original loop, when scalarized, is represented by UF x VF scalar values in the new unrolled loop, where UF is the unroll factor and VF is the vectorization factor.
Definition at line 601 of file LoopVectorize.cpp.
|
inline |
Definition at line 504 of file LoopVectorize.cpp.
References BFI, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::IRPass, llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isZero(), MinProfitableTripCount, OptForSizeBasedOnProfile, OrigLoop, PSI, and llvm::shouldOptimizeForSize().
|
virtualdefault |
|
inline |
Definition at line 546 of file LoopVectorize.cpp.
References AddedSafetyChecks.
Referenced by llvm::LoopVectorizePass::processLoop().
|
protected |
Complete the loop skeleton by adding debug MDs, creating appropriate conditional branches in the middle block, preparing the builder and running the verifier.
Return the preheader of the completed vector loop.
Definition at line 3105 of file LoopVectorize.cpp.
References assert(), B, DT, llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), getOrCreateVectorTripCount(), llvm::BasicBlock::getTerminator(), getTripCount(), llvm::hasBranchWeightMD(), llvm::ElementCount::isVector(), LoopMiddleBlock, LoopVectorPreHeader, OrigLoop, llvm::setBranchWeights(), llvm::BranchInst::setCondition(), TripCount, UF, VectorTripCount, llvm::DominatorTreeBase< NodeT, IsPostDom >::verify(), and VF.
Referenced by llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().
|
protected |
Returns a bitcasted value to the requested vector type.
Also handles bitcasts of vector<float> <-> vector<pointer> types.
Definition at line 2797 of file LoopVectorize.cpp.
References assert(), Builder, llvm::IRBuilderBase::CreateBitOrPointerCast(), DL, llvm::VectorType::get(), llvm::Type::getIntNTy(), llvm::CastInst::isBitOrNoopPointerCastable(), llvm::Type::isFloatingPointTy(), llvm::Type::isPointerTy(), and VF.
Referenced by vectorizeInterleaveGroup().
PHINode * InnerLoopVectorizer::createInductionResumeValue | ( | PHINode * | OrigPhi, |
const InductionDescriptor & | ID, | ||
Value * | Step, | ||
ArrayRef< BasicBlock * > | BypassBlocks, | ||
std::pair< BasicBlock *, Value * > | AdditionalBypass = {nullptr, nullptr} |
||
) |
Create a new phi node for the induction variable OrigPhi
to resume iteration count in the scalar epilogue, from where the vectorized loop left off.
Step
is the SCEV-expanded induction step to use. In cases where the loop skeleton is more complicated (i.e., epilogue vectorization) and the resume values can come from an additional bypass block, the AdditionalBypass
pair provides information about the bypass block and the end value on the edge from bypass to this loop.
Definition at line 3010 of file LoopVectorize.cpp.
References llvm::PHINode::addIncoming(), assert(), B, llvm::PHINode::Create(), emitTransformedIndex(), llvm::Instruction::getDebugLoc(), llvm::Instruction::getFastMathFlags(), llvm::InductionDescriptor::getInductionBinOp(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::InductionDescriptor::getKind(), getOrCreateVectorTripCount(), llvm::LoopVectorizationLegality::getPrimaryInduction(), llvm::InductionDescriptor::getStartValue(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), IVEndValues, Legal, LoopMiddleBlock, LoopScalarPreHeader, LoopVectorPreHeader, llvm::Instruction::setDebugLoc(), llvm::PHINode::setIncomingValueForBlock(), llvm::Value::setName(), and VectorTripCount.
Referenced by createInductionResumeValues(), and llvm::LoopVectorizePass::processLoop().
|
protected |
Create new phi nodes for the induction variables to resume iteration count in the scalar epilogue, from where the vectorized loop left off.
In cases where the loop skeleton is more complicated (eg. epilogue vectorization) and the resume values can come from an additional bypass block, the AdditionalBypass
pair provides information about the bypass block and the end value on the edge from bypass to this loop.
Definition at line 3082 of file LoopVectorize.cpp.
References assert(), createInductionResumeValue(), getExpandedStep(), llvm::LoopVectorizationLegality::getInductionVars(), Legal, LoopBypassBlocks, LoopScalarPreHeader, and llvm::PHINode::setIncomingValueForBlock().
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().
|
virtual |
Create a new empty loop that will contain vectorized instructions later on, while the old loop will be used as the scalar remainder.
Control flow is generated around the vectorized (and scalar epilogue) loops consisting of various checks and bypasses. Return the pre-header block of the new loop and the start value for the canonical induction, if it is != 0. The latter is the case when vectorizing the epilogue loop. In the case of epilogue vectorization, this function is overriden to handle the more complex control flow around the loops. ExpandedSCEVs
is used to look up SCEV expansions for expressions needed during skeleton creation.
Reimplemented in llvm::InnerLoopAndEpilogueVectorizer.
Definition at line 3151 of file LoopVectorize.cpp.
References completeLoopSkeleton(), createInductionResumeValues(), createVectorLoopSkeleton(), emitIterationCountCheck(), emitMemRuntimeChecks(), emitSCEVChecks(), and LoopScalarPreHeader.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
protected |
Emit basic blocks (prefixed with Prefix
) for the iteration check, vector loop preheader, middle block and scalar preheader.
Definition at line 2967 of file LoopVectorize.cpp.
References assert(), Builder, llvm::DominatorTreeBase< NodeT, IsPostDom >::changeImmediateDominator(), llvm::BranchInst::Create(), DT, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getTerminator(), llvm::IRBuilderBase::getTrue(), llvm::LoopBase< BlockT, LoopT >::getUniqueExitBlock(), llvm::ElementCount::isVector(), LI, LoopExitBlock, LoopMiddleBlock, LoopScalarBody, LoopScalarPreHeader, LoopVectorPreHeader, OrigLoop, llvm::ReplaceInstWithInst(), llvm::Instruction::setDebugLoc(), llvm::SplitBlock(), and VF.
Referenced by llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().
|
protected |
Emit a bypass check to see if the vector trip count is zero, including if it overflows.
Definition at line 2828 of file LoopVectorize.cpp.
References assert(), Builder, llvm::DominatorTreeBase< NodeT, IsPostDom >::changeImmediateDominator(), llvm::BranchInst::Create(), llvm::IRBuilderBase::CreateBinaryIntrinsic(), llvm::IRBuilderBase::CreateICmp(), llvm::createStepForVF(), llvm::IRBuilderBase::CreateSub(), llvm::DataAndControlFlowWithoutRuntimeCheck, DT, llvm::IRBuilderBase::getFalse(), llvm::DomTreeNodeBase< NodeT >::getIDom(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::BasicBlock::getTerminator(), getTripCount(), llvm::Value::getType(), llvm::hasBranchWeightMD(), llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, isIndvarOverflowCheckKnownFalse(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::ElementCount::isVector(), LHS, LI, LoopBypassBlocks, LoopExitBlock, LoopVectorPreHeader, MinItersBypassWeights, MinProfitableTripCount, llvm::None, OrigLoop, P, llvm::DominatorTreeBase< NodeT, IsPostDom >::properlyDominates(), llvm::ReplaceInstWithInst(), llvm::setBranchWeights(), llvm::SplitBlock(), UF, and VF.
Referenced by createVectorizedLoopSkeleton().
|
protected |
Emit bypass checks to check any memory assumptions we may have made.
Returns the block containing the checks or nullptr if no checks have been added.
Definition at line 2931 of file LoopVectorize.cpp.
References AddedSafetyChecks, assert(), DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::EnableVPlanNativePath, llvm::LoopVectorizeHints::FK_Enabled, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BasicBlock::getParent(), llvm::Loop::getStartLoc(), llvm::Function::hasOptSize(), LoopBypassBlocks, LoopVectorPreHeader, OptForSizeBasedOnProfile, ORE, OrigLoop, and RTChecks.
Referenced by llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().
|
protected |
Emit a bypass check to see if all of the SCEV assumptions we've had to make are correct.
Returns the block containing the checks or nullptr if no checks have been added.
Definition at line 2904 of file LoopVectorize.cpp.
References AddedSafetyChecks, assert(), llvm::DominatorTreeBase< NodeT, IsPostDom >::changeImmediateDominator(), DT, llvm::LoopVectorizeHints::FK_Enabled, llvm::BasicBlock::getParent(), llvm::Function::hasOptSize(), llvm::ElementCount::isVector(), LoopBypassBlocks, LoopExitBlock, LoopVectorPreHeader, OptForSizeBasedOnProfile, RTChecks, and VF.
Referenced by llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().
|
protected |
Create the exit value of first order recurrences in the middle block and update their users.
Definition at line 3492 of file LoopVectorize.cpp.
References llvm::PHINode::addIncoming(), assert(), llvm::BasicBlock::begin(), Builder, llvm::IRBuilderBase::CreateExtractElement(), llvm::IRBuilderBase::CreatePHI(), llvm::IRBuilderBase::CreateSub(), llvm::SmallVectorBase< Size_T >::empty(), llvm::VPInstruction::FirstOrderRecurrenceSplice, llvm::VPTransformState::get(), llvm::VPHeaderPHIRecipe::getBackedgeValue(), llvm::IRBuilderBase::getInt32Ty(), llvm::VPValue::getLiveInIRValue(), llvm::VPValue::getNumUsers(), llvm::getRuntimeVF(), llvm::VPHeaderPHIRecipe::getStartValue(), llvm::BasicBlock::getTerminator(), llvm::VPValue::getUnderlyingValue(), Idx, llvm::ElementCount::isVector(), LoopMiddleBlock, LoopScalarPreHeader, llvm::VPTransformState::Plan, llvm::predecessors(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::VPlan::removeLiveOut(), llvm::IRBuilderBase::SetInsertPoint(), UF, llvm::VPValue::user_begin(), and VF.
Referenced by fixVectorizedLoop().
void InnerLoopVectorizer::fixNonInductionPHIs | ( | VPlan & | Plan, |
VPTransformState & | State | ||
) |
Fix the non-induction PHIs in Plan
.
Definition at line 3686 of file LoopVectorize.cpp.
References llvm::PHINode::addIncoming(), Builder, llvm::VPTransformState::CFG, llvm::VPTransformState::get(), llvm::VPlan::getEntry(), llvm::VPWidenPHIRecipe::getIncomingBlock(), llvm::VPWidenPHIRecipe::getIncomingValue(), llvm::VPUser::getNumOperands(), P, llvm::IRBuilderBase::SetInsertPoint(), llvm::vp_depth_first_deep(), and llvm::VPTransformState::CFGState::VPBB2IRBB.
Referenced by fixVectorizedLoop().
|
protected |
Set up the values of the IVs correctly when exiting the vector loop.
Definition at line 3216 of file LoopVectorize.cpp.
References assert(), B, llvm::LoopBase< BlockT, LoopT >::contains(), emitTransformedIndex(), llvm::VPTransformState::get(), llvm::Instruction::getFastMathFlags(), llvm::PHINode::getIncomingValueForBlock(), llvm::InductionDescriptor::getInductionBinOp(), llvm::InductionDescriptor::getKind(), llvm::VPValue::getLiveInIRValue(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::VPlan::getSCEVExpansion(), llvm::InductionDescriptor::getStartValue(), llvm::InductionDescriptor::getStep(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::LoopBase< BlockT, LoopT >::getUniqueExitBlock(), I, llvm::VPValue::isLiveIn(), OrigLoop, PHI, PostInc, llvm::VPlan::removeLiveOut(), llvm::Value::setName(), llvm::Value::users(), and VectorTripCount.
Referenced by fixVectorizedLoop().
void InnerLoopVectorizer::fixVectorizedLoop | ( | VPTransformState & | State, |
VPlan & | Plan | ||
) |
Fix the vectorized code, taking care of header phi's, live-outs, and more.
Definition at line 3407 of file LoopVectorize.cpp.
References llvm::VPTransformState::Builder, llvm::VPTransformState::CFG, cse(), llvm::EnableVPlanNativePath, llvm::VPTransformState::CFGState::ExitBB, fixFixedOrderRecurrence(), fixNonInductionPHIs(), fixupIVUsers(), llvm::ScalarEvolution::forgetBlockAndLoopDispositions(), llvm::ScalarEvolution::forgetLcssaPhiWithNewPredecessor(), llvm::ScalarEvolution::forgetLoop(), llvm::VPBlockBase::getEntryBasicBlock(), llvm::LoopBase< BlockT, LoopT >::getExitBlocks(), llvm::VPBlockBase::getExitingBasicBlock(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopVectorizationLegality::getInductionVars(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::VPlan::getLiveOuts(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), getOrCreateVectorTripCount(), llvm::PredicatedScalarEvolution::getSE(), llvm::VPlan::getVectorLoopRegion(), llvm::ElementCount::isVector(), IVEndValues, Legal, LI, LoopMiddleBlock, LoopScalarBody, OrigLoop, llvm::VPBasicBlock::phis(), llvm::VPTransformState::Plan, PredicatedInstructions, PSE, llvm::IRBuilderBase::SetInsertPoint(), llvm::setProfileInfoAfterUnrolling(), sinkScalarOperands(), UF, VF, and llvm::VPTransformState::CFGState::VPBB2IRBB.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
|
protected |
Returns (and creates if needed) the trip count of the widened loop.
Definition at line 2747 of file LoopVectorize.cpp.
References assert(), Builder, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateSelect(), llvm::createStepForVF(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateURem(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::getRuntimeVF(), llvm::BasicBlock::getTerminator(), getTripCount(), llvm::Value::getType(), llvm::isPowerOf2_32(), llvm::ElementCount::isVector(), UF, VectorTripCount, and VF.
Referenced by completeLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), createInductionResumeValue(), llvm::LoopVectorizationPlanner::executePlan(), and fixVectorizedLoop().
|
inline |
Returns the original loop trip count.
Definition at line 584 of file LoopVectorize.cpp.
References TripCount.
Referenced by completeLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::LoopVectorizationPlanner::executePlan(), getOrCreateVectorTripCount(), and llvm::LoopVectorizePass::processLoop().
|
inlineprotectedvirtual |
Reimplemented in llvm::EpilogueVectorizerMainLoop, and llvm::EpilogueVectorizerEpilogueLoop.
Definition at line 662 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 661 of file LoopVectorize.cpp.
Referenced by llvm::LoopVectorizationPlanner::executePlan().
void InnerLoopVectorizer::scalarizeInstruction | ( | const Instruction * | Instr, |
VPReplicateRecipe * | RepRecipe, | ||
const VPIteration & | Instance, | ||
VPTransformState & | State | ||
) |
A helper function to scalarize a single Instruction in the innermost loop.
Generates a sequence of scalar instances for each lane between MinLane
and MaxLane
, times each part between MinPart
and MaxPart
, inclusive. Uses the VPValue operands from RepRecipe
instead of Instr's
operands.
Definition at line 2689 of file LoopVectorize.cpp.
References AC, llvm::VPTransformState::addNewMetadata(), assert(), llvm::VPTransformState::Builder, DL, llvm::enumerate(), llvm::VPTransformState::get(), llvm::VPLane::getFirstLane(), llvm::VPBlockBase::getParent(), llvm::VPRecipeBase::getParent(), llvm::Value::getType(), I, llvm::VPTypeAnalysis::inferScalarType(), llvm::IRBuilderBase::Insert(), llvm::VPIteration::isFirstIteration(), llvm::VPRegionBlock::isReplicator(), llvm::vputils::isUniformAfterVectorization(), llvm::VPUser::operands(), PredicatedInstructions, llvm::AssumptionCache::registerAssumption(), llvm::VPTransformState::set(), llvm::VPTransformState::setDebugLocFrom(), llvm::VPRecipeWithIRFlags::setFlags(), llvm::Value::setName(), llvm::User::setOperand(), and llvm::VPTransformState::TypeAnalysis.
Referenced by llvm::VPReplicateRecipe::execute().
|
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 589 of file LoopVectorize.cpp.
References TripCount.
Referenced by llvm::LoopVectorizationPlanner::executePlan(), and llvm::LoopVectorizePass::processLoop().
|
protected |
Iteratively sink the scalarized operands of a predicated instruction into the block that was created for it.
Definition at line 3611 of file LoopVectorize.cpp.
References llvm::all_of(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorImpl< T >::clear(), llvm::SetVector< T, Vector, Set, N >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::PHINode::getIncomingValueNumForOperand(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::Instruction::getParent(), I, llvm::SetVector< T, Vector, Set, N >::insert(), LI, llvm::User::op_begin(), llvm::User::op_end(), llvm::SetVector< T, Vector, Set, N >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by fixVectorizedLoop().
void InnerLoopVectorizer::vectorizeInterleaveGroup | ( | const InterleaveGroup< Instruction > * | Group, |
ArrayRef< VPValue * > | VPDefs, | ||
VPTransformState & | State, | ||
VPValue * | Addr, | ||
ArrayRef< VPValue * > | StoredValues, | ||
VPValue * | BlockInMask, | ||
bool | NeedsMaskForGaps | ||
) |
Try to vectorize interleaved access group Group
with the base address given in Addr
, optionally masking the vector operations if BlockInMask
is non-null.
Use State
to translate given VPValues to IR values in the vectorized loop.
Definition at line 2447 of file LoopVectorize.cpp.
References llvm::InterleaveGroup< InstTy >::addMetadata(), Addr, assert(), Builder, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAlignedLoad(), llvm::IRBuilderBase::CreateAlignedStore(), llvm::IRBuilderBase::CreateBinOp(), llvm::createBitMaskForGaps(), createBitOrPointerCast(), llvm::IRBuilderBase::CreateExtractValue(), llvm::IRBuilderBase::CreateGEP(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateMaskedLoad(), llvm::IRBuilderBase::CreateMaskedStore(), llvm::IRBuilderBase::CreateMul(), llvm::IRBuilderBase::CreateNeg(), llvm::createReplicatedMask(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::createStrideMask(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateVectorReverse(), DL, gep, llvm::VectorType::get(), llvm::PoisonValue::get(), llvm::VPTransformState::get(), llvm::InterleaveGroup< InstTy >::getAlign(), llvm::InterleaveGroup< InstTy >::getFactor(), llvm::InterleaveGroup< InstTy >::getIndex(), llvm::InterleaveGroup< InstTy >::getInsertPos(), llvm::IRBuilderBase::getInt1Ty(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt32Ty(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::getLoadStoreType(), llvm::InterleaveGroup< InstTy >::getMember(), llvm::getRuntimeVF(), llvm::Value::getType(), I, Idx, interleaveVectors(), llvm::InterleaveGroup< InstTy >::isReverse(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::VPTransformState::set(), llvm::VPTransformState::setDebugLocFrom(), llvm::Value::stripPointerCasts(), UF, useMaskedInterleavedAccesses(), and VF.
Referenced by llvm::VPInterleaveRecipe::execute().
|
friend |
Definition at line 592 of file LoopVectorize.cpp.
|
protected |
Assumption Cache.
Definition at line 685 of file LoopVectorize.cpp.
Referenced by scalarizeInstruction().
|
protected |
Definition at line 740 of file LoopVectorize.cpp.
Referenced by areSafetyChecksAdded(), emitMemRuntimeChecks(), and emitSCEVChecks().
|
protected |
BFI and PSI are used to check for profile guided size optimizations.
Definition at line 747 of file LoopVectorize.cpp.
Referenced by InnerLoopVectorizer().
|
protected |
The builder that we use.
Definition at line 701 of file LoopVectorize.cpp.
Referenced by createBitOrPointerCast(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), llvm::LoopVectorizationPlanner::executePlan(), fixFixedOrderRecurrence(), fixNonInductionPHIs(), getOrCreateVectorTripCount(), and vectorizeInterleaveGroup().
|
protected |
The profitablity analysis.
Definition at line 737 of file LoopVectorize.cpp.
|
protected |
Dominator Tree.
Definition at line 676 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), and emitSCEVChecks().
Definition at line 744 of file LoopVectorize.cpp.
Referenced by createInductionResumeValue(), and fixVectorizedLoop().
|
protected |
The legality analysis.
Definition at line 734 of file LoopVectorize.cpp.
Referenced by createInductionResumeValue(), createInductionResumeValues(), llvm::LoopVectorizationPlanner::executePlan(), and fixVectorizedLoop().
|
protected |
Loop Info.
Definition at line 673 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), fixVectorizedLoop(), and sinkScalarOperands().
|
protected |
A list of all bypass blocks. The first block is the entry of the loop.
Definition at line 722 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createInductionResumeValues(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitMemRuntimeChecks(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), and emitSCEVChecks().
|
protected |
The unique ExitBlock of the scalar loop if one exists.
Note that there can be multiple exiting edges reaching this block.
Definition at line 716 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), and emitSCEVChecks().
|
protected |
Middle Block between the vector and the scalar.
Definition at line 712 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), createInductionResumeValue(), createVectorLoopSkeleton(), fixFixedOrderRecurrence(), and fixVectorizedLoop().
|
protected |
The scalar loop body.
Definition at line 719 of file LoopVectorize.cpp.
Referenced by createVectorLoopSkeleton(), and fixVectorizedLoop().
|
protected |
The scalar-loop preheader.
Definition at line 709 of file LoopVectorize.cpp.
Referenced by llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createInductionResumeValue(), createInductionResumeValues(), createVectorizedLoopSkeleton(), createVectorLoopSkeleton(), and fixFixedOrderRecurrence().
|
protected |
The vector-loop preheader.
Definition at line 706 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createInductionResumeValue(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitMemRuntimeChecks(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), and emitSCEVChecks().
|
protected |
Definition at line 694 of file LoopVectorize.cpp.
Referenced by emitIterationCountCheck(), and InnerLoopVectorizer().
|
protected |
Definition at line 752 of file LoopVectorize.cpp.
Referenced by emitMemRuntimeChecks(), emitSCEVChecks(), and InnerLoopVectorizer().
|
protected |
Interface to emit optimization remarks.
Definition at line 688 of file LoopVectorize.cpp.
Referenced by emitMemRuntimeChecks().
|
protected |
The original loop.
Definition at line 665 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitMemRuntimeChecks(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), fixupIVUsers(), fixVectorizedLoop(), InnerLoopVectorizer(), llvm::EpilogueVectorizerMainLoop::printDebugTracesAtEnd(), and llvm::EpilogueVectorizerEpilogueLoop::printDebugTracesAtEnd().
|
protected |
Store instructions that were predicated.
Definition at line 725 of file LoopVectorize.cpp.
Referenced by fixVectorizedLoop(), and scalarizeInstruction().
|
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 670 of file LoopVectorize.cpp.
Referenced by fixVectorizedLoop().
|
protected |
Definition at line 748 of file LoopVectorize.cpp.
Referenced by InnerLoopVectorizer().
|
protected |
Definition at line 761 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 756 of file LoopVectorize.cpp.
Referenced by emitMemRuntimeChecks(), and emitSCEVChecks().
|
protected |
Target Library Info.
Definition at line 679 of file LoopVectorize.cpp.
|
protected |
Trip count of the original loop.
Definition at line 728 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), llvm::EpilogueVectorizerEpilogueLoop::EpilogueVectorizerEpilogueLoop(), getTripCount(), and setTripCount().
|
protected |
Target Transform Info.
Definition at line 682 of file LoopVectorize.cpp.
|
protected |
The vectorization unroll factor to use.
Each scalar is vectorized to this many different vector instructions.
Definition at line 698 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), fixFixedOrderRecurrence(), fixVectorizedLoop(), getOrCreateVectorTripCount(), and vectorizeInterleaveGroup().
|
protected |
Trip count of the widened loop (TripCount - TripCount % (VF*UF))
Definition at line 731 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), createInductionResumeValue(), fixupIVUsers(), and getOrCreateVectorTripCount().
|
protected |
The vectorization SIMD factor to use.
Each vector will have this many vector elements.
Definition at line 692 of file LoopVectorize.cpp.
Referenced by completeLoopSkeleton(), createBitOrPointerCast(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), llvm::EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(), emitSCEVChecks(), fixFixedOrderRecurrence(), fixVectorizedLoop(), getOrCreateVectorTripCount(), and vectorizeInterleaveGroup().