[llvm-branch-commits] [llvm] [AMDGPU] Fold sreg32 operand across Lo16 subcopy (PR #217999)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Sep 13 09:05:46 PDT 2026
================
@@ -1538,6 +1556,45 @@ bool SIFoldOperandsImpl::foldOperand(
return true;
}
+ // Look through Lo16 Copy
+ // OpToFold: %0
+ // %1:vgpr32 = copy %0:sreg32/sregxx:sub_x
+ // %2:vgpr16 = copy %1.lo16:vgpr32 (UseMI)
+ // VALU16 %2:vgpr16 ...
+ // =>
+ // VALU16 %0:sreg32/sregxx:sub_x...
+ // Hack to allow 32-bit SGPRs to be folded into True16 instructions
+ // Remove this if 16-bit SGPRs (i.e. SGPR_LO16) are added to the
+ // VS_16RegClass
+ if (UseMI->isCopy() && OpToFold.isReg() &&
+ UseMI->getOperand(0).getReg().isVirtual() &&
+ TRI->isSGPRReg(*MRI, OpToFold.getReg()) &&
----------------
arsenm wrote:
Can be more direct than isSGPRReg
https://github.com/llvm/llvm-project/pull/217999
More information about the llvm-branch-commits
mailing list