Shaders: exclude masks widened past block reachability from Structured::active #2627

Open
github-bot wants to merge 1 commit from github-bot/gh-2627 into main AGit
Owner

@⁠VastyViz on GitHub · 2026-11-25 17:08 UTC · original
VastyViz:shaders/active-mask-reachability → main · +579 −1 · 3 files · 1 commits · open

Summary

Fixes a correctness bug in Structured::active (structure.rs) where lane masks that can hold bits for lanes outside the writing block's reachability (cond[b]) were still marked active, causing Lower::mask_dword to take a waveActiveBallot inside a divergent block and silently drop lanes that skipped the block.

Root Cause

Lanes::step unconditionally inserted:

  1. Every EXEC write (r.exec.is_some_and(|e| e.0 == k)) and every VALU compare/carry mask into self.active, even when a divergent block (cond[b] narrower than the wave) widened or replaced EXEC past cond[b] (e.g. s_or_b32 exec_lo, exec_lo, s_saved or s_xor_b32 exec_lo, exec_lo, s_saved inside an s_cbranch_execz body) and ran subsequent v_cmp / scalar mask ops under that widened EXEC.
  2. Any scalar mask op whose BDD implied exec — when Lanes::join simplified a loop's EXEC phi inside a divergent region to Bool::TRUE (true for lanes entering the loop), b.implies(m, Bool::TRUE) held trivially for complementing ops (s_not, s_nand, s_nor, s_orn2, s_orn1, s_xnor), leaving bits set for skipped lanes marked active.

Changes

  • crates/victory-shader/src/structure.rs:
    • Added read-only memoized BDD helpers on Bools (is_uniform_ro, confined_ro) that allocate zero BDD nodes and cannot trigger Bools::overflow.
    • Added a single non-recursive RPO post-pass Lanes::filter_active (called from Lanes::finish) that drops masks written under widened EXEC or by complementing scalar mask ops under a Bool::TRUE-simplified EXEC phi in divergent blocks, while preserving:
      • purely uniform blocks (is_uniform_ro),
      • s_wqm and non-widening narrowings of EXEC,
      • pre-widening saved masks from *_saveexec,
      • one-step same-scope restores of an active mask (following restored VGPR spills) whose defining block is confined to cond[b] or post-dominated by b within its loop iteration (postdominates).
    • Added unit tests in structure::tests:
      • widened_exec_and_masks_in_divergent_block_are_not_active
      • complement_inside_divergent_loop_is_not_active_but_uniform_branch_stays_active
      • post_loop_reconvergence_exec_restore_stays_active_but_back_edge_escape_does_not
  • crates/victory-shader/src/emit/lower.rs:
    • Relaxed the EXEC-write guard in Lower::mask_number from inst.write(Reg::S(EXEC)).is_some() to (*code != EXEC && inst.write(Reg::S(EXEC)).is_some()), allowing pure s_or/s_xor/s_mov writes to EXEC (while still excluding *_saveexec) to be reconstructed from operand ballots when read as data in compute shaders.
    • Added device-free unit test widened_exec_read_as_data_reconstructs_scalar_ops_and_refuses_valu_cmp.
  • crates/victory-shader/src/emit/synthetic_tests.rs:
    • Added GPU + WARP + DXIL-validator test widened_exec_in_divergent_block_counts_all_lanes verifying that:
      • s_or_b32 exec_lo, exec_lo, s20 + s_bcnt1_i32_b32 inside a 16-lane divergent block produces 32 (previously miscompiled to 16),
      • s_xor_b32 exec_lo, exec_lo, s20 + s_bcnt1_i32_b32 produces 16 (previously miscompiled to 0),
      • reading a v_cmp run under widened EXEC inside a divergent block is refused cleanly with "a lane mask holding lanes elsewhere read as data".

