mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-28 06:58:19 +00:00
we can only thread blocks when there is a pred we can determine the succ of.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50003 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
177480b7ed
commit
f9065a904f
@ -134,15 +134,30 @@ bool JumpThreading::ThreadBlock(BasicBlock &BB) {
|
|||||||
PHINode *PN = dyn_cast<PHINode>(Condition);
|
PHINode *PN = dyn_cast<PHINode>(Condition);
|
||||||
if (!PN || PN->getParent() != &BB) return false;
|
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.
|
// See if the cost of duplicating this block is low enough.
|
||||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
||||||
if (JumpThreadCost > Threshold) {
|
if (JumpThreadCost > Threshold) {
|
||||||
DOUT << " Not threading BB '" << BB.getNameStart()
|
DOUT << " Not threading BB '" << BB.getNameStart()
|
||||||
<< "': Cost is too high: " << JumpThreadCost << "\n";
|
<< "' - Cost is too high: " << JumpThreadCost << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DOUT << " Threading BB '" << BB.getNameStart() << "'. Cost is : "
|
DOUT << " Threading BB '" << BB.getNameStart() << "'. Cost is: "
|
||||||
<< JumpThreadCost << "\n";
|
<< JumpThreadCost << "\n";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user