From fffd64acde62a29d26375a160ff5903860af41ed Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sat, 17 Oct 2015 00:35:59 +0000 Subject: [PATCH] RegisterPressure: Remove 0 entries from PressureChange This should not change behaviour because as far as I can see all code reading the pressure changes has no effect if the PressureInc is 0. Removing these entries however does avoid unnecessary computation, and results in a more stable debug output. I want the stable debug output to check that some upcoming changes are indeed NFC and identical even at the debug output level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250595 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/RegisterPressure.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/RegisterPressure.cpp b/lib/CodeGen/RegisterPressure.cpp index 88566d88732..2ebca20e599 100644 --- a/lib/CodeGen/RegisterPressure.cpp +++ b/lib/CodeGen/RegisterPressure.cpp @@ -79,8 +79,8 @@ void RegPressureTracker::dump() const { void PressureDiff::dump(const TargetRegisterInfo &TRI) const { for (const PressureChange &Change : *this) { - if (!Change.isValid() || Change.getUnitInc() == 0) - continue; + if (!Change.isValid()) + break; dbgs() << " " << TRI.getRegPressureSetName(Change.getPSet()) << " " << Change.getUnitInc(); } @@ -401,10 +401,20 @@ void PressureDiff::addPressureChange(unsigned RegUnit, bool IsDec, if (!I->isValid() || I->getPSet() != *PSetI) { PressureChange PTmp = PressureChange(*PSetI); for (PressureDiff::iterator J = I; J != E && PTmp.isValid(); ++J) - std::swap(*J,PTmp); + std::swap(*J, PTmp); } // Update the units for this pressure set. - I->setUnitInc(I->getUnitInc() + Weight); + unsigned NewUnitInc = I->getUnitInc() + Weight; + if (NewUnitInc != 0) { + I->setUnitInc(NewUnitInc); + } else { + // Remove entry + PressureDiff::iterator J; + for (J = std::next(I); J != E && J->isValid(); ++J, ++I) + *I = *J; + if (J != E) + *I = *J; + } } } -- 2.34.1