[llvm] [AMDGPU] Fold copies of constant physical registers into their uses (PR #154410)
    Jay Foad via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Sep 17 02:21:32 PDT 2025
    
    
  
================
@@ -727,8 +728,12 @@ bool SIFoldOperandsImpl::updateOperand(FoldCandidate &Fold) const {
   // 16-bit SGPRs instead of 32-bit ones.
   if (Old.getSubReg() == AMDGPU::lo16 && TRI->isSGPRReg(*MRI, New->getReg()))
     Old.setSubReg(AMDGPU::NoSubRegister);
-  Old.substVirtReg(New->getReg(), New->getSubReg(), *TRI);
-  Old.setIsUndef(New->isUndef());
+  if (New->getReg().isPhysical()) {
+    Old.substPhysReg(New->getReg(), *TRI);
+  } else {
+    Old.substVirtReg(New->getReg(), New->getSubReg(), *TRI);
+    Old.setIsUndef(New->isUndef());
----------------
jayfoad wrote:
I am not objecting to this change!
https://github.com/llvm/llvm-project/pull/154410
    
    
More information about the llvm-commits
mailing list