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

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 11 12:18:07 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Akhilesh Moorthy (isakhilesh)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/135424.diff


1 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/SIFoldOperands.cpp (+3-1) 


``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index d6acf9e081b9f..701d17930d7df 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;
       }

``````````

</details>


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


More information about the llvm-commits mailing list