1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

sched: Avoid trivially redundant DAG edges. Take the one with higher latency.

llvm-svn: 158379
This commit is contained in:
Andrew Trick 2012-06-13 02:39:00 +00:00
parent 7e0382b71e
commit 858cf20add
2 changed files with 27 additions and 5 deletions

View File

@ -117,8 +117,9 @@ namespace llvm {
} }
} }
bool operator==(const SDep &Other) const { /// Return true if the specified SDep is equivalent except for latency.
if (Dep != Other.Dep || Latency != Other.Latency) return false; bool overlaps(const SDep &Other) const {
if (Dep != Other.Dep) return false;
switch (Dep.getInt()) { switch (Dep.getInt()) {
case Data: case Data:
case Anti: case Anti:
@ -133,6 +134,10 @@ namespace llvm {
llvm_unreachable("Invalid dependency kind!"); llvm_unreachable("Invalid dependency kind!");
} }
bool operator==(const SDep &Other) const {
return overlaps(Other) && Latency == Other.Latency;
}
bool operator!=(const SDep &Other) const { bool operator!=(const SDep &Other) const {
return !operator==(Other); return !operator==(Other);
} }

View File

@ -64,10 +64,27 @@ const MCInstrDesc *ScheduleDAG::getNodeDesc(const SDNode *Node) const {
/// specified node. /// specified node.
bool SUnit::addPred(const SDep &D) { bool SUnit::addPred(const SDep &D) {
// If this node already has this depenence, don't add a redundant one. // 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(); for (SmallVector<SDep, 4>::iterator I = Preds.begin(), E = Preds.end();
I != E; ++I) I != E; ++I) {
if (*I == D) 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; return false;
}
}
// Now add a corresponding succ to N. // Now add a corresponding succ to N.
SDep P = D; SDep P = D;
P.setSUnit(this); P.setSUnit(this);