Defer adding critical edges to the "toSplit" list until after checking for

indirect branches in all the predecessors.  This avoids unnecessarily
splitting edges in cases where load PRE is not possible anyway.
Thanks to Jakub Staszak for pointing this out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103034 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bob Wilson 2010-05-04 20:03:21 +00:00
parent cd465012b3
commit 34414a634e

View File

@ -1584,7 +1584,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
for (unsigned i = 0, e = UnavailableBlocks.size(); i != e; ++i)
FullyAvailableBlocks[UnavailableBlocks[i]] = false;
bool NeedToSplitEdges = false;
SmallVector<std::pair<TerminatorInst*, unsigned>, 4> NeedToSplit;
for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB);
PI != E; ++PI) {
BasicBlock *Pred = *PI;
@ -1600,12 +1600,13 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
return false;
}
unsigned SuccNum = GetSuccessorNumber(Pred, LoadBB);
toSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum));
NeedToSplitEdges = true;
NeedToSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum));
}
}
if (NeedToSplitEdges)
if (!NeedToSplit.empty()) {
toSplit.append(NeedToSplit.size(), NeedToSplit.front());
return false;
}
// Decide whether PRE is profitable for this load.
unsigned NumUnavailablePreds = PredLoads.size();