LLVM  16.0.0git
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::InnerLoopVectorizer Class Reference

InnerLoopVectorizer vectorizes loops which contain only one basic block to a specified vectorization factor (VF). More...

Inheritance diagram for llvm::InnerLoopVectorizer:
Inheritance graph
[legend]
Collaboration diagram for llvm::InnerLoopVectorizer:
Collaboration graph
[legend]

Public Types

using VectorParts = SmallVector< Value *, 2 >
 A type for vectorized values in the new loop. 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 ()
 Create a new empty loop that will contain vectorized instructions later on, while the old loop will be used as the scalar remainder. More...
 
void fixVectorizedLoop (VPTransformState &State, VPlan &Plan)
 Fix the vectorized code, taking care of header phi's, live-outs, and more. More...
 
bool areSafetyChecksAdded ()
 
void scalarizeInstruction (const Instruction *Instr, VPReplicateRecipe *RepRecipe, const VPIteration &Instance, bool IfPredicateInstr, VPTransformState &State)
 A helper function to scalarize a single Instruction in the innermost loop. More...
 
void packScalarIntoVectorValue (VPValue *Def, const VPIteration &Instance, VPTransformState &State)
 Construct the vector value of a scalarized value V one lane at a time. More...
 
void vectorizeInterleaveGroup (const InterleaveGroup< Instruction > *Group, ArrayRef< VPValue * > VPDefs, VPTransformState &State, VPValue *Addr, ArrayRef< VPValue * > StoredValues, VPValue *BlockInMask=nullptr)
 Try to vectorize interleaved access group Group with the base address given in Addr, optionally masking the vector operations if BlockInMask is non-null. More...
 
void fixNonInductionPHIs (VPlan &Plan, VPTransformState &State)
 Fix the non-induction PHIs in Plan. More...
 
bool useOrderedReductions (const RecurrenceDescriptor &RdxDesc)
 Returns true if the reordering of FP operations is not allowed, but we are able to vectorize with strict in-order reductions for the given RdxDesc. More...
 
virtual ValuegetBroadcastInstrs (Value *V)
 Create a broadcast instruction. More...
 
PHINodegetReductionResumeValue (const RecurrenceDescriptor &RdxDesc)
 
PHINodecreateInductionResumeValue (PHINode *OrigPhi, const InductionDescriptor &ID, 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. More...
 

Protected Types

using PhiVector = SmallVector< PHINode *, 4 >
 A small list of PHINodes. More...
 
using ScalarParts = SmallVector< SmallVector< Value *, 4 >, 2 >
 A type for scalarized values in the new loop. More...
 

Protected Member Functions

void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II, Value *VectorTripCount, Value *EndValue, BasicBlock *MiddleBlock, BasicBlock *VectorHeader, VPlan &Plan)
 Set up the values of the IVs correctly when exiting the vector loop. More...
 
void fixCrossIterationPHIs (VPTransformState &State)
 Handle all cross-iteration phis in the header. More...
 
void fixFixedOrderRecurrence (VPFirstOrderRecurrencePHIRecipe *PhiR, VPTransformState &State)
 Create the exit value of first order recurrences in the middle block and update their users. More...
 
void fixReduction (VPReductionPHIRecipe *Phi, VPTransformState &State)
 Create code for the loop exit value of the reduction. More...
 
void clearReductionWrapFlags (VPReductionPHIRecipe *PhiR, VPTransformState &State)
 Clear NSW/NUW flags from reduction instructions if necessary. More...
 
void sinkScalarOperands (Instruction *PredInst)
 Iteratively sink the scalarized operands of a predicated instruction into the block that was created for it. More...
 
void truncateToMinimalBitwidths (VPTransformState &State)
 Shrinks vector element sizes to the smallest bitwidth they can be legally represented as. More...
 
ValuegetOrCreateTripCount (BasicBlock *InsertBlock)
 Returns (and creates if needed) the original loop trip count. More...
 
ValuegetOrCreateVectorTripCount (BasicBlock *InsertBlock)
 Returns (and creates if needed) the trip count of the widened loop. More...
 
ValuecreateBitOrPointerCast (Value *V, VectorType *DstVTy, const DataLayout &DL)
 Returns a bitcasted value to the requested vector type. More...
 
