From: Dan Gohman Date: Wed, 11 Feb 2009 00:12:28 +0000 (+0000) Subject: Use iterators to iterate through the Preds array instead of X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5cffa6fe271351a8fd80e7767b5d61a999acfa9b;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64262 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/ScheduleDAG.cpp b/lib/CodeGen/ScheduleDAG.cpp index f9b94083548..db7d92218b3 100644 --- a/lib/CodeGen/ScheduleDAG.cpp +++ b/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;