[llvm] AMDGPU: Fix using illegal VOP3 literal in frame index elimination (PR #115747)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 02:56:40 PST 2024


================
@@ -2496,6 +2496,25 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
       Register MaterializedReg = FrameReg;
       Register ScavengedVGPR;
 
+      int64_t Offset = FrameInfo.getObjectOffset(Index);
+      // For the non-immediate case, we could fall through to the default
+      // handling, but we do an in-place update of the result register here to
+      // avoid scavenging another register.
+      if (OtherOp->isImm()) {
+        int64_t TotalOffset = OtherOp->getImm() + Offset;
+
+        if (!ST.hasVOP3Literal() && SIInstrInfo::isVOP3(*MI) &&
+            !AMDGPU::isInlinableIntLiteral(TotalOffset)) {
+          // If we can't support a VOP3 literal in the VALU instruction, we
+          // can't specially fold into the add.
+          // TODO: Handle VOP3->VOP2 shrink to support the fold.
+          break;
+        }
----------------
jayfoad wrote:

I assume this is the only significant change?

Why does this block have to move before the !enableFlatScratch handling?

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


More information about the llvm-commits mailing list