[llvm] r250595 - RegisterPressure: Remove 0 entries from PressureChange
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 17:36:00 PDT 2015
Author: matze
Date: Fri Oct 16 19:35:59 2015
New Revision: 250595
URL: http://llvm.org/viewvc/llvm-project?rev=250595&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/RegisterPressure.cpp
Modified: llvm/trunk/lib/CodeGen/RegisterPressure.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterPressure.cpp?rev=250595&r1=250594&r2=250595&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterPressure.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterPressure.cpp Fri Oct 16 19:35:59 2015
@@ -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(uns
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;
+ }
}
}
More information about the llvm-commits
mailing list