[llvm] r305003 - [Hexagon] Speedup NumNodesBlocking calculation. NFCI.
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 8 11:49:26 PDT 2017
Author: niravd
Date: Thu Jun 8 13:49:25 2017
New Revision: 305003
URL: http://llvm.org/viewvc/llvm-project?rev=305003&view=rev
Log:
[Hexagon] Speedup NumNodesBlocking calculation. NFCI.
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp?rev=305003&r1=305002&r2=305003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonMachineScheduler.cpp Thu Jun 8 13:49:25 2017
@@ -563,40 +563,33 @@ void ConvergingVLIWScheduler::readyQueue
}
#endif
-/// getSingleUnscheduledPred - If there is exactly one unscheduled predecessor
-/// of SU, return it, otherwise return null.
-static SUnit *getSingleUnscheduledPred(SUnit *SU) {
- SUnit *OnlyAvailablePred = nullptr;
- for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
- I != E; ++I) {
- SUnit &Pred = *I->getSUnit();
- if (!Pred.isScheduled) {
- // We found an available, but not scheduled, predecessor. If it's the
- // only one we have found, keep track of it... otherwise give up.
- if (OnlyAvailablePred && OnlyAvailablePred != &Pred)
- return nullptr;
- OnlyAvailablePred = &Pred;
- }
+/// isSingleUnscheduledPred - If SU2 is the only unscheduled predecessor
+/// of SU, return true (we may have duplicates)
+static inline bool isSingleUnscheduledPred(SUnit *SU, SUnit *SU2) {
+ if (SU->NumPredsLeft == 0)
+ return false;
+
+ for (auto &Pred : SU->Preds) {
+ // We found an available, but not scheduled, predecessor.
+ if (!Pred.getSUnit()->isScheduled && (Pred.getSUnit() != SU2))
+ return false;
}
- return OnlyAvailablePred;
+
+ return true;
}
-/// getSingleUnscheduledSucc - If there is exactly one unscheduled successor
-/// of SU, return it, otherwise return null.
-static SUnit *getSingleUnscheduledSucc(SUnit *SU) {
- SUnit *OnlyAvailableSucc = nullptr;
- for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
- I != E; ++I) {
- SUnit &Succ = *I->getSUnit();
- if (!Succ.isScheduled) {
- // We found an available, but not scheduled, successor. If it's the
- // only one we have found, keep track of it... otherwise give up.
- if (OnlyAvailableSucc && OnlyAvailableSucc != &Succ)
- return nullptr;
- OnlyAvailableSucc = &Succ;
- }
+/// isSingleUnscheduledSucc - If SU2 is the only unscheduled successor
+/// of SU, return true (we may have duplicates)
+static inline bool isSingleUnscheduledSucc(SUnit *SU, SUnit *SU2) {
+ if (SU->NumSuccsLeft == 0)
+ return false;
+
+ for (auto &Succ : SU->Succs) {
+ // We found an available, but not scheduled, successor.
+ if (!Succ.getSUnit()->isScheduled && (Succ.getSUnit() != SU2))
+ return false;
}
- return OnlyAvailableSucc;
+ return true;
}
// Constants used to denote relative importance of
@@ -673,12 +666,12 @@ int ConvergingVLIWScheduler::SchedulingC
// Count the number of nodes that
// this node is the sole unscheduled node for.
for (const SDep &SI : SU->Succs)
- if (getSingleUnscheduledPred(SI.getSUnit()) == SU)
+ if (isSingleUnscheduledPred(SI.getSUnit(), SU))
++NumNodesBlocking;
} else {
// How many unscheduled predecessors block this node?
for (const SDep &PI : SU->Preds)
- if (getSingleUnscheduledSucc(PI.getSUnit()) == SU)
+ if (isSingleUnscheduledSucc(PI.getSUnit(), SU))
++NumNodesBlocking;
}
ResCount += (NumNodesBlocking * ScaleTwo);
More information about the llvm-commits
mailing list