Changes in directory llvm/lib/CodeGen/SelectionDAG:
ScheduleDAGList.cpp updated: 1.47 -> 1.48 --- Log message: Don't advance the hazard recognizer when there are no hazards and no instructions to be emitted. Don't add one to the latency of a completed instruction if the latency of the op is 0. --- Diffs of the changes: (+40 -25) ScheduleDAGList.cpp | 65 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 40 insertions(+), 25 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp:1.47 llvm/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp:1.48 --- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp:1.47 Sat Mar 11 21:52:09 2006 +++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp Sun Mar 12 03:01:41 2006 @@ -357,6 +357,8 @@ // Remove MainNode from FlaggedNodes again. SU->FlaggedNodes.pop_back(); } + + return; DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su].dumpAll(&DAG)); } @@ -550,14 +552,14 @@ unsigned AvailableCycle = 0; for (std::set<std::pair<SUnit*, bool> >::iterator I = SuccSU->Preds.begin(), E = SuccSU->Preds.end(); I != E; ++I) { - // If this is a token edge, we don't need to wait for the full latency of - // the preceeding instruction (e.g. a long-latency load) unless there is - // also some other data dependence. + // If this is a token edge, we don't need to wait for the latency of the + // preceeding instruction (e.g. a long-latency load) unless there is also + // some other data dependence. unsigned PredDoneCycle = I->first->Cycle; if (!I->second) PredDoneCycle += I->first->Latency; - else - PredDoneCycle += 1; + else if (I->first->Latency) + PredDoneCycle += 1; AvailableCycle = std::max(AvailableCycle, PredDoneCycle); } @@ -608,7 +610,7 @@ while (!AvailableQueue->empty() || !PendingQueue.empty()) { // Check to see if any of the pending instructions are ready to issue. If // so, add them to the available queue. - for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) + for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) { if (PendingQueue[i].first == CurCycle) { AvailableQueue->push(PendingQueue[i].second); PendingQueue[i].second->isAvailable = true; @@ -618,54 +620,67 @@ } else { assert(PendingQueue[i].first > CurCycle && "Negative latency?"); } + } - SUnit *FoundNode = 0; + // If there are no instructions available, don't try to issue anything, and + // don't advance the hazard recognizer. + if (AvailableQueue->empty()) { + ++CurCycle; + continue; + } + SUnit *FoundSUnit = 0; + SDNode *FoundNode = 0; + bool HasNoopHazards = false; while (!AvailableQueue->empty()) { - SUnit *CurNode = AvailableQueue->pop(); + SUnit *CurSUnit = AvailableQueue->pop(); // Get the node represented by this SUnit. - SDNode *N = CurNode->Node; + FoundNode = CurSUnit->Node; + // If this is a pseudo op, like copyfromreg, look to see if there is a // real target node flagged to it. If so, use the target node. - for (unsigned i = 0, e = CurNode->FlaggedNodes.size(); - N->getOpcode() < ISD::BUILTIN_OP_END && i != e; ++i) - N = CurNode->FlaggedNodes[i]; + for (unsigned i = 0, e = CurSUnit->FlaggedNodes.size(); + FoundNode->getOpcode() < ISD::BUILTIN_OP_END && i != e; ++i) + FoundNode = CurSUnit->FlaggedNodes[i]; - HazardRecognizer::HazardType HT = HazardRec->getHazardType(N); + HazardRecognizer::HazardType HT = HazardRec->getHazardType(FoundNode); if (HT == HazardRecognizer::NoHazard) { - FoundNode = CurNode; + FoundSUnit = CurSUnit; break; } // Remember if this is a noop hazard. HasNoopHazards |= HT == HazardRecognizer::NoopHazard; - NotReady.push_back(CurNode); + NotReady.push_back(CurSUnit); } // Add the nodes that aren't ready back onto the available list. - AvailableQueue->push_all(NotReady); - NotReady.clear(); + if (!NotReady.empty()) { + AvailableQueue->push_all(NotReady); + NotReady.clear(); + } // If we found a node to schedule, do it now. - if (FoundNode) { - ScheduleNodeTopDown(FoundNode, CurCycle); - HazardRec->EmitInstruction(FoundNode->Node); - FoundNode->isScheduled = true; - AvailableQueue->ScheduledNode(FoundNode); + if (FoundSUnit) { + ScheduleNodeTopDown(FoundSUnit, CurCycle); + HazardRec->EmitInstruction(FoundNode); + FoundSUnit->isScheduled = true; + AvailableQueue->ScheduledNode(FoundSUnit); // If this is a pseudo-op node, we don't want to increment the current // cycle. - if (FoundNode->Latency == 0) - continue; // Don't increment for pseudo-ops! + if (FoundSUnit->Latency) // Don't increment CurCycle for pseudo-ops! + ++CurCycle; } else if (!HasNoopHazards) { // Otherwise, we have a pipeline stall, but no other problem, just advance // the current cycle and try again. DEBUG(std::cerr << "*** Advancing cycle, no work to do\n"); HazardRec->AdvanceCycle(); ++NumStalls; + ++CurCycle; } else { // Otherwise, we have no instructions to issue and we have instructions // that will fault if we don't do this right. This is the case for @@ -674,8 +689,8 @@ HazardRec->EmitNoop(); Sequence.push_back(0); // NULL SUnit* -> noop ++NumNoops; + ++CurCycle; } - ++CurCycle; } #ifndef NDEBUG _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits