[llvm] [AMDGPU] Convert SVS form scratch frame index fallback into SV form (PR #219239)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 09:19:33 PDT 2026


================
@@ -3265,15 +3265,17 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
       // after). Only bail out when there is no frame register, or a VGPR
       // operand is needed but none could be scavenged.
       if ((!TmpSReg && !FrameReg) || (!TmpReg && !UseSGPR)) {
-        int SVOpcode = AMDGPU::getFlatScratchInstSVfromSS(MI->getOpcode());
+        int SVfromSSOpcode =
+            AMDGPU::getFlatScratchInstSVfromSS(MI->getOpcode());
+        int SVfromSVSOpcode =
+            AMDGPU::getFlatScratchInstSVfromSVS(MI->getOpcode());
+        int SVOpcode = SVfromSSOpcode != -1 ? SVfromSSOpcode : SVfromSVSOpcode;
         if (ST.hasFlatScratchSVSMode() && SVOpcode != -1) {
           // SV form encodes only the offset in vaddr; an SS-form scratch op
           // keeps its FI in the SGPR saddr, so this is only reached with no
           // frame register.
----------------
JanekvO wrote:

Not sure I completely hit the mark with my extension to this comment block; I believe the block comments on the assert right below it so my SVS form comments are in line with that.

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


More information about the llvm-commits mailing list