Don't charge full latency for an anti-dependence, in this simplistic
authorDan Gohman <gohman@apple.com>
Tue, 9 Dec 2008 00:26:46 +0000 (00:26 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 9 Dec 2008 00:26:46 +0000 (00:26 +0000)
pipeline model.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60733 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LatencyPriorityQueue.cpp

index 70b6574996be5d555a99fb0212e215e5043ff966..8a6d1f23af142809f7c8c4c97da70d3e8e3cee07 100644 (file)
@@ -52,8 +52,9 @@ int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
   WorkList.push_back(&SU);
   while (!WorkList.empty()) {
     const SUnit *Cur = WorkList.back();
+    unsigned CurLatency = Cur->Latency;
     bool AllDone = true;
-    int MaxSuccLatency = 0;
+    unsigned MaxSuccLatency = 0;
     for (SUnit::const_succ_iterator I = Cur->Succs.begin(),E = Cur->Succs.end();
          I != E; ++I) {
       int SuccLatency = Latencies[I->Dep->NodeNum];
@@ -61,11 +62,14 @@ int LatencyPriorityQueue::CalcLatency(const SUnit &SU) {
         AllDone = false;
         WorkList.push_back(I->Dep);
       } else {
-        MaxSuccLatency = std::max(MaxSuccLatency, SuccLatency);
+        // This assumes that there's no delay for reusing registers.
+        unsigned NewLatency =
+          SuccLatency + ((I->isCtrl && I->Reg != 0) ? 1 : CurLatency);
+        MaxSuccLatency = std::max(MaxSuccLatency, NewLatency);
       }
     }
     if (AllDone) {
-      Latencies[Cur->NodeNum] = MaxSuccLatency + Cur->Latency;
+      Latencies[Cur->NodeNum] = MaxSuccLatency;
       WorkList.pop_back();
     }
   }