diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-20 21:18:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-20 21:18:09 +0000 |
commit | 9c1f1a82bfdc6878870644d296d1a476c8a4ac52 (patch) | |
tree | 1ba6d639aa7d54072d2c9f69b81117b1a0b5b24c /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 2115722ffa606fb05a8c291ca83bd9c887a93e99 (diff) | |
download | bcm5719-llvm-9c1f1a82bfdc6878870644d296d1a476c8a4ac52.tar.gz bcm5719-llvm-9c1f1a82bfdc6878870644d296d1a476c8a4ac52.zip |
we can only thread blocks when there is a pred we can determine the succ of.
llvm-svn: 50003
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index e203f2d4a4f..9f870ab78ab 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -134,15 +134,30 @@ bool JumpThreading::ThreadBlock(BasicBlock &BB) { PHINode *PN = dyn_cast<PHINode>(Condition); if (!PN || PN->getParent() != &BB) return false; + // See if the phi node has any constant values. If so, we can determine where + // the corresponding predecessor will branch. + unsigned PredNo = ~0U; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + if (isa<ConstantInt>(PN->getIncomingValue(i))) { + PredNo = i; + break; + } + } + + // If no incoming value has a constant, we don't know the destination of any + // predecessors. + if (PredNo == ~0U) + return false; + // See if the cost of duplicating this block is low enough. unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB); if (JumpThreadCost > Threshold) { DOUT << " Not threading BB '" << BB.getNameStart() - << "': Cost is too high: " << JumpThreadCost << "\n"; + << "' - Cost is too high: " << JumpThreadCost << "\n"; return false; } - DOUT << " Threading BB '" << BB.getNameStart() << "'. Cost is : " + DOUT << " Threading BB '" << BB.getNameStart() << "'. Cost is: " << JumpThreadCost << "\n"; return false; |