Shaders: a wave64 mask restored from word-by-word scalar copies is the same mask #2814

Open
0xkn0wh3r3 wants to merge 8 commits from upstream-pr/2816 into main
0xkn0wh3r3 commented 2026-11-25 21:18:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T21:18:58Z.


What

A wave64 lane mask copied into two scalars one dword at a time and later copied back into EXEC used to reach the structurizer as an unknown pair, so the mask was opaque:

v_cmp_eq_u32  vcc, 0, v0
s_mov_b32     s2, vcc_lo
s_mov_b32     s3, vcc_hi
...
s_mov_b32     s4, s2
s_mov_b32     s5, s3
s_mov_b64     exec, s[4:5]

Lanes::mask now follows each word back through its chain of s_mov_b32 copies. A pair of copies is the pair of the two words' sources, in that order, resolved like any other pair: a known mask, a join, a spill read back, or an opaque pair. If the words are swapped or mixed (for example s3 = vcc_lo), the source pair is a different one and is not the original mask. The source is resolved first even when nothing has read it yet. That covers a high-dword copy at the start of a join block, right before its first reader.

Wave64 mask uses read both dwords (later commits)

Structured::finish keys masks and other by the low dword only, and several wave64 uses resolved their mask by that low dword. After s_mov_b32 s3, 0, a mask read from s[2:3] could therefore get the earlier pair's predicate for lanes 32-63. This is older than this PR: on main, v_cndmask_b32 ..., vcc after s_mov_b32 vcc_hi, 0 lowers the same way. This PR's copy chain adds another way to reach it. Each use now goes by the full (low, high) pair:

  • v_cndmask_b32: looks up the exact pair the structurizer tracked for it (Structured::select_bits, over the wave64 pairs of masks and a new paired_other).
  • v_add/sub/subrev_co_ci_u32 carry-in: looks up the exact pair in masks (Structured::mask_bits). The structurizer resolves the carry-in's pair where it is read, as it does for a select's. A carry-in that is the first reader of a pair made of copies (e.g. vcc_hi copied through an SGPR and back) therefore finds the mask.
  • Atom::Opaque and Atom::Phi: carry the (low, high) pair, not one value (the same value twice in wave32).
    • Opaque, lowered: reads exactly those two dwords. Before, the high dword came from the low dword's definition (pair_high, now removed), so a pair copied with s_mov_b64 after its high dword changed read the old high dword.
    • Phi, lowered: builds each incoming edge's mask from that edge's pair of arguments. Before, it used the low dword's phi argument only, as did the skip-edge check and the join links in avoids.
  • Descriptor picked per lane (Source::Lanes): records the select's high dword alongside its low one. Tracking and lowering look the pair up with mask_bits.
  • A pair read back from VGPR spill lanes: only the mask written with the same pair is the mask; reversed words aren't. The fallback in Lanes::mask now checks that the writing instruction's (low, high) destination is the pair asked for.
  • touches: the check behind dead_on_edge. It counts either dword of a Phi/Opaque atom as a dependency. It also lets a compare's known result settle only that compare's own lane or SCC bit (Atom::compare, as can_be does); before, it also settled a joined or opaque mask whose low dword the compare wrote. The walk is now Bools::reaches.
  • Joins left as a phi atom: after each pass over the program, every edge's pair into the join is resolved, including a loop's back edge, which isn't followed where the join is met. A back edge bringing a copied pair is then found by both dwords. This runs before wrong_joins, so a join it resolves to a constant is checked on all its edges, like any other.
  • Pairs that aren't tracked: refused as before ("a select on an untracked mask", "a carry-in from an untracked mask", "a lane-mask join of an untracked mask", "a descriptor chosen per lane by an untracked mask", or "an opaque lane mask" without console lanes).

Wave32 is unchanged.

Where it came from

Ported from DexNom's fork: DexNom/VIctory@76749ce ("Recover voxel visibility shader when a wave64 mask is restored from scalar copies"). The first commit keeps DexNom as author. The fork's BENCHMARK.md says this recovered one previously refused pixel shader in the title's archive, a voxel visibility shader.

The change only needed adapting to this tree's mask(), which now also follows masks spilled to VGPR lanes (restored). The copy-chain check runs before that.

