[llvm] [AMDGPU] Split wide constant address space stores (PR #226069)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 01:39:27 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Keshav Vinayak Jha (keshavvinayak01)
<details>
<summary>Changes</summary>
Wide stores to addrspace(4) can reach AMDGPU SelectionDAG instruction selection without being split, causing `Cannot select` on a 256-bit store. Include AS4 in the existing global/flat wide-store split so the resulting 128-bit stores use the global-store patterns added by llvm/llvm-project#<!-- -->153835.
The reproducer came from fuzzer-generated IR where the AS4 store is undefined behavior. This change prevents the codegen crash without defining that store's runtime behavior.
Tests: `llc -O0 -global-isel=false` on gfx90a and gfx1201 (The original reproducer for the bug).
More information in https://github.com/llvm/llvm-project/issues/226039
Assisted-by: Codex
---
Full diff: https://github.com/llvm/llvm-project/pull/226069.diff
2 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/SIISelLowering.cpp (+2-1)
- (added) llvm/test/CodeGen/AMDGPU/store-to-constant-wide.ll (+11)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index e47dd0e788796..676294053975b 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -14287,7 +14287,8 @@ SDValue SITargetLowering::LowerSTORE(SDValue Op, SelectionDAG &DAG) const {
: AMDGPUAS::GLOBAL_ADDRESS;
unsigned NumElements = VT.getVectorNumElements();
- if (AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) {
+ if (AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::CONSTANT_ADDRESS ||
+ AS == AMDGPUAS::FLAT_ADDRESS) {
if (NumElements > 4)
return SplitVectorStore(Op, DAG);
// v3 stores not supported on SI.
diff --git a/llvm/test/CodeGen/AMDGPU/store-to-constant-wide.ll b/llvm/test/CodeGen/AMDGPU/store-to-constant-wide.ll
new file mode 100644
index 0000000000000..26cc3eb5943cb
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/store-to-constant-wide.ll
@@ -0,0 +1,11 @@
+; RUN: llc -O0 -global-isel=false -mtriple=amdgpu9.0a-amd-amdhsa %s -o - | FileCheck %s --check-prefix=GFX90A
+; RUN: llc -O0 -global-isel=false -mtriple=amdgpu12.01-amd-amdhsa %s -o - | FileCheck %s --check-prefix=GFX12
+
+define amdgpu_kernel void @store_as4_v4i64(ptr addrspace(4) %dst, <4 x i64> %value) {
+; GFX90A-LABEL: store_as4_v4i64:
+; GFX90A-COUNT-2: global_store_dwordx4
+; GFX12-LABEL: store_as4_v4i64:
+; GFX12-COUNT-2: global_store_b128
+ store <4 x i64> %value, ptr addrspace(4) %dst, align 32
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/226069
More information about the llvm-commits
mailing list