Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Sep 19, 2025

This shadows the member in the base class, but differs slightly
in behavior. The base method doesn't check for the invalid case.

Copy link
Contributor Author

arsenm commented Sep 19, 2025

@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2025

@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

This shadows the member in the base class, but differs slightly
in behavior. The base method doesn't check for the invalid case.


Full diff: https://github.com/llvm/llvm-project/pull/159885.diff

4 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIFoldOperands.cpp (+4-3)
  • (modified) llvm/lib/Target/AMDGPU/SIInstrInfo.cpp (+3-2)
  • (modified) llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp (-11)
  • (modified) llvm/lib/Target/AMDGPU/SIRegisterInfo.h (-2)
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 533c130364249..2710b98488e99 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1301,10 +1301,11 @@ void SIFoldOperandsImpl::foldOperand(
         continue;
 
       const int SrcIdx = MovOp == AMDGPU::V_MOV_B16_t16_e64 ? 2 : 1;
-      const TargetRegisterClass *MovSrcRC =
-          TRI->getRegClass(TII->getOpRegClassID(MovDesc.operands()[SrcIdx]));
 
-      if (MovSrcRC) {
+      int16_t RegClassID = TII->getOpRegClassID(MovDesc.operands()[SrcIdx]);
+      if (RegClassID != -1) {
+        const TargetRegisterClass *MovSrcRC = TRI->getRegClass(RegClassID);
+
         if (UseSubReg)
           MovSrcRC = TRI->getMatchingSuperRegClass(SrcRC, MovSrcRC, UseSubReg);
         if (!MRI->constrainRegClass(SrcReg, MovSrcRC))
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 06190323dda8f..a368a0de891ea 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -5964,7 +5964,7 @@ SIInstrInfo::getRegClass(const MCInstrDesc &TID, unsigned OpNum,
     return nullptr;
   const MCOperandInfo &OpInfo = TID.operands()[OpNum];
   int16_t RegClass = getOpRegClassID(OpInfo);
-  return RI.getRegClass(RegClass);
+  return RegClass < 0 ? nullptr : RI.getRegClass(RegClass);
 }
 
 const TargetRegisterClass *SIInstrInfo::getOpRegClass(const MachineInstr &MI,
@@ -5982,7 +5982,8 @@ const TargetRegisterClass *SIInstrInfo::getOpRegClass(const MachineInstr &MI,
     return RI.getPhysRegBaseClass(Reg);
   }
 
-  return RI.getRegClass(getOpRegClassID(Desc.operands()[OpNo]));
+  int16_t RegClass = getOpRegClassID(Desc.operands()[OpNo]);
+  return RegClass < 0 ? nullptr : RI.getRegClass(RegClass);
 }
 
 void SIInstrInfo::legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const {
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index b019c98f15ee2..af7f0cbd4ae7a 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -3897,17 +3897,6 @@ const TargetRegisterClass *SIRegisterInfo::getVGPR64Class() const {
                                 : &AMDGPU::VReg_64RegClass;
 }
 
-// FIXME: This should be deleted
-const TargetRegisterClass *
-SIRegisterInfo::getRegClass(unsigned RCID) const {
-  switch ((int)RCID) {
-  case -1:
-    return nullptr;
-  default:
-    return AMDGPUGenRegisterInfo::getRegClass(RCID);
-  }
-}
-
 // Find reaching register definition
 MachineInstr *SIRegisterInfo::findReachingDef(Register Reg, unsigned SubReg,
                                               MachineInstr &Use,
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
index 7b91ba7bc581f..813f6bb1a503a 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h
@@ -391,8 +391,6 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
 
   MCRegister getExec() const;
 
-  const TargetRegisterClass *getRegClass(unsigned RCID) const;
-
   // Find reaching register definition
   MachineInstr *findReachingDef(Register Reg, unsigned SubReg,
                                 MachineInstr &Use,

@arsenm arsenm force-pushed the users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs branch from 99aa6e5 to 1bb104e Compare October 4, 2025 10:06
@arsenm arsenm force-pushed the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch 2 times, most recently from bcaa5f7 to 979997d Compare October 8, 2025 02:21
@arsenm arsenm force-pushed the users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs branch from 1bb104e to 326e05d Compare October 8, 2025 02:21
@arsenm arsenm force-pushed the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch from 979997d to 76c4167 Compare October 10, 2025 15:56
@arsenm arsenm force-pushed the users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs branch from 326e05d to a6de0f1 Compare October 10, 2025 15:56
@arsenm arsenm force-pushed the users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs branch from a6de0f1 to fc0f34c Compare October 22, 2025 10:55
@arsenm arsenm force-pushed the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch from 76c4167 to c16ce8f Compare October 22, 2025 10:55
@arsenm arsenm force-pushed the users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs branch from fc0f34c to 1fafa1c Compare November 11, 2025 01:32
@arsenm arsenm force-pushed the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch from c16ce8f to 7a2d9da Compare November 11, 2025 01:32
Base automatically changed from users/arsenm/amdgpu/use-RegClassByHwMode-wavesize-vregs to main November 11, 2025 23:08
This shadows the member in the base class, but differs slightly
in behavior. The base method doesn't check for the invalid case.
@arsenm arsenm force-pushed the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch from 7a2d9da to f5c71b3 Compare November 11, 2025 23:09
@arsenm arsenm enabled auto-merge (squash) November 11, 2025 23:09
@arsenm arsenm disabled auto-merge November 11, 2025 23:31
@arsenm arsenm merged commit e3a9ac5 into main Nov 11, 2025
6 of 9 checks passed
@arsenm arsenm deleted the users/arsenm/amdgpu/remove-wrapper-tri-getRegClass branch November 11, 2025 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants