[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:37:41 PDT 2025


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

>From 69c34655c8b45f4cbeabd8ddf6b8f917fe09750c 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 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index d6acf9e081b9f..7b1ff514bbb16 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1159,6 +1159,8 @@ void SIFoldOperandsImpl::foldOperand(
 
         UseMI->setDesc(TII->get(AMDGPU::S_MOV_B32));
 
+        if (OpToFold.isGlobal())
+          return;
         if (OpToFold.isImm())
           UseMI->getOperand(1).ChangeToImmediate(OpToFold.getImm());
         else



More information about the llvm-commits mailing list