[llvm] [AMDGPU] RewriteMFMAFormStage: pre-check dst/src2 eligibility in initHeuristics() (PR #199825)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 05:18:36 PDT 2026


================
@@ -2307,10 +2307,18 @@ bool RewriteMFMAFormStage::initHeuristics(
       int ReplacementOp = AMDGPU::getMFMASrcCVDstAGPROp(MI.getOpcode());
       assert(ReplacementOp != -1);
 
+      MachineOperand *Src2 = TII->getNamedOperand(MI, AMDGPU::OpName::src2);
+      MachineOperand &Dst = MI.getOperand(0);
+      assert(Src2);
+      // Pre-validate: both dst and src2 (if a register) must be virtual.
+      if (!Dst.getReg().isVirtual() ||
+          (Src2->isReg() && !Src2->getReg().isVirtual())) {
+        continue;
+      }
+
       RewriteCands.push_back({&MI, MI.getOpcode()});
----------------
xgxanq wrote:


<img width="1545" height="145" alt="image" src="https://github.com/user-attachments/assets/cf51f440-c8c8-4596-83d3-c396030f2d47" />
just like this

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


More information about the llvm-commits mailing list