From 112572e95eb8cd33606b376d5508b555aa00eedf Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 22 Dec 2008 21:11:33 +0000 Subject: [PATCH] Optimize setDepthDirty and setHeightDirty a little, as they showed up on a profile. llvm-svn: 61344 --- lib/CodeGen/ScheduleDAG.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/ScheduleDAG.cpp b/lib/CodeGen/ScheduleDAG.cpp index 3ec538cf2fc..8630cfee7d7 100644 --- a/lib/CodeGen/ScheduleDAG.cpp +++ b/lib/CodeGen/ScheduleDAG.cpp @@ -119,29 +119,35 @@ void SUnit::removePred(const SDep &D) { } void SUnit::setDepthDirty() { + if (!isDepthCurrent) return; SmallVector WorkList; WorkList.push_back(this); - while (!WorkList.empty()) { + do { SUnit *SU = WorkList.pop_back_val(); - if (!SU->isDepthCurrent) continue; SU->isDepthCurrent = false; for (SUnit::const_succ_iterator I = SU->Succs.begin(), - E = SU->Succs.end(); I != E; ++I) - WorkList.push_back(I->getSUnit()); - } + E = SU->Succs.end(); I != E; ++I) { + SUnit *SuccSU = I->getSUnit(); + if (SuccSU->isDepthCurrent) + WorkList.push_back(SuccSU); + } + } while (!WorkList.empty()); } void SUnit::setHeightDirty() { + if (!isHeightCurrent) return; SmallVector WorkList; WorkList.push_back(this); - while (!WorkList.empty()) { + do { SUnit *SU = WorkList.pop_back_val(); - if (!SU->isHeightCurrent) continue; SU->isHeightCurrent = false; for (SUnit::const_pred_iterator I = SU->Preds.begin(), - E = SU->Preds.end(); I != E; ++I) - WorkList.push_back(I->getSUnit()); - } + E = SU->Preds.end(); I != E; ++I) { + SUnit *PredSU = I->getSUnit(); + if (PredSU->isHeightCurrent) + WorkList.push_back(PredSU); + } + } while (!WorkList.empty()); } /// setDepthToAtLeast - Update this node's successors to reflect the