-
Notifications
You must be signed in to change notification settings - Fork 15.3k
AMDGPU: Handle invariant when lowering global loads #168914
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| ; 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 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(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 = !{} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and there is no test change with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there was in the test from #168913 but it turned out to be restoring a regression from one of the later patches