[llvm] ec85dd4 - AMDGPU: Fix using getVRegDef on a physical register in SIFoldOperands (#216775)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 10:51:15 PDT 2026


Author: Matt Arsenault
Date: 2026-08-17T17:51:10Z
New Revision: ec85dd474365e2e195617ee705924784a14cf0ce

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

LOG: AMDGPU: Fix using getVRegDef on a physical register in SIFoldOperands (#216775)

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 7401ff8456cae..efbe5cf281f0f 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -391,6 +391,9 @@ bool SIFoldOperandsImpl::frameIndexMayFold(const MachineInstr &UseMI, int OpNo,
 ///   => %vgpr = V_ADD_U32 x, frameindex
 bool SIFoldOperandsImpl::foldCopyToVGPROfScalarAddOfFrameIndex(
     Register DstReg, Register SrcReg, MachineInstr &MI) const {
+  if (!SrcReg.isVirtual())
+    return false;
+
   if (TRI->isVGPR(*MRI, DstReg) && TRI->isSGPRReg(*MRI, SrcReg) &&
       MRI->hasOneNonDBGUse(SrcReg)) {
     MachineInstr *Def = MRI->getVRegDef(SrcReg);


        


More information about the llvm-commits mailing list