Tested

  • structure::tests::split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask (DexNom's). It fails on main and passes with the change. It covers the intact pair and a pair whose high word is a copy of the low one, which must stay distinct.
  • emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask, one wave64 shader: a compare copied into s[2:3] word by word and read by one v_cndmask_b32, then s3 written again and read by a second one. If s3 is copied from vcc_hi again, the shader lowers and passes DXIL validation. If s3 is set to 0, the second select is the opaque pair of s2 and the new s3, which this shader (without console lanes) refuses. At the first commit alone, it lowered with the compare's predicate.
  • structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_one: s_mov_b64 s[2:3], vcc, s_mov_b32 s3, 0, s_mov_b64 s[4:5], s[2:3] and a select on s[4:5]. The select's mask is Atom::Opaque(s2, cleared s3), so lanes 32-63 read the cleared word.
  • emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask:
    • Join: a mask joined at a block entry whose incoming pair on one edge is a compare copy with s3 then cleared.
    • Carry-in: a carry-in read after s_mov_b32 vcc_hi, 0.
    • Loop: a uniform loop that narrows s[2:3] each pass and reads it at its header.
    • Results: with the high dword kept, or copied through another SGPR and back (same bits, a new value), the join, the loop and the carry-in all lower and pass DXIL validation. The join is tested with the copy on the incoming edge and with the copy at the join's start; at 5ef2e88a the second was refused at 0x30. At 751722ff, the copied loop and the copied carry-in were refused; main translates both. With the high dword cleared, the join and the carry-in are refused; at d4895407 both lowered with the old high dword.
  • structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask: s_mov_b64 s[4:5], vcc spilled with v_writelane_b32 to lanes 0 and 1, then read back into s[6:7]. In order, it is the compare. Swapped, it is not; without the destination check, the swapped pair was the compare.
  • resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one and emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused:
    • Shader: a wave64 waterfall over one of two image descriptors picked per lane by v_cndmask_b32 on VCC.
    • Without s_mov_b32 vcc_hi, 0 after the compare, or with vcc_hi copied through s2 and back: the pick's pair is the compare, and the shader lowers and validates.
    • With it: the pick names the cleared high dword, and lowering refuses it. With the old low-dword lookup it lowered with the compare's mask.
  • structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own:
    • Shader: an outer uniform loop whose header join (a compare on entry) stays a phi atom. Its back edge brings an inner loop header's join: EXEC on entry, the compare from its own back edge.
    • Result: that join is resolved only for the outer back edge, and it isn't all lanes. When back-edge pairs were resolved after the last check, it folded to all lanes from its entry edge alone.
  • structure::tests::only_a_compare_s_own_bit_is_decided_by_the_compare tests the walk touches makes (Bools::reaches with Atom::compare and Atom::values) on a constructed diagram:
    • Shape: a decided atom OR a tainted lane bit, with the compare writing lo known true.
    • Lane bit: for Lane(lo), the tainted branch is pruned.
    • Joined or opaque mask: for Opaque(lo, hi) and Phi(lo, hi), it is still searched, and a tainted hi alone counts.
    • Old rule: with the earlier low-dword pruning, the test fails.
  • cargo test -p victory-shader --lib on Windows 11 (NVIDIA, WARP, dxil.dll), with heap_direct_texture_reads_mark_their_heap_index skipped because it crashes the process: 307 passed, 3 failed, 3 ignored. The 3 failures are gathers_at_a_level_match_the_hardware and two stride_tests heap-buffer reads, known failures on main on this machine.
  • cargo test -p victory: all passed.
  • cargo clippy --workspace --all-targets -- -D warnings (default and --all-features): clean. cargo xtask policy: 191 files ok.

Not tested

  • I haven't run the title's shader archive or the game, so the voxel visibility shader itself isn't checked here.

  • Wave64 pipelines don't run on this machine's NVIDIA adapter or on WARP. The new tests check translation and the structurizer's masks, not results on a GPU.

  • @Venom2054 checked a cascade-shadow compute shader at df392b22 on an RTX 5070 Ti: it translates and passes DXIL validation, but D3D12 refuses its pipeline (wave size 64 on an adapter whose range is 32–32), as it does on main. On this tree, the programs this unblocks run only on hosts with 64-lane waves.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5499350338 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T21:18:58Z. --- ## What A wave64 lane mask copied into two scalars one dword at a time and later copied back into EXEC used to reach the structurizer as an unknown pair, so the mask was opaque: ``` v_cmp_eq_u32 vcc, 0, v0 s_mov_b32 s2, vcc_lo s_mov_b32 s3, vcc_hi ... s_mov_b32 s4, s2 s_mov_b32 s5, s3 s_mov_b64 exec, s[4:5] ``` `Lanes::mask` now follows each word back through its chain of `s_mov_b32` copies. A pair of copies is the pair of the two words' sources, in that order, resolved like any other pair: a known mask, a join, a spill read back, or an opaque pair. If the words are swapped or mixed (for example `s3 = vcc_lo`), the source pair is a different one and is not the original mask. The source is resolved first even when nothing has read it yet. That covers a high-dword copy at the start of a join block, right before its first reader. ### Wave64 mask uses read both dwords (later commits) `Structured::finish` keys `masks` and `other` by the low dword only, and several wave64 uses resolved their mask by that low dword. After `s_mov_b32 s3, 0`, a mask read from `s[2:3]` could therefore get the earlier pair's predicate for lanes 32-63. This is older than this PR: on main, `v_cndmask_b32 ..., vcc` after `s_mov_b32 vcc_hi, 0` lowers the same way. This PR's copy chain adds another way to reach it. Each use now goes by the full `(low, high)` pair: - **`v_cndmask_b32`:** looks up the exact pair the structurizer tracked for it (`Structured::select_bits`, over the wave64 pairs of `masks` and a new `paired_other`). - **`v_add/sub/subrev_co_ci_u32` carry-in:** looks up the exact pair in `masks` (`Structured::mask_bits`). The structurizer resolves the carry-in's pair where it is read, as it does for a select's. A carry-in that is the first reader of a pair made of copies (e.g. `vcc_hi` copied through an SGPR and back) therefore finds the mask. - **`Atom::Opaque` and `Atom::Phi`:** carry the `(low, high)` pair, not one value (the same value twice in wave32). - **Opaque, lowered:** reads exactly those two dwords. Before, the high dword came from the low dword's definition (`pair_high`, now removed), so a pair copied with `s_mov_b64` after its high dword changed read the old high dword. - **Phi, lowered:** builds each incoming edge's mask from that edge's pair of arguments. Before, it used the low dword's phi argument only, as did the skip-edge check and the join links in `avoids`. - **Descriptor picked per lane** (`Source::Lanes`): records the select's high dword alongside its low one. Tracking and lowering look the pair up with `mask_bits`. - **A pair read back from VGPR spill lanes:** only the mask written with the same pair is the mask; reversed words aren't. The fallback in `Lanes::mask` now checks that the writing instruction's (low, high) destination is the pair asked for. - **`touches`:** the check behind `dead_on_edge`. It counts either dword of a `Phi`/`Opaque` atom as a dependency. It also lets a compare's known result settle only that compare's own lane or SCC bit (`Atom::compare`, as `can_be` does); before, it also settled a joined or opaque mask whose low dword the compare wrote. The walk is now `Bools::reaches`. - **Joins left as a phi atom:** after each pass over the program, every edge's pair into the join is resolved, including a loop's back edge, which isn't followed where the join is met. A back edge bringing a copied pair is then found by both dwords. This runs before `wrong_joins`, so a join it resolves to a constant is checked on all its edges, like any other. - **Pairs that aren't tracked:** refused as before ("a select on an untracked mask", "a carry-in from an untracked mask", "a lane-mask join of an untracked mask", "a descriptor chosen per lane by an untracked mask", or "an opaque lane mask" without console lanes). Wave32 is unchanged. ## Where it came from Ported from DexNom's fork: [DexNom/VIctory@76749ce](https://github.com/DexNom/VIctory/commit/76749ce58da23a43a3500454a8b69c53f05aa477) ("Recover voxel visibility shader when a wave64 mask is restored from scalar copies"). The first commit keeps DexNom as author. The fork's `BENCHMARK.md` says this recovered one previously refused pixel shader in the title's archive, a voxel visibility shader. The change only needed adapting to this tree's `mask()`, which now also follows masks spilled to VGPR lanes (`restored`). The copy-chain check runs before that. ## Tested - `structure::tests::split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask` (DexNom's). It fails on main and passes with the change. It covers the intact pair and a pair whose high word is a copy of the low one, which must stay distinct. - `emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask`, one wave64 shader: a compare copied into `s[2:3]` word by word and read by one `v_cndmask_b32`, then `s3` written again and read by a second one. If `s3` is copied from `vcc_hi` again, the shader lowers and passes DXIL validation. If `s3` is set to 0, the second select is the opaque pair of `s2` and the new `s3`, which this shader (without console lanes) refuses. At the first commit alone, it lowered with the compare's predicate. - `structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_one`: `s_mov_b64 s[2:3], vcc`, `s_mov_b32 s3, 0`, `s_mov_b64 s[4:5], s[2:3]` and a select on `s[4:5]`. The select's mask is `Atom::Opaque(s2, cleared s3)`, so lanes 32-63 read the cleared word. - `emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask`: - **Join:** a mask joined at a block entry whose incoming pair on one edge is a compare copy with `s3` then cleared. - **Carry-in:** a carry-in read after `s_mov_b32 vcc_hi, 0`. - **Loop:** a uniform loop that narrows `s[2:3]` each pass and reads it at its header. - **Results:** with the high dword kept, or copied through another SGPR and back (same bits, a new value), the join, the loop and the carry-in all lower and pass DXIL validation. The join is tested with the copy on the incoming edge and with the copy at the join's start; at 5ef2e88a the second was refused at 0x30. At 751722ff, the copied loop and the copied carry-in were refused; main translates both. With the high dword cleared, the join and the carry-in are refused; at d4895407 both lowered with the old high dword. - `structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask`: `s_mov_b64 s[4:5], vcc` spilled with `v_writelane_b32` to lanes 0 and 1, then read back into `s[6:7]`. In order, it is the compare. Swapped, it is not; without the destination check, the swapped pair was the compare. - `resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one` and `emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused`: - **Shader:** a wave64 waterfall over one of two image descriptors picked per lane by `v_cndmask_b32` on VCC. - **Without `s_mov_b32 vcc_hi, 0` after the compare, or with `vcc_hi` copied through `s2` and back:** the pick's pair is the compare, and the shader lowers and validates. - **With it:** the pick names the cleared high dword, and lowering refuses it. With the old low-dword lookup it lowered with the compare's mask. - `structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own`: - **Shader:** an outer uniform loop whose header join (a compare on entry) stays a phi atom. Its back edge brings an inner loop header's join: EXEC on entry, the compare from its own back edge. - **Result:** that join is resolved only for the outer back edge, and it isn't all lanes. When back-edge pairs were resolved after the last check, it folded to all lanes from its entry edge alone. - `structure::tests::only_a_compare_s_own_bit_is_decided_by_the_compare` tests the walk `touches` makes (`Bools::reaches` with `Atom::compare` and `Atom::values`) on a constructed diagram: - **Shape:** a decided atom OR a tainted lane bit, with the compare writing `lo` known true. - **Lane bit:** for `Lane(lo)`, the tainted branch is pruned. - **Joined or opaque mask:** for `Opaque(lo, hi)` and `Phi(lo, hi)`, it is still searched, and a tainted `hi` alone counts. - **Old rule:** with the earlier low-dword pruning, the test fails. - `cargo test -p victory-shader --lib` on Windows 11 (NVIDIA, WARP, `dxil.dll`), with `heap_direct_texture_reads_mark_their_heap_index` skipped because it crashes the process: 307 passed, 3 failed, 3 ignored. The 3 failures are `gathers_at_a_level_match_the_hardware` and two `stride_tests` heap-buffer reads, known failures on main on this machine. - `cargo test -p victory`: all passed. - `cargo clippy --workspace --all-targets -- -D warnings` (default and `--all-features`): clean. `cargo xtask policy`: 191 files ok. ## Not tested - I haven't run the title's shader archive or the game, so the voxel visibility shader itself isn't checked here. - Wave64 pipelines don't run on this machine's NVIDIA adapter or on WARP. The new tests check translation and the structurizer's masks, not results on a GPU. - @Venom2054 checked a cascade-shadow compute shader at df392b22 on an RTX 5070 Ti: it translates and passes DXIL validation, but D3D12 refuses its pipeline (wave size 64 on an adapter whose range is 32–32), as it does on main. On this tree, the programs this unblocks run only on hosts with 64-lane waves.
kotekompotek commented 2026-11-25 21:49:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:49:44Z.

Review: COMMENTED


Complementary to #2836 (which carries the true pair through Atom::Opaque) — this recovers masks that were tracked and merely parked behind s_mov chains, which is strictly better than keeping them opaque: they participate in BDD reasoning again rather than becoming lane-bit reads. move_source follows only single-read s_mov_b32 chains so SSA can't cycle, the source != k guard avoids self-matches, and consulting only masks (not other) means moved non-derived scalars conservatively stay opaque. The test's reorder case (s3 from vcc_lo) correctly asserts no false recovery. Sits cleanly before the restored/join/Opaque fallbacks. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065452184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6065452184). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:49:44Z. **Review:** COMMENTED --- Complementary to #2836 (which carries the true pair through `Atom::Opaque`) — this recovers masks that were tracked and merely parked behind `s_mov` chains, which is strictly better than keeping them opaque: they participate in BDD reasoning again rather than becoming lane-bit reads. `move_source` follows only single-read `s_mov_b32` chains so SSA can't cycle, the `source != k` guard avoids self-matches, and consulting only `masks` (not `other`) means moved non-derived scalars conservatively stay opaque. The test's reorder case (s3 from vcc_lo) correctly asserts no false recovery. Sits cleanly before the restored/join/Opaque fallbacks. LGTM.
fuzeofficlal commented 2026-11-25 22:04:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:30:44Z.


Verified 306e73c4 on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll):

  • cargo xtask policy: 184 files ok; cargo clippy -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings.
  • RTX 5090 (structure::, emit::flow_tests, emit::lower::tests): 40 passed, 0 failed (1 ignored bench_bools).
  • WARP + dxil.dll: 268 passed, 0 failed (3 ignored, 3 pre-existing hardware-only synthetic_tests filtered).
  • Code review: move_source walks self.defs (SSA insts only, so acyclic) through single-SGPR s_mov_b32 chains; mismatched/overwritten halves miss self.masks safely, and cross-block phis recurse through self.join onto edge operands.
  • Clean git merge-tree against origin/main 13f91ca and #2783 (complementary: #2816 recovers split scalar copies back into self.masks, while #2783 preserves remaining opaque pairs).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175174282 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7175174282). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:30:44Z. --- Verified `306e73c4` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`): - `cargo xtask policy`: 184 files ok; `cargo clippy -p victory-shader --all-targets -- -D warnings` (default & `--features host`): 0 warnings. - RTX 5090 (`structure::`, `emit::flow_tests`, `emit::lower::tests`): 40 passed, 0 failed (1 ignored `bench_bools`). - WARP + `dxil.dll`: 268 passed, 0 failed (3 ignored, 3 pre-existing hardware-only `synthetic_tests` filtered). - Code review: `move_source` walks `self.defs` (SSA `insts` only, so acyclic) through single-SGPR `s_mov_b32` chains; mismatched/overwritten halves miss `self.masks` safely, and cross-block phis recurse through `self.join` onto edge operands. - Clean `git merge-tree` against `origin/main` `13f91ca` and #2783 (complementary: #2816 recovers split scalar copies back into `self.masks`, while #2783 preserves remaining opaque pairs).
