LLVM  7.0.0
Public Member Functions | List of all members
llvm::VPRecipeBuilder Class Reference

Helper class to create VPRecipies from IR instructions. More...

#include "Transforms/Vectorize/VPRecipeBuilder.h"

Public Member Functions

VPValue * createBlockInMask (BasicBlock *BB, VPlanPtr &Plan)
 A helper function that computes the predicate of the block BB, assuming that the header block of the loop is set to True. More...
 
VPValue * createEdgeMask (BasicBlock *Src, BasicBlock *Dst, VPlanPtr &Plan)
 A helper function that computes the predicate of the edge between SRC and DST. More...
 
VPInterleaveRecipe * tryToInterleaveMemory (Instruction *I, VFRange &Range)
 Check if belongs to an Interleave Group within the given VF Range,. More...
 
VPWidenMemoryInstructionRecipe * tryToWidenMemory (Instruction *I, VFRange &Range, VPlanPtr &Plan)
 Check if is a memory instruction to be widened for Range.Start and potentially masked. More...
 
VPWidenIntOrFpInductionRecipe * tryToOptimizeInduction (Instruction *I, VFRange &Range)
 Check if an induction recipe should be constructed for within the given VF Range. More...
 
VPBlendRecipe * tryToBlend (Instruction *I, VPlanPtr &Plan)
 Handle non-loop phi nodes. More...
 
bool tryToWiden (Instruction *I, VPBasicBlock *VPBB, VFRange &Range)
 Check if I can be widened within the given VF Range. More...
 
VPRegionBlock * createReplicateRegion (Instruction *I, VPRecipeBase *PredRecipe, VPlanPtr &Plan)
 Create a replicating region for instruction I that requires predication. More...
 
 VPRecipeBuilder (Loop *OrigLoop, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, LoopVectorizationLegality *Legal, LoopVectorizationCostModel &CM, VPBuilder &Builder)
 
bool tryToCreateRecipe (Instruction *Instr, VFRange &Range, VPlanPtr &Plan, VPBasicBlock *VPBB)
 Check if a recipe can be create for I withing the given VF Range. More...
 
VPBasicBlock * handleReplication (Instruction *I, VFRange &Range, VPBasicBlock *VPBB, DenseMap< Instruction *, VPReplicateRecipe *> &PredInst2Recipe, VPlanPtr &Plan)
 Build a VPReplicationRecipe for I and enclose it within a Region if it is predicated. More...
 

Detailed Description

Helper class to create VPRecipies from IR instructions.

Definition at line 26 of file VPRecipeBuilder.h.

Constructor & Destructor Documentation

◆ VPRecipeBuilder()

llvm::VPRecipeBuilder::VPRecipeBuilder ( Loop *  OrigLoop,
const TargetLibraryInfo *  TLI,
const TargetTransformInfo *  TTI,
LoopVectorizationLegality *  Legal,
LoopVectorizationCostModel &  CM,
VPBuilder &  Builder 
)
inline

Definition at line 106 of file VPRecipeBuilder.h.

References handleReplication(), and tryToCreateRecipe().

Member Function Documentation

◆ createBlockInMask()

VPValue * VPRecipeBuilder::createBlockInMask ( BasicBlock *  BB,
VPlanPtr &  Plan 
)

A helper function that computes the predicate of the block BB, assuming that the header block of the loop is set to True.

It returns the entry mask for the block BB.

Definition at line 6542 of file LoopVectorize.cpp.

References assert(), llvm::InnerLoopVectorizer::Builder, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), if(), llvm::InnerLoopVectorizer::OrigLoop, and llvm::predecessors().

◆ createEdgeMask()

VPValue * VPRecipeBuilder::createEdgeMask ( BasicBlock *  Src,
BasicBlock *  Dst,
VPlanPtr &  Plan 
)

◆ createReplicateRegion()

VPRegionBlock * VPRecipeBuilder::createReplicateRegion ( Instruction *  I,
VPRecipeBase *  PredRecipe,
VPlanPtr &  Plan 
)

Create a replicating region for instruction I that requires predication.

PredRecipe is a VPReplicateRecipe holding I.

Definition at line 6827 of file LoopVectorize.cpp.

