From 8182347d70413174f2e80ea429801e887aee5cc3 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 12 Feb 2009 08:59:45 +0000 Subject: [PATCH] Replace one of burr scheduling heuristic with something more sensible. Now calcMaxScratches simply compute the number of true data dependencies. This actually improve a couple of tests in dejagnu suite as many tests in llvm nightly test suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64369 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../SelectionDAG/ScheduleDAGRRList.cpp | 22 ++++--------------- .../CodeGen/ARM/2008-11-19-ScavengerAssert.ll | 1 + test/CodeGen/X86/2008-08-05-SpillerBug.ll | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index a0652a72c94..912e8ed7f7c 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -916,7 +916,7 @@ CalcNodeSethiUllmanNumber(const SUnit *SU, std::vector &SUNumbers) { if (PredSethiUllman > SethiUllmanNumber) { SethiUllmanNumber = PredSethiUllman; Extra = 0; - } else if (PredSethiUllman == SethiUllmanNumber && !I->isCtrl()) + } else if (PredSethiUllman == SethiUllmanNumber) ++Extra; } @@ -1070,24 +1070,13 @@ static unsigned closestSucc(const SUnit *SU) { } /// calcMaxScratches - Returns an cost estimate of the worse case requirement -/// for scratch registers. Live-in operands and live-out results don't count -/// since they are "fixed". +/// for scratch registers, i.e. number of data dependencies. static unsigned calcMaxScratches(const SUnit *SU) { unsigned Scratches = 0; for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); - I != E; ++I) { + I != E; ++I) if (I->isCtrl()) continue; // ignore chain preds - if (!I->getSUnit()->getNode() || - I->getSUnit()->getNode()->getOpcode() != ISD::CopyFromReg) Scratches++; - } - for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); - I != E; ++I) { - if (I->isCtrl()) continue; // ignore chain succs - if (!I->getSUnit()->getNode() || - I->getSUnit()->getNode()->getOpcode() != ISD::CopyToReg) - Scratches += 10; - } return Scratches; } @@ -1120,10 +1109,7 @@ bool bu_ls_rr_sort::operator()(const SUnit *left, const SUnit *right) const { if (LDist != RDist) return LDist < RDist; - // Intuitively, it's good to push down instructions whose results are - // liveout so their long live ranges won't conflict with other values - // which are needed inside the BB. Further prioritize liveout instructions - // by the number of operands which are calculated within the BB. + // How many registers becomes live when the node is scheduled. unsigned LScratch = calcMaxScratches(left); unsigned RScratch = calcMaxScratches(right); if (LScratch != RScratch) diff --git a/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll b/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll index 3f0b94bf5b8..0a73b3fc257 100644 --- a/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll +++ b/test/CodeGen/ARM/2008-11-19-ScavengerAssert.ll @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin9 +; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin9 -stats |& grep asm-printer | grep 186 %"struct.Adv5::Ekin<3>" = type <{ i8 }> %"struct.Adv5::X::Energyflux<3>" = type { double } diff --git a/test/CodeGen/X86/2008-08-05-SpillerBug.ll b/test/CodeGen/X86/2008-08-05-SpillerBug.ll index 868c4958623..5ae802d61e2 100644 --- a/test/CodeGen/X86/2008-08-05-SpillerBug.ll +++ b/test/CodeGen/X86/2008-08-05-SpillerBug.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin -disable-fp-elim -stats -info-output-file - | grep {Number of dead stores elided} | count 1 +; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 57 ; PR2568 @g_3 = external global i16 ; [#uses=1]