Use iterators to iterate through the Preds array instead of

an index. This code is on the hot-path because the current
way SDep edges are uniqued has quadratic complexity.

llvm-svn: 64262
This commit is contained in:
Dan Gohman 2009-02-11 00:12:28 +00:00
parent a3d9025dd3
commit 27fa408b64
1 changed files with 3 additions and 2 deletions

View File

@ -74,8 +74,9 @@ void ScheduleDAG::Run(SelectionDAG *dag, MachineBasicBlock *bb,
/// specified node.
void SUnit::addPred(const SDep &D) {
// If this node already has this depenence, don't add a redundant one.
for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i)
if (Preds[i] == D)
for (SmallVector<SDep, 4>::const_iterator I = Preds.begin(), E = Preds.end();
I != E; ++I)
if (*I == D)
return;
// Now add a corresponding succ to N.
SDep P = D;