-
Notifications
You must be signed in to change notification settings - Fork 15.3k
AMDGPU: Add baseline test for split/widen invariant loads #168913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arsenm
merged 1 commit into
main
from
users/arsenm/amdgpu/add-baseline-test-invariant-vector-load
Nov 21, 2025
Merged
AMDGPU: Add baseline test for split/widen invariant loads #168913
arsenm
merged 1 commit into
main
from
users/arsenm/amdgpu/add-baseline-test-invariant-vector-load
Nov 21, 2025
+77
−0
Conversation
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
This was referenced Nov 20, 2025
Contributor
Author
This was referenced Nov 20, 2025
Member
|
@llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/168913.diff 1 Files Affected:
diff --git a/llvm/test/CodeGen/AMDGPU/load-global-invariant.ll b/llvm/test/CodeGen/AMDGPU/load-global-invariant.ll
new file mode 100644
index 0000000000000..b881edde0f448
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/load-global-invariant.ll
@@ -0,0 +1,70 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck %s
+
+; Check that invariant global loads are treated like constant
+; loads. The optnone disables the annotation of of amdgpu.noclobber.
+
+define amdgpu_kernel void @load_constant_v3i64(ptr addrspace(1) %dst, ptr addrspace(4) %src) #0 {
+; CHECK-LABEL: load_constant_v3i64:
+; CHECK: ; %bb.0:
+; CHECK-NEXT: v_mov_b32_e32 v4, 0
+; CHECK-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
+; CHECK-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x8
+; CHECK-NEXT: s_waitcnt lgkmcnt(0)
+; CHECK-NEXT: s_load_dwordx4 s[0:3], s[6:7], 0x0
+; CHECK-NEXT: s_nop 0
+; CHECK-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x10
+; CHECK-NEXT: s_waitcnt lgkmcnt(0)
+; CHECK-NEXT: v_mov_b32_e32 v0, s6
+; CHECK-NEXT: v_mov_b32_e32 v1, s7
+; CHECK-NEXT: global_store_dwordx2 v4, v[0:1], s[4:5] offset:16
+; CHECK-NEXT: v_mov_b32_e32 v0, s0
+; CHECK-NEXT: v_mov_b32_e32 v1, s1
+; CHECK-NEXT: v_mov_b32_e32 v2, s2
+; CHECK-NEXT: v_mov_b32_e32 v3, s3
+; CHECK-NEXT: global_store_dwordx4 v4, v[0:3], s[4:5]
+; CHECK-NEXT: s_endpgm
+ %ld = load <3 x i64>, ptr addrspace(4) %src, align 32
+ store <3 x i64> %ld, ptr addrspace(1) %dst, align 32
+ ret void
+}
+
+define amdgpu_kernel void @load_global_v3i64(ptr addrspace(1) %dst, ptr addrspace(1) %src) #0 {
+; CHECK-LABEL: load_global_v3i64:
+; CHECK: ; %bb.0:
+; CHECK-NEXT: v_mov_b32_e32 v6, 0
+; CHECK-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
+; CHECK-NEXT: s_load_dwordx2 s[2:3], s[8:9], 0x8
+; CHECK-NEXT: s_waitcnt lgkmcnt(0)
+; CHECK-NEXT: global_load_dwordx4 v[0:3], v6, s[2:3]
+; CHECK-NEXT: global_load_dwordx2 v[4:5], v6, s[2:3] offset:16
+; CHECK-NEXT: s_waitcnt vmcnt(0)
+; CHECK-NEXT: global_store_dwordx2 v6, v[4:5], s[0:1] offset:16
+; CHECK-NEXT: global_store_dwordx4 v6, v[0:3], s[0:1]
+; CHECK-NEXT: s_endpgm
+ %ld = load <3 x i64>, ptr addrspace(1) %src, align 32
+ store <3 x i64> %ld, ptr addrspace(1) %dst, align 32
+ ret void
+}
+
+define amdgpu_kernel void @load_global_v3i64_invariant(ptr addrspace(1) %dst, ptr addrspace(1) %src) #0 {
+; CHECK-LABEL: load_global_v3i64_invariant:
+; CHECK: ; %bb.0:
+; CHECK-NEXT: v_mov_b32_e32 v6, 0
+; CHECK-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0
+; CHECK-NEXT: s_load_dwordx2 s[2:3], s[8:9], 0x8
+; CHECK-NEXT: s_waitcnt lgkmcnt(0)
+; CHECK-NEXT: global_load_dwordx4 v[0:3], v6, s[2:3]
+; CHECK-NEXT: global_load_dwordx2 v[4:5], v6, s[2:3] offset:16
+; CHECK-NEXT: s_waitcnt vmcnt(0)
+; CHECK-NEXT: global_store_dwordx2 v6, v[4:5], s[0:1] offset:16
+; CHECK-NEXT: global_store_dwordx4 v6, v[0:3], s[0:1]
+; CHECK-NEXT: s_endpgm
+ %ld = load <3 x i64>, ptr addrspace(1) %src, align 32, !invariant.load !0
+ store <3 x i64> %ld, ptr addrspace(1) %dst, align 32
+ ret void
+}
+
+attributes #0 = { noinline nounwind optnone }
+
+!0 = !{}
|
🐧 Linux x64 Test Results
|
Base automatically changed from
users/arsenm/amdgpu/handle-invariant-load-isUniformLoad
to
main
November 20, 2025 18:07
dd3f339 to
1c8ddb0
Compare
1c8ddb0 to
a8b806c
Compare
shiltian
approved these changes
Nov 21, 2025
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.

This works fine on main, but broke after a future patch.