[llvm] a1bfa2f - AMDGPU: Avoid directly using MCOperandInfo RegClass field (#156641)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 03:50:11 PDT 2025


Author: Matt Arsenault
Date: 2025-09-03T10:50:07Z
New Revision: a1bfa2f6a69b9bff45529809af932f0484795b90

URL: https://github.com/llvm/llvm-project/commit/a1bfa2f6a69b9bff45529809af932f0484795b90
DIFF: https://github.com/llvm/llvm-project/commit/a1bfa2f6a69b9bff45529809af932f0484795b90.diff

LOG: AMDGPU: Avoid directly using MCOperandInfo RegClass field (#156641)

This value should not be directly interpreted. Also avoids
a function only used for an assert.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
index 627f89c58e7ad..8821558bb0239 100644
--- a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
@@ -193,16 +193,6 @@ MachineOperand *GCNDPPCombine::getOldOpndValue(MachineOperand &OldOpnd) const {
   return &OldOpnd;
 }
 
-[[maybe_unused]] static unsigned getOperandSize(MachineInstr &MI, unsigned Idx,
-                               MachineRegisterInfo &MRI) {
-  int16_t RegClass = MI.getDesc().operands()[Idx].RegClass;
-  if (RegClass == -1)
-    return 0;
-
-  const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
-  return TRI->getRegSizeInBits(*TRI->getRegClass(RegClass));
-}
-
 MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
                                            MachineInstr &MovMI,
                                            RegSubRegPair CombOldVGPR,
@@ -321,8 +311,8 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
       // requirements are the same as for src0. We check src0 instead because
       // pseudos are shared between subtargets and allow SGPR for src1 on all.
       if (!ST->hasDPPSrc1SGPR()) {
-        assert(getOperandSize(*DPPInst, Src0Idx, *MRI) ==
-                   getOperandSize(*DPPInst, NumOperands, *MRI) &&
+        assert(TII->getOpSize(*DPPInst, Src0Idx) ==
+                   TII->getOpSize(*DPPInst, NumOperands) &&
                "Src0 and Src1 operands should have the same size");
       }
 


        


More information about the llvm-commits mailing list