@@ -413,9 +413,13 @@ bool GCNRPTarget::isSaveBeneficial(Register Reg) const {
413413
414414 if (SRI->isSGPRClass (RC))
415415 return RP.getSGPRNum () > MaxSGPRs;
416- if (SRI->isAGPRClass (RC))
417- return isVGPRSaveBeneficial (RP.getAGPRNum (), RP.getArchVGPRNum ());
418- return isVGPRSaveBeneficial (RP.getArchVGPRNum (), RP.getAGPRNum ());
416+ unsigned NumVGPRs =
417+ SRI->isAGPRClass (RC) ? RP.getAGPRNum () : RP.getArchVGPRNum ();
418+ // The addressable limit must always be respected.
419+ if (NumVGPRs > MaxVGPRs)
420+ return true ;
421+ // For unified RFs, combined VGPR usage limit must be respected as well.
422+ return UnifiedRF && RP.getVGPRNum (true ) > MaxUnifiedVGPRs;
419423}
420424
421425bool GCNRPTarget::satisfied () const {
@@ -426,25 +430,6 @@ bool GCNRPTarget::satisfied() const {
426430 return true ;
427431}
428432
429- bool GCNRPTarget::isVGPRSaveBeneficial (unsigned NumRegsInRC,
430- unsigned NumRegsInOtherRC) const {
431- // The addressable limit must always be respected.
432- if (NumRegsInRC > MaxVGPRs)
433- return true ;
434- if (UnifiedRF) {
435- // Combined VGPR usage must be respected in unified RFs.
436- if (RP.getVGPRNum (true ) > MaxUnifiedVGPRs)
437- return true ;
438- // When the other VGPR RC is above its addressable limit and there is not
439- // enough space in this VGPR RC to fit all that excess through copies, we
440- // consider savings in this VGPR RC beneficial as well.
441- if (NumRegsInOtherRC > MaxVGPRs &&
442- 2 * MaxVGPRs < NumRegsInRC + NumRegsInOtherRC)
443- return true ;
444- }
445- return false ;
446- }
447-
448433// /////////////////////////////////////////////////////////////////////////////
449434// GCNRPTracker
450435
0 commit comments