Keep folded Wave64 branches converged across EXEC restores #2265
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2265
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2265"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@FIocker on GitHub · 2026-11-29 11:11 UTC · original
FIocker:contrib/folded-exec-restore→main· +52 −10 · 2 files · 1 commits · openA folded Wave64 shader can branch on EXEC and later restore lanes from a saved scalar mask. Treat scalar writes that can reactivate EXEC lanes as requiring wave-wide branch control. The two save forms that only intersect the current mask still qualify for the existing path.
The synthetic regression branches on EXEC and restores it inside the branch. The offline regression passed with this patch and failed on
829188e9. A separate GPU fixture covers masks with 0, 1, 33, and 64 active guest lanes. Gameplay validation on this branch is pending.@Lyrnc on GitHub · 2026-11-30 06:11 UTC · original
Checked this against a Radeon gfx1036 (RDNA 2) running the same kernels natively in wave64, and ran the translator's output for main and for this PR on an RTX 5080 and on that Radeon through D3D12.
Setup
mainat41adb551with this PR's head (7230502) merged locally, no conflict. The victory-shader test binary was built from that merged tree, one tree and one target directory per PR.super::folded(the two-lanes-per-host-lane rewrite) andsuper::emitwith a 32-lane host forced, each throughdxil.dllvalidation, dispatched on the 5080 and on the Radeon (VICTORY_ADAPTER=radeon). Alsosuper::emitwith 64 host lanes on the Radeon.Cases
restore_exec/<k>:s_mov_b64 s[42:43], exec,v_cmpx_gt_u32 k, v0,s_cbranch_execzover a block that restores the saved mask (s_mov_b64 exec, s[42:43]) and writes v40 = 200, then the join restores EXEC again. On the gfx1036 every one of the 64 lanes holds 200 for k = 1, 31, 32, 33, 64 (the restore inside the branch brings the lanes back) and 100 for k = 0 (the branch is skipped).restore_exec_or/<k>: the same withs_or_b64 exec, exec, s[42:43]in the branch, thenexec_lo = 0/exec_lo = s42,exec_hi = 0around one more write.waterfall/<mixed|upper_only|sparse>: av_readfirstlane_b32waterfall (v_cmp_eq_u32,s_and_saveexec_b64,s_xor_b64 exec, s[42:43], exec,s_cbranch_execnz) with a scalar counter that is read after the loop. On the hardware the counter is the same in every lane (5, 3, 5 rounds).join_leader*/*(EXEC set to one half, branches on SCC and EXEC at a join),counter_loop*/*(a loop with an if inside, exiting on av_readfirstlane_b32counter),permute_cmpx,saveexec_forms.Results (values that differ from the gfx1036, out of 64 lanes x outputs)
restore_exec/0restore_exec/1restore_exec/31restore_exec/32,/33,/64restore_exec_or/1restore_exec_or/40waterfall/mixedwaterfall/sparsewaterfall/upper_onlyjoin_leader/*(4 cases)super::emitand a 32-lane host,restore_exec_or/1goes from 124 differing values to exact on both cards (it now ends in the folded form, PSV0 wave 32). Every other case gives the same values as main there, and with 64 host lanes on the Radeon nothing changes.join_leader2/hi0_scc1, the case #3097 fixes, still differs in the folded form here.)What still differs (not this PR's change)
super::emitkeeps the per-lane form forrestore_exec/1..33: the lanes outside thev_cmpxmask keep 100 (63, 33, 32, 31 values), on both cards and with 64 host lanes too. The waterfall cases differ there as well.A question on the scope
widens_execnow holds for any SOP instruction that writes EXEC excepts_and_saveexec_b64ands_andn1_saveexec_b64. That includess_and_b64 exec, exec, vcc,s_andn2_b64 exec, exec, s[..]and thes_or_b64 exec, exec, s[..]/s_mov_b64 exec, s[..]at the end of every divergent if, so nearly every folded program with a divergent branch now takes the wave-wide branches (before, only the forms with an inline -1 did). The exempted two are the right ones on the hardware (saveexec table below). Do you have a count of the folded programs whose form changes, and their card time? The PR's own numbers cover the synthetic shaders only.saveexec_formson the gfx1036 (wave64): EXEC = lanes 0..31, S0 = lanes 16..47, then each save form; the new EXEC:s_and_saveexec_b64s_andn1_saveexec_b64s_andn2_saveexec_b64s_or_saveexec_b64s_orn1_saveexec_b64s_orn2_saveexec_b64s_xor_saveexec_b64s_nand_saveexec_b64So
s_andn1_saveexec_b64is ~S0 & EXEC ands_andn2_saveexec_b64is S0 & ~EXEC on this hardware: the two the PR exempts are the only ones that stay inside the old mask.AI use: Claude Code (Claude Opus 5.5) ran the oracle and host cases and wrote this comment.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.