From 12dd99dc308150a6beff32aafc824e1d6fec1139 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Thu, 12 Nov 2009 19:08:21 +0000 Subject: [PATCH] Rename registers to break output dependencies in addition to anti-dependencies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87015 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AggressiveAntiDepBreaker.cpp | 5 +++-- lib/CodeGen/LatencyPriorityQueue.cpp | 15 ++++++++++++--- lib/CodeGen/PostRASchedulerList.cpp | 10 +++++++--- lib/CodeGen/ScheduleDAG.cpp | 10 ++++++++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/AggressiveAntiDepBreaker.cpp b/lib/CodeGen/AggressiveAntiDepBreaker.cpp index 17b50bd9559..b8cea27e515 100644 --- a/lib/CodeGen/AggressiveAntiDepBreaker.cpp +++ b/lib/CodeGen/AggressiveAntiDepBreaker.cpp @@ -285,7 +285,7 @@ static void AntiDepPathStep(SUnit *SU, AntiDepBreaker::AntiDepRegVector& Regs, for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end(); P != PE; ++P) { - if (P->getKind() == SDep::Anti) { + if ((P->getKind() == SDep::Anti) || (P->getKind() == SDep::Output)) { unsigned Reg = P->getReg(); if (RegSet.count(Reg) != 0) { Edges.push_back(&*P); @@ -716,7 +716,8 @@ unsigned AggressiveAntiDepBreaker::BreakAntiDependencies( SDep *Edge = Edges[i]; SUnit *NextSU = Edge->getSUnit(); - if (Edge->getKind() != SDep::Anti) continue; + if ((Edge->getKind() != SDep::Anti) && + (Edge->getKind() != SDep::Output)) continue; unsigned AntiDepReg = Edge->getReg(); DEBUG(errs() << "\tAntidep reg: " << TRI->getName(AntiDepReg)); diff --git a/lib/CodeGen/LatencyPriorityQueue.cpp b/lib/CodeGen/LatencyPriorityQueue.cpp index 794ecf7bd19..23dce4a91a1 100644 --- a/lib/CodeGen/LatencyPriorityQueue.cpp +++ b/lib/CodeGen/LatencyPriorityQueue.cpp @@ -55,7 +55,10 @@ SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(SUnit *SU) { SUnit *OnlyAvailablePred = 0; for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit &Pred = *I->getSUnit(); if (!Pred.isScheduled) { // We found an available, but not scheduled, predecessor. If it's the @@ -75,7 +78,10 @@ void LatencyPriorityQueue::push_impl(SUnit *SU) { unsigned NumNodesBlocking = 0; for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + if (getSingleUnscheduledPred(I->getSUnit()) == SU) ++NumNodesBlocking; } @@ -92,7 +98,10 @@ void LatencyPriorityQueue::push_impl(SUnit *SU) { void LatencyPriorityQueue::ScheduledNode(SUnit *SU) { for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + AdjustPriorityOfUnscheduledPreds(I->getSUnit()); } } diff --git a/lib/CodeGen/PostRASchedulerList.cpp b/lib/CodeGen/PostRASchedulerList.cpp index b5729bbed55..a29f349b0b5 100644 --- a/lib/CodeGen/PostRASchedulerList.cpp +++ b/lib/CodeGen/PostRASchedulerList.cpp @@ -603,7 +603,9 @@ void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge, void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU, bool IgnoreAntiDep) { for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; ReleaseSucc(SU, &*I, IgnoreAntiDep); } } @@ -658,7 +660,7 @@ void SchedulePostRATDList::ListScheduleTopDown( available = true; for (SUnit::const_pred_iterator I = SUnits[i].Preds.begin(), E = SUnits[i].Preds.end(); I != E; ++I) { - if (I->getKind() != SDep::Anti) { + if ((I->getKind() != SDep::Anti) && (I->getKind() != SDep::Output)) { available = false; } else { SUnits[i].NumPredsLeft -= 1; @@ -737,7 +739,9 @@ void SchedulePostRATDList::ListScheduleTopDown( AntiDepBreaker::AntiDepRegVector AntiDepRegs; for (SUnit::const_pred_iterator I = FoundSUnit->Preds.begin(), E = FoundSUnit->Preds.end(); I != E; ++I) { - if ((I->getKind() == SDep::Anti) && !I->getSUnit()->isScheduled) + if (((I->getKind() == SDep::Anti) || + (I->getKind() == SDep::Output)) && + !I->getSUnit()->isScheduled) AntiDepRegs.push_back(I->getReg()); } diff --git a/lib/CodeGen/ScheduleDAG.cpp b/lib/CodeGen/ScheduleDAG.cpp index 1363a92fed6..6b27db263b2 100644 --- a/lib/CodeGen/ScheduleDAG.cpp +++ b/lib/CodeGen/ScheduleDAG.cpp @@ -214,7 +214,10 @@ void SUnit::ComputeDepth(bool IgnoreAntiDep) { unsigned MaxPredDepth = 0; for (SUnit::const_pred_iterator I = Cur->Preds.begin(), E = Cur->Preds.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit *PredSU = I->getSUnit(); if (PredSU->isDepthCurrent) MaxPredDepth = std::max(MaxPredDepth, @@ -248,7 +251,10 @@ void SUnit::ComputeHeight(bool IgnoreAntiDep) { unsigned MaxSuccHeight = 0; for (SUnit::const_succ_iterator I = Cur->Succs.begin(), E = Cur->Succs.end(); I != E; ++I) { - if (IgnoreAntiDep && (I->getKind() == SDep::Anti)) continue; + if (IgnoreAntiDep && + ((I->getKind() == SDep::Anti) || (I->getKind() == SDep::Output))) + continue; + SUnit *SuccSU = I->getSUnit(); if (SuccSU->isHeightCurrent) MaxSuccHeight = std::max(MaxSuccHeight,