diff options
author | Andrew Trick <atrick@apple.com> | 2012-06-13 02:39:00 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-06-13 02:39:00 +0000 |
commit | 9df55eed0470c898c4003dc433c4479bdb0e0aac (patch) | |
tree | 7d10e955ea96551b7bd3734036ff70e9c479725b /lib/CodeGen/ScheduleDAG.cpp | |
parent | a256ac521017a1da05c2e044beabe54e556e910b (diff) | |
download | llvm-9df55eed0470c898c4003dc433c4479bdb0e0aac.tar.gz llvm-9df55eed0470c898c4003dc433c4479bdb0e0aac.tar.bz2 llvm-9df55eed0470c898c4003dc433c4479bdb0e0aac.tar.xz |
sched: Avoid trivially redundant DAG edges. Take the one with higher latency.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ScheduleDAG.cpp')
-rw-r--r-- | lib/CodeGen/ScheduleDAG.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/CodeGen/ScheduleDAG.cpp b/lib/CodeGen/ScheduleDAG.cpp index 8fd64265fd..752f8e4080 100644 --- a/lib/CodeGen/ScheduleDAG.cpp +++ b/lib/CodeGen/ScheduleDAG.cpp @@ -64,10 +64,27 @@ const MCInstrDesc *ScheduleDAG::getNodeDesc(const SDNode *Node) const { /// specified node. bool SUnit::addPred(const SDep &D) { // If this node already has this depenence, don't add a redundant one. - for (SmallVector<SDep, 4>::const_iterator I = Preds.begin(), E = Preds.end(); - I != E; ++I) - if (*I == D) + for (SmallVector<SDep, 4>::iterator I = Preds.begin(), E = Preds.end(); + I != E; ++I) { + if (I->overlaps(D)) { + // Extend the latency if needed. Equivalent to removePred(I) + addPred(D). + if (I->getLatency() < D.getLatency()) { + SUnit *PredSU = I->getSUnit(); + // Find the corresponding successor in N. + SDep ForwardD = *I; + ForwardD.setSUnit(this); + for (SmallVector<SDep, 4>::iterator II = PredSU->Succs.begin(), + EE = PredSU->Succs.end(); II != EE; ++II) { + if (*II == ForwardD) { + II->setLatency(D.getLatency()); + break; + } + } + I->setLatency(D.getLatency()); + } return false; + } + } // Now add a corresponding succ to N. SDep P = D; P.setSUnit(this); |