Verification

  • cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes — 52 passed, 0 failed
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- widened_exec_in_divergent_block_counts_all_lanes — passed
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings — pass
  • cargo xtask policy — 191 files ok
  • git diff --check — clean
  • Full title shader archive translation (26,599 containers / 26,177 programs against 63bcca4):
    • 26,177 / 26,177 structured (0 BDD overflows)
    • 14,258 / 14,259 VP, 2,733 / 2,763 CS, 8,765 / 8,765 MS emitted (exact match with main, 0 "a lane mask holding lanes elsewhere read as data" regressions)
**@⁠VastyViz** on GitHub · 2026-11-25 17:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627) `VastyViz:shaders/active-mask-reachability` → `main` · +579 −1 · 3 files · 1 commits · open ## Summary Fixes a correctness bug in `Structured::active` ([`structure.rs`](crates/victory-shader/src/structure.rs)) where lane masks that can hold bits for lanes **outside** the writing block's reachability (`cond[b]`) were still marked `active`, causing `Lower::mask_dword` to take a `waveActiveBallot` inside a divergent block and silently drop lanes that skipped the block. ### Root Cause `Lanes::step` unconditionally inserted: 1. Every `EXEC` write (`r.exec.is_some_and(|e| e.0 == k)`) and every VALU compare/carry mask into `self.active`, even when a divergent block (`cond[b]` narrower than the wave) widened or replaced `EXEC` past `cond[b]` (e.g. `s_or_b32 exec_lo, exec_lo, s_saved` or `s_xor_b32 exec_lo, exec_lo, s_saved` inside an `s_cbranch_execz` body) and ran subsequent `v_cmp` / scalar mask ops under that widened `EXEC`. 2. Any scalar mask op whose BDD implied `exec` — when `Lanes::join` simplified a loop's `EXEC` phi inside a divergent region to `Bool::TRUE` (true for lanes entering the loop), `b.implies(m, Bool::TRUE)` held trivially for complementing ops (`s_not`, `s_nand`, `s_nor`, `s_orn2`, `s_orn1`, `s_xnor`), leaving bits set for skipped lanes marked `active`. ### Changes - **`crates/victory-shader/src/structure.rs`**: - Added read-only memoized BDD helpers on `Bools` (`is_uniform_ro`, `confined_ro`) that allocate zero BDD nodes and cannot trigger `Bools::overflow`. - Added a single non-recursive RPO post-pass `Lanes::filter_active` (called from `Lanes::finish`) that drops masks written under widened `EXEC` or by complementing scalar mask ops under a `Bool::TRUE`-simplified `EXEC` phi in divergent blocks, while preserving: - purely uniform blocks (`is_uniform_ro`), - `s_wqm` and non-widening narrowings of `EXEC`, - pre-widening saved masks from `*_saveexec`, - one-step same-scope restores of an `active` mask (following `restored` VGPR spills) whose defining block is confined to `cond[b]` or post-dominated by `b` within its loop iteration (`postdominates`). - Added unit tests in `structure::tests`: - `widened_exec_and_masks_in_divergent_block_are_not_active` - `complement_inside_divergent_loop_is_not_active_but_uniform_branch_stays_active` - `post_loop_reconvergence_exec_restore_stays_active_but_back_edge_escape_does_not` - **`crates/victory-shader/src/emit/lower.rs`**: - Relaxed the `EXEC`-write guard in `Lower::mask_number` from `inst.write(Reg::S(EXEC)).is_some()` to `(*code != EXEC && inst.write(Reg::S(EXEC)).is_some())`, allowing pure `s_or`/`s_xor`/`s_mov` writes to `EXEC` (while still excluding `*_saveexec`) to be reconstructed from operand ballots when read as data in compute shaders. - Added device-free unit test `widened_exec_read_as_data_reconstructs_scalar_ops_and_refuses_valu_cmp`. - **`crates/victory-shader/src/emit/synthetic_tests.rs`**: - Added GPU + WARP + DXIL-validator test `widened_exec_in_divergent_block_counts_all_lanes` verifying that: - `s_or_b32 exec_lo, exec_lo, s20` + `s_bcnt1_i32_b32` inside a 16-lane divergent block produces `32` (previously miscompiled to `16`), - `s_xor_b32 exec_lo, exec_lo, s20` + `s_bcnt1_i32_b32` produces `16` (previously miscompiled to `0`), - reading a `v_cmp` run under widened `EXEC` inside a divergent block is refused cleanly with `"a lane mask holding lanes elsewhere read as data"`. ## Verification - `cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes` — **52 passed, 0 failed** - `VICTORY_WARP=1 cargo test -p victory-shader --locked -- widened_exec_in_divergent_block_counts_all_lanes` — **passed** - `cargo clippy --workspace --all-targets --locked -- -D warnings` — **pass** - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` — **pass** - `cargo xtask policy` — **191 files ok** - `git diff --check` — **clean** - Full title shader archive translation (`26,599` containers / `26,177` programs against `63bcca4`): - `26,177 / 26,177` structured (`0` BDD overflows) - `14,258 / 14,259` VP, `2,733 / 2,763` CS, `8,765 / 8,765` MS emitted (exact match with `main`, `0` `"a lane mask holding lanes elsewhere read as data"` regressions)
`Lanes::step` added every `EXEC` write, every `v_cmp`/`v_cmpx`/carry mask,
and every scalar mask op whose result implied the block's current `EXEC`
to `Structured::active`. Lowering treats membership in `active` as a proof
that every set lane reaches the writing block, so `mask_dword` can take a
`waveActiveBallot` in that block.

