-
Notifications
You must be signed in to change notification settings - Fork 15k
AMDGPU/GFX12: Fix s_barrier_signal_isfirst for single-wave workgroups #143634
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 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2676f40
AMDGPU: Precommit a lit test
nhaehnle 28ea046
AMDGPU/GFX12: Fix s_barrier_signal_isfirst for single-wave workgroups
nhaehnle 12fad59
Update llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.barrier.signal.isfirst.ll
nhaehnle 2b7f942
Update llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.barrier.signal.isfirst.ll
nhaehnle 35ed3ca
Add a note in AMDGPUUsage
nhaehnle 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
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
41 changes: 41 additions & 0 deletions
41
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.barrier.signal.isfirst.ll
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,41 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12-SDAG %s | ||
| ; RUN: llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12-GISEL %s | ||
nhaehnle marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| define i1 @func1() { | ||
| ; GFX12-SDAG-LABEL: func1: | ||
| ; GFX12-SDAG: ; %bb.0: | ||
| ; GFX12-SDAG-NEXT: s_wait_loadcnt_dscnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_wait_expcnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_wait_samplecnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_wait_bvhcnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_wait_kmcnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_cmp_eq_u32 0, 0 | ||
| ; GFX12-SDAG-NEXT: s_wait_storecnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_barrier_signal_isfirst -1 | ||
| ; GFX12-SDAG-NEXT: s_cselect_b32 s0, -1, 0 | ||
| ; GFX12-SDAG-NEXT: s_wait_alu 0xfffe | ||
| ; GFX12-SDAG-NEXT: v_cndmask_b32_e64 v0, 0, 1, s0 | ||
| ; GFX12-SDAG-NEXT: s_wait_kmcnt 0x0 | ||
| ; GFX12-SDAG-NEXT: s_setpc_b64 s[30:31] | ||
| ; | ||
| ; GFX12-GISEL-LABEL: func1: | ||
| ; GFX12-GISEL: ; %bb.0: | ||
| ; GFX12-GISEL-NEXT: s_wait_loadcnt_dscnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_wait_expcnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_wait_samplecnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_wait_bvhcnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_wait_kmcnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_cmp_eq_u32 0, 0 | ||
| ; GFX12-GISEL-NEXT: s_wait_storecnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_barrier_signal_isfirst -1 | ||
| ; GFX12-GISEL-NEXT: s_cselect_b32 s0, 1, 0 | ||
| ; GFX12-GISEL-NEXT: s_wait_alu 0xfffe | ||
| ; GFX12-GISEL-NEXT: v_mov_b32_e32 v0, s0 | ||
| ; GFX12-GISEL-NEXT: s_wait_kmcnt 0x0 | ||
| ; GFX12-GISEL-NEXT: s_setpc_b64 s[30:31] | ||
| %r = call i1 @llvm.amdgcn.s.barrier.signal.isfirst(i32 -1) | ||
| ret i1 %r | ||
nhaehnle marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| declare i1 @llvm.amdgcn.s.barrier.signal.isfirst(i32) | ||
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.
Can this leave a dead instruction behind if it doesn't?
Uh oh!
There was an error while loading. Please reload this page.
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.
Perhaps the comment isn't clear enough. The point is that hardware at runtime can convert the barrier instructions into NOPs (when the workgroup is launched with a single wave).
I suppose we could remove the barrier instruction ourselves if the workgroup size is statically known to be too small, but I would we hope we'd do that earlier in LLVM IR since it might expose more optimization opportunities.
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.
So it's sort of a hardware bug? The ordinary behavior is SCC is always set to 1? And if it nops it leaves it in the previous state?
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.
Yes, exactly.