Skip to content

Commit 1b22c91

Browse files
committed
Use getMaxNumVectorRegs instead of getArchVGPRAllocationThreshold
Change-Id: I36e92840e35774cb419389ee6dadc26dd376ebaa
1 parent 9f7597b commit 1b22c91

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ void GCNRegPressure::inc(unsigned Reg,
9999
bool GCNRegPressure::less(const MachineFunction &MF, const GCNRegPressure &O,
100100
unsigned MaxOccupancy) const {
101101
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
102-
unsigned ArchVGPRThreshold = ST.getArchVGPRAllocationThreshold(MF);
102+
unsigned ArchVGPRThreshold =
103+
ST.getRegisterInfo()->getMaxNumVectorRegs(MF).first;
103104
unsigned DynamicVGPRBlockSize =
104105
MF.getInfo<SIMachineFunctionInfo>()->getDynamicVGPRBlockSize();
105106

@@ -250,7 +251,8 @@ bool GCNRegPressure::less(const MachineFunction &MF, const GCNRegPressure &O,
250251
Printable llvm::print(const GCNRegPressure &RP, const GCNSubtarget *ST,
251252
unsigned DynamicVGPRBlockSize,
252253
const MachineFunction *MF) {
253-
unsigned ArchVGPRThreshold = ST->getArchVGPRAllocationThreshold(*MF);
254+
unsigned ArchVGPRThreshold =
255+
ST->getRegisterInfo()->getMaxNumVectorRegs(*MF).first;
254256
return Printable(
255257
[&RP, ST, DynamicVGPRBlockSize, ArchVGPRThreshold, MF](raw_ostream &OS) {
256258
OS << "VGPRs: " << RP.getArchVGPRNum(ArchVGPRThreshold) << ' '
@@ -903,10 +905,10 @@ bool GCNRegPressurePrinter::runOnMachineFunction(MachineFunction &MF) {
903905
auto printRP = [&MF](const GCNRegPressure &RP) {
904906
return Printable([&RP, &MF](raw_ostream &OS) {
905907
OS << format(PFX " %-5d", RP.getSGPRNum())
906-
<< format(
907-
" %-5d",
908-
RP.getVGPRNum(false, MF.getSubtarget<GCNSubtarget>()
909-
.getArchVGPRAllocationThreshold(MF)));
908+
<< format(" %-5d", RP.getVGPRNum(false, MF.getSubtarget<GCNSubtarget>()
909+
.getRegisterInfo()
910+
->getMaxNumVectorRegs(MF)
911+
.first));
910912
});
911913
};
912914

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ struct GCNRegPressure {
8989
getAVGPRsAsVGPRsNum(NumArchVGPRs, NumAVGPRs, AddressableArchVGPR);
9090
unsigned AVGPRsAsAGPRs = getAVGPRsAsAGPRsNum(
9191
NumArchVGPRs, NumAGPRs, NumAVGPRs, AddressableArchVGPR);
92-
NumAVGPRs > AVGPRsAsVGPRs ? NumAVGPRs - AVGPRsAsVGPRs : 0;
9392
return alignTo(NumArchVGPRs + AVGPRsAsVGPRs,
9493
AMDGPU::IsaInfo::getArchVGPRAllocGranule()) +
9594
NumAGPRs + AVGPRsAsAGPRs;
@@ -129,11 +128,12 @@ struct GCNRegPressure {
129128
unsigned DynamicVGPRBlockSize =
130129
MF.getInfo<SIMachineFunctionInfo>()->getDynamicVGPRBlockSize();
131130

132-
return std::min(ST.getOccupancyWithNumSGPRs(getSGPRNum()),
133-
ST.getOccupancyWithNumVGPRs(
134-
getVGPRNum(ST.hasGFX90AInsts(),
135-
ST.getArchVGPRAllocationThreshold(MF)),
136-
DynamicVGPRBlockSize));
131+
return std::min(
132+
ST.getOccupancyWithNumSGPRs(getSGPRNum()),
133+
ST.getOccupancyWithNumVGPRs(
134+
getVGPRNum(ST.hasGFX90AInsts(),
135+
ST.getRegisterInfo()->getMaxNumVectorRegs(MF).first),
136+
DynamicVGPRBlockSize));
137137
}
138138

139139
void inc(unsigned Reg,

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ static void getRegisterPressures(
190190
TempUpwardTracker.recede(*MI);
191191
NewPressure = TempUpwardTracker.getPressure();
192192
}
193-
unsigned ArchVGPRThreshold =
194-
DAG->MF.getSubtarget<GCNSubtarget>().getArchVGPRAllocationThreshold(
195-
DAG->MF);
193+
unsigned ArchVGPRThreshold = DAG->MF.getSubtarget<GCNSubtarget>()
194+
.getRegisterInfo()
195+
->getMaxNumVectorRegs(DAG->MF)
196+
.first;
196197
Pressure[AMDGPU::RegisterPressureSets::SReg_32] = NewPressure.getSGPRNum();
197198
Pressure[AMDGPU::RegisterPressureSets::VGPR_32] =
198199
NewPressure.getArchVGPRNum(ArchVGPRThreshold);
@@ -343,9 +344,11 @@ void GCNSchedStrategy::pickNodeFromQueue(SchedBoundary &Zone,
343344
? static_cast<GCNRPTracker *>(&UpwardTracker)
344345
: static_cast<GCNRPTracker *>(&DownwardTracker);
345346
SGPRPressure = T->getPressure().getSGPRNum();
346-
VGPRPressure = T->getPressure().getArchVGPRNum(
347-
DAG->MF.getSubtarget<GCNSubtarget>().getArchVGPRAllocationThreshold(
348-
DAG->MF));
347+
VGPRPressure =
348+
T->getPressure().getArchVGPRNum(DAG->MF.getSubtarget<GCNSubtarget>()
349+
.getRegisterInfo()
350+
->getMaxNumVectorRegs(DAG->MF)
351+
.first);
349352
}
350353
}
351354
ReadyQueue &Q = Zone.Available;
@@ -1286,7 +1289,8 @@ void GCNSchedStage::checkScheduling() {
12861289
<< print(PressureAfter, &ST, 0, &MF));
12871290
LLVM_DEBUG(dbgs() << "Region: " << RegionIdx << ".\n");
12881291

1289-
unsigned ArchVGPRThreshold = ST.getArchVGPRAllocationThreshold(MF);
1292+
unsigned ArchVGPRThreshold =
1293+
ST.getRegisterInfo()->getMaxNumVectorRegs(MF).first;
12901294
if (PressureAfter.getSGPRNum() <= S.SGPRCriticalLimit &&
12911295
PressureAfter.getVGPRNum(ST.hasGFX90AInsts(), ArchVGPRThreshold) <=
12921296
S.VGPRCriticalLimit) {
@@ -1478,7 +1482,8 @@ bool GCNSchedStage::shouldRevertScheduling(unsigned WavesAfter) {
14781482

14791483
// For dynamic VGPR mode, we don't want to waste any VGPR blocks.
14801484
if (DAG.MFI.isDynamicVGPREnabled()) {
1481-
unsigned ArchVGPRThreshold = ST.getArchVGPRAllocationThreshold(MF);
1485+
unsigned ArchVGPRThreshold =
1486+
ST.getRegisterInfo()->getMaxNumVectorRegs(MF).first;
14821487
unsigned BlocksBefore = AMDGPU::IsaInfo::getAllocatedNumVGPRBlocks(
14831488
&ST, DAG.MFI.getDynamicVGPRBlockSize(),
14841489
PressureBefore.getVGPRNum(false, ArchVGPRThreshold));

llvm/lib/Target/AMDGPU/GCNSubtarget.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,15 +1626,6 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
16261626
return AMDGPU::IsaInfo::getAddressableNumArchVGPRs(this);
16271627
}
16281628

1629-
unsigned getArchVGPRAllocationThreshold(const MachineFunction &MF) const {
1630-
if (hasGFX90AInsts() || !hasMAIInsts())
1631-
return AMDGPU::IsaInfo::getAddressableNumArchVGPRs(this);
1632-
1633-
const Function &F = MF.getFunction();
1634-
std::pair<unsigned, unsigned> Waves = getWavesPerEU(F);
1635-
return getMaxNumVGPRs(Waves.first, 0);
1636-
}
1637-
16381629
/// \returns Addressable number of VGPRs supported by the subtarget.
16391630
unsigned getAddressableNumVGPRs(unsigned DynamicVGPRBlockSize) const {
16401631
return AMDGPU::IsaInfo::getAddressableNumVGPRs(this, DynamicVGPRBlockSize);

llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ bool SIFormMemoryClausesImpl::checkPressure(const MachineInstr &MI,
209209
// tracking does not account for the alignment requirements for SGPRs, or the
210210
// fragmentation of registers the allocator will need to satisfy.
211211
if (Occupancy >= MFI->getMinAllowedOccupancy() &&
212-
MaxPressure.getVGPRNum(ST->hasGFX90AInsts(),
213-
ST->getArchVGPRAllocationThreshold(*MI.getMF())) <=
212+
MaxPressure.getVGPRNum(
213+
ST->hasGFX90AInsts(),
214+
ST->getRegisterInfo()->getMaxNumVectorRegs(*MI.getMF()).first) <=
214215
MaxVGPRs / 2 &&
215216
MaxPressure.getSGPRNum() <= MaxSGPRs / 2) {
216217
LastRecordedOccupancy = Occupancy;

0 commit comments

Comments
 (0)