summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-06-13 02:39:00 +0000
committerAndrew Trick <atrick@apple.com>2012-06-13 02:39:00 +0000
commit5b90645abb6fdf8e3b098adc2da650b791016b7d (patch)
treee2b43d46ca57e5c492cff66383e0b5f65348c3b1 /llvm/lib/CodeGen
parent3fe00f29ad49e46152e26f771d6c21c3aab89b24 (diff)
downloadbcm5719-llvm-5b90645abb6fdf8e3b098adc2da650b791016b7d.tar.gz
bcm5719-llvm-5b90645abb6fdf8e3b098adc2da650b791016b7d.zip
sched: Avoid trivially redundant DAG edges. Take the one with higher latency.
llvm-svn: 158379
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/ScheduleDAG.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/ScheduleDAG.cpp b/llvm/lib/CodeGen/ScheduleDAG.cpp
index 8fd64265fda..752f8e40804 100644
--- a/llvm/lib/CodeGen/ScheduleDAG.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud