[WaveTransform] Handle SI_WAVE_CF_EDGE in SGPR hazard wait merging - #3813
Closed
cdevadas wants to merge 1 commit into
Closed
Conversation
The AMDGPUWaitSGPRHazards pass's runWaitMerging function skips meta instructions and only treats isBranch/isCall/isReturn as control-flow boundaries. SI_WAVE_CF_EDGE is a meta terminator that is none of these, so the pass would skip over it and move S_WAITCNT_DEPCTR past it to before the following S_CBRANCH_EXECZ. This placed a non-terminator instruction between two terminators, causing a machine verifier error. Fix by teaching runWaitMerging to not skip SI_WAVE_CF_EDGE despite it being a meta instruction, and to treat it as a control-flow boundary alongside branches, calls, and returns. Note: This is a temporary workaround. The handling should be done differently before upstreaming this feature. This also removes the XFAIL from divergence-divergent-i1-used-outside-loop.ll and regenerates its CHECK lines.
cdevadas
commented
Aug 7, 2026
| ; GFX1100-W64-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, v0 | ||
| ; GFX1100-W64-NEXT: s_mov_b32 s6, 0 | ||
| ; GFX1100-W64-NEXT: s_mov_b64 s[8:9], -1 | ||
| ; GFX1100-W64-NEXT: s_mov_b64 s[12:13], -1 |
Author
There was a problem hiding this comment.
All the test changes are not due to this patch. This was earlier XFAILed during the previous merge from amd-staging commit due to this error. Now I regenrated their check patterns for the latest changes.
Author
|
I don't particularly like this fix. But we need a similar custom fix at the moment to avoid this error. The SI_WAVE_CF_EDGE should be a Meta instruction. Removing the Meta field from it causes some problems at the moment. So I custom-added these instructions in the two conditional checks in AMDGPUWaitSGPRHazards. |
|
PSDB Build Link: http://mlse-bdc-20dd129:8065/#/builders/10/builds/754 |
lalaniket8
approved these changes
Aug 7, 2026
vg0204
approved these changes
Aug 10, 2026
Author
|
Closing this infavor of upstream PR llvm#214935 |
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.
The AMDGPUWaitSGPRHazards pass's runWaitMerging function skips meta instructions and only treats isBranch/isCall/isReturn as control-flow boundaries. SI_WAVE_CF_EDGE is a meta terminator that is none of these, so the pass would skip over it and move S_WAITCNT_DEPCTR past it to before the following S_CBRANCH_EXECZ. This placed a non-terminator instruction between two terminators, causing a machine verifier error.
Fix by teaching runWaitMerging to not skip SI_WAVE_CF_EDGE despite it being a meta instruction, and to treat it as a control-flow boundary alongside branches, calls, and returns.
Note: This is a temporary workaround. The handling should be done differently before upstreaming this feature.
This also removes the XFAIL from
divergence-divergent-i1-used-outside-loop.ll and regenerates its CHECK lines.