Machad3x commented 2026-11-25 22:04:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-25T22:02:08Z.


Hardware result: tested at head 306e73c4. One host: RTX 3080 Ti, driver 621.24, Windows 11, a fork stacking open PRs, Series X mode. Cherry-picked together with #332 and #2831; one 7-minute run in play, no device removal. A test the stack carried that expected a dword-by-dword mask restore into EXEC to be refused now translates; turned into an execution test (64 threads, wave64 split in halves, lanes below 20 take the branch), it gives the expected values on this GPU.

Ran with AI assistance (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175852372 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7175852372). Originally posted by [Machad3x](https://github.com/Machad3x) on 2026-11-25T22:02:08Z. --- Hardware result: tested at head 306e73c4. One host: RTX 3080 Ti, driver 621.24, Windows 11, a fork stacking open PRs, Series X mode. Cherry-picked together with #332 and #2831; one 7-minute run in play, no device removal. A test the stack carried that expected a dword-by-dword mask restore into EXEC to be refused now translates; turned into an execution test (64 threads, wave64 split in halves, lanes below 20 take the branch), it gives the expected values on this GPU. Ran with AI assistance (Claude Code).
Dukestar69 commented 2026-11-26 02:31:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T02:31:53Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-shader --lib structure::tests: 14 passed, 0 failed, 1 ignored (including new split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6067780495 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6067780495). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T02:31:53Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-shader --lib structure::tests`: **14 passed, 0 failed, 1 ignored** (including new `split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-26 03:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:20:33Z.


Automated triage for the maintainers.

Lanes::mask (structure.rs) now follows each word of a wave64 mask back through s_mov_b32 copies (move_source). When both words still come from a known mask, in order, the pair is that mask. Swapped or mixed words stay opaque, and the test checks both cases. It only reuses masks already in self.masks (EXEC/VALU-derived), so it cannot invent a mask, and the copy chain follows SSA defs, so it terminates. It is a port of DexNom's fork commit, with authorship kept.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180710843 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7180710843). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:20:33Z. --- <!-- victory-triage v1 head=7fafdf36dc3bf028402682b6a040194ab4ea7749 verdict=merge-candidate at=2026-11-26T02:20:25Z --> Automated triage for the maintainers. `Lanes::mask` (`structure.rs`) now follows each word of a wave64 mask back through `s_mov_b32` copies (`move_source`). When both words still come from a known mask, in order, the pair is that mask. Swapped or mixed words stay opaque, and the test checks both cases. It only reuses masks already in `self.masks` (EXEC/VALU-derived), so it cannot invent a mask, and the copy chain follows SSA defs, so it terminates. It is a port of DexNom's fork commit, with authorship kept. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Venom2054 commented 2026-11-26 08:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-26T07:30:57Z.


Tested the mask change at 7fafdf36 on Windows 11 with an RTX 5070 Ti. I applied the translator change to Zayfway/victory-fork@3e760ed and added only the resulting cache entry for one alpha-tested cascade-shadow compute shader to a private copy of the warm cache. The game executable and other shader entries were the same as in the control.

The stock translator refused this shader at 0x1eb4. With the change it passed Windows SDK DXIL validation and D3D12 created its compute pipeline. In the Series S prologue, both the second and sixth frames after world entry logged a dropped command for this shader in the control. The treatment recorded two ExecuteIndirect dispatch commands in each of those frames. The indirect group counts remain unmeasured. In the loaded-window interval the control reported about one drop per frame for this shader, and the treatment logged none. The run completed without device loss.

The localized flicker at the courtyard tables remained visible with this shader enabled.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7185540077 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7185540077). Originally posted by [Venom2054](https://github.com/Venom2054) on 2026-11-26T07:30:57Z. --- Tested the mask change at `7fafdf36` on Windows 11 with an RTX 5070 Ti. I applied the translator change to `Zayfway/victory-fork@3e760ed` and added only the resulting cache entry for one alpha-tested cascade-shadow compute shader to a private copy of the warm cache. The game executable and other shader entries were the same as in the control. The stock translator refused this shader at `0x1eb4`. With the change it passed Windows SDK DXIL validation and D3D12 created its compute pipeline. In the Series S prologue, both the second and sixth frames after world entry logged a dropped command for this shader in the control. The treatment recorded two `ExecuteIndirect` dispatch commands in each of those frames. The indirect group counts remain unmeasured. In the loaded-window interval the control reported about one drop per frame for this shader, and the treatment logged none. The run completed without device loss. The localized flicker at the courtyard tables remained visible with this shader enabled.
fuzeofficlal commented 2026-11-26 09:34:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:34:03Z.

Review: CHANGES_REQUESTED


Verified 7fafdf36 locally on Windows 11 x64 (git merge-tree onto 63bcca43 is clean):

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean (2.57s / 2.21s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory-shader --lib --locked structure::tests: 14 passed, 0 failed, 1 ignored (0.01s).

move_source and the (lo, hi) copy-chain lookup inside Lanes::mask (structure.rs:935-942, 986-999) are sound, acyclic, and reject swapped/mixed words. However, Structured::finish (structure.rs:875) flattens self.masks to low-word-only keys ((lo, _) -> (lo, m)), and v_cndmask_b32 in emit/lower.rs:6533-6542 looks up the predicate by the low word alone. If a wave64 shader uses the restored (lo, hi) pair once, overwrites only the high word (e.g. s_mov_b32 hi, 0), and uses (lo, 0) in a second v_cndmask_b32, the second select silently reuses the first full-wave predicate for the upper 32 lanes. Please validate the full (lo, hi) pair at wave64 select lowering (or reject mismatched high words) and add a single-shader regression covering both uses.

<!-- greyfinch-sync:Marvisak/VIctory:review:6071626219 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6071626219). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T09:34:03Z. **Review:** CHANGES_REQUESTED --- Verified `7fafdf36` locally on Windows 11 x64 (`git merge-tree` onto `63bcca43` is clean): - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean (`2.57s` / `2.21s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). - `cargo test -p victory-shader --lib --locked structure::tests`: 14 passed, 0 failed, 1 ignored (`0.01s`). `move_source` and the `(lo, hi)` copy-chain lookup inside `Lanes::mask` (`structure.rs:935-942, 986-999`) are sound, acyclic, and reject swapped/mixed words. However, `Structured::finish` (`structure.rs:875`) flattens `self.masks` to low-word-only keys (`(lo, _) -> (lo, m)`), and `v_cndmask_b32` in `emit/lower.rs:6533-6542` looks up the predicate by the low word alone. If a wave64 shader uses the restored `(lo, hi)` pair once, overwrites only the high word (e.g. `s_mov_b32 hi, 0`), and uses `(lo, 0)` in a second `v_cndmask_b32`, the second select silently reuses the first full-wave predicate for the upper 32 lanes. Please validate the full `(lo, hi)` pair at wave64 select lowering (or reject mismatched high words) and add a single-shader regression covering both uses.
fuzeofficlal commented 2026-11-26 10:32:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:32:30Z.

Review: CHANGES_REQUESTED


d4895407 cleanly closes the direct-select failure after a Wave64 high-word overwrite (paired_other, Structured::select_bits(lo, hi), and checking hi == self.pair_high(lo) for Atom::Opaque(lo)), and the new a_wave64_select_after_its_high_word_changes_is_not_the_old_mask test passes.

One bypass remains before merge:

  • Opaque pair forwarding via s_mov_b64 (structure.rs:940-998, 1078-1145, emit/lower.rs:2595-2607, 6540-6547): When s[4:5] is copied from an opaque pair s[2:3] with s_mov_b64 after s3 is overwritten (e.g., cleared to 0), s[4:5]'s paired_other predicate inherits Atom::Opaque(src_lo) rather than Atom::Opaque(dst_lo). v_cndmask_b32 only checks support(m).contains(&Atom::Opaque(lo)) for dst_lo, misses Opaque(src_lo), and Atom::Opaque(src_lo) later reads pair_high(src_lo) from the source's definition site—causing lanes 32–63 to see the old high word when console lane numbering is active.
  • Related low-word paths: Atom::Phi mask materialization (structure.rs:1021-1075, emit/lower.rs:2575-2587) and v_{add,sub,subrev}_co_ci_u32 carry-in (emit/lower.rs:6599-6614) also still resolve predicates by the low word alone.

Please preserve the full opaque pair identity through copies/phis (or reject mismatched/ambiguous pairs) and add a regression covering lanes 32–63 after s_mov_b64. Also note rustfmt --edition 2024 --check flags formatting on structure.rs lines 491 and 895.

Verified locally on Windows 11 x64 (d4895407):

  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • structure::tests / emit::lower::tests: 14 passed (1 ignored) / 33 passed, 0 failed
  • a_wave64_select_after_its_high_word_changes_is_not_the_old_mask: 1 passed, 0 failed
<!-- greyfinch-sync:Marvisak/VIctory:review:6072498113 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6072498113). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:32:30Z. **Review:** CHANGES_REQUESTED --- `d4895407` cleanly closes the direct-select failure after a Wave64 high-word overwrite (`paired_other`, `Structured::select_bits(lo, hi)`, and checking `hi == self.pair_high(lo)` for `Atom::Opaque(lo)`), and the new `a_wave64_select_after_its_high_word_changes_is_not_the_old_mask` test passes. One bypass remains before merge: - **Opaque pair forwarding via `s_mov_b64` (`structure.rs:940-998, 1078-1145`, `emit/lower.rs:2595-2607, 6540-6547`)**: When `s[4:5]` is copied from an opaque pair `s[2:3]` with `s_mov_b64` after `s3` is overwritten (e.g., cleared to 0), `s[4:5]`'s `paired_other` predicate inherits `Atom::Opaque(src_lo)` rather than `Atom::Opaque(dst_lo)`. `v_cndmask_b32` only checks `support(m).contains(&Atom::Opaque(lo))` for `dst_lo`, misses `Opaque(src_lo)`, and `Atom::Opaque(src_lo)` later reads `pair_high(src_lo)` from the source's definition site—causing lanes 32–63 to see the old high word when console lane numbering is active. - **Related low-word paths**: `Atom::Phi` mask materialization (`structure.rs:1021-1075`, `emit/lower.rs:2575-2587`) and `v_{add,sub,subrev}_co_ci_u32` carry-in (`emit/lower.rs:6599-6614`) also still resolve predicates by the low word alone. Please preserve the full opaque pair identity through copies/phis (or reject mismatched/ambiguous pairs) and add a regression covering lanes 32–63 after `s_mov_b64`. Also note `rustfmt --edition 2024 --check` flags formatting on `structure.rs` lines 491 and 895. Verified locally on Windows 11 x64 (`d4895407`): - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `structure::tests` / `emit::lower::tests`: 14 passed (1 ignored) / 33 passed, 0 failed - `a_wave64_select_after_its_high_word_changes_is_not_the_old_mask`: 1 passed, 0 failed
0xkn0wh3r3 commented 2026-11-26 11:03:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T10:15:31Z.


Thanks @fuzeofficlal, good catch. It reproduced. At 7fafdf36, a wave64 shader that copies a compare into s[2:3] word by word, selects on it, sets s3 to 0 with s_mov_b32 s3, 0 and selects on s[2:3] again lowered both selects with the compare's predicate. The low-word keying is older than this PR: on main, v_cndmask_b32 ..., vcc after s_mov_b32 vcc_hi, 0 lowers the same way. The copy chain here only adds another way to reach it.

Fixed in d4895407 (the branch is also rebased onto 63bcca43):

  • Structured keeps the wave64 pairs of other (paired_other) as it already did for masks. select_bits(lo, hi) looks a select's mask up by the exact (lo, hi) pair the structurizer tracked at that instruction.
  • v_cndmask_b32 in wave64 reads both dwords and uses that lookup. An opaque mask is lowered with its low dword's own high dword, so the select doesn't take one whose high dword is a different value either. Anything else is refused as "a select on an untracked mask", the select's existing outcome for an unknown mask. Wave32 is unchanged.
  • New test emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask: one shader with both selects. When s3 is copied back from vcc_hi, it lowers and passes DXIL validation. When s3 is set to 0, translation is refused. The test fails at 7fafdf36. The PR's copy-chain code and its test are unchanged.

The _co_ci_u32 carry-in still looks its mask up by the low dword. I left it as is.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189120514 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7189120514). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T10:15:31Z. --- Thanks @fuzeofficlal, good catch. It reproduced. At 7fafdf36, a wave64 shader that copies a compare into `s[2:3]` word by word, selects on it, sets `s3` to 0 with `s_mov_b32 s3, 0` and selects on `s[2:3]` again lowered both selects with the compare's predicate. The low-word keying is older than this PR: on main, `v_cndmask_b32 ..., vcc` after `s_mov_b32 vcc_hi, 0` lowers the same way. The copy chain here only adds another way to reach it. Fixed in d4895407 (the branch is also rebased onto 63bcca43): - `Structured` keeps the wave64 pairs of `other` (`paired_other`) as it already did for `masks`. `select_bits(lo, hi)` looks a select's mask up by the exact `(lo, hi)` pair the structurizer tracked at that instruction. - `v_cndmask_b32` in wave64 reads both dwords and uses that lookup. An opaque mask is lowered with its low dword's own high dword, so the select doesn't take one whose high dword is a different value either. Anything else is refused as "a select on an untracked mask", the select's existing outcome for an unknown mask. Wave32 is unchanged. - New test `emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask`: one shader with both selects. When `s3` is copied back from `vcc_hi`, it lowers and passes DXIL validation. When `s3` is set to 0, translation is refused. The test fails at 7fafdf36. The PR's copy-chain code and its test are unchanged. The `_co_ci_u32` carry-in still looks its mask up by the low dword. I left it as is.
0xkn0wh3r3 commented 2026-11-26 11:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T10:45:50Z.


Thanks @fuzeofficlal. Both points reproduced, and both are fixed in 39a37182.

  1. Opaque pair forwarding via s_mov_b64: Atom::Opaque now carries the (low, high) pair it was made for. Lowering reads those two dwords, and pair_high is gone. s_mov_b64 s[4:5], s[2:3] after s_mov_b32 s3, 0 therefore gives Opaque(s2, cleared s3), and lanes 32-63 read the cleared word. That made the select-side guard from d4895407 unnecessary, so I removed it. Regression: structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_one asserts the select's mask is exactly Atom::Opaque(s2, cleared s3).

  2. Low-word paths:

    • Phi: Atom::Phi carries the joined (low, high) pair. Its lowering builds each incoming edge from that edge's pair of phi arguments, looked up by pair. The skip-edge check (no_mask_lane_on_edge) and the join links in avoids use the same pairs.
    • Carry-in: the v_{add,sub,subrev}_co_ci_u32 carry-in reads both dwords and looks the pair up in masks.
    • Regression: emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask. A join whose incoming pair on one edge has s3 cleared, and a carry-in after s_mov_b32 vcc_hi, 0, both lower without the clearing write and are refused with it. At d4895407 both lowered with the old high dword.

The round-one select test still passes; its second case is now refused as an opaque pair of s2 and the new s3, not as an untracked mask. The rustfmt --check hunks at structure.rs 491 and 895 are fixed by hand.

cargo test -p victory-shader --lib: 302 passed; only the 3 known failures (the gathers test and two stride_tests) fail, with the crashing heap test skipped. Clippy is clean (default and --all-features) and cargo xtask policy passes. Wave64 doesn't run on this machine's GPU or on WARP, so the tests check translation and the structurizer, not GPU results.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189803965 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7189803965). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T10:45:50Z. --- Thanks @fuzeofficlal. Both points reproduced, and both are fixed in 39a37182. 1. **Opaque pair forwarding via `s_mov_b64`:** `Atom::Opaque` now carries the `(low, high)` pair it was made for. Lowering reads those two dwords, and `pair_high` is gone. `s_mov_b64 s[4:5], s[2:3]` after `s_mov_b32 s3, 0` therefore gives `Opaque(s2, cleared s3)`, and lanes 32-63 read the cleared word. That made the select-side guard from d4895407 unnecessary, so I removed it. Regression: `structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_one` asserts the select's mask is exactly `Atom::Opaque(s2, cleared s3)`. 2. **Low-word paths:** - **Phi:** `Atom::Phi` carries the joined `(low, high)` pair. Its lowering builds each incoming edge from that edge's pair of phi arguments, looked up by pair. The skip-edge check (`no_mask_lane_on_edge`) and the join links in `avoids` use the same pairs. - **Carry-in:** the `v_{add,sub,subrev}_co_ci_u32` carry-in reads both dwords and looks the pair up in `masks`. - **Regression:** `emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask`. A join whose incoming pair on one edge has `s3` cleared, and a carry-in after `s_mov_b32 vcc_hi, 0`, both lower without the clearing write and are refused with it. At d4895407 both lowered with the old high dword. The round-one select test still passes; its second case is now refused as an opaque pair of `s2` and the new `s3`, not as an untracked mask. The `rustfmt --check` hunks at `structure.rs` 491 and 895 are fixed by hand. `cargo test -p victory-shader --lib`: 302 passed; only the 3 known failures (the gathers test and two `stride_tests`) fail, with the crashing heap test skipped. Clippy is clean (default and `--all-features`) and `cargo xtask policy` passes. Wave64 doesn't run on this machine's GPU or on WARP, so the tests check translation and the structurizer, not GPU results.
fuzeofficlal commented 2026-11-26 11:18:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:18:39Z.

Review: CHANGES_REQUESTED


Verified the fixes in df392b22: the direct v_cndmask_b32, _co_ci_u32 carry-in, pending_masks, no_mask_lane_on_edge, and avoids paths now check both Wave64 dwords, Atom::Opaque carries both (lo, hi) across s_mov_b64, and the new structure and synthetic lowering tests pass (emit/lower.rs = 520,658 bytes).

Two bugs still bypass the full-pair check, plus one liveness gap:

  1. Reversed spill-restore pairs in Lanes::mask (crates/victory-shader/src/structure.rs:971-989): when (lo, hi) comes from restored in swapped order (e.g., s5 and s4 defined by s_mov_b64 s[4:5], vcc, spilled, and read back in reverse), the (None, _) fallback only checks defs.get(&k.0) == defs.get(&k.1) and returns sop(i).dst without verifying that (k.0, k.1) matches the definition's (low, high) register order.
  2. Descriptor selection via Source::Lanes (crates/victory-shader/src/resource.rs:1708-1783, crates/victory-shader/src/emit/lower.rs:5639-5663): lane_picked only records the low SGPR (Reg::S(code)) of v_cndmask_b32, and lane_select / lane_heap_index look up masks.get(&mask) by that low dword alone, bypassing select_bits(lo, hi) when the high dword is overwritten.
  3. High-word liveness in touches (crates/victory-shader/src/emit/lower.rs:10416-10431): Atom::Phi(v, _) | Atom::Opaque(v, _) => Some(v) drops the high dword, so dead_on_edge misses dependencies that only taint the high word.

Please preserve the ordered pair check in both paths (with regressions for reversed spill words and descriptor selection) and check both words in touches.

Verified locally on Windows 11 x64 (df392b22):

  • cargo run --locked -p xtask -- policy (191 files ok) and cargo clippy --workspace --all-targets -- -D warnings (default and --all-features): clean.
  • structure::tests (15 passed, 1 ignored), emit::lower::tests (33 passed), and both new Wave64 synthetic tests: passed.
<!-- greyfinch-sync:Marvisak/VIctory:review:6073236100 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6073236100). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T11:18:39Z. **Review:** CHANGES_REQUESTED --- Verified the fixes in `df392b22`: the direct `v_cndmask_b32`, `_co_ci_u32` carry-in, `pending_masks`, `no_mask_lane_on_edge`, and `avoids` paths now check both Wave64 dwords, `Atom::Opaque` carries both `(lo, hi)` across `s_mov_b64`, and the new structure and synthetic lowering tests pass (`emit/lower.rs` = `520,658` bytes). Two bugs still bypass the full-pair check, plus one liveness gap: 1. **Reversed spill-restore pairs in `Lanes::mask` (`crates/victory-shader/src/structure.rs:971-989`)**: when `(lo, hi)` comes from `restored` in swapped order (e.g., `s5` and `s4` defined by `s_mov_b64 s[4:5], vcc`, spilled, and read back in reverse), the `(None, _)` fallback only checks `defs.get(&k.0) == defs.get(&k.1)` and returns `sop(i).dst` without verifying that `(k.0, k.1)` matches the definition's `(low, high)` register order. 2. **Descriptor selection via `Source::Lanes` (`crates/victory-shader/src/resource.rs:1708-1783`, `crates/victory-shader/src/emit/lower.rs:5639-5663`)**: `lane_picked` only records the low SGPR (`Reg::S(code)`) of `v_cndmask_b32`, and `lane_select` / `lane_heap_index` look up `masks.get(&mask)` by that low dword alone, bypassing `select_bits(lo, hi)` when the high dword is overwritten. 3. **High-word liveness in `touches` (`crates/victory-shader/src/emit/lower.rs:10416-10431`)**: `Atom::Phi(v, _) | Atom::Opaque(v, _) => Some(v)` drops the high dword, so `dead_on_edge` misses dependencies that only taint the high word. Please preserve the ordered pair check in both paths (with regressions for reversed spill words and descriptor selection) and check both words in `touches`. Verified locally on Windows 11 x64 (`df392b22`): - `cargo run --locked -p xtask -- policy` (`191 files ok`) and `cargo clippy --workspace --all-targets -- -D warnings` (default and `--all-features`): clean. - `structure::tests` (15 passed, 1 ignored), `emit::lower::tests` (33 passed), and both new Wave64 synthetic tests: passed.
0xkn0wh3r3 commented 2026-11-26 12:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T11:44:57Z.


Thanks @fuzeofficlal. All three are fixed in 68c0d2b9, on top of df392b22.

  1. Reversed spill-restore pairs: reproduced. The (None, _) fallback in Lanes::mask now takes the writing instruction's destination mask only when that destination's (low, high) key is the pair asked for (.filter(|d| d.0 == k)). Reversed words now get an opaque pair of their own.

    • Regression: structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask. s_mov_b64 s[4:5], vcc is spilled with v_writelane_b32 to lanes 0 and 1 and read back into s[6:7]. In order, it is the compare; swapped, it is not.
    • Without the filter, the swapped case was the compare.
  2. Descriptor selection via Source::Lanes: reproduced. Source::Lanes gains high: Option<Value>. lane_picked records both words the v_cndmask_b32 reads (the high one in wave64 only). lane_select and lane_heap_index look the pair up with Structured::mask_bits(mask, high).

    • Regression on the tracking side: resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one. The program is a wave64 version of WATERFALL_PICKED_WAVE32 (picked_wave64), with lanes below 48 taking the first descriptor and the WATERFALL_FETCHED_WAVE64 loop.
    • Regression on the lowering side: emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused. Without s_mov_b32 vcc_hi, 0, the pick is the compare and the shader lowers. With it, the pick names the cleared high word and lowering refuses it as "a descriptor chosen per lane by an untracked mask".
    • With the old low-word lookup, the lowering test fails: the shader lowered with the compare's mask. waterfall_tests::build is split so this test can lower in wave64 (lower_wave).
  3. High-word liveness in touches: Atom::Phi and Atom::Opaque now give both words, and either one being tainted counts. There is no test for this one: building a synthetic wave64 branch whose only tainted word is the high one isn't easy.

Checks: cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, is clean. cargo xtask policy passes. cargo test -p victory passes. cargo test -p victory-shader --lib: 305 passed; only the 3 known failures (the gathers test and two stride_tests) fail, with the crashing heap test skipped.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191117128 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7191117128). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T11:44:57Z. --- Thanks @fuzeofficlal. All three are fixed in 68c0d2b9, on top of df392b22. 1. **Reversed spill-restore pairs:** reproduced. The `(None, _)` fallback in `Lanes::mask` now takes the writing instruction's destination mask only when that destination's `(low, high)` key is the pair asked for (`.filter(|d| d.0 == k)`). Reversed words now get an opaque pair of their own. - Regression: `structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask`. `s_mov_b64 s[4:5], vcc` is spilled with `v_writelane_b32` to lanes 0 and 1 and read back into `s[6:7]`. In order, it is the compare; swapped, it is not. - Without the filter, the swapped case was the compare. 2. **Descriptor selection via `Source::Lanes`:** reproduced. `Source::Lanes` gains `high: Option<Value>`. `lane_picked` records both words the `v_cndmask_b32` reads (the high one in wave64 only). `lane_select` and `lane_heap_index` look the pair up with `Structured::mask_bits(mask, high)`. - Regression on the tracking side: `resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one`. The program is a wave64 version of `WATERFALL_PICKED_WAVE32` (`picked_wave64`), with lanes below 48 taking the first descriptor and the `WATERFALL_FETCHED_WAVE64` loop. - Regression on the lowering side: `emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused`. Without `s_mov_b32 vcc_hi, 0`, the pick is the compare and the shader lowers. With it, the pick names the cleared high word and lowering refuses it as "a descriptor chosen per lane by an untracked mask". - With the old low-word lookup, the lowering test fails: the shader lowered with the compare's mask. `waterfall_tests::build` is split so this test can lower in wave64 (`lower_wave`). 3. **High-word liveness in `touches`:** `Atom::Phi` and `Atom::Opaque` now give both words, and either one being tainted counts. There is no test for this one: building a synthetic wave64 branch whose only tainted word is the high one isn't easy. Checks: `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`, is clean. `cargo xtask policy` passes. `cargo test -p victory` passes. `cargo test -p victory-shader --lib`: 305 passed; only the 3 known failures (the gathers test and two `stride_tests`) fail, with the crashing heap test skipped.
Venom2054 commented 2026-11-26 12:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-26T11:47:14Z.


Follow-up to my earlier fork result. I tested the same cascade-shadow compute shader at upstream PR revision df392b22 and the base translator (63bcca43). I used separate build directories, the Windows SDK DXIL validator, and the D3D12 debug layer on an RTX 5070 Ti.

Both builds translated the shader and passed DXIL validation. On both, D3D12 rejected compute pipeline creation with message 622. The shader requests a wave size of 64 and this adapter reports a native range of 32–32. A separate compute shader successfully created its pipeline on both builds.

The successful pipeline creation in my earlier comment used the downstream translator with 32-lane host support. The wave-size limit reproduces on the upstream base as well.

AI-assisted hardware test.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191164735 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7191164735). Originally posted by [Venom2054](https://github.com/Venom2054) on 2026-11-26T11:47:14Z. --- Follow-up to my earlier fork result. I tested the same cascade-shadow compute shader at upstream PR revision `df392b22` and the base translator (`63bcca43`). I used separate build directories, the Windows SDK DXIL validator, and the D3D12 debug layer on an RTX 5070 Ti. Both builds translated the shader and passed DXIL validation. On both, D3D12 rejected compute pipeline creation with message 622. The shader requests a wave size of 64 and this adapter reports a native range of 32–32. A separate compute shader successfully created its pipeline on both builds. The successful pipeline creation in my earlier comment used the downstream translator with 32-lane host support. The wave-size limit reproduces on the upstream base as well. AI-assisted hardware test.
0xkn0wh3r3 commented 2026-11-26 12:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T12:03:45Z.


Thanks, that settles both questions. The shader still translates and validates with the stricter wave64 mask checks in this PR (df392b22; 68c0d2b9 only adds the spill-restore and per-lane descriptor checks). And on this tree it only runs where the host has 64-lane waves: an RX-class AMD card reporting 64 in its wave range. On a 32–32 adapter, D3D12 refuses a wave-size-64 pipeline, on main as well. So the gain this PR gives in the title is limited to hosts with 64-lane waves until there's 32-lane host support. I've added that to the description's limits.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191516836 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7191516836). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T12:03:45Z. --- Thanks, that settles both questions. The shader still translates and validates with the stricter wave64 mask checks in this PR (df392b22; 68c0d2b9 only adds the spill-restore and per-lane descriptor checks). And on this tree it only runs where the host has 64-lane waves: an RX-class AMD card reporting 64 in its wave range. On a 32–32 adapter, D3D12 refuses a wave-size-64 pipeline, on main as well. So the gain this PR gives in the title is limited to hosts with 64-lane waves until there's 32-lane host support. I've added that to the description's limits.
fuzeofficlal commented 2026-11-26 12:10:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:10:55Z.

Review: CHANGES_REQUESTED


Both the ordered spill-restore pair check (structure.rs:984-988) and tracking (mask, high) through Source::Lanes (resource.rs:1702-1796, emit/lower.rs:5643-5657) cleanly resolve the earlier mask-reuse issues.

One liveness bug remains in touches (crates/victory-shader/src/emit/lower.rs:10423-10426):

  • While lines 10415-10421 check both words of Atom::Phi(v, h) and Atom::Opaque(v, h) against tainted, line 10423 still prunes BDD branches using self.compared(env, v) on the low word alone.
  • compared (emit/lower.rs:10524-10558) only evaluates the integer compare writing the low SSA word v. If an Atom::Opaque(lo, hi) has a constant-true lo compare and zero hi (false in lanes 32–63), or an Atom::Phi(lo, hi) joins only on the high word while lo comes from a compare, compared(env, lo) returns Some(true) and skips the false branch where another tainted dependency may sit, risking unsound dead_on_edge pruning.

Please restrict compared-based pruning in touches to Atom::Lane and Atom::Uniform (matching can_be at emit/lower.rs:10446-10449) and add a focused regression test.

Local verification on 68c0d2b9: xtask policy (191 files ok), clippy (default & --all-features) clean, CLI tests (18 passed), structure::tests (16 passed, 1 ignored), resource::tests (36 passed), emit::lower::tests (33 passed), and emit::waterfall_tests (6 passed) + emit::synthetic_tests (2 passed) on both RTX 5090 and WARP (cargo fmt --check only flags pre-existing lines in resource.rs).

<!-- greyfinch-sync:Marvisak/VIctory:review:6073904034 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6073904034). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T12:10:55Z. **Review:** CHANGES_REQUESTED --- Both the ordered spill-restore pair check (`structure.rs:984-988`) and tracking `(mask, high)` through `Source::Lanes` (`resource.rs:1702-1796`, `emit/lower.rs:5643-5657`) cleanly resolve the earlier mask-reuse issues. One liveness bug remains in `touches` (`crates/victory-shader/src/emit/lower.rs:10423-10426`): - While lines `10415-10421` check both words of `Atom::Phi(v, h)` and `Atom::Opaque(v, h)` against `tainted`, line `10423` still prunes BDD branches using `self.compared(env, v)` on the low word alone. - `compared` (`emit/lower.rs:10524-10558`) only evaluates the integer compare writing the low SSA word `v`. If an `Atom::Opaque(lo, hi)` has a constant-true `lo` compare and zero `hi` (false in lanes 32–63), or an `Atom::Phi(lo, hi)` joins only on the high word while `lo` comes from a compare, `compared(env, lo)` returns `Some(true)` and skips the false branch where another tainted dependency may sit, risking unsound `dead_on_edge` pruning. Please restrict `compared`-based pruning in `touches` to `Atom::Lane` and `Atom::Uniform` (matching `can_be` at `emit/lower.rs:10446-10449`) and add a focused regression test. Local verification on `68c0d2b9`: `xtask policy` (`191 files ok`), `clippy` (default & `--all-features`) clean, CLI tests (`18 passed`), `structure::tests` (`16 passed, 1 ignored`), `resource::tests` (`36 passed`), `emit::lower::tests` (`33 passed`), and `emit::waterfall_tests` (`6 passed`) + `emit::synthetic_tests` (`2 passed`) on both RTX 5090 and WARP (`cargo fmt --check` only flags pre-existing lines in `resource.rs`).
fuzeofficlal commented 2026-11-26 12:58:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:58:09Z.

Review: CHANGES_REQUESTED


The BDD follow-up resolves my earlier concern: Atom::compare() (crates/victory-shader/src/structure.rs:68-84) only lets a compare's own Lane or Uniform bit select a branch, and either word of a Phi or Opaque mask counts as a dependency in touches.

One Wave64 carry-in regression remains:

  • structure.rs:1345-1364 resolves v_cndmask_b32 select inputs (self.mask(k)) and records carry outputs, but never resolves the carry-in input pair (v_{add,sub,subrev}_co_ci_u32) that crates/victory-shader/src/emit/lower.rs:6587-6595 now looks up as an exact (lo, hi) pair via mask_bits(lo, hi).
  • Copying vcc_hi through an SGPR and back (e.g., s_mov_b32 s2, vcc_hi; s_mov_b32 vcc_hi, s2) preserves the mask bits while producing a new high-word SSA Value. When a carry-in instruction is the first consumer of that pair, lowering fails with a carry-in from an untracked mask, whereas main (63bcca43) succeeds.

Please resolve and register the ordered pair at the carry-in use during structuring and add a positive copy-preserving carry-in regression test alongside the existing cleared-high-word test.

Local verification on 751722ff890c: xtask policy (191 files ok; lower.rs = 519,963 bytes), cargo clippy --workspace --all-targets / --all-features, victory CLI tests (18 passed), structure:: (17 passed, 1 ignored), resource:: (36 passed), emit::lower::tests (33 passed), and emit::waterfall_tests (6 passed) + both Wave64 synthetic_tests cases (2 passed) on both RTX 5090 and VICTORY_WARP=1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6074517385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6074517385). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T12:58:09Z. **Review:** CHANGES_REQUESTED --- The BDD follow-up resolves my earlier concern: `Atom::compare()` (`crates/victory-shader/src/structure.rs:68-84`) only lets a compare's own `Lane` or `Uniform` bit select a branch, and either word of a `Phi` or `Opaque` mask counts as a dependency in `touches`. One Wave64 carry-in regression remains: - `structure.rs:1345-1364` resolves `v_cndmask_b32` select inputs (`self.mask(k)`) and records carry outputs, but never resolves the carry-in input pair (`v_{add,sub,subrev}_co_ci_u32`) that `crates/victory-shader/src/emit/lower.rs:6587-6595` now looks up as an exact `(lo, hi)` pair via `mask_bits(lo, hi)`. - Copying `vcc_hi` through an SGPR and back (e.g., `s_mov_b32 s2, vcc_hi; s_mov_b32 vcc_hi, s2`) preserves the mask bits while producing a new high-word SSA `Value`. When a carry-in instruction is the first consumer of that pair, lowering fails with `a carry-in from an untracked mask`, whereas `main` (`63bcca43`) succeeds. Please resolve and register the ordered pair at the carry-in use during structuring and add a positive copy-preserving carry-in regression test alongside the existing cleared-high-word test. Local verification on `751722ff890c`: `xtask policy` (`191 files ok`; `lower.rs` = `519,963` bytes), `cargo clippy --workspace --all-targets` / `--all-features`, `victory` CLI tests (`18 passed`), `structure::` (`17 passed, 1 ignored`), `resource::` (`36 passed`), `emit::lower::tests` (`33 passed`), and `emit::waterfall_tests` (`6 passed`) + both Wave64 `synthetic_tests` cases (`2 passed`) on both RTX 5090 and `VICTORY_WARP=1`.
0xkn0wh3r3 commented 2026-11-26 13:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T12:21:46Z.


Thanks @fuzeofficlal. It's fixed in 751722ff.

touches no longer prunes on compared(env, lo) for a joined or opaque mask. A compare's known result now settles only that compare's own bit, Atom::Lane or Atom::Uniform. The rule is Atom::compare(), which can_be now uses as well, so the two match. Atom::Phi and Atom::Opaque are walked both ways, and either of their dwords being tainted counts (Atom::values()). The walk itself moved into Bools::reaches(b, decide, hit), and touches is now those two closures over it.

Regression: structure::tests::only_a_compare_s_own_bit_is_decided_by_the_compare, a unit test on a constructed diagram. The diagram is x OR Lane(t), with t tainted and the compare writing lo known true:

  • for x = Lane(lo), the tainted branch is pruned;
  • for x = Opaque(lo, hi) and x = Phi(lo, hi), it is searched;
  • a tainted hi alone is found for both pair atoms.

With the old pruning (Phi and Opaque decided by their low dword), the test fails.

Checks: cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, is clean. cargo xtask policy passes. cargo test -p victory passes. cargo test -p victory-shader --lib: 306 passed; only the 3 known failures (the gathers test and two stride_tests) fail, with the crashing heap test skipped.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191903789 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7191903789). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T12:21:46Z. --- Thanks @fuzeofficlal. It's fixed in 751722ff. `touches` no longer prunes on `compared(env, lo)` for a joined or opaque mask. A compare's known result now settles only that compare's own bit, `Atom::Lane` or `Atom::Uniform`. The rule is `Atom::compare()`, which `can_be` now uses as well, so the two match. `Atom::Phi` and `Atom::Opaque` are walked both ways, and either of their dwords being tainted counts (`Atom::values()`). The walk itself moved into `Bools::reaches(b, decide, hit)`, and `touches` is now those two closures over it. Regression: `structure::tests::only_a_compare_s_own_bit_is_decided_by_the_compare`, a unit test on a constructed diagram. The diagram is `x OR Lane(t)`, with `t` tainted and the compare writing `lo` known true: - for `x = Lane(lo)`, the tainted branch is pruned; - for `x = Opaque(lo, hi)` and `x = Phi(lo, hi)`, it is searched; - a tainted `hi` alone is found for both pair atoms. With the old pruning (Phi and Opaque decided by their low dword), the test fails. Checks: `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`, is clean. `cargo xtask policy` passes. `cargo test -p victory` passes. `cargo test -p victory-shader --lib`: 306 passed; only the 3 known failures (the gathers test and two `stride_tests`) fail, with the crashing heap test skipped.
fuzeofficlal commented 2026-11-26 13:54:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T13:54:55Z.

Review: CHANGES_REQUESTED


The vcc_hi copy round trip for carry-in is fixed: structure.rs:1369-1378 now resolves the carry-in pair before recording the new carry-out, and synthetic_tests.rs verifies both the copied and cleared cases.

Two edge cases remain in structure.rs:

  1. High-word copy placed inside the join block (structure.rs:1038-1046): mask() only caches a scalar-move alias if source is already in self.masks. If the two s_mov_b32 high-word copies sit inside the join block itself right before the first v_cndmask_b32, (phi_lo, phi_hi) has not been entered in self.masks yet, so join() receives (phi_lo, copied_hi) and propagates the post-join copied_hi back along incoming edges. Resolving the normalized source first (and adding a test with COPIED in the join block) would close that gap.
  2. Unvalidated constant Joins from join_args() (structure.rs:573-582, 893, 1143-1158): finish() runs self.join_args() after wrong_joins() has already exited the fixpoint loop. If a back-edge pair discovered there lets join() fold a new Join using only forward edges, that Join skips back-edge implication validation. Please validate newly created joins alongside wrong_joins() or defer folding them until their back edges are checked.

Local verification on commit 5ef2e88a7770: emit/lower.rs is 519,963 B (< 524,288 B), cargo run --locked -p xtask -- policy (191 files ok), cargo clippy --workspace --all-targets (default and --all-features), victory (18 passed), structure::tests (17 passed, 1 ignored), resource::tests (36 passed), and emit::lower::tests (33 passed) all pass, as do emit::waterfall_tests (6 passed) and both Wave64 synthetic_tests cases on both RTX 5090 and VICTORY_WARP=1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075324669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6075324669). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T13:54:55Z. **Review:** CHANGES_REQUESTED --- The `vcc_hi` copy round trip for carry-in is fixed: `structure.rs:1369-1378` now resolves the carry-in pair before recording the new carry-out, and `synthetic_tests.rs` verifies both the copied and cleared cases. Two edge cases remain in `structure.rs`: 1. **High-word copy placed inside the join block (`structure.rs:1038-1046`):** `mask()` only caches a scalar-move alias if `source` is already in `self.masks`. If the two `s_mov_b32` high-word copies sit inside the join block itself right before the first `v_cndmask_b32`, `(phi_lo, phi_hi)` has not been entered in `self.masks` yet, so `join()` receives `(phi_lo, copied_hi)` and propagates the post-join `copied_hi` back along incoming edges. Resolving the normalized `source` first (and adding a test with `COPIED` in the join block) would close that gap. 2. **Unvalidated constant `Join`s from `join_args()` (`structure.rs:573-582, 893, 1143-1158`):** `finish()` runs `self.join_args()` after `wrong_joins()` has already exited the fixpoint loop. If a back-edge pair discovered there lets `join()` fold a new `Join` using only forward edges, that `Join` skips back-edge implication validation. Please validate newly created joins alongside `wrong_joins()` or defer folding them until their back edges are checked. Local verification on commit `5ef2e88a7770`: `emit/lower.rs` is `519,963 B` (< `524,288 B`), `cargo run --locked -p xtask -- policy` (191 files ok), `cargo clippy --workspace --all-targets` (`default` and `--all-features`), `victory` (18 passed), `structure::tests` (17 passed, 1 ignored), `resource::tests` (36 passed), and `emit::lower::tests` (33 passed) all pass, as do `emit::waterfall_tests` (6 passed) and both Wave64 `synthetic_tests` cases on both RTX 5090 and `VICTORY_WARP=1`.
0xkn0wh3r3 commented 2026-11-26 14:01:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T13:08:45Z.


Thanks @fuzeofficlal. It reproduced: at 751722ff, a wave64 carry-in that was the first reader of a pair whose vcc_hi had been copied through an SGPR and back was refused with "a carry-in from an untracked mask", while main translates it. It's fixed in 5ef2e88a.

  • Carry-in: Lanes::step now resolves the carry-in pair of v_{add,sub,subrev}_co_ci_u32 where it is read, the same way it resolves a select's mask. A pair of copies is followed back by move_source and registered as the mask.
  • Select and descriptor pick: I checked both for the same first-reader gap, and neither has it.
    • The pick is itself a v_cndmask_b32, so its pair is already resolved at the select.
    • Both copy cases already pass at 751722ff. The round-one select test's kept case reads a pair whose s3 was copied from vcc_hi, and the pick tests now include a vcc_hi copied through s2 and back.
  • Joins: I found the same gap on a loop's back edge. A join left as a phi atom only had its forward-edge pairs resolved, so lowering the join couldn't find a back edge bringing a copied pair. Main finds that by the low dword. finish now first resolves every edge's pair of each such join (join_args).

Regressions, all positive cases also DXIL-validated:

  • emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask. A forward join, a uniform loop that narrows s[2:3] each pass (read at its header), and a carry-in all lower with the high dword kept or copied through another SGPR and back. The cleared-high-dword refusals for the join and the carry-in are unchanged. Without the new resolution, the copied carry-in and the copied loop are refused; on main (63bcca43) both translate.
  • resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one and emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused now also cover vcc_hi copied through s2 and back: the pick is the compare, and the shader lowers. The cleared case is still refused.

Checks: cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, is clean. cargo xtask policy passes. cargo test -p victory passes. cargo test -p victory-shader --lib: 306 passed; only the 3 known failures (the gathers test and two stride_tests) fail, with the crashing heap test skipped.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192936810 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7192936810). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T13:08:45Z. --- Thanks @fuzeofficlal. It reproduced: at 751722ff, a wave64 carry-in that was the first reader of a pair whose `vcc_hi` had been copied through an SGPR and back was refused with "a carry-in from an untracked mask", while main translates it. It's fixed in 5ef2e88a. - **Carry-in:** `Lanes::step` now resolves the carry-in pair of `v_{add,sub,subrev}_co_ci_u32` where it is read, the same way it resolves a select's mask. A pair of copies is followed back by `move_source` and registered as the mask. - **Select and descriptor pick:** I checked both for the same first-reader gap, and neither has it. - The pick is itself a `v_cndmask_b32`, so its pair is already resolved at the select. - Both copy cases already pass at 751722ff. The round-one select test's kept case reads a pair whose `s3` was copied from `vcc_hi`, and the pick tests now include a `vcc_hi` copied through `s2` and back. - **Joins:** I found the same gap on a loop's back edge. A join left as a phi atom only had its forward-edge pairs resolved, so lowering the join couldn't find a back edge bringing a copied pair. Main finds that by the low dword. `finish` now first resolves every edge's pair of each such join (`join_args`). Regressions, all positive cases also DXIL-validated: - `emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask`. A forward join, a uniform loop that narrows `s[2:3]` each pass (read at its header), and a carry-in all lower with the high dword kept or copied through another SGPR and back. The cleared-high-dword refusals for the join and the carry-in are unchanged. Without the new resolution, the copied carry-in and the copied loop are refused; on main (63bcca43) both translate. - `resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one` and `emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused` now also cover `vcc_hi` copied through `s2` and back: the pick is the compare, and the shader lowers. The cleared case is still refused. Checks: `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`, is clean. `cargo xtask policy` passes. `cargo test -p victory` passes. `cargo test -p victory-shader --lib`: 306 passed; only the 3 known failures (the gathers test and two `stride_tests`) fail, with the crashing heap test skipped.
Venom2054 commented 2026-11-26 14:01:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-26T14:01:30Z.


I reproduced the first review finding on 5ef2e88a7770 with the existing wave64_program synthetic fixture. For the two-instruction COPIED case, changing only the conditional branch displacement from 4 to 2 moves the high-word copy from one incoming edge to the start of the join, immediately before the select.

High word Copy on incoming edge Copy at start of join
Unchanged DXIL validated DXIL validated
Copied through an SGPR and back DXIL validated Refused at 0x30 with a lane-mask join of an untracked mask
Cleared Refused at 0x34 Refused at 0x30

The Windows SDK validator passed every emitted shader. This isolates the first finding at translation time. The loop-back-edge finding and the effect in game are still open. Codex assisted with the synthetic test.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7194167556 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7194167556). Originally posted by [Venom2054](https://github.com/Venom2054) on 2026-11-26T14:01:30Z. --- I reproduced the first review finding on `5ef2e88a7770` with the existing `wave64_program` synthetic fixture. For the two-instruction `COPIED` case, changing only the conditional branch displacement from 4 to 2 moves the high-word copy from one incoming edge to the start of the join, immediately before the select. | High word | Copy on incoming edge | Copy at start of join | | --- | --- | --- | | Unchanged | DXIL validated | DXIL validated | | Copied through an SGPR and back | DXIL validated | Refused at `0x30` with `a lane-mask join of an untracked mask` | | Cleared | Refused at `0x34` | Refused at `0x30` | The Windows SDK validator passed every emitted shader. This isolates the first finding at translation time. The loop-back-edge finding and the effect in game are still open. Codex assisted with the synthetic test.
0xkn0wh3r3 commented 2026-11-26 18:18:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T18:18:34Z.


Thanks @fuzeofficlal, and @Venom2054 for the repro. Both items are fixed in 30ff13de.

  1. High-word copy inside the join block: reproduced, matching Venom2054's numbers. With the copy at the start of the join, the copied case was refused at 0x30 with "a lane-mask join of an untracked mask".

    • Fix: Lanes::mask now resolves the normalized source pair first whenever it differs from the pair being read, and caches the copy pair as that result. It no longer requires the source to be in masks already. Copies hold their sources' bits, so this is exact. For the join case, the source is (phi_lo, phi_hi), so join() gets the real phi pair and each edge's own arguments.
    • Unchanged: swapped or mixed words still make a different source pair, so split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask still passes.
    • Regression: wave64_joins_and_carry_ins_read_both_dwords_of_their_mask now runs the join case with the change on the incoming edge and at the join's start (branch displacement 2). Kept and copied lower and DXIL-validate in both places, and cleared stays refused in both.
  2. Unvalidated constant joins from join_args():

    • Fix: join_args() now runs in the fixpoint loop, after masks_in_order() and before paths() and wrong_joins(), instead of in finish(). A join it folds to a constant is checked on all its edges like any other. If it's wrong, it's unresolved and the next round starts. paths() doesn't read the mask caches, so moving it there is safe.
    • Regression: structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own.
      • Shader: an outer uniform loop whose header join (a compare on entry) stays a phi atom. Its back edge brings an inner loop header's join, which is EXEC on entry and the compare on its own back edge, and nothing else reads it.
      • Result: the inner join is now not all lanes. With join_args() back in finish(), it folded to all lanes from its entry edge alone and the test fails.

Checks: cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, is clean. cargo xtask policy passes. cargo test -p victory passes. cargo test -p victory-shader --lib: 307 passed; only the 3 known failures (the gathers test and two stride_tests) fail, with the crashing heap test skipped.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7200305740 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#issuecomment-7200305740). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T18:18:34Z. --- Thanks @fuzeofficlal, and @Venom2054 for the repro. Both items are fixed in 30ff13de. 1. **High-word copy inside the join block:** reproduced, matching Venom2054's numbers. With the copy at the start of the join, the copied case was refused at 0x30 with "a lane-mask join of an untracked mask". - **Fix:** `Lanes::mask` now resolves the normalized source pair first whenever it differs from the pair being read, and caches the copy pair as that result. It no longer requires the source to be in `masks` already. Copies hold their sources' bits, so this is exact. For the join case, the source is `(phi_lo, phi_hi)`, so `join()` gets the real phi pair and each edge's own arguments. - **Unchanged:** swapped or mixed words still make a different source pair, so `split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask` still passes. - **Regression:** `wave64_joins_and_carry_ins_read_both_dwords_of_their_mask` now runs the join case with the change on the incoming edge and at the join's start (branch displacement 2). Kept and copied lower and DXIL-validate in both places, and cleared stays refused in both. 2. **Unvalidated constant joins from `join_args()`:** - **Fix:** `join_args()` now runs in the fixpoint loop, after `masks_in_order()` and before `paths()` and `wrong_joins()`, instead of in `finish()`. A join it folds to a constant is checked on all its edges like any other. If it's wrong, it's unresolved and the next round starts. `paths()` doesn't read the mask caches, so moving it there is safe. - **Regression:** `structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own`. - **Shader:** an outer uniform loop whose header join (a compare on entry) stays a phi atom. Its back edge brings an inner loop header's join, which is EXEC on entry and the compare on its own back edge, and nothing else reads it. - **Result:** the inner join is now not all lanes. With `join_args()` back in `finish()`, it folded to all lanes from its entry edge alone and the test fails. Checks: `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`, is clean. `cargo xtask policy` passes. `cargo test -p victory` passes. `cargo test -p victory-shader --lib`: 307 passed; only the 3 known failures (the gathers test and two `stride_tests`) fail, with the crashing heap test skipped.
fuzeofficlal commented 2026-11-26 18:48:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T18:48:38Z.

Review: APPROVED


Re-reviewed at 30ff13de58ab merged onto 63bcca43 — both earlier findings are cleanly addressed:

  • In-join word-by-word copy resolution (crates/victory-shader/src/structure.rs:1039-1051): Lanes::mask now resolves normalized (self.move_source(k.0), self.move_source(k.1)) unconditionally whenever source != k (without requiring source to already be cached in self.masks), caches k under masks or other according to derived, and keeps swapped/mismatched word pairs distinct. Since move_source reduces to an idempotent SSA fixed point, the single recursive lookup terminates without cycling.
  • Validation of join_args() constant joins (crates/victory-shader/src/structure.rs:575): l.join_args() now runs inside the fixpoint loop before l.paths() and l.wrong_joins(&cond) instead of in finish(), and is covered by structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own.
  • Policy / file size: crates/victory-shader/src/emit/lower.rs is 519,963 bytes (4,325 bytes under the 524,288-byte cap); cargo xtask policy and cargo clippy --locked -p victory-shader -p victory --all-targets -- -D warnings (both default and --all-features) pass cleanly.

Hardware & validation verification (RTX 5090 + Microsoft WARP + Windows SDK dxil.dll):

  • cargo test --locked -p victory (18/18), structure::tests:: (18/18), resource::tests:: (36/36), emit::waterfall_tests:: (6/6), emit::synthetic_tests::wave64 on WARP (3/3), and 12/12 non-gather emit::synthetic_tests:: on RTX 5090 (gathers_at_a_level_match_the_hardware fails identically on clean main 63bcca43 on this adapter).
  • Verified an additional Wave64 probe covering 2-hop s_mov_b32 copy chains both before and inside a join block (lowered and validated through dxil.dll), while confirming both cross-edge uninitialized high-word copies and swapped low/high-word pairs are rejected with lane-mask join of an untracked mask.

LGTM — ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079160243 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2816#pullrequestreview-6079160243). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T18:48:38Z. **Review:** APPROVED --- Re-reviewed at `30ff13de58ab` merged onto `63bcca43` — both earlier findings are cleanly addressed: - **In-join word-by-word copy resolution (`crates/victory-shader/src/structure.rs:1039-1051`)**: `Lanes::mask` now resolves normalized `(self.move_source(k.0), self.move_source(k.1))` unconditionally whenever `source != k` (without requiring `source` to already be cached in `self.masks`), caches `k` under `masks` or `other` according to `derived`, and keeps swapped/mismatched word pairs distinct. Since `move_source` reduces to an idempotent SSA fixed point, the single recursive lookup terminates without cycling. - **Validation of `join_args()` constant joins (`crates/victory-shader/src/structure.rs:575`)**: `l.join_args()` now runs inside the fixpoint loop before `l.paths()` and `l.wrong_joins(&cond)` instead of in `finish()`, and is covered by `structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own`. - **Policy / file size**: `crates/victory-shader/src/emit/lower.rs` is `519,963` bytes (`4,325` bytes under the `524,288`-byte cap); `cargo xtask policy` and `cargo clippy --locked -p victory-shader -p victory --all-targets -- -D warnings` (both default and `--all-features`) pass cleanly. **Hardware & validation verification** (RTX 5090 + Microsoft WARP + Windows SDK `dxil.dll`): - `cargo test --locked -p victory` (18/18), `structure::tests::` (18/18), `resource::tests::` (36/36), `emit::waterfall_tests::` (6/6), `emit::synthetic_tests::wave64` on WARP (3/3), and 12/12 non-gather `emit::synthetic_tests::` on RTX 5090 (`gathers_at_a_level_match_the_hardware` fails identically on clean `main` `63bcca43` on this adapter). - Verified an additional Wave64 probe covering 2-hop `s_mov_b32` copy chains both before and inside a join block (lowered and validated through `dxil.dll`), while confirming both cross-edge uninitialized high-word copies and swapped low/high-word pairs are rejected with `lane-mask join of an untracked mask`. LGTM — ready to merge.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2816:upstream-pr/2816'
git switch 'upstream-pr/2816'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2816'
git switch 'upstream-pr/2816'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2816'
git switch 'upstream-pr/2816'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2816'
git switch 'main'
git merge --squash 'upstream-pr/2816'
git switch 'main'
git merge --ff-only 'upstream-pr/2816'
git switch 'main'
git merge 'upstream-pr/2816'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2814
No description provided.