|
LLVM
10.0.0
|
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... | |
| void | recordRecipeOf (Instruction *I) |
| Mark given ingredient for recording its recipe once one is created for it. More... | |
| VPRecipeBase * | getRecipe (Instruction *I) |
| Return the recipe created for given ingredient. 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, 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... | |
Helper class to create VPRecipies from IR instructions.
Definition at line 25 of file VPRecipeBuilder.h.
|
inline |
Definition at line 127 of file VPRecipeBuilder.h.
References handleReplication(), and tryToCreateRecipe().
| 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 6734 of file LoopVectorize.cpp.
References assert(), llvm::InnerLoopVectorizer::Builder, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopVectorizationLegality::getPrimaryInduction(), llvm::VPInstruction::ICmpULE, if(), llvm::InnerLoopVectorizer::Legal, llvm::InnerLoopVectorizer::OrigLoop, and llvm::predecessors().
| VPValue * VPRecipeBuilder::createEdgeMask | ( | BasicBlock * | Src, |
| BasicBlock * | Dst, | ||
| VPlanPtr & | Plan | ||
| ) |
A helper function that computes the predicate of the edge between SRC and DST.
Definition at line 6703 of file LoopVectorize.cpp.
References assert(), llvm::InnerLoopVectorizer::Builder, llvm::dyn_cast(), llvm::BranchInst::getCondition(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::is_contained(), llvm::BranchInst::isConditional(), and llvm::predecessors().
| 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 7016 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().
Referenced by getRecipe().
|
inline |
Return the recipe created for given ingredient.
Definition at line 87 of file VPRecipeBuilder.h.
References assert(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), createReplicateRegion(), I, tryToBlend(), tryToOptimizeInduction(), tryToWiden(), and tryToWidenMemory().
Referenced by tryToCreateRecipe().
| 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.
VPBB augmented with this new recipe if I is not predicated, otherwise I. Range.End may be decreased to ensure same recipe behavior from Range.Start to Range.End. Definition at line 6976 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 tryToCreateRecipe(), and VPRecipeBuilder().
|
inline |
Mark given ingredient for recording its recipe once one is created for it.
Definition at line 80 of file VPRecipeBuilder.h.
References assert(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::count(), and I.
Referenced by tryToCreateRecipe().
| 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 6840 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 >::push_back().
Referenced by getRecipe().
| 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 7044 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, DFS(), llvm::VPBlockUtils::disconnectBlocks(), llvm::dyn_cast(), llvm::LoopBase< BlockT, LoopT >::empty(), llvm::VPBasicBlock::empty(), llvm::VFRange::End, llvm::SmallPtrSetImpl< PtrType >::end(), llvm::LoopBlocksDFS::endRPO(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::VPRecipeBase::eraseFromParent(), llvm::SmallPtrSetImpl< PtrType >::find(), GEP, llvm::BranchInst::getCondition(), llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopVectorizationLegality::getPrimaryInduction(), getRecipe(), llvm::LoopVectorizationLegality::getReductionVars(), llvm::VPBlockBase::getSingleSuccessor(), llvm::LoopVectorizationLegality::getSinkAfter(), handleReplication(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::VPBlockUtils::insertBlockAfter(), llvm::BranchInst::isConditional(), llvm::InnerLoopVectorizer::Legal, llvm::InnerLoopVectorizer::LI, llvm::make_range(), llvm::VPRecipeBase::moveAfter(), llvm::InnerLoopVectorizer::OrigLoop, llvm::LoopBlocksDFS::perform(), recordRecipeOf(), Reduction, llvm::VPBlockBase::setName(), llvm::cl::Sink, llvm::InnerLoopVectorizer::TLI, tryToCreateRecipe(), and llvm::InnerLoopVectorizer::VF.
Referenced by tryToCreateRecipe(), and VPRecipeBuilder().
| 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 6808 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.
Referenced by getRecipe().
| 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 6864 of file LoopVectorize.cpp.
References llvm::MCID::Add, llvm::VPBasicBlock::appendRecipe(), assert(), llvm::VPBasicBlock::back(), llvm::MCID::Call, llvm::LoopVectorizationCostModel::CM_Scalarize, llvm::VPBasicBlock::empty(), llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::Instruction::getOpcode(), llvm::getVectorIntrinsicIDForCall(), llvm::SPII::Load, llvm::MCID::Select, llvm::SPII::Store, llvm::InnerLoopVectorizer::TLI, and llvm::InnerLoopVectorizer::VF.
Referenced by getRecipe().
| VPWidenMemoryInstructionRecipe * VPRecipeBuilder::tryToWidenMemory | ( | Instruction * | I, |
| VFRange & | Range, | ||
| VPlanPtr & | Plan | ||
| ) |
Check if is a memory instruction to be widened for Range.Start and potentially masked.
Such instructions are handled by a recipe that takes an additional VPInstruction for the mask.
Definition at line 6776 of file LoopVectorize.cpp.
References assert(), llvm::LoopVectorizationCostModel::CM_Interleave, llvm::LoopVectorizationCostModel::CM_Scalarize, llvm::LoopVectorizationCostModel::CM_Unknown, llvm::LoopVectorizationPlanner::getDecisionAndClampRange(), llvm::getLoadStorePointerOperand(), llvm::Instruction::getParent(), llvm::LoopVectorizationLegality::isMaskRequired(), llvm::InnerLoopVectorizer::Legal, llvm::BitmaskEnumDetail::Mask(), and llvm::InnerLoopVectorizer::VF.
Referenced by getRecipe().
1.8.13