[llvm-commits] [llvm] r61372 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
Dan Gohman
gohman at apple.com
Tue Dec 23 09:24:57 PST 2008
Author: djg
Date: Tue Dec 23 11:24:50 2008
New Revision: 61372
URL: http://llvm.org/viewvc/llvm-project?rev=61372&view=rev
Log:
Avoid an unnecessary call to allnodes_size(), which is linear.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=61372&r1=61371&r2=61372&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Tue Dec 23 11:24:50 2008
@@ -68,20 +68,23 @@
/// 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();
More information about the llvm-commits
mailing list