[llvm] [AMDGPU] Handle MachineOperandType global address in SIFoldOperands. (PR #135424)

Akhilesh Moorthy via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 11 12:25:14 PDT 2025


https://github.com/isakhilesh updated https://github.com/llvm/llvm-project/pull/135424

>From 686a2b5691f9d60b89858a5fec89844164c4264c Mon Sep 17 00:00:00 2001
From: Akhilesh Moorthy <akhilesh.moorthy at amd.com>
Date: Fri, 11 Apr 2025 14:01:30 -0500
Subject: [PATCH] [AMDGPU] Handle MachineOperandType global address in
 SIFoldOperands.

While FoldingImmLike accepts :
MO_Immediate, MO_FrameIndex and MO_GlobalAddress.
The conditional block after it only covers the first 2.
So I have added a case for the global value as well.
---
 llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index d6acf9e081b9f..e2fb5ffd42cc1 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1161,8 +1161,10 @@ void SIFoldOperandsImpl::foldOperand(
 
         if (OpToFold.isImm())
           UseMI->getOperand(1).ChangeToImmediate(OpToFold.getImm());
-        else
+        else if (OpToFold.isFI())
           UseMI->getOperand(1).ChangeToFrameIndex(OpToFold.getIndex());
+        else if (OpToFold.isGlobal())
+          return;
         UseMI->removeOperand(2); // Remove exec read (or src1 for readlane)
         return;
       }



More information about the llvm-commits mailing list