summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-12-23 17:24:50 +0000
committerDan Gohman <gohman@apple.com>2008-12-23 17:24:50 +0000
commit92cf280dfb315be4a8c703c7803c45b795ae703b (patch)
treeb6942b196830c4e4f2f31700e601a9b6c8893d1f /llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
parent3a57213e3847d95d58ef01a99c450d0ecc6df7f3 (diff)
downloadbcm5719-llvm-92cf280dfb315be4a8c703c7803c45b795ae703b.tar.gz
bcm5719-llvm-92cf280dfb315be4a8c703c7803c45b795ae703b.zip
Avoid an unnecessary call to allnodes_size(), which is linear.
llvm-svn: 61372
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
index 4b6469b5d06..4a7920acedb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
@@ -68,20 +68,23 @@ static void CheckForPhysRegDependency(SDNode *Def, SDNode *User, unsigned Op,
/// This SUnit graph is similar to the SelectionDAG, but represents flagged
/// together nodes with a single SUnit.
void ScheduleDAGSDNodes::BuildSchedUnits() {
- // Reserve entries in the vector for each of the SUnits we are creating. This
- // ensure that reallocation of the vector won't happen, so SUnit*'s won't get
- // invalidated.
- // FIXME: Multiply by 2 because we may clone nodes during scheduling.
- // This is a temporary workaround.
- SUnits.reserve(DAG->allnodes_size() * 2);
-
// During scheduling, the NodeId field of SDNode is used to map SDNodes
// to their associated SUnits by holding SUnits table indices. A value
// of -1 means the SDNode does not yet have an associated SUnit.
+ unsigned NumNodes = 0;
for (SelectionDAG::allnodes_iterator NI = DAG->allnodes_begin(),
- E = DAG->allnodes_end(); NI != E; ++NI)
+ E = DAG->allnodes_end(); NI != E; ++NI) {
NI->setNodeId(-1);
+ ++NumNodes;
+ }
+ // Reserve entries in the vector for each of the SUnits we are creating. This
+ // ensure that reallocation of the vector won't happen, so SUnit*'s won't get
+ // invalidated.
+ // FIXME: Multiply by 2 because we may clone nodes during scheduling.
+ // This is a temporary workaround.
+ SUnits.reserve(NumNodes * 2);
+
// Check to see if the scheduler cares about latencies.
bool UnitLatencies = ForceUnitLatencies();
OpenPOWER on IntegriCloud