void emitIterationCountCheck (BasicBlock *Bypass)
 Emit a bypass check to see if the vector trip count is zero, including if it overflows. More...
 
BasicBlockemitSCEVChecks (BasicBlock *Bypass)
 Emit a bypass check to see if all of the SCEV assumptions we've had to make are correct. More...
 
BasicBlockemitMemRuntimeChecks (BasicBlock *Bypass)
 Emit bypass checks to check any memory assumptions we may have made. More...
 
void createVectorLoopSkeleton (StringRef Prefix)
 Emit basic blocks (prefixed with Prefix) for the iteration check, vector loop preheader, middle block and scalar preheader. More...
 
void createInductionResumeValues (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. More...
 
BasicBlockcompleteLoopSkeleton (MDNode *OrigLoopID)
 Complete the loop skeleton by adding debug MDs, creating appropriate conditional branches in the middle block, preparing the builder and running the verifier. More...
 
void collectPoisonGeneratingRecipes (VPTransformState &State)
 Collect poison-generating recipes that may generate a poison value that is used after vectorization, even when their operands are not poison. More...
 
virtual void printDebugTracesAtStart ()
 Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested. More...
 
virtual void printDebugTracesAtEnd ()
 

Protected Attributes

LoopOrigLoop
 The original loop. More...
 
PredicatedScalarEvolutionPSE
 A wrapper around ScalarEvolution used to add runtime SCEV checks. More...
 
LoopInfoLI
 Loop Info. More...
 
DominatorTreeDT
 Dominator Tree. More...
 
AAResultsAA
 Alias Analysis. More...
 
const TargetLibraryInfoTLI
 Target Library Info. More...
 
const TargetTransformInfoTTI
 Target Transform Info. More...
 
AssumptionCacheAC
 Assumption Cache. More...
 
OptimizationRemarkEmitterORE
 Interface to emit optimization remarks. More...
 
ElementCount VF
 The vectorization SIMD factor to use. More...
 
ElementCount MinProfitableTripCount
 
unsigned UF
 The vectorization unroll factor to use. More...
 
IRBuilder Builder
 The builder that we use. More...
 
BasicBlockLoopVectorPreHeader
 The vector-loop preheader. More...
 
BasicBlockLoopScalarPreHeader
 The scalar-loop preheader. More...
 
BasicBlockLoopMiddleBlock
 Middle Block between the vector and the scalar. More...
 
BasicBlockLoopExitBlock
 The unique ExitBlock of the scalar loop if one exists. More...
 
BasicBlockLoopScalarBody
 The scalar loop body. More...
 
SmallVector< BasicBlock *, 4 > LoopBypassBlocks
 A list of all bypass blocks. The first block is the entry of the loop. More...
 
SmallVector< Instruction *, 4 > PredicatedInstructions
 Store instructions that were predicated. More...
 
ValueTripCount = nullptr
 Trip count of the original loop. More...
 
ValueVectorTripCount = nullptr
 Trip count of the widened loop (TripCount - TripCount % (VF*UF)) More...
 
LoopVectorizationLegalityLegal
 The legality analysis. More...
 
LoopVectorizationCostModelCost
 The profitablity analysis. More...
 
bool AddedSafetyChecks = false
 
DenseMap< PHINode *, Value * > IVEndValues
 
BlockFrequencyInfoBFI
 BFI and PSI are used to check for profile guided size optimizations. More...
 
ProfileSummaryInfoPSI
 
bool OptForSizeBasedOnProfile
 
GeneratedRTChecksRTChecks
 Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable. More...
 
SmallMapVector< const RecurrenceDescriptor *, PHINode *, 4 > ReductionResumeValues
 

Friends

class LoopVectorizationPlanner
 

Detailed Description

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 443 of file LoopVectorize.cpp.

Member Typedef Documentation

◆ PhiVector

A small list of PHINodes.

Definition at line 549 of file LoopVectorize.cpp.

◆ ScalarParts

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 555 of file LoopVectorize.cpp.

◆ VectorParts

A type for vectorized values in the new loop.

Each value from the original loop, when vectorized, is represented by UF vector values in the new unrolled loop, where UF is the unroll factor.

Definition at line 490 of file LoopVectorize.cpp.

Constructor & Destructor Documentation

◆ InnerLoopVectorizer()

llvm::InnerLoopVectorizer::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 
)
inline

