[llvm] [AMDGPU] Add commute for some VOP3 inst (PR #121326)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 08:06:19 PST 2025


================
@@ -5817,6 +5877,49 @@ bool SIInstrInfo::isLegalRegOperand(const MachineRegisterInfo &MRI,
   return RC->hasSuperClassEq(DRC);
 }
 
+bool SIInstrInfo::isLegalRegOperand(const MachineInstr &MI, unsigned OpIdx,
+                                    const MachineOperand &MO) const {
+  const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
+  const MCOperandInfo OpInfo = MI.getDesc().operands()[OpIdx];
+  unsigned Opc = MI.getOpcode();
+
+  if (!isLegalRegOperand(MRI, OpInfo, MO))
+    return false;
+
+  // check Accumulate GPR operand
+  bool IsAGPR = RI.isAGPR(MRI, MO.getReg());
+  if (IsAGPR && !ST.hasMAIInsts())
+    return false;
+  if (IsAGPR && (!ST.hasGFX90AInsts() || !MRI.reservedRegsFrozen()) &&
----------------
arsenm wrote:

This !MRI.reservedRegsFrozen() doesn't make any sense but all of this code looks copied directly from existing code 

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


More information about the llvm-commits mailing list