Shader: preserve EXEC on stores behind wave-wide SCC branches #78
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/DoubleGhosty--cool_fox!78
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-78"
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?
@steven-seagull27 on GitHub · 2026-11-27 09:06 UTC · original
steven-seagull27:codex/coolfox-66-scc-exec-guards→main· +74 −22 · 3 files · 1 commits · closed without mergingFollow-up to #66 and
9a4aa8d3. The original select and branch fixtures now pass on both the RTX 5080 and WARP. Moving the store from the join into the two branch arms exposed another case.The generated program narrows EXEC to
lane < limit. The SCC set bys_and_b64 s[18:19], vcc, execcorrectly takes the whole wave into the same arm. Each vector store in that arm still obeys EXEC. With 48 active lanes and lane 37 selected, main wrote 2 to all 64 dwords, including the 16 assigned to inactive lanes. Every address in the fixture is distinct and in bounds.The lowerer already emitted a wave-wide SCC decision. Structure analysis still used the branch edge as proof of the current lane’s own comparison bit and could remove the store’s EXEC guard. The patch records the existing branch classification during structuring and uses it in both places. The lowerer keeps its existing rules for where the two host waves can exchange.
The patched select, branch and combined controls also produced 0/576 wrong per shader on each adapter. Inbox WARP advertised Wave4 and skipped Wave32 execution. The CPU regression fails on the previous emitter and passes with the fix. Strict all-targets/all-features shader Clippy and the 16 structure tests passed locally.
AI-assisted implementation and verification using synthetic instructions and readbacks.
@Hasusmogus on GitHub · 2026-11-27 09:28 UTC · original · reviewed
Looks right to me, and I could reproduce it on other hardware.
Run on an NVIDIA RTX A3000 Laptop GPU (Ampere, waves of 32) through vkd3d-proton:
main+ this PR's tests onlyboth_arms_of_a_wave_wide_scc_branch_keep_their_store_guardsStoreOnClearStoreOnSetCombined/Branch/Selectvictory-shadersuiteSame 127 as your RTX 5080 and WARP. The one failure (
emit::tests::stub_pipeline_is_created) fails on every build under vkd3d-proton. Clippy (-p victory-shader --all-targets --all-features) is clean.Notes:
is_wave_scc_branchexcluded an SCC if any instruction in its defining block wrote that SCC and EXEC;wave_sccasks only of the writer itself (defs[scc]).s_and_saveexecis still out, where the per-lane split is exact. An unrelated EXEC write in the same block no longer hides it. An SCC that comes through a phi is out in both.wave_sccis filled during the reverse-postorder walk inmasks_in_order, andedge()there only reads it for already visited predecessors;paths()runs once it is complete;reset()clears it, so eachstructure_wideround rebuilds it.widemeanscontrol_regionsstill treats these arms as per-lane regions, so exchanges inside them stay refused. That's conservative, as the doc comment says, but may leave some programs untranslated that thewideform would take. Worth a look ifVICTORY_WAVE_WHYshows refusals inside such arms.s_and_b64 vcc, vcc, execthens_cbranch_vccz/vccnz) on a VCC that differs between lanes has the same per-lane split and still goes through the lane-own-bit path. Compilers mostly emit those on uniform VCC, where the split is exact, so it's rare.Review written with AI assistance (Claude), tests run and reviewed by me.
@DoubleGhosty on GitHub · 2026-11-27 09:31 UTC · original
Cherry-picked into main as
bd8b4f52. Verified on Wave32 hardware (both_halves_observe_the_same_mask_scc_on_a_wave32_device + both_arms_of_a_wave_wide_scc_branch_keep_their_store_guards) and strict shader clippy. Thanks!Pull request closed