[llvm] AMDGPU: Avoid querying operand parent in isLegalRegOperand (PR #219464)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 06:13:18 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/219464

This is accessible through MachineRegisterInfo and doesn't need to
look at the operand parent chain.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>

>From 053468ce07fd72f6995a114ce33895824b69813a Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 28 Aug 2026 10:00:14 +0200
Subject: [PATCH] AMDGPU: Avoid querying operand parent in isLegalRegOperand

This is accessible through MachineRegisterInfo and doesn't need to
look at the operand parent chain.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index bc419d813f171..4551287a7a619 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -6544,8 +6544,8 @@ bool SIInstrInfo::isLegalRegOperand(const MachineRegisterInfo &MRI,
   const TargetRegisterClass *RC = MRI.getRegClass(Reg);
 
   if (MO.getSubReg()) {
-    const MachineFunction *MF = MO.getParent()->getMF();
-    const TargetRegisterClass *SuperRC = RI.getLargestLegalSuperClass(RC, *MF);
+    const TargetRegisterClass *SuperRC =
+        RI.getLargestLegalSuperClass(RC, MRI.getMF());
     if (!SuperRC)
       return false;
     return RI.getMatchingSuperRegClass(SuperRC, DRC, MO.getSubReg()) != nullptr;



More information about the llvm-commits mailing list