[llvm] AMDGPU/GlobalISel: RegBankLegalize rules for gfx90a/gfx942 MFMAs (PR #194076)

Petar Avramovic via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 02:58:05 PDT 2026


================
@@ -2031,21 +2032,64 @@ RegBankLegalizeRules::RegBankLegalizeRules(const GCNSubtarget &_ST,
       .Uni(S16, {{UniInVgprS16}, {IntrId, Vgpr32}})
       .Div(S16, {{Vgpr16}, {IntrId, Vgpr32}});
 
-  // TODO: Add handling for GFX90A+ which should use VGPRs instead of AGPRs.
+  // Predicates to check if we want to use the VGPR form or the AGPR form
+  // for an MFMA / SMFMAC intrinsic on gfx90a+.
+  Predicate needAGPR([](const MachineInstr &MI) -> bool {
+    const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
+    unsigned DstSize = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
+    unsigned MinNumRegsRequired = DstSize / 32;
+    const SIMachineFunctionInfo *Info =
+        MI.getMF()->getInfo<SIMachineFunctionInfo>();
+    return Info->selectAGPRFormMFMA(MinNumRegsRequired);
+  });
+  Predicate needVGPR = !needAGPR;
----------------
petar-avramovic wrote:

think it is better to use !needAGPR directly

https://github.com/llvm/llvm-project/pull/194076


More information about the llvm-commits mailing list