Lines Matching +full:current +full:- +full:boost +full:- +full:limit

1 //===- RegisterPressure.cpp - Dynamic Register Pressure -------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
30 #include "llvm/Config/llvm-config.h"
75 CurrSetPressure[*PSetI] -= Weight;
86 dbgs() << TRI->getRegPressureSetName(i) << "=" << SetPressure[i] << '\n';
161 PSetIterator PSetI = MRI->getPressureSets(RegUnit);
192 /// If the current top is not less than or equal to the next index, open it.
201 /// If the current top is the previous instruction (before receding), open it.
209 /// If the current bottom is not greater than the previous index, open it.
217 /// If the current bottom is the previous instr (before advancing), open it.
230 this->NumRegUnits = NumRegUnits;
272 TRI = MF->getSubtarget().getRegisterInfo();
274 MRI = &MF->getRegInfo();
276 this->TrackUntiedDefs = TrackUntiedDefs;
277 this->TrackLaneMasks = TrackLaneMasks;
285 CurrSetPressure.assign(TRI->getNumRegPressureSets(), 0);
291 UntiedDefs.setUniverse(MRI->getNumVirtRegs());
312 skipDebugInstructionsForward(CurrPos, MBB->end());
313 if (IdxPos == MBB->end())
314 return LIS->getMBBEndIdx(MBB);
315 return LIS->getInstructionIndex(*IdxPos).getRegSlot();
356 /// live-thru ranges. However, two-address or coalesced chains can also lead
360 LiveThruPressure.assign(TRI->getNumRegPressureSets(), 0);
361 assert(isBottomClosed() && "need bottom-up tracking to intialize.");
377 return I->LaneMask;
390 I->LaneMask |= Pair.LaneMask;
402 I->LaneMask = LaneBitmask::getNone();
414 I->LaneMask &= ~Pair.LaneMask;
415 if (I->LaneMask.none())
539 // Treat read-undef subreg defs as definitions of the whole register.
582 Register Reg = RI->RegUnit;
585 LiveQueryResult LRQ = LR->Query(SlotIdx);
603 LaneBitmask LiveAfter = getLiveLanesAt(LIS, MRI, true, I->RegUnit,
606 // of a subregister def we need a read-undef flag.
607 Register RegUnit = I->RegUnit;
609 (LiveAfter & ~I->LaneMask).none())
610 AddFlagsMI->setRegisterDefReadUndef(RegUnit);
612 LaneBitmask ActualDef = I->LaneMask & LiveAfter;
616 I->LaneMask = ActualDef;
633 AddFlagsMI->setRegisterDefReadUndef(RegUnit);
654 assert(!PDiff.begin()->isValid() && "stale PDiff");
665 PSetIterator PSetI = MRI->getPressureSets(RegUnit);
666 int Weight = IsDec ? -PSetI.getWeight() : PSetI.getWeight();
670 for (; I != E && I->isValid(); ++I) {
671 if (I->getPSet() >= *PSetI)
678 if (!I->isValid() || I->getPSet() != *PSetI) {
684 unsigned NewUnitInc = I->getUnitInc() + Weight;
686 I->setUnitInc(NewUnitInc);
690 for (J = std::next(I); J != E && J->isValid(); ++J, ++I)
721 PrevMask = I->LaneMask;
723 I->LaneMask = NewMask;
752 /// RegUnits that are made live by the current instruction's uses. This includes
758 assert(!CurrPos->isDebugOrPseudoInstr());
760 // Boost pressure for all dead defs together.
792 SlotIdx = LIS->getInstructionIndex(*CurrPos).getRegSlot();
813 bool IsRedef = I != LiveUses->end();
815 // ignore re-defs here...
816 assert(I->LaneMask.none());
845 assert(CurrPos != MBB->begin());
854 CurrPos = prev_nodbg(CurrPos, MBB->begin());
857 if (RequireIntervals && !CurrPos->isDebugOrPseudoInstr())
858 SlotIdx = LIS->getInstructionIndex(*CurrPos).getRegSlot();
867 if (CurrPos->isDebugInstr() || CurrPos->isPseudoProbe()) {
870 assert(CurrPos == MBB->begin());
878 SlotIndex SlotIdx = LIS->getInstructionIndex(*CurrPos).getRegSlot();
887 /// Advance across the current instruction.
890 assert(CurrPos != MBB->end());
932 // Boost pressure for all dead defs together.
936 CurrPos = next_nodbg(CurrPos, MBB->end());
960 int PDiff = (int)PNew - (int)POld;
963 // Only consider change beyond the limit.
964 unsigned Limit = RCI->getRegPressureSetLimit(i);
966 Limit += LiveThruPressureVec[i];
968 if (Limit > POld) {
969 if (Limit > PNew)
970 PDiff = 0; // Under the limit
972 PDiff = PNew - Limit; // Just exceeded limit.
973 } else if (Limit > PNew)
974 PDiff = Limit - POld; // Just obeyed limit.
985 /// limit or exceeds the current MaxPressureLimit.
1010 int PDiff = (int)PNew - (int)CriticalPSets[CritIdx].getUnitInc();
1021 Delta.CurrentMax.setUnitInc(PNew - POld);
1028 /// Record the upward impact of a single instruction on current register
1033 /// with the current position, so must be restored by the caller.
1035 assert(!MI->isDebugOrPseudoInstr() && "Expect a nondebug instruction.");
1039 SlotIdx = LIS->getInstructionIndex(*MI).getRegSlot();
1050 // Boost max pressure for all dead defs together.
1082 /// bottom-up. Find the pressure set with the most change beyond its pressure
1083 /// limit based on the tracker's current pressure, and return the change in
1087 /// This assumes that the current LiveOut set is sufficient.
1089 /// This is expensive for an on-the-fly query because it calls
1090 /// bumpUpwardPressure to recompute the pressure sets based on current
1092 /// -verify-misched. getUpwardPressureDelta is the fast version of this query
1093 /// that uses the per-SUnit cache of the PressureDiff.
1127 PDiff->dump(*TRI);
1130 dbgs() << "Excess1 " << TRI->getRegPressureSetName(Delta.Excess.getPSet())
1133 dbgs() << "Critic1 " << TRI->getRegPressureSetName(Delta.CriticalMax.getPSet())
1136 dbgs() << "CurrMx1 " << TRI->getRegPressureSetName(Delta.CurrentMax.getPSet())
1139 dbgs() << "Excess2 " << TRI->getRegPressureSetName(Delta2.Excess.getPSet())
1142 dbgs() << "Critic2 " << TRI->getRegPressureSetName(Delta2.CriticalMax.getPSet())
1145 dbgs() << "CurrMx2 " << TRI->getRegPressureSetName(Delta2.CurrentMax.getPSet())
1153 /// directly depend on current liveness.
1158 /// limit within the region, not necessarily at the current position.
1161 /// necessarily at the current position.
1170 PDiffI != PDiffE && PDiffI->isValid(); ++PDiffI) {
1172 unsigned PSetID = PDiffI->getPSet();
1173 unsigned Limit = RCI->getRegPressureSetLimit(PSetID);
1175 Limit += LiveThruPressure[PSetID];
1181 unsigned PNew = POld + PDiffI->getUnitInc();
1182 assert((PDiffI->getUnitInc() >= 0) == (PNew >= POld)
1186 // Check if current pressure has exceeded the limit.
1189 if (PNew > Limit)
1190 ExcessInc = POld > Limit ? PNew - POld : PNew - Limit;
1191 else if (POld > Limit)
1192 ExcessInc = Limit - POld;
1206 int CritInc = (int)MNew - (int)CriticalPSets[CritIdx].getUnitInc();
1213 // Check if max pressure has exceeded the current max.
1216 Delta.CurrentMax.setUnitInc(MNew - MOld);
1233 SlotIndex InstSlot = LIS->getInstructionIndex(*MI).getRegSlot();
1262 return S != nullptr && S->end == Pos.getRegSlot();
1273 return S != nullptr && S->start < Pos.getRegSlot(true) &&
1274 S->end != Pos.getDeadSlot();
1278 /// Record the downward impact of a single instruction on current register
1283 /// with the current position, so must be restored by the caller.
1285 assert(!MI->isDebugOrPseudoInstr() && "Expect a nondebug instruction.");
1289 SlotIdx = LIS->getInstructionIndex(*MI).getRegSlot();
1305 // last uses for the current position.
1307 // to be bottom-scheduled to avoid searching uses at each query.
1328 // Boost pressure for all dead defs together.
1333 /// top-down. Find the register class with the most change in its pressure limit
1334 /// based on the tracker's current pressure, and return the number of excess
1337 /// This assumes that the current LiveIn set is sufficient.
1339 /// This is expensive for an on-the-fly query because it calls
1340 /// bumpDownwardPressure to recompute the pressure sets based on current
1365 /// Get the pressure of each PSet after traversing this instruction bottom-up.
1376 // Current pressure becomes the result. Restore current pressure.
1381 /// Get the pressure of each PSet after traversing this instruction top-down.
1392 // Current pressure becomes the result. Restore current pressure.