[llvm] [AMDGPU] Optionally Use GCNRPTrackers during scheduling (PR #93090)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 12:21:15 PDT 2024
================
@@ -151,14 +157,42 @@ static bool canUsePressureDiffs(const SUnit &SU) {
static void getRegisterPressures(bool AtTop,
const RegPressureTracker &RPTracker, SUnit *SU,
std::vector<unsigned> &Pressure,
- std::vector<unsigned> &MaxPressure) {
+ std::vector<unsigned> &MaxPressure,
+ GCNDownwardRPTracker &DownwardTracker,
+ GCNUpwardRPTracker &UpwardTracker,
+ ScheduleDAGMI *DAG) {
// getDownwardPressure() and getUpwardPressure() make temporary changes to
// the tracker, so we need to pass those function a non-const copy.
RegPressureTracker &TempTracker = const_cast<RegPressureTracker &>(RPTracker);
- if (AtTop)
- TempTracker.getDownwardPressure(SU->getInstr(), Pressure, MaxPressure);
- else
- TempTracker.getUpwardPressure(SU->getInstr(), Pressure, MaxPressure);
+ if (!GCNTrackers) {
+ if (AtTop)
+ TempTracker.getDownwardPressure(SU->getInstr(), Pressure, MaxPressure);
+ else
+ TempTracker.getUpwardPressure(SU->getInstr(), Pressure, MaxPressure);
+ } else {
+ Pressure.resize(4, 0);
+ if (AtTop) {
+ GCNDownwardRPTracker TempTopTracker(DownwardTracker);
+ auto MI = SU->getInstr();
+ TempTopTracker.advance(MI, false, DAG->getLIS());
+
+ Pressure[AMDGPU::RegisterPressureSets::SReg_32] =
----------------
jrbyrnes wrote:
Hi thanks for taking a look.
I'm not sure about this one.
In order to sink the Pressure assignments without introducing a ternary, we would need to do something like:
```
// GCNTrackers
Pressure.resize(4, 0);
GCNRPTracker TempTracker(
AtTop ? static_cast<GCNRPTracker>(DownwardTracker)
: static_cast<GCNRPTracker>(UpwardTracker));
MachineInstr *MI = SU->getInstr();
AtTop ? (void)reinterpret_cast<GCNDownwardRPTracker *>(&TempTracker)
->advance(MI, false, DAG->getLIS())
: reinterpret_cast<GCNUpwardRPTracker *>(&TempTracker)
->recede(*MI);
Pressure[AMDGPU::RegisterPressureSets::SReg_32] =
TempTracker.getPressure().getSGPRNum();
Pressure[AMDGPU::RegisterPressureSets::VGPR_32] =
TempTracker.getPressure().getVGPRNum(false);
```
I'm not sure I prefer this over what we have now. But if you feel strongly about it, I will change.
https://github.com/llvm/llvm-project/pull/93090
More information about the llvm-commits
mailing list