[llvm] [AMDGPU] Allow folding of non-subregs through REG_SEQUENCE (PR #151033)

Josh Hutton via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 11:42:51 PST 2025


================
@@ -1465,6 +1477,33 @@ void SIFoldOperandsImpl::foldOperand(
       return;
   }
 
+  if (!FoldingImmLike && OpToFold.isReg() && ST->needsAlignedVGPRs()) {
----------------
JoshHuttonCode wrote:

That makes sense to me that this isn't something core for the pass to worry about, I just don't understand how RegClassByHwMode solves this issue. I did add a FIXME comment. There are two pieces that we would need to fix it: RegClassByHwMode for these specific instructions, having access to a 32-bit aligned register class. Without having a 32-bit aligned register class, I don't think we would ever actually perform the folding without some special casing anyway. As you mentioned, this PR is not for addressing this underlying issue. Do you think this needs to be addressed before this PR can be accepted?

Additionally, I borrowed this code from `SIInstrInfo::verifyInstruction()`. It may make sense to extract this code so it does not need to be redefined.

https://github.com/llvm/llvm-project/pull/151033


More information about the llvm-commits mailing list