Skip to content

[AMDGPU] Remove GCNRewritePartialRegUsesImpl::getOperandRegClass #135153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Apr 10, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 10, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Jay Foad (jayfoad)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.cpp (-18)
diff --git a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.cpp b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.cpp
index c58d1b00a1002..4988eaa1a947d 100644
--- a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.cpp
@@ -105,9 +105,6 @@ class GCNRewritePartialRegUsesImpl {
 
   /// Helper methods.
 
-  /// Return reg class expected by a MO's parent instruction for a given MO.
-  const TargetRegisterClass *getOperandRegClass(MachineOperand &MO) const;
-
   /// Find right-shifted by RShift amount version of the SubReg if it exists,
   /// return 0 otherwise.
   unsigned shiftSubReg(unsigned SubReg, unsigned RShift) const;
@@ -404,13 +401,6 @@ void GCNRewritePartialRegUsesImpl::updateLiveIntervals(
   LIS->removeInterval(OldReg);
 }
 
-const TargetRegisterClass *
-GCNRewritePartialRegUsesImpl::getOperandRegClass(MachineOperand &MO) const {
-  MachineInstr *MI = MO.getParent();
-  return TII->getRegClass(TII->get(MI->getOpcode()), MI->getOperandNo(&MO), TRI,
-                          *MI->getParent()->getParent());
-}
-
 bool GCNRewritePartialRegUsesImpl::rewriteReg(Register Reg) const {
   auto Range = MRI->reg_nodbg_operands(Reg);
   if (Range.empty() || any_of(Range, [](MachineOperand &MO) {
@@ -436,14 +426,6 @@ bool GCNRewritePartialRegUsesImpl::rewriteReg(Register Reg) const {
     if (Inserted)
       SubRegRC = TRI->getSubRegisterClass(RC, SubReg);
 
-    if (SubRegRC) {
-      if (const TargetRegisterClass *OpDescRC = getOperandRegClass(MO)) {
-        LLVM_DEBUG(dbgs() << TRI->getRegClassName(SubRegRC) << " & "
-                          << TRI->getRegClassName(OpDescRC) << " = ");
-        SubRegRC = TRI->getCommonSubClass(SubRegRC, OpDescRC);
-      }
-    }
-
     if (!SubRegRC) {
       LLVM_DEBUG(dbgs() << "couldn't find target regclass\n");
       return false;

@@ -436,14 +426,6 @@ bool GCNRewritePartialRegUsesImpl::rewriteReg(Register Reg) const {
if (Inserted)
SubRegRC = TRI->getSubRegisterClass(RC, SubReg);

if (SubRegRC) {
if (const TargetRegisterClass *OpDescRC = getOperandRegClass(MO)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any test case where this is needed. If getSubRegisterClass returns an exact match (i.e. not a superclass of what you ask for) then I guess it doesn't need to be constrained any more than the original RC was.

SubRegRC = TRI->getCommonSubClass(SubRegRC, OpDescRC);
}
}

if (!SubRegRC) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this can be an assert now.

@vpykhtin
Copy link
Contributor

vpykhtin commented Apr 10, 2025

Thanks Jay, this reminds me that I have a cleanup patch for this pass that removes some leftover hacks existed before #67245. I don't mind submitting this but I would like to take a look into my patch and remember what I did.

More details available here #69957

@jayfoad
Copy link
Contributor Author

jayfoad commented Apr 11, 2025

Superseded by #135199.

@jayfoad jayfoad closed this Apr 11, 2025
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