Shaders/ir: keep skips when body can resurrect EXEC or has scalar side effects #443
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/443"
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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T00:52:33Z.
Problem
In
crates/victory-shader/src/ir.rs,without_skipsremovess_cbranch_execzbranches so waves withEXEC == 0fall through and execute the skipped regioninside. Previously:EXECresurrection:skipped()exemptedReg::S(126 | 127)(EXEC_LO/EXEC_HI) from join-phi checks without verifying thatinsidepreservesEXEC == 0. Ifinsiderestored an outer savedEXEC(s_mov_b64 exec, s[12:13]) or widenedEXEC(s_or_b64,s_not_b64,s_andn2_b64 exec, s[12:13], exec, etc.), removings_cbranch_execzresurrected skipped lanes insideinside(executing vector stores/writes on skipped lanes and arriving at the join with non-zeroEXEC).skipped()did not rejects_store_*/s_buffer_store_*/s_scratch_store_*/s_atomic_*/s_buffer_atomic_*,s_sendmsg/s_sendmsghalt,s_barrier, ors_round_mode/s_denorm_modeinsideinside, all of which execute even whenEXEC == 0.Fix
skipped()if any block ininsidecontains an EXEC-independent scalar side effect (s_*store*,s_*atomic*,s_sendmsg*,s_barrier,s_round_mode,s_denorm_mode).EXECentersinsideas0(least fixpoint, with only thes_cbranch_execz's ownEXECdwords known zero on entry), preserving zero across narrowingv_cmpx_*,s_and*/s_andn2*,s_mov_b32/s_mov_b64, and pure whole-wave sections (s_or_saveexec/s_nand_saveexecpaired with an exact full-width restore and no side effects). Reject if anyEXECwrite/phi outside pure whole-wave sections or incomingEXECjoin phi can become nonzero, or if a join VGPR phi receives a write from inside a whole-wave section.a_skip_is_kept_when_body_resurrects_exec_or_has_scalar_side_effects.Verification
cargo test -p victory-shader --locked ir::tests: 8 passed, 0 failedcargo test -p victory-shader --locked wave64_tests: 5 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.