◆ ~InnerLoopVectorizer()

virtual llvm::InnerLoopVectorizer::~InnerLoopVectorizer ( )
virtualdefault

Member Function Documentation

◆ areSafetyChecksAdded()

bool llvm::InnerLoopVectorizer::areSafetyChecksAdded ( )
inline

Definition at line 485 of file LoopVectorize.cpp.

References AddedSafetyChecks.

Referenced by llvm::LoopVectorizePass::processLoop().

◆ clearReductionWrapFlags()

void InnerLoopVectorizer::clearReductionWrapFlags ( VPReductionPHIRecipe PhiR,
VPTransformState State 
)
protected

◆ collectPoisonGeneratingRecipes()

void InnerLoopVectorizer::collectPoisonGeneratingRecipes ( VPTransformState State)
protected

Collect poison-generating recipes that may generate a poison value that is used after vectorization, even when their operands are not poison.

Those recipes meet the following conditions:

  • Contribute to the address computation of a recipe generating a widen memory load/store (VPWidenMemoryInstructionRecipe or VPInterleaveRecipe).
  • Such a widen memory load/store has at least one underlying Instruction that is in a basic block that needs predication and after vectorization the generated instruction won't be predicated.

Definition at line 1015 of file LoopVectorize.cpp.

References llvm::LoopVectorizationLegality::blockNeedsPredication(), llvm::depth_first(), llvm::VPlan::getEntry(), llvm::InterleaveGroup< InstTy >::getMember(), llvm::InterleaveGroup< InstTy >::getNumMembers(), llvm::Instruction::getParent(), I, Legal, and llvm::VPTransformState::Plan.

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

◆ completeLoopSkeleton()

BasicBlock * InnerLoopVectorizer::completeLoopSkeleton ( MDNode OrigLoopID)
protected

◆ createBitOrPointerCast()

Value * InnerLoopVectorizer::createBitOrPointerCast ( Value V,
VectorType DstVTy,
const DataLayout DL 
)
protected

Returns a bitcasted value to the requested vector type.

Also handles bitcasts of vector<float> <-> vector<pointer> types.

Definition at line 2911 of file LoopVectorize.cpp.

References assert(), Builder, llvm::IRBuilderBase::CreateBitOrPointerCast(), DL, llvm::FixedVectorType::get(), llvm::Value::getContext(), llvm::Type::getIntNTy(), llvm::Value::getType(), llvm::CastInst::isBitOrNoopPointerCastable(), llvm::Type::isFloatingPointTy(), llvm::Type::isPointerTy(), and VF.

Referenced by vectorizeInterleaveGroup().

◆ createInductionResumeValue()

PHINode * InnerLoopVectorizer::createInductionResumeValue ( PHINode OrigPhi,
const InductionDescriptor ID,
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.

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 3118 of file LoopVectorize.cpp.

References llvm::PHINode::addIncoming(), assert(), B, BB, llvm::PHINode::Create(), CreateStepValue(), emitTransformedIndex(), llvm::CastInst::getCastOpcode(), llvm::Instruction::getDebugLoc(), llvm::Instruction::getFastMathFlags(), llvm::InductionDescriptor::getInductionBinOp(), getOrCreateVectorTripCount(), llvm::LoopVectorizationLegality::getPrimaryInduction(), llvm::PredicatedScalarEvolution::getSE(), llvm::InductionDescriptor::getStartValue(), llvm::InductionDescriptor::getStep(), llvm::BasicBlock::getTerminator(), llvm::SCEV::getType(), llvm::Value::getType(), IVEndValues, Legal, LoopMiddleBlock, LoopScalarPreHeader, LoopVectorPreHeader, PSE, llvm::Instruction::setDebugLoc(), llvm::PHINode::setIncomingValueForBlock(), llvm::Value::setName(), and VectorTripCount.

Referenced by createInductionResumeValues().

◆ createInductionResumeValues()

void InnerLoopVectorizer::createInductionResumeValues ( std::pair< BasicBlock *, Value * >  AdditionalBypass = {nullptr, nullptr})
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 3183 of file LoopVectorize.cpp.

References assert(), createInductionResumeValue(), llvm::LoopVectorizationLegality::getInductionVars(), Legal, LoopBypassBlocks, LoopScalarPreHeader, and llvm::PHINode::setIncomingValueForBlock().

Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), and createVectorizedLoopSkeleton().

