From 27fa408b64edcfb5e8e13e4ede14121a632e2dd6 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 11 Feb 2009 00:12:28 +0000 Subject: 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 --- llvm/lib/CodeGen/ScheduleDAG.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/ScheduleDAG.cpp b/llvm/lib/CodeGen/ScheduleDAG.cpp index f9b94083548..db7d92218b3 100644 --- a/llvm/lib/CodeGen/ScheduleDAG.cpp +++ b/llvm/lib/CodeGen/ScheduleDAG.cpp @@ -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::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; -- cgit v1.2.3