[llvm-commits] [llvm] r50003 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Chris Lattner
sabre at nondot.org
Sun Apr 20 14:18:09 PDT 2008
Author: lattner
Date: Sun Apr 20 16:18:09 2008
New Revision: 50003
URL: http://llvm.org/viewvc/llvm-project?rev=50003&view=rev
Log:
we can only thread blocks when there is a pred we can determine the succ of.
Modified:
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50003&r1=50002&r2=50003&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Apr 20 16:18:09 2008
@@ -134,15 +134,30 @@
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;
More information about the llvm-commits
mailing list