◆ createVectorizedLoopSkeleton()

std::pair< BasicBlock *, Value * > InnerLoopVectorizer::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.

Reimplemented in llvm::InnerLoopAndEpilogueVectorizer.

Definition at line 3240 of file LoopVectorize.cpp.

References completeLoopSkeleton(), createInductionResumeValues(), createVectorLoopSkeleton(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitMemRuntimeChecks(), emitSCEVChecks(), llvm::Loop::getLoopID(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), getOrCreateTripCount(), LoopScalarPreHeader, and OrigLoop.

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

◆ createVectorLoopSkeleton()

void InnerLoopVectorizer::createVectorLoopSkeleton ( StringRef  Prefix)
protected

◆ emitIterationCountCheck()

void InnerLoopVectorizer::emitIterationCountCheck ( BasicBlock Bypass)
protected

◆ emitMemRuntimeChecks()

BasicBlock * InnerLoopVectorizer::emitMemRuntimeChecks ( BasicBlock Bypass)
protected

◆ emitSCEVChecks()

BasicBlock * InnerLoopVectorizer::emitSCEVChecks ( BasicBlock Bypass)
protected

◆ fixCrossIterationPHIs()

void InnerLoopVectorizer::fixCrossIterationPHIs ( VPTransformState State)
protected

◆ fixFixedOrderRecurrence()

void InnerLoopVectorizer::fixFixedOrderRecurrence ( VPFirstOrderRecurrencePHIRecipe PhiR,
VPTransformState State 
)
protected

◆ fixNonInductionPHIs()

void InnerLoopVectorizer::fixNonInductionPHIs ( VPlan Plan,
VPTransformState State 
)

◆ fixReduction()

void InnerLoopVectorizer::fixReduction ( VPReductionPHIRecipe Phi,
VPTransformState State 
)
protected

Create code for the loop exit value of the reduction.

Definition at line 3861 of file LoopVectorize.cpp.

References llvm::PHINode::addIncoming(), assert(), llvm::PHINode::blocks(), Builder, llvm::VPTransformState::CFG, clearReductionWrapFlags(), Cost, llvm::PHINode::Create(), llvm::IRBuilderBase::CreateBinOp(), llvm::createMinMaxOp(), llvm::createSelectCmpOp(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateStore(), llvm::createTargetReduction(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateZExt(), llvm::LoopVectorizationCostModel::foldTailByMasking(), llvm::VPTransformState::get(), llvm::VectorType::get(), llvm::VPHeaderPHIRecipe::getBackedgeValue(), llvm::PHINode::getBasicBlockIndex(), llvm::VPBasicBlock::getEnclosingLoopRegion(), llvm::VPBlockBase::getExitingBasicBlock(), llvm::RecurrenceDescriptor::getFastMathFlags(), llvm::BasicBlock::getFirstInsertionPt(), llvm::PHINode::getIncomingValueForBlock(), llvm::RecurrenceDescriptor::getLoopExitInstr(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::RecurrenceDescriptor::getOpcode(), llvm::VPRecipeBase::getParent(), llvm::VPReductionPHIRecipe::getRecurrenceDescriptor(), llvm::RecurrenceDescriptor::getRecurrenceKind(), llvm::RecurrenceDescriptor::getRecurrenceStartValue(), llvm::RecurrenceDescriptor::getRecurrenceType(), llvm::VPHeaderPHIRecipe::getStartValue(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::VPValue::getUnderlyingValue(), llvm::RecurrenceDescriptor::IntermediateStore, llvm::is_contained(), llvm::VPReductionPHIRecipe::isInLoop(), llvm::VPReductionPHIRecipe::isOrdered(), llvm::LoopVectorizationLegality::isReductionVariable(), llvm::RecurrenceDescriptor::isSelectCmpRecurrenceKind(), llvm::RecurrenceDescriptor::isSigned(), llvm::ElementCount::isVector(), Legal, LoopExitBlock, LoopMiddleBlock, LoopScalarPreHeader, llvm::make_early_inc_range(), OrigLoop, llvm::BasicBlock::phis(), llvm::VPTransformState::Plan, llvm::predecessors(), PreferPredicatedReductionSelect, llvm::TargetTransformInfo::preferPredicatedReductionSelect(), llvm::propagateMetadata(), ReductionResumeValues, llvm::VPlan::removeLiveOut(), llvm::LoopVectorizationCostModel::requiresScalarEpilogue(), llvm::VPTransformState::reset(), llvm::VPTransformState::setDebugLocFromInst(), llvm::IRBuilderBase::setFastMathFlags(), llvm::Instruction::setFastMathFlags(), llvm::PHINode::setIncomingValue(), llvm::IRBuilderBase::SetInsertPoint(), SI, UF, users, llvm::Value::users(), VF, and llvm::VPTransformState::CFGState::VPBB2IRBB.

Referenced by fixCrossIterationPHIs().

◆ fixupIVUsers()

void InnerLoopVectorizer::fixupIVUsers ( PHINode OrigPhi,
const InductionDescriptor II,
Value VectorTripCount,
Value EndValue,
BasicBlock MiddleBlock,
BasicBlock VectorHeader,
VPlan Plan 
)
protected

◆ fixVectorizedLoop()

void InnerLoopVectorizer::fixVectorizedLoop ( VPTransformState State,
VPlan Plan 
)

◆ getBroadcastInstrs()

Value * InnerLoopVectorizer::getBroadcastInstrs ( Value V)
virtual

Create a broadcast instruction.

This method generates a broadcast instruction (shuffle) for loop invariant values and for the induction value. If this is the induction variable then we extend it to N, N+1, ... this is needed because each iteration in the loop corresponds to a SIMD element.

Definition at line 2261 of file LoopVectorize.cpp.

References Builder, llvm::IRBuilderBase::CreateVectorSplat(), llvm::DominatorTree::dominates(), DT, llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Loop::isLoopInvariant(), LoopVectorPreHeader, OrigLoop, llvm::IRBuilderBase::SetInsertPoint(), and VF.

◆ getOrCreateTripCount()

Value * InnerLoopVectorizer::getOrCreateTripCount ( BasicBlock InsertBlock)
protected

◆ getOrCreateVectorTripCount()

Value * InnerLoopVectorizer::getOrCreateVectorTripCount ( BasicBlock InsertBlock)
protected

◆ getReductionResumeValue()

PHINode * InnerLoopVectorizer::getReductionResumeValue ( const RecurrenceDescriptor RdxDesc)

Definition at line 1096 of file LoopVectorize.cpp.

References assert(), and ReductionResumeValues.

Referenced by llvm::LoopVectorizePass::processLoop().

◆ packScalarIntoVectorValue()

void InnerLoopVectorizer::packScalarIntoVectorValue ( VPValue Def,
const VPIteration Instance,
VPTransformState State 
)

◆ printDebugTracesAtEnd()

virtual void llvm::InnerLoopVectorizer::printDebugTracesAtEnd ( )
inlineprotectedvirtual

◆ printDebugTracesAtStart()

virtual void llvm::InnerLoopVectorizer::printDebugTracesAtStart ( )
inlineprotectedvirtual

Allow subclasses to override and print debug traces before/after vplan execution, when trace information is requested.

Reimplemented in llvm::EpilogueVectorizerEpilogueLoop, and llvm::EpilogueVectorizerMainLoop.

Definition at line 642 of file LoopVectorize.cpp.

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

◆ scalarizeInstruction()

void InnerLoopVectorizer::scalarizeInstruction ( const Instruction Instr,
VPReplicateRecipe RepRecipe,
const VPIteration Instance,
bool  IfPredicateInstr,
VPTransformState State 
)

◆ sinkScalarOperands()

void InnerLoopVectorizer::sinkScalarOperands ( Instruction PredInst)
protected

◆ truncateToMinimalBitwidths()

void InnerLoopVectorizer::truncateToMinimalBitwidths ( VPTransformState State)
protected

◆ useOrderedReductions()

bool InnerLoopVectorizer::useOrderedReductions ( const RecurrenceDescriptor RdxDesc)

Returns true if the reordering of FP operations is not allowed, but we are able to vectorize with strict in-order reductions for the given RdxDesc.

Definition at line 4187 of file LoopVectorize.cpp.

References Cost, and llvm::LoopVectorizationCostModel::useOrderedReductions().

Referenced by llvm::LoopVectorizationCostModel::collectElementTypesForWidening(), llvm::LoopVectorizationCostModel::collectInLoopReductions(), and llvm::VPReductionRecipe::execute().

◆ vectorizeInterleaveGroup()

void InnerLoopVectorizer::vectorizeInterleaveGroup ( const InterleaveGroup< Instruction > *  Group,
ArrayRef< VPValue * >  VPDefs,
VPTransformState State,
VPValue Addr,
ArrayRef< VPValue * >  StoredValues,
VPValue BlockInMask = nullptr 
)

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 2556 of file LoopVectorize.cpp.

References llvm::InterleaveGroup< InstTy >::addMetadata(), Addr, assert(), Builder, llvm::concatenateVectors(), Cost, llvm::IRBuilderBase::CreateAlignedLoad(), llvm::IRBuilderBase::CreateAlignedStore(), llvm::IRBuilderBase::CreateBinOp(), llvm::IRBuilderBase::CreateBitCast(), llvm::createBitMaskForGaps(), createBitOrPointerCast(), llvm::IRBuilderBase::CreateGEP(), llvm::createInterleaveMask(), llvm::IRBuilderBase::CreateMaskedLoad(), llvm::IRBuilderBase::CreateMaskedStore(), llvm::createReplicatedMask(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::createStrideMask(), llvm::IRBuilderBase::CreateVectorReverse(), DL, gep, llvm::VPTransformState::get(), llvm::VectorType::get(), llvm::PoisonValue::get(), llvm::InterleaveGroup< InstTy >::getAlign(), llvm::Module::getDataLayout(), llvm::InterleaveGroup< InstTy >::getFactor(), llvm::InterleaveGroup< InstTy >::getIndex(), llvm::InterleaveGroup< InstTy >::getInsertPos(), llvm::IRBuilderBase::getInt32(), llvm::LinearPolySize< LeafTy >::getKnownMinValue(), llvm::getLoadStoreType(), llvm::InterleaveGroup< InstTy >::getMember(), llvm::Instruction::getModule(), llvm::Type::getPointerAddressSpace(), llvm::Type::getPointerTo(), llvm::Value::getType(), i, I, llvm::InterleaveGroup< InstTy >::isReverse(), llvm::LinearPolySize< LeafTy >::isScalable(), llvm::LoopVectorizationCostModel::isScalarEpilogueAllowed(), llvm::InterleaveGroup< InstTy >::requiresScalarEpilogue(), llvm::VPTransformState::set(), llvm::VPTransformState::setDebugLocFromInst(), llvm::Value::stripPointerCasts(), UF, llvm::RegState::Undef, useMaskedInterleavedAccesses(), and VF.

Referenced by llvm::VPInterleaveRecipe::execute().

Friends And Related Function Documentation

◆ LoopVectorizationPlanner

friend class LoopVectorizationPlanner
friend

Definition at line 546 of file LoopVectorize.cpp.

Member Data Documentation

◆ AA

AAResults* llvm::InnerLoopVectorizer::AA
protected

Alias Analysis.

Definition at line 660 of file LoopVectorize.cpp.

◆ AC

AssumptionCache* llvm::InnerLoopVectorizer::AC
protected

◆ AddedSafetyChecks

bool llvm::InnerLoopVectorizer::AddedSafetyChecks = false
protected

Definition at line 724 of file LoopVectorize.cpp.

Referenced by areSafetyChecksAdded(), emitMemRuntimeChecks(), and emitSCEVChecks().

◆ BFI

BlockFrequencyInfo* llvm::InnerLoopVectorizer::BFI
protected

BFI and PSI are used to check for profile guided size optimizations.

Definition at line 731 of file LoopVectorize.cpp.

Referenced by getScalarEpilogueLowering(), InnerLoopVectorizer(), and processLoopInVPlanNativePath().

◆ Builder

IRBuilder llvm::InnerLoopVectorizer::Builder
protected

◆ Cost

LoopVectorizationCostModel* llvm::InnerLoopVectorizer::Cost
protected

◆ DT

DominatorTree* llvm::InnerLoopVectorizer::DT
protected

◆ IVEndValues

DenseMap<PHINode *, Value *> llvm::InnerLoopVectorizer::IVEndValues
protected

Definition at line 728 of file LoopVectorize.cpp.

Referenced by createInductionResumeValue().

◆ Legal

LoopVectorizationLegality* llvm::InnerLoopVectorizer::Legal
protected

◆ LI

LoopInfo* llvm::InnerLoopVectorizer::LI
protected

◆ LoopBypassBlocks

SmallVector<BasicBlock *, 4> llvm::InnerLoopVectorizer::LoopBypassBlocks
protected

◆ LoopExitBlock

BasicBlock* llvm::InnerLoopVectorizer::LoopExitBlock
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 700 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton(), createVectorLoopSkeleton(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitSCEVChecks(), fixFixedOrderRecurrence(), and fixReduction().

◆ LoopMiddleBlock

BasicBlock* llvm::InnerLoopVectorizer::LoopMiddleBlock
protected

Middle Block between the vector and the scalar.

Definition at line 696 of file LoopVectorize.cpp.

Referenced by completeLoopSkeleton(), createInductionResumeValue(), createVectorLoopSkeleton(), fixFixedOrderRecurrence(), and fixReduction().

◆ LoopScalarBody

BasicBlock* llvm::InnerLoopVectorizer::LoopScalarBody
protected

The scalar loop body.

Definition at line 703 of file LoopVectorize.cpp.

Referenced by createVectorLoopSkeleton().

◆ LoopScalarPreHeader

BasicBlock* llvm::InnerLoopVectorizer::LoopScalarPreHeader
protected

◆ LoopVectorPreHeader

BasicBlock* llvm::InnerLoopVectorizer::LoopVectorPreHeader
protected

◆ MinProfitableTripCount

ElementCount llvm::InnerLoopVectorizer::MinProfitableTripCount
protected

Definition at line 678 of file LoopVectorize.cpp.

Referenced by emitIterationCountCheck(), and InnerLoopVectorizer().

◆ OptForSizeBasedOnProfile

bool llvm::InnerLoopVectorizer::OptForSizeBasedOnProfile
protected

Definition at line 736 of file LoopVectorize.cpp.

Referenced by emitMemRuntimeChecks(), emitSCEVChecks(), and InnerLoopVectorizer().

◆ ORE

OptimizationRemarkEmitter* llvm::InnerLoopVectorizer::ORE
protected

◆ OrigLoop

Loop* llvm::InnerLoopVectorizer::OrigLoop
protected

◆ PredicatedInstructions

SmallVector<Instruction *, 4> llvm::InnerLoopVectorizer::PredicatedInstructions
protected

Store instructions that were predicated.

Definition at line 709 of file LoopVectorize.cpp.

Referenced by scalarizeInstruction().

◆ PSE

PredicatedScalarEvolution& llvm::InnerLoopVectorizer::PSE
protected

◆ PSI

ProfileSummaryInfo* llvm::InnerLoopVectorizer::PSI
protected

◆ ReductionResumeValues

SmallMapVector<const RecurrenceDescriptor *, PHINode *, 4> llvm::InnerLoopVectorizer::ReductionResumeValues
protected

Definition at line 745 of file LoopVectorize.cpp.

Referenced by fixReduction(), and getReductionResumeValue().

◆ RTChecks

GeneratedRTChecks& llvm::InnerLoopVectorizer::RTChecks
protected

Structure to hold information about generated runtime checks, responsible for cleaning the checks, if vectorization turns out unprofitable.

Definition at line 740 of file LoopVectorize.cpp.

Referenced by emitMemRuntimeChecks(), and emitSCEVChecks().

◆ TLI

const TargetLibraryInfo* llvm::InnerLoopVectorizer::TLI
protected

◆ TripCount

Value* llvm::InnerLoopVectorizer::TripCount = nullptr
protected

Trip count of the original loop.

Definition at line 712 of file LoopVectorize.cpp.

Referenced by llvm::EpilogueVectorizerEpilogueLoop::EpilogueVectorizerEpilogueLoop(), and getOrCreateTripCount().

◆ TTI

const TargetTransformInfo* llvm::InnerLoopVectorizer::TTI
protected

Target Transform Info.

Definition at line 666 of file LoopVectorize.cpp.

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

◆ UF

unsigned llvm::InnerLoopVectorizer::UF
protected

The vectorization unroll factor to use.

Each scalar is vectorized to this many different vector instructions.

Definition at line 682 of file LoopVectorize.cpp.

Referenced by clearReductionWrapFlags(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), fixFixedOrderRecurrence(), fixReduction(), getOrCreateVectorTripCount(), truncateToMinimalBitwidths(), and vectorizeInterleaveGroup().

◆ VectorTripCount

Value* llvm::InnerLoopVectorizer::VectorTripCount = nullptr
protected

Trip count of the widened loop (TripCount - TripCount % (VF*UF))

Definition at line 715 of file LoopVectorize.cpp.

Referenced by completeLoopSkeleton(), createInductionResumeValue(), fixupIVUsers(), and getOrCreateVectorTripCount().

◆ VF

ElementCount llvm::InnerLoopVectorizer::VF
protected

The vectorization SIMD factor to use.

Each vector will have this many vector elements.

Definition at line 676 of file LoopVectorize.cpp.

Referenced by areRuntimeChecksProfitable(), llvm::LoopVectorizationPlanner::buildVPlans(), llvm::LoopVectorizationCostModel::calculateRegisterUsage(), llvm::LoopVectorizationCostModel::canTruncateToMinimalBitwidth(), llvm::LoopVectorizationCostModel::collectInstsToScalarize(), llvm::LoopVectorizationCostModel::collectUniformsAndScalars(), completeLoopSkeleton(), GeneratedRTChecks::Create(), createBitOrPointerCast(), llvm::createStepForVF(), createVectorLoopSkeleton(), createWidenInductionRecipes(), emitIterationCountCheck(), llvm::EpilogueVectorizerMainLoop::emitIterationCountCheck(), emitSCEVChecks(), fixFixedOrderRecurrence(), fixReduction(), fixVectorizedLoop(), llvm::VPTransformState::get(), llvm::LoopVectorizationPlanner::getBestPlanFor(), getBroadcastInstrs(), llvm::LoopVectorizationCostModel::getDivRemSpeculationCost(), getOrCreateVectorTripCount(), llvm::getRuntimeVF(), llvm::getRuntimeVFAsFloat(), getStepVector(), llvm::LoopVectorizationCostModel::getVectorCallCost(), llvm::LoopVectorizationCostModel::getVectorIntrinsicCost(), llvm::LoopVectorizationCostModel::getWideningCost(), llvm::LoopVectorizationCostModel::getWideningDecision(), llvm::VPRecipeBuilder::handleReplication(), llvm::LoopVectorizationCostModel::interleavedAccessCanBeWidened(), llvm::LoopVectorizationCostModel::isLegalGatherOrScatter(), llvm::LoopVectorizationCostModel::isOptimizableIVTruncate(), llvm::LoopVectorizationCostModel::isProfitableToScalarize(), llvm::LoopVectorizationCostModel::isScalarAfterVectorization(), llvm::LoopVectorizationCostModel::isScalarWithPredication(), llvm::LoopVectorizationCostModel::isUniformAfterVectorization(), MaybeVectorizeType(), llvm::LoopVectorizationCostModel::memoryInstructionCanBeWidened(), packScalarIntoVectorValue(), llvm::LoopVectorizationPlanner::plan(), llvm::LoopVectorizationPlanner::planInVPlanNativePath(), processLoopInVPlanNativePath(), llvm::LoopVectorizationCostModel::requiresScalarEpilogue(), llvm::LoopVectorizationCostModel::selectInterleaveCount(), llvm::LoopVectorizationCostModel::setCostBasedWideningDecision(), llvm::LoopVectorizationCostModel::setWideningDecision(), llvm::VPRecipeBuilder::tryToCreateWidenRecipe(), and vectorizeInterleaveGroup().


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