Skip to content

Commit 4dc2135

Browse files
committed
Split spills-to-memory from satisfied.
1 parent b1f9b3d commit 4dc2135

File tree

5 files changed

+302
-291
lines changed

5 files changed

+302
-291
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,16 @@ bool GCNRPTarget::isSaveBeneficial(Register Reg) const {
428428
}
429429

430430
bool GCNRPTarget::satisfied() const {
431+
if (RP.getSGPRNum() > MaxSGPRs || RP.getVGPRNum(false) > MaxVGPRs)
432+
return false;
433+
if (UnifiedRF && RP.getVGPRNum(true) > MaxUnifiedVGPRs)
434+
return false;
435+
return true;
436+
}
437+
438+
bool GCNRPTarget::spillsToMemory() const {
431439
RegExcess Excess(MF, RP, MaxSGPRs, MaxVGPRs);
432-
return !Excess.spillsToMemory();
440+
return Excess.spillsToMemory();
433441
}
434442

435443
///////////////////////////////////////////////////////////////////////////////

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ class GCNRPTarget {
234234

235235
/// Whether the current RP is at or below the defined pressure target.
236236
bool satisfied() const;
237+
bool spillsToMemory() const;
237238

238239
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
239240
friend raw_ostream &operator<<(raw_ostream &OS, const GCNRPTarget &Target) {

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,14 +2046,16 @@ bool PreRARematStage::setObjective() {
20462046
// Set up "spilling targets" for all regions.
20472047
unsigned MaxSGPRs = ST.getMaxNumSGPRs(F);
20482048
unsigned MaxVGPRs = ST.getMaxNumVGPRs(F);
2049+
bool SpillsToMemory = false;
20492050
for (unsigned I = 0, E = DAG.Regions.size(); I != E; ++I) {
20502051
const GCNRegPressure &RP = DAG.Pressure[I];
20512052
GCNRPTarget &Target = RPTargets.emplace_back(MaxSGPRs, MaxVGPRs, MF, RP);
20522053
if (!Target.satisfied())
20532054
TargetRegions.set(I);
2055+
SpillsToMemory |= Target.spillsToMemory();
20542056
}
20552057

2056-
if (TargetRegions.any() || DAG.MinOccupancy >= MFI.getMaxWavesPerEU()) {
2058+
if (SpillsToMemory || DAG.MinOccupancy >= MFI.getMaxWavesPerEU()) {
20572059
// In addition to register usage being above addressable limits, occupancy
20582060
// below the minimum is considered like "spilling" as well.
20592061
TargetOcc = std::nullopt;

0 commit comments

Comments
 (0)