Use iterators to iterate through the Preds array instead of
authorDan Gohman <gohman@apple.com>
Wed, 11 Feb 2009 00:12:28 +0000 (00:12 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 11 Feb 2009 00:12:28 +0000 (00:12 +0000)
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

lib/CodeGen/ScheduleDAG.cpp

index f9b94083548f6a03f4132008923e965ec0c22fa0..db7d92218b3708fd592a403c3223e1831ae81c81 100644 (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;