@@ -64,6 +64,10 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F,
6464 }
6565
6666 MayNeedAGPRs = ST.hasMAIInsts ();
67+ if (ST.hasGFX90AInsts () &&
68+ ST.getMaxNumVGPRs (F) <= AMDGPU::VGPR_32RegClass.getNumRegs () &&
69+ !mayUseAGPRs (F))
70+ MayNeedAGPRs = false ; // We will select all MAI with VGPR operands.
6771
6872 if (AMDGPU::isChainCC (CC)) {
6973 // Chain functions don't receive an SP from their caller, but are free to
@@ -100,11 +104,6 @@ SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F,
100104 ImplicitArgPtr = false ;
101105 MaxKernArgAlign = std::max (ST.getAlignmentForImplicitArgPtr (),
102106 MaxKernArgAlign);
103-
104- if (ST.hasGFX90AInsts () &&
105- ST.getMaxNumVGPRs (F) <= ST.getAddressableNumArchVGPRs () &&
106- !mayUseAGPRs (F))
107- MayNeedAGPRs = false ; // We will select all MAI with VGPR operands.
108107 }
109108
110109 if (!AMDGPU::isGraphics (CC) ||
@@ -787,44 +786,3 @@ bool SIMachineFunctionInfo::initializeBaseYamlFields(
787786bool SIMachineFunctionInfo::mayUseAGPRs (const Function &F) const {
788787 return !F.hasFnAttribute (" amdgpu-no-agpr" );
789788}
790-
791- bool SIMachineFunctionInfo::usesAGPRs (const MachineFunction &MF) const {
792- if (UsesAGPRs)
793- return *UsesAGPRs;
794-
795- if (!mayNeedAGPRs ()) {
796- UsesAGPRs = false ;
797- return false ;
798- }
799-
800- if (!AMDGPU::isEntryFunctionCC (MF.getFunction ().getCallingConv ()) ||
801- MF.getFrameInfo ().hasCalls ()) {
802- UsesAGPRs = true ;
803- return true ;
804- }
805-
806- const MachineRegisterInfo &MRI = MF.getRegInfo ();
807-
808- for (unsigned I = 0 , E = MRI.getNumVirtRegs (); I != E; ++I) {
809- const Register Reg = Register::index2VirtReg (I);
810- const TargetRegisterClass *RC = MRI.getRegClassOrNull (Reg);
811- if (RC && SIRegisterInfo::isAGPRClass (RC)) {
812- UsesAGPRs = true ;
813- return true ;
814- }
815- if (!RC && !MRI.use_empty (Reg) && MRI.getType (Reg).isValid ()) {
816- // Defer caching UsesAGPRs, function might not yet been regbank selected.
817- return true ;
818- }
819- }
820-
821- for (MCRegister Reg : AMDGPU::AGPR_32RegClass) {
822- if (MRI.isPhysRegUsed (Reg)) {
823- UsesAGPRs = true ;
824- return true ;
825- }
826- }
827-
828- UsesAGPRs = false ;
829- return false ;
830- }
0 commit comments