LLVM: lib/Transforms/Scalar/JumpThreading.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
STATISTIC (NumThreads, "Number of jumps threaded")
STATISTIC (NumFolds, "Number of terminators folded")
STATISTIC (NumDupes, "Number of branch blocks duplicated to eliminate phi")
static void updatePredecessorProfileMetadata (PHINode *PN, BasicBlock *BB)
static bool replaceFoldableUses (Instruction *Cond, Value *ToVal, BasicBlock *KnownAtEndOfBB)
static unsigned getJumpThreadDuplicationCost (const TargetTransformInfo *TTI, BasicBlock *BB, Instruction *StopAt, unsigned Threshold)
Return the cost of duplicating a piece of this block from first non-phi and before StopAt instruction to thread across it.
static Constant * getKnownConstant (Value *Val, ConstantPreference Preference)
getKnownConstant - Helper method to determine if we can thread over a terminator with the given value as its condition, and if so what value to use for that.
static unsigned getBestDestForJumpOnUndef (BasicBlock *BB)
GetBestDestForBranchOnUndef - If we determine that the specified block ends in an undefined jump, decide which block is best to revector to.
static bool hasAddressTakenAndUsed (BasicBlock *BB)
static bool isOpDefinedInBlock (Value *Op, BasicBlock *BB)
Return true if Op is an instruction defined in the given block.
static BasicBlock * findMostPopularDest (BasicBlock *BB, const SmallVectorImpl< std::pair< BasicBlock *, BasicBlock * > > &PredToDestList)
findMostPopularDest - The specified list contains multiple possible threadable destinations.
static void addPHINodeEntriesForMappedBlock (BasicBlock *PHIBB, BasicBlock *OldPred, BasicBlock *NewPred, ValueToValueMapTy &ValueMap)
addPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new predecessor to the PHIBB block.
Variables
static cl::opt< unsigned > BBDuplicateThreshold ("jump-threading-threshold", cl::desc("Max block size to duplicate for jump threading"), cl::init(6), cl::Hidden)
static cl::opt< unsigned > ImplicationSearchThreshold ("jump-threading-implication-search-threshold", cl::desc("The number of predecessors to search for a stronger " "condition to use to thread over a weaker condition"), cl::init(3), cl::Hidden)
static cl::opt< unsigned > PhiDuplicateThreshold ("jump-threading-phi-threshold", cl::desc("Max PHIs in BB to duplicate for jump threading"), cl::init(76), cl::Hidden)
static cl::opt< bool > ThreadAcrossLoopHeaders ("jump-threading-across-loop-headers", cl::desc("Allow JumpThreading to thread across loop headers, for testing"), cl::init(false), cl::Hidden)

DEBUG_TYPE

#define DEBUG_TYPE "jump-threading"

addPHINodeEntriesForMappedBlock()

addPHINodeEntriesForMappedBlock - We're adding 'NewPred' as a new predecessor to the PHIBB block.

If it has PHI nodes, add entries for NewPred using the entries from OldPred (suitably mapped).

Definition at line 1866 of file JumpThreading.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::end(), llvm::ValueMap< KeyT, ValueT, Config >::find(), I, IV, and llvm::BasicBlock::phis().

Referenced by llvm::JumpThreadingPass::duplicateCondBranchOnPHIIntoPred(), llvm::JumpThreadingPass::threadEdge(), and llvm::JumpThreadingPass::threadThroughTwoBasicBlocks().

findMostPopularDest()

getBestDestForJumpOnUndef()

getJumpThreadDuplicationCost()

Return the cost of duplicating a piece of this block from first non-phi and before StopAt instruction to thread across it.

Stop scanning the block when exceeding the threshold. If duplication is impossible, returns ~0U.

Ignore PHI nodes, these will be flattened when duplication happens.

Definition at line 425 of file JumpThreading.cpp.

References assert(), llvm::TargetTransformInfo::getInstructionCost(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), I, PhiDuplicateThreshold, Size, llvm::TargetTransformInfo::TCC_Free, and llvm::TargetTransformInfo::TCK_SizeAndLatency.

Referenced by llvm::JumpThreadingPass::duplicateCondBranchOnPHIIntoPred(), llvm::JumpThreadingPass::maybethreadThroughTwoBasicBlocks(), llvm::JumpThreadingPass::threadGuard(), and llvm::JumpThreadingPass::tryThreadEdge().

getKnownConstant()

hasAddressTakenAndUsed()

isOpDefinedInBlock()

replaceFoldableUses()

STATISTIC() [1/3]

STATISTIC ( NumDupes ,
"Number of branch blocks duplicated to eliminate phi"
)

STATISTIC() [2/3]

STATISTIC ( NumFolds ,
"Number of terminators folded"
)

STATISTIC() [3/3]

STATISTIC ( NumThreads ,
"Number of jumps threaded"
)

updatePredecessorProfileMetadata()

static void updatePredecessorProfileMetadata ( PHINode * PN, BasicBlock * BB ) static

Definition at line 147 of file JumpThreading.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::extractBranchWeights(), llvm::BranchProbability::getBranchProbability(), llvm::BranchProbability::getCompl(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::BranchProbability::getNumerator(), llvm::PHINode::getNumIncomingValues(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::hasBranchWeightOrigin(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::BranchInst::isConditional(), llvm::Type::isIntegerTy(), llvm::ConstantInt::isOne(), and llvm::setBranchWeights().

Referenced by llvm::JumpThreadingPass::processBlock().

BBDuplicateThreshold

cl::opt< unsigned > BBDuplicateThreshold("jump-threading-threshold", cl::desc("Max block size to duplicate for jump threading"), cl::init(6), cl::Hidden) ( "jump-threading-threshold" , cl::desc("Max block size to duplicate for jump threading") , cl::init(6) , cl::Hidden ) static

ImplicationSearchThreshold

cl::opt< unsigned > ImplicationSearchThreshold("jump-threading-implication-search-threshold", cl::desc("The number of predecessors to search for a stronger " "condition to use to thread over a weaker condition"), cl::init(3), cl::Hidden) ( "jump-threading-implication-search-threshold" , cl::desc("The number of predecessors to search for a stronger " "condition to use to thread over a weaker condition") , cl::init(3) , cl::Hidden ) static

PhiDuplicateThreshold

cl::opt< unsigned > PhiDuplicateThreshold("jump-threading-phi-threshold", cl::desc("Max PHIs in BB to duplicate for jump threading"), cl::init(76), cl::Hidden) ( "jump-threading-phi-threshold" , cl::desc("Max PHIs in BB to duplicate for jump threading") , cl::init(76) , cl::Hidden ) static

ThreadAcrossLoopHeaders

cl::opt< bool > ThreadAcrossLoopHeaders("jump-threading-across-loop-headers", cl::desc("Allow JumpThreading to thread across loop headers, for testing"), cl::init(false), cl::Hidden) ( "jump-threading-across-loop-headers" , cl::desc("Allow JumpThreading to thread across loop headers, for testing") , cl::init(false) , cl::Hidden ) static