[llvm] AMDGPU: Handle rewriting VGPR MFMA fed from AGPR copy (PR #153022)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 14:17:44 PDT 2025
================
@@ -60,6 +64,32 @@ class AMDGPURewriteAGPRCopyMFMAImpl {
return TII.isMAI(MI) && AMDGPU::getMFMASrcCVDstAGPROp(MI.getOpcode()) != -1;
}
+ /// Find AV_* registers assigned to AGPRs (or virtual registers which were
+ /// already required to be AGPR).
+ ///
+ /// \return the assigned physical register that \p VReg is assigned to if it
+ /// is an AGPR, otherwise MCRegister().
+ MCRegister getAssignedAGPR(Register VReg) const {
+ MCRegister PhysReg = VRM.getPhys(VReg);
+ if (!PhysReg)
+ return MCRegister();
+
+ const TargetRegisterClass *VirtRegRC = MRI.getRegClass(VReg);
+ if (!TRI.hasAGPRs(VirtRegRC))
+ return MCRegister();
+
+ if (!TRI.hasVGPRs(VirtRegRC))
+ return PhysReg;
+
+ // If this is an AV register, we have to check if the actual assignment is
+ // to an AGPR
+ const TargetRegisterClass *AssignedRC = TRI.getPhysRegBaseClass(PhysReg);
+ return TRI.isAGPRClass(AssignedRC) ? PhysReg : MCRegister();
----------------
jrbyrnes wrote:
To echo perlfu: it's unclear why we don't just use this instead of doing the VirtRegRC checks -- comment would be helpful.
https://github.com/llvm/llvm-project/pull/153022
More information about the llvm-commits
mailing list