That invariant broke in two cases inside a divergent block (`cond[b]`
strictly narrower than the whole wave):

1. Widening or replacing `EXEC` past `cond[b]` (for example `s_or_b32` or
   `s_xor_b32` restoring saved outer lanes inside an `s_cbranch_execz`
   region) left both the widened `EXEC` write and any subsequent `v_cmp` /
   scalar mask ops under it in `active`. Taking `waveActiveBallot` in that
   block silently dropped every lane that skipped the block.
2. When `Lanes::join` simplified a loop's `EXEC` phi inside a divergent
   region to `Bool::TRUE` (valid for lanes that reach the loop), `implies(m,
   TRUE)` held for complementing scalar mask ops (`s_not`, `s_nand`,
   `s_nor`, `s_orn2`, `s_orn1`, `s_xnor`), marking masks that set bits for
   skipped lanes as `active`.

Add read-only memoized BDD checks (`is_uniform_ro`, `implies_ro`,
`confined_ro`) and a post-pass `Lanes::filter_active` (with a memoized
`ActiveCheck` helper that allocates no BDD nodes and cannot trip
`Bools::overflow`) to drop masks that can hold lanes outside `cond[b]`,
while preserving:
- `s_wqm` and syntactic narrowings of `EXEC`,
- pre-widening `*_saveexec` saved masks,
- same-scope restores (following `restored` spills, phis, non-complementing
  SOPs, and intra-iteration post-dominating reconvergence blocks).

Also allow `Lower::mask_number` to reconstruct pure scalar `EXEC` writes
(`*code == EXEC`, excluding `*_saveexec`) from operand ballots so compute
shaders that read a widened `s_or`/`s_xor`/`s_mov` `EXEC` as data still
lower accurately instead of being refused.
- Add device-free `emit::lower::tests::widened_exec_read_as_data_reconstructs_scalar_ops_and_refuses_valu_cmp`
  so the `mask_number` guard relaxation for pure scalar `EXEC` writes
  (`s_or_b32`/`s_xor_b32`) and the `v_cmp` refusal are exercised without a
  GPU.
- Skip the `"hardware"` pass in
  `synthetic_tests::widened_exec_in_divergent_block_counts_all_lanes` when
  `VICTORY_WARP=1` is set so software-only WARP runs do not trip the
  non-WARP wave-32 pipeline assertion.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:39 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 17:38 UTC · original

Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5).

  • Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), VICTORY_D3D12_WARP=1 and VICTORY_WARP=1 (software WARP only; VICTORY_WARP=1 is what makes the shader test harness skip its "hardware" adapter pass).
  • origin/main = 13f91caee2
  • PR head: 51acc47c91b7fd791a85a4f4b5b3fbe77b6f655c (based on the main tip; merges cleanly)

