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

Open
VastyViz wants to merge 1 commit from upstream-pr/2627 into main
VastyViz commented 2026-11-25 17:08:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-25T17:08:23Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6609657023 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627). Originally posted by [VastyViz](https://github.com/VastyViz) on 2026-11-25T17:08:23Z. --- ## 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)
oni-swr commented 2026-11-25 18:02:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T17:38:07Z.


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: 51acc47c91 (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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169783673 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7169783673). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T17:38:07Z. --- 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.
kotekompotek commented 2026-11-25 18:02:51 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170050059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7170050059). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:49:26Z. --- 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.
VastyViz commented 2026-11-25 18:02:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-25T17:55:53Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170200070 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7170200070). Originally posted by [VastyViz](https://github.com/VastyViz) on 2026-11-25T17:55:53Z. --- 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`.
Marvisak commented 2026-11-25 23:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:15:55Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176143826 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7176143826). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:15:55Z. --- <!-- 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)_
VastyViz commented 2026-11-26 02:07:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-26T01:28:04Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:comment:7179800986 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7179800986). Originally posted by [VastyViz](https://github.com/VastyViz) on 2026-11-26T01:28:04Z. --- 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 commented 2026-11-26 16:05:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VastyViz on 2026-11-26T15:07:43Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:comment:7195823028 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2627#issuecomment-7195823028). Originally posted by [VastyViz](https://github.com/VastyViz) on 2026-11-26T15:07:43Z. --- 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 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/2627:upstream-pr/2627'
git switch 'upstream-pr/2627'

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/2627'
git switch 'upstream-pr/2627'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2627'
git switch 'upstream-pr/2627'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2627'
git switch 'main'
git merge --squash 'upstream-pr/2627'
git switch 'main'
git merge --ff-only 'upstream-pr/2627'
git switch 'main'
git merge 'upstream-pr/2627'
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!2625
No description provided.