References assert(), llvm::VPBlockUtils::connectBlocks(), llvm::Instruction::getOpcodeName(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::VPBlockUtils::insertTwoBlocksAfter(), and llvm::Type::isVoidTy().

◆ handleReplication()

VPBasicBlock * VPRecipeBuilder::handleReplication ( Instruction *  I,
VFRange &  Range,
VPBasicBlock *  VPBB,
DenseMap< Instruction *, VPReplicateRecipe *> &  PredInst2Recipe,
VPlanPtr &  Plan 
)

Build a VPReplicationRecipe for I and enclose it within a Region if it is predicated.

Returns
VPBB augmented with this new recipe if I is not predicated, otherwise
a new VPBasicBlock that succeeds the new Region. Update the packing decision of predicated instructions if they feed I. Range.End may be decreased to ensure same recipe behavior from Range.Start to Range.End.

Definition at line 6790 of file LoopVectorize.cpp.

References llvm::VPBasicBlock::appendRecipe(), assert(), llvm::dbgs(), llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::VPBlockBase::getSuccessors(), I, llvm::VPBlockUtils::insertBlockAfter(), LLVM_DEBUG, and llvm::User::operands().

Referenced by VPRecipeBuilder().

◆ tryToBlend()

VPBlendRecipe * VPRecipeBuilder::tryToBlend ( Instruction *  I,
VPlanPtr &  Plan 
)

Handle non-loop phi nodes.

Currently all such phi nodes are turned into a sequence of select instructions as the vectorizer currently performs full if-conversion.

Definition at line 6665 of file LoopVectorize.cpp.

References assert(), llvm::dyn_cast(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), I, llvm::tgtok::In, llvm::InnerLoopVectorizer::OrigLoop, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

◆ tryToCreateRecipe()

bool VPRecipeBuilder::tryToCreateRecipe ( Instruction *  Instr,
VFRange &  Range,
VPlanPtr &  Plan,
VPBasicBlock *  VPBB 
)

Check if a recipe can be create for I withing the given VF Range.

If a recipe can be created, it adds it to VPBB.

Definition at line 6855 of file LoopVectorize.cpp.

References llvm::VPBasicBlock::appendRecipe(), assert(), llvm::LoopBlocksDFS::beginRPO(), llvm::LoopBase< BlockT, LoopT >::blocks(), llvm::MCID::Branch, llvm::InnerLoopVectorizer::Builder, llvm::LoopVectorizationCostModel::CM_Interleave, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), DFS(), llvm::VPBlockUtils::disconnectBlocks(), llvm::dyn_cast(), llvm::LoopBase< BlockT, LoopT >::empty(), llvm::VPBasicBlock::empty(), EnableVPlanNativePath, llvm::VFRange::End, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::LoopBlocksDFS::endRPO(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::raw_ostream::flush(), llvm::BranchInst::getCondition(), llvm::InterleaveGroup::getInsertPos(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::VPBlockBase::getSingleSuccessor(), llvm::LoopVectorizationLegality::getSinkAfter(), I, llvm::VPBlockUtils::insertBlockAfter(), llvm::BranchInst::isConditional(), llvm::InnerLoopVectorizer::Legal, llvm::InnerLoopVectorizer::LI, LLVM_DEBUG, llvm::make_range(), llvm::InnerLoopVectorizer::OrigLoop, llvm::LoopBlocksDFS::perform(), llvm::VPBlockBase::setName(), llvm::VFRange::Start, llvm::InnerLoopVectorizer::TLI, llvm::InnerLoopVectorizer::TTI, and llvm::InnerLoopVectorizer::VF.

Referenced by VPRecipeBuilder().

◆ tryToInterleaveMemory()

VPInterleaveRecipe * VPRecipeBuilder::tryToInterleaveMemory ( Instruction *  I,
VFRange &  Range 
)

Check if belongs to an Interleave Group within the given VF Range,.

Returns
true in the first returned value if so and false otherwise. Build a new VPInterleaveGroup Recipe if is the primary member of an IG for Range.Start, and provide it as the second returned value. Note that if is an adjunct member of an IG for Range.Start, the
value is <true, nullptr>, as it is handled by another recipe. Range.End may be decreased to ensure same decision from Range.Start to Range.End.

Definition at line 6575 of file LoopVectorize.cpp.

References assert(), llvm::LoopVectorizationCostModel::CM_Interleave, function, llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::InterleaveGroup::getInsertPos(), I, and llvm::InnerLoopVectorizer::VF.

◆ tryToOptimizeInduction()

VPWidenIntOrFpInductionRecipe * VPRecipeBuilder::tryToOptimizeInduction ( Instruction *  I,
VFRange &  Range 
)

Check if an induction recipe should be constructed for within the given VF Range.

If so build and return it. If not, return null. Range.End may be decreased to ensure same decision from Range.Start to Range.End.

Definition at line 6633 of file LoopVectorize.cpp.

References function, llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::LoopVectorizationLegality::getInductionVars(), llvm::InductionDescriptor::getKind(), llvm::User::getOperand(), llvm::InductionDescriptor::IK_FpInduction, llvm::InductionDescriptor::IK_IntInduction, llvm::InnerLoopVectorizer::Legal, llvm::MapVector< KeyT, ValueT, MapType, VectorType >::lookup(), and llvm::InnerLoopVectorizer::VF.

◆ tryToWiden()

bool VPRecipeBuilder::tryToWiden ( Instruction *  I,
VPBasicBlock *  VPBB,
VFRange &  Range 
)

Check if I can be widened within the given VF Range.

If I can be widened for Range.Start, check if the last recipe of VPBB can be extended to include I or else build a new VPWidenRecipe for it and append it to VPBB. Return true if I can be widened for Range.Start, false otherwise. Range.End may be decreased to ensure same decision from Range.Start to Range.End.

Definition at line 6689 of file LoopVectorize.cpp.

References llvm::MCID::Add, llvm::VPWidenRecipe::appendInstruction(), llvm::VPBasicBlock::appendRecipe(), assert(), llvm::VPBasicBlock::back(), llvm::MCID::Call, llvm::LoopVectorizationCostModel::CM_Scalarize, llvm::dyn_cast(), llvm::VPBasicBlock::empty(), llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::Instruction::getOpcode(), getVectorCallCost(), getVectorIntrinsicCost(), llvm::getVectorIntrinsicIDForCall(), llvm::SPII::Load, llvm::MCID::Select, llvm::SPII::Store, llvm::InnerLoopVectorizer::TLI, llvm::InnerLoopVectorizer::TTI, and llvm::InnerLoopVectorizer::VF.

◆ tryToWidenMemory()

VPWidenMemoryInstructionRecipe * VPRecipeBuilder::tryToWidenMemory ( Instruction *  I,
VFRange &  Range,
VPlanPtr &  Plan 
)

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