Results

  • cargo test -p victory-shader --lib --locked structure::: 14 passed, 0 failed, 1 ignored (includes the new device-free structure::tests cases).
  • Negative control: with only the self.filter_active(cond, execs); call disabled, widened_exec_and_masks_in_divergent_block_are_not_active and post_loop_reconvergence_exec_restore_stays_active_but_back_edge_escape_does_not FAIL (12 passed, 2 failed); restored, all 14 pass. The 2-line lower.rs change is not covered by these (they still pass with it reverted); only the GPU test below exercises it.
  • Full cargo test -p victory-shader --lib --locked -- --test-threads=1: 270 passed, 4 failed, 3 ignored. Three are the same failures as on origin/main (WARP is not a 32-lane wave device; main: 267 passed, 3 failed, 3 ignored). The fourth is the PR's own synthetic_tests::widened_exec_in_divergent_block_counts_all_lanes: hardware/or: no pipeline for a wave of 32. WARP cannot build a wave-32 pipeline, and the test tolerates that only when its loop's warp flag is true; with VICTORY_WARP=1 both passes are WARP, so the first one trips assert!(warp, ...). The translation half of that test (DXIL validation and the Unsupported refusal) runs before that point and passes.
  • cargo clippy -p victory-shader --all-targets --locked: no warnings.

Review: filter_active is read-only on the BDD (allocates no nodes, so no new overflow path) and only runs for non-uniform blocks that write EXEC or have a true-EXEC phi. No correctness issue found in the diff. Note that the runtime assertions of widened_exec_in_divergent_block_counts_all_lanes never execute on WARP (it skips there), so the lane-count claim is only checked on a wave-32 GPU.

Not tested: the runtime half of widened_exec_in_divergent_block_counts_all_lanes (needs a wave-32 GPU; no physical GPU used here) and any retail title.

