Conversation
Contributor
Author
Member
|
@llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesDoesn't touch the globalisel version because the handling Full diff: https://github.com/llvm/llvm-project/pull/168787.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 6a0a9e3d3e5ac..6c36f8ad9b6a9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -4437,7 +4437,8 @@ bool AMDGPUDAGToDAGISel::isUniformLoad(const SDNode *N) const {
Ld->getAlign() >=
Align(std::min(MMO->getSize().getValue().getKnownMinValue(),
uint64_t(4))) &&
- ((Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS ||
+ (MMO->isInvariant() ||
+ (Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS ||
Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT) ||
(Subtarget->getScalarizeGlobalBehavior() &&
Ld->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS &&
diff --git a/llvm/test/CodeGen/AMDGPU/invariant-load-no-alias-store.ll b/llvm/test/CodeGen/AMDGPU/invariant-load-no-alias-store.ll
index 6815050d0a441..23970d454526c 100644
--- a/llvm/test/CodeGen/AMDGPU/invariant-load-no-alias-store.ll
+++ b/llvm/test/CodeGen/AMDGPU/invariant-load-no-alias-store.ll
@@ -10,7 +10,7 @@
; GCN-DAG: buffer_load_dwordx2 [[PTR:v\[[0-9]+:[0-9]+\]]],
; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x1c8007b
; GCN: buffer_store_dword [[K]], [[PTR]]
-define amdgpu_kernel void @test_merge_store_constant_i16_invariant_global_pointer_load(ptr addrspace(1) dereferenceable(4096) nonnull %in) #0 {
+define void @test_merge_store_constant_i16_invariant_global_pointer_load(ptr addrspace(1) dereferenceable(4096) nonnull %in) #0 {
%ptr = load ptr addrspace(1), ptr addrspace(1) %in, !invariant.load !0
%ptr.1 = getelementptr i16, ptr addrspace(1) %ptr, i64 1
store i16 123, ptr addrspace(1) %ptr, align 4
@@ -30,6 +30,19 @@ define amdgpu_kernel void @test_merge_store_constant_i16_invariant_constant_poin
ret void
}
+; Invariant global load should be equivalently handled to constant.
+; GCN-LABEL: {{^}}test_merge_store_global_i16_invariant_uniform_global_pointer_load:
+; GCN: s_load_dwordx2 s[[[SPTR_LO:[0-9]+]]:[[SPTR_HI:[0-9]+]]]
+; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x1c8007b
+; GCN: buffer_store_dword [[K]], off, s[[[SPTR_LO]]:
+define amdgpu_kernel void @test_merge_store_global_i16_invariant_uniform_global_pointer_load(ptr addrspace(1) dereferenceable(4096) nonnull %in) #0 {
+ %ptr = load ptr addrspace(1), ptr addrspace(1) %in, !invariant.load !0
+ %ptr.1 = getelementptr i16, ptr addrspace(1) %ptr, i64 1
+ store i16 123, ptr addrspace(1) %ptr, align 4
+ store i16 456, ptr addrspace(1) %ptr.1
+ ret void
+}
+
!0 = !{}
attributes #0 = { nounwind }
|
🐧 Linux x64 Test Results
|
7bad49b to
e2c7ac8
Compare
7d7cabd to
cd38396
Compare
jayfoad
approved these changes
Nov 20, 2025
Contributor
jayfoad
left a comment
There was a problem hiding this comment.
This is saying that invariant loads can be selected to SMEM instructions regardless of any "no clobber" check, right? I think that's safe...
Base automatically changed from
users/arsenm/amdgpu/reapply-allow-select-ptr-combine-168292
to
main
November 20, 2025 17:13
Doesn't touch the globalisel version because the handling there looks a bit broken.
cd38396 to
34253e8
Compare
This was referenced Nov 20, 2025
aadeshps-mcw
pushed a commit
to aadeshps-mcw/llvm-project
that referenced
this pull request
Nov 26, 2025
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Nov 26, 2025
augusto2112
pushed a commit
to augusto2112/llvm-project
that referenced
this pull request
Dec 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Doesn't touch the globalisel version because the handling
there looks a bit broken.