summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LatencyPriorityQueue.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-12-10 00:24:36 +0000
committerDan Gohman <gohman@apple.com>2008-12-10 00:24:36 +0000
commit43a120303beec97ac771bd2aa471f012005dc498 (patch)
treed80b356248832a98f71d94a0a658e3f96d351f33 /llvm/lib/CodeGen/LatencyPriorityQueue.cpp
parent7572ac5614e189e4498ffe2b98791544cd0d66ec (diff)
downloadbcm5719-llvm-43a120303beec97ac771bd2aa471f012005dc498.tar.gz
bcm5719-llvm-43a120303beec97ac771bd2aa471f012005dc498.zip
Update CalcLatency to work in terms of edge latencies, rather than
node latencies. Use CalcLatency instead of manual code in CalculatePriorities to keep it consistent. Previously it computed slightly different results. llvm-svn: 60817
Diffstat (limited to 'llvm/lib/CodeGen/LatencyPriorityQueue.cpp')
-rw-r--r--llvm/lib/CodeGen/LatencyPriorityQueue.cpp31
1 files changed, 5 insertions, 26 deletions
diff --git a/llvm/lib/CodeGen/LatencyPriorityQueue.cpp b/llvm/lib/CodeGen/LatencyPriorityQueue.cpp
index 131da27c337..2abbf364e32 100644
--- a/llvm/lib/CodeGen/LatencyPriorityQueue.cpp
+++ b/llvm/lib/CodeGen/LatencyPriorityQueue.cpp
@@ -43,16 +43,15 @@ bool latency_sort::operator()(const SUnit *LHS, const SUnit *RHS) const {
/// CalcNodePriority - Calculate the maximal path from the node to the exit.
///
-int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
+void LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
int &Latency = Latencies[SU.NodeNum];
if (Latency != -1)
- return Latency;
+ return;
std::vector<const SUnit*> WorkList;
WorkList.push_back(&SU);
while (!WorkList.empty()) {
const SUnit *Cur = WorkList.back();
- unsigned CurLatency = Cur->Latency;
bool AllDone = true;
unsigned MaxSuccLatency = 0;
for (SUnit::const_succ_iterator I = Cur->Succs.begin(),E = Cur->Succs.end();
@@ -62,8 +61,7 @@ int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
AllDone = false;
WorkList.push_back(I->getSUnit());
} else {
- // This assumes that there's no delay for reusing registers.
- unsigned NewLatency = SuccLatency + CurLatency;
+ unsigned NewLatency = SuccLatency + I->getLatency();
MaxSuccLatency = std::max(MaxSuccLatency, NewLatency);
}
}
@@ -72,8 +70,6 @@ int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
WorkList.pop_back();
}
}
-
- return Latency;
}
/// CalculatePriorities - Calculate priorities of all scheduling units.
@@ -82,25 +78,8 @@ void LatencyPriorityQueue::CalculatePriorities() {
NumNodesSolelyBlocking.assign(SUnits->size(), 0);
// For each node, calculate the maximal path from the node to the exit.
- std::vector<std::pair<const SUnit*, unsigned> > WorkList;
- for (unsigned i = 0, e = SUnits->size(); i != e; ++i) {
- const SUnit *SU = &(*SUnits)[i];
- if (SU->Succs.empty())
- WorkList.push_back(std::make_pair(SU, 0U));
- }
-
- while (!WorkList.empty()) {
- const SUnit *SU = WorkList.back().first;
- unsigned SuccLat = WorkList.back().second;
- WorkList.pop_back();
- int &Latency = Latencies[SU->NodeNum];
- if (Latency == -1 || (SU->Latency + SuccLat) > (unsigned)Latency) {
- Latency = SU->Latency + SuccLat;
- for (SUnit::const_pred_iterator I = SU->Preds.begin(),E = SU->Preds.end();
- I != E; ++I)
- WorkList.push_back(std::make_pair(I->getSUnit(), Latency));
- }
- }
+ for (unsigned i = 0, e = SUnits->size(); i != e; ++i)
+ CalcLatency((*SUnits)[i]);
}
/// getSingleUnscheduledPred - If there is exactly one unscheduled predecessor
OpenPOWER on IntegriCloud