**@⁠oni-swr** on GitHub · 2026-11-25 17:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7169783673) Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5). - Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1` (software WARP only; `VICTORY_WARP=1` is what makes the shader test harness skip its "hardware" adapter pass). - `origin/main` = 13f91caee25f2fdf2c062be5f7a27f058e51cbca - PR head: 51acc47c91b7fd791a85a4f4b5b3fbe77b6f655c (based on the main tip; merges cleanly) **Results** - `cargo test -p victory-shader --lib --locked structure::`: 14 passed, 0 failed, 1 ignored (includes the new device-free `structure::tests` cases). - Negative control: with only the `self.filter_active(cond, execs);` call disabled, `widened_exec_and_masks_in_divergent_block_are_not_active` and `post_loop_reconvergence_exec_restore_stays_active_but_back_edge_escape_does_not` FAIL (12 passed, 2 failed); restored, all 14 pass. The 2-line `lower.rs` change is not covered by these (they still pass with it reverted); only the GPU test below exercises it. - Full `cargo test -p victory-shader --lib --locked -- --test-threads=1`: 270 passed, 4 failed, 3 ignored. Three are the same failures as on `origin/main` (WARP is not a 32-lane wave device; main: 267 passed, 3 failed, 3 ignored). The fourth is the PR's own `synthetic_tests::widened_exec_in_divergent_block_counts_all_lanes`: `hardware/or: no pipeline for a wave of 32`. WARP cannot build a wave-32 pipeline, and the test tolerates that only when its loop's `warp` flag is true; with `VICTORY_WARP=1` both passes are WARP, so the first one trips `assert!(warp, ...)`. The translation half of that test (DXIL validation and the `Unsupported` refusal) runs before that point and passes. - `cargo clippy -p victory-shader --all-targets --locked`: no warnings. **Review**: `filter_active` is read-only on the BDD (allocates no nodes, so no new `overflow` path) and only runs for non-uniform blocks that write EXEC or have a true-EXEC phi. No correctness issue found in the diff. Note that the runtime assertions of `widened_exec_in_divergent_block_counts_all_lanes` never execute on WARP (it skips there), so the lane-count claim is only checked on a wave-32 GPU. **Not tested**: the runtime half of `widened_exec_in_divergent_block_counts_all_lanes` (needs a wave-32 GPU; no physical GPU used here) and any retail title.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:49 UTC · original

Reviewed: the guard change is right — when the op's destination IS exec (*code == EXEC), writing exec is the operation itself, not a side effect to reject; the old condition refused s_or_b32 exec_lo, exec_lo, s20-style widening. s_and_saveexec-family writes still fail the first check via the extra destination. The wave64-in-wave32-half test (counting 32/16 lanes through widened exec) is a solid repro. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7170050059) Reviewed: the guard change is right — when the op's destination IS `exec` (`*code == EXEC`), writing exec is the operation itself, not a side effect to reject; the old condition refused `s_or_b32 exec_lo, exec_lo, s20`-style widening. `s_and_saveexec`-family writes still fail the first check via the extra destination. The wave64-in-wave32-half test (counting 32/16 lanes through widened exec) is a solid repro. CI green.
Author
Owner

@⁠VastyViz on GitHub · 2026-11-25 17:55 UTC · original

Thanks @⁠oni-swr and @⁠kotekompotek for the review and independent verification!

Pushed follow-up commit c001191 addressing both test-coverage points from @⁠oni-swr:

  • Added device-free emit::lower::tests::widened_exec_read_as_data_reconstructs_scalar_ops_and_refuses_valu_cmp covering both the Lower::mask_number scalar EXEC reconstruction (s_or_b32 / s_xor_b32) and the v_cmp under widened EXEC refusal without requiring a GPU.
  • Skipped the "hardware" pass in synthetic_tests::widened_exec_in_divergent_block_counts_all_lanes when VICTORY_WARP=1 is set (matching Host::new's VICTORY_WARP override), so software-only WARP runs no longer trip the wave-32 assertion while hardware runs still enforce the exact lane counts (32 and 16).

Verified locally with structure::tests + emit::lower::tests + widened_exec_in_divergent_block_counts_all_lanes (both hardware RTX 3080 and VICTORY_WARP=1), cargo clippy (default and --all-features), and cargo xtask policy.

**@⁠VastyViz** on GitHub · 2026-11-25 17:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7170200070) Thanks @⁠oni-swr and @⁠kotekompotek for the review and independent verification! Pushed follow-up commit `c001191` addressing both test-coverage points from @⁠oni-swr: - Added device-free `emit::lower::tests::widened_exec_read_as_data_reconstructs_scalar_ops_and_refuses_valu_cmp` covering both the `Lower::mask_number` scalar `EXEC` reconstruction (`s_or_b32` / `s_xor_b32`) and the `v_cmp` under widened `EXEC` refusal without requiring a GPU. - Skipped the `"hardware"` pass in `synthetic_tests::widened_exec_in_divergent_block_counts_all_lanes` when `VICTORY_WARP=1` is set (matching `Host::new`'s `VICTORY_WARP` override), so software-only WARP runs no longer trip the wave-32 assertion while hardware runs still enforce the exact lane counts (`32` and `16`). Verified locally with `structure::tests` + `emit::lower::tests` + `widened_exec_in_divergent_block_counts_all_lanes` (both hardware RTX 3080 and `VICTORY_WARP=1`), `cargo clippy` (default and `--all-features`), and `cargo xtask policy`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:15 UTC · original · edited 2026-11-26 03:25 UTC

Automated triage for the maintainers.

Verdict: needs work. Thanks for rebasing; it merges cleanly now and CI (check) passes.

The idea is sound: a mask written in a divergent block after EXEC has been widened past cond[b] should not be in Structured::active, since mask_dword's ballot would miss the lanes that skipped the block. The Lower::mask_number change (allow *code == EXEC) is small and the tests cover it.

What holds it back is the size of Lanes::filter_active / ActiveCheck in crates/victory-shader/src/structure.rs: about 650 lines of special cases (per-opcode narrowing/restore tables, postdominates, a 16-step restored walk, a 64-deep visit cap, optimistic answers on cycles). Your own archive run shows no program whose output changes against main (no new successes, no new refusals). So this is a lot of analysis for a pattern not yet seen in the title's shaders.

To change the verdict, either:

  • show which title programs this changes: a count of programs whose translation differs from main, and ideally one whose output was wrong before (no shader data in the PR), or
  • cut it down to the cases the compiler actually emits, e.g. just the EXEC-widening s_or/s_xor/s_mov without the ActiveCheck restore tracking, and keep the rest for when a program needs it.

Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7176143826) · edited 2026-11-26 03:25 UTC <!-- victory-triage v1 head=54cae73d906199a72f4c57fd0926427c4b770a02 verdict=needs-work at=2026-11-26T03:25:32Z --> Automated triage for the maintainers. **Verdict: needs work.** Thanks for rebasing; it merges cleanly now and CI (`check`) passes. The idea is sound: a mask written in a divergent block after `EXEC` has been widened past `cond[b]` should not be in `Structured::active`, since `mask_dword`'s ballot would miss the lanes that skipped the block. The `Lower::mask_number` change (allow `*code == EXEC`) is small and the tests cover it. What holds it back is the size of `Lanes::filter_active` / `ActiveCheck` in `crates/victory-shader/src/structure.rs`: about 650 lines of special cases (per-opcode narrowing/restore tables, `postdominates`, a 16-step `restored` walk, a 64-deep visit cap, optimistic answers on cycles). Your own archive run shows no program whose output changes against `main` (no new successes, no new refusals). So this is a lot of analysis for a pattern not yet seen in the title's shaders. To change the verdict, either: - show which title programs this changes: a count of programs whose translation differs from `main`, and ideally one whose output was wrong before (no shader data in the PR), or - cut it down to the cases the compiler actually emits, e.g. just the `EXEC`-widening `s_or`/`s_xor`/`s_mov` without the `ActiveCheck` restore tracking, and keep the rest for when a program needs it. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠VastyViz on GitHub · 2026-11-26 01:28 UTC · original

Rebased onto latest main (63bcca4, new head 54cae73), resolving the append conflict at the end of crates/victory-shader/src/emit/synthetic_tests.rs.

Re-verified after rebase:

  • cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes (52 passed, 0 failed)
  • VICTORY_WARP=1 pass on widened_exec_in_divergent_block_counts_all_lanes (passed)
  • cargo clippy --workspace --all-targets --locked -- -D warnings & --all-features (pass)
  • cargo xtask policy (191 files ok) & git diff --check (clean)
**@⁠VastyViz** on GitHub · 2026-11-26 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7179800986) Rebased onto latest `main` (`63bcca4`, new head `54cae73`), resolving the append conflict at the end of `crates/victory-shader/src/emit/synthetic_tests.rs`. Re-verified after rebase: - `cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes` (52 passed, 0 failed) - `VICTORY_WARP=1` pass on `widened_exec_in_divergent_block_counts_all_lanes` (passed) - `cargo clippy --workspace --all-targets --locked -- -D warnings` & `--all-features` (pass) - `cargo xtask policy` (191 files ok) & `git diff --check` (clean)
github-bot force-pushed github-bot/gh-2627 from 54cae73d90 to 913f8485b5 2026-11-26 15:08:19 +00:00 Compare
Author
Owner

@⁠VastyViz on GitHub · 2026-11-26 15:07 UTC · original

Addressed the triage feedback by cutting crates/victory-shader/src/structure.rs down to a single non-recursive RPO pass (new head 913f848 on 63bcca4):

What was removed

  • Deleted ActiveCheck, recursive val_confined / val_confined_body SSA/phi walking, the 64-deep visit cap, optimistic cycle returns, the 16-step restored loop, implies_ro / implies_memo, and the separate syntactic_narrow / val_mask / true_masks tables.
  • structure.rs diff dropped from +648 to +414 lines (of which 145 lines are unit tests — implementation cut roughly in half from ~503 to ~266 lines).

Why the one-step op_confined + postdominates check stays

  • Tested stripping restore/reconvergence tracking completely across all 26,177 title programs (26,599 containers): without checking whether an EXEC-restoring s_or/s_xor/s_mov restores an active mask from a confining or post-dominated block, 203 title programs (88 VP, 113 CS, 2 MS) regress and fail to emit with "a lane mask holding lanes elsewhere read as data" (due to Lanes::join simplifying loop EXEC phis to Bool::TRUE inside divergent regions and post-loop reconvergence blocks keeping unsimplified loop-exit atoms in cond[b]).
  • Keeping just the one-step non-recursive check (active.contains(&v) + confined_ro(cond[blk], c) || postdominates(block, blk)) fixes all 203 false positives with zero recursion and zero heuristics.
  • Across all 26,177 title programs, 0 programs currently read a widened-EXEC mask as data (14,258/14,259 VP, 2,733/2,763 CS, 8,765/8,765 MS emitted — identical to main with 0 regressions).

Verification

  • cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes — 52 passed, 0 failed
  • VICTORY_WARP=1 on widened_exec_in_divergent_block_counts_all_lanes — passed
  • cargo clippy --workspace --all-targets --locked -- -D warnings & --all-features — pass
  • cargo xtask policy (191 files ok) & git diff --check (clean)
**@⁠VastyViz** on GitHub · 2026-11-26 15:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7195823028) Addressed the triage feedback by cutting `crates/victory-shader/src/structure.rs` down to a single non-recursive RPO pass (new head `913f848` on `63bcca4`): ### What was removed - Deleted `ActiveCheck`, recursive `val_confined` / `val_confined_body` SSA/phi walking, the 64-deep visit cap, optimistic cycle returns, the 16-step `restored` loop, `implies_ro` / `implies_memo`, and the separate `syntactic_narrow` / `val_mask` / `true_masks` tables. - `structure.rs` diff dropped from **+648** to **+414** lines (of which 145 lines are unit tests — implementation cut roughly in half from ~503 to ~266 lines). ### Why the one-step `op_confined` + `postdominates` check stays - Tested stripping restore/reconvergence tracking completely across all **26,177** title programs (`26,599` containers): without checking whether an `EXEC`-restoring `s_or`/`s_xor`/`s_mov` restores an `active` mask from a confining or post-dominated block, **203 title programs** (`88` VP, `113` CS, `2` MS) regress and fail to emit with `"a lane mask holding lanes elsewhere read as data"` (due to `Lanes::join` simplifying loop `EXEC` phis to `Bool::TRUE` inside divergent regions and post-loop reconvergence blocks keeping unsimplified loop-exit atoms in `cond[b]`). - Keeping just the one-step non-recursive check (`active.contains(&v)` + `confined_ro(cond[blk], c) || postdominates(block, blk)`) fixes all 203 false positives with zero recursion and zero heuristics. - Across all **26,177** title programs, `0` programs currently read a widened-`EXEC` mask as data (`14,258/14,259` VP, `2,733/2,763` CS, `8,765/8,765` MS emitted — identical to `main` with `0` regressions). ### Verification - `cargo test -p victory-shader --locked -- structure::tests emit::lower::tests widened_exec_in_divergent_block_counts_all_lanes pops_wait_loop_exits_immediately_for_inactive_lanes` — **52 passed, 0 failed** - `VICTORY_WARP=1` on `widened_exec_in_divergent_block_counts_all_lanes` — **passed** - `cargo clippy --workspace --all-targets --locked -- -D warnings` & `--all-features` — **pass** - `cargo xtask policy` (191 files ok) & `git diff --check` (clean)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2627/head:github-bot/gh-2627'
git switch 'github-bot/gh-2627'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2627'
git switch 'github-bot/gh-2627'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2627'
git switch 'github-bot/gh-2627'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2627'
git switch 'main'
git merge --squash 'github-bot/gh-2627'
git switch 'main'
git merge --ff-only 'github-bot/gh-2627'
git switch 'main'
git merge 'github-bot/gh-2627'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2627
No description provided.