Shaders: s_cbranch_vccz/vccnz on a scalar VCC decide once for the wave (#2780, on #2836) #3023

Open
github-bot wants to merge 5 commits from github-bot/gh-3023 into main AGit
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 03:36 UTC · original
wwwwwwww3333333:fix/vcc-branch-whole → main · +598 −54 · 6 files · 5 commits · open

Fixes the open point of #2780 that both #2783 and #2836 leave (noted in the triage there): s_cbranch_vccz/s_cbranch_vccnz test VCC as a whole (RDNA2 ISA, 12.5: VCCZ is VCC == 0), one decision for the wave, not each lane's bit.

Built on #2836: its two commits are kept as they are (Devin, @⁠kotekompotek), rebased onto main 63bcca4. The third commit is this change.

What changes

  • A VCC that is a pair the structure pass cannot see into (Atom::Opaque, both dwords since #2836) now gives a new Atom::Nonzero(lo, hi) at the branch, the same in every lane, lowered as (lo | hi) != 0. The branch is uniform (uniform_join and the translate counts treat it so).
  • A constant VCC other than all lanes or none is taken.
  • No wave operation and no forced wave size, so 32-lane hosts are not affected.
  • shortcut (marked in the code): a VCC from lane results (compares) still branches per lane. That is the same as the hardware while VCC is set only in lanes of EXEC and the skipped block does nothing in lanes whose bit is clear.

GPU test synthetic_tests::vcc_branches_test_the_whole_mask: a full wave64 group, VCC written by two s_mov_b32, v4 = 17 on the taken path and 43 otherwise. Lanes taking s_cbranch_vccz with only VCC_HI set (the hardware takes none):

tree lanes taking the branch
main 63bcca4 64
main + #2836 63 (all but lane 32)
this PR 0, and every lane right in all six cases (VCC_HI only, VCC zero, VCC_LO only; vccz and vccnz)

RX 6750 XT (driver 32.0.21045.29003) and WARP. This replaces a CPU replay with a GPU run; the numbers for main and #2836 match the ones reported on #2780.

Also: structure::tests::vcc_branches_on_scalar_masks_are_uniform checks the branch's condition is Atom::Nonzero alone, without a GPU.

Suites (Windows 11, Rust 1.98.1 MSVC): victory-shader 305 passed, twice. cargo clippy -p victory-shader --all-targets -- -D warnings: clean. cargo check -p victory: clean.

Not measured: any title. Unit tests only, no game files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 03:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023) `wwwwwwww3333333:fix/vcc-branch-whole` → `main` · +598 −54 · 6 files · 5 commits · open Fixes the open point of #2780 that both #2783 and #2836 leave (noted in the triage there): `s_cbranch_vccz`/`s_cbranch_vccnz` test VCC as a whole (RDNA2 ISA, 12.5: VCCZ is VCC == 0), one decision for the wave, not each lane's bit. Built on #2836: its two commits are kept as they are (Devin, @⁠kotekompotek), rebased onto main 63bcca4. The third commit is this change. **What changes** - A VCC that is a pair the structure pass cannot see into (`Atom::Opaque`, both dwords since #2836) now gives a new `Atom::Nonzero(lo, hi)` at the branch, the same in every lane, lowered as `(lo | hi) != 0`. The branch is uniform (`uniform_join` and the translate counts treat it so). - A constant VCC other than all lanes or none is taken. - No wave operation and no forced wave size, so 32-lane hosts are not affected. - shortcut (marked in the code): a VCC from lane results (compares) still branches per lane. That is the same as the hardware while VCC is set only in lanes of EXEC and the skipped block does nothing in lanes whose bit is clear. **GPU test** `synthetic_tests::vcc_branches_test_the_whole_mask`: a full wave64 group, VCC written by two `s_mov_b32`, v4 = 17 on the taken path and 43 otherwise. Lanes taking `s_cbranch_vccz` with only VCC_HI set (the hardware takes none): | tree | lanes taking the branch | |---|---| | main 63bcca4 | 64 | | main + #2836 | 63 (all but lane 32) | | this PR | 0, and every lane right in all six cases (VCC_HI only, VCC zero, VCC_LO only; vccz and vccnz) | RX 6750 XT (driver 32.0.21045.29003) and WARP. This replaces a CPU replay with a GPU run; the numbers for main and #2836 match the ones reported on #2780. **Also:** `structure::tests::vcc_branches_on_scalar_masks_are_uniform` checks the branch's condition is `Atom::Nonzero` alone, without a GPU. **Suites** (Windows 11, Rust 1.98.1 MSVC): victory-shader 305 passed, twice. `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. `cargo check -p victory`: clean. **Not measured:** any title. Unit tests only, no game files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
In wave64 a mask the structure pass cannot see into was kept as
Atom::Opaque of the pair's low value alone, and lowering guessed the high
dword from the register next to it (#2780). A mask whose dwords are
written apart — LLVM splits a 64-bit constant that is not inline into two
s_mov_b32, and vcc_lo/vcc_hi are written apart the same way — got no
guess, so lanes 32-63 tested the low dword's bits again; a high dword
rewritten after a 64-bit write could be guessed stale.

The opaque atom now names both dwords of the pair as they were read, and
the emitter tests them directly (no guessing, so pair_high goes); two
masks sharing a low dword with different high dwords are different masks.
The atom's birth index is the later of the pair's, so forgetting masks
when a region's values are redefined drops a pair the region assembled.

A wave64 cndmask over s[12:13] written by halves now differs in DXIL for
a high dword of -1 versus 0 (identical before), matching the console.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
s_cbranch_vccz and s_cbranch_vccnz test VCC as a whole (RDNA2 ISA, 12.5:
VCCZ is VCC == 0), one decision for the wave. The structure pass gave
them each lane's own bit of VCC under EXEC. With VCC written by halves
from scalars, and only VCC_HI set, lanes 0-31 and 33-63 took the branch
and lane 32 did not, on #2836 (all 64 took it on main).

A VCC that is a pair the pass cannot see into (Atom::Opaque, both dwords
since #2836) now gives Atom::Nonzero, the same in every lane and lowered
as (lo | hi) != 0, so the branch is uniform; a constant VCC other than
all lanes or none is taken. No wave operation and no forced wave size.

shortcut: a VCC from lane results (compares) still branches per lane,
the same while VCC is set only in lanes of EXEC and the skipped block
does nothing in lanes whose bit is clear.

Tests: synthetic_tests::vcc_branches_test_the_whole_mask (wave64, VCC_HI
only, VCC zero and VCC_LO only, for both branches; every lane takes the
same path, on the hardware adapter and WARP) and
structure::tests::vcc_branches_on_scalar_masks_are_uniform.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:20:22 +00:00
Follow scalar inputs and reachable phi edges before treating a VCC word as wave-wide. A lane-local DXIL phi can feed an ordinary SGPR copy even when the final VCC value is opaque. Check both dwords in wave64 and preserve the original comparison for proven inputs.

Cover a lane-selected write to s12 copied into either word. On a 64-lane synthetic dispatch the unguarded comparison wrongly branches in just one lane on RTX 5080, built-in WARP and WARP 1.0.22.
s_cbranch_vccz/vccnz decided once for the wave only when VCC was one
positive opaque pair or one constant. s_not_b64, s_cselect_b64 (an SCC
select), s_and_b64 with a constant and the like over scalar masks fell
back to each lane's own bit: s_cselect_b64 vcc, 1, 2 took the branch in
lane 1 alone.

A VCC whose diagram tests only atoms held in scalars is now one condition
for the wave. With constants and SCC alone it is decided in the structure
pass, lane by lane over the constants. With opaque pairs it becomes
Atom::Any, lowered as the scalar mask's two words and tested for zero
(VCC_LO alone in wave32). A VCC from compares or a mask join keeps the
per-lane shortcut.

vcc_branches_test_the_whole_mask also fails when a device runs some
cases but makes no pipeline for others, and covers the new forms; the
structure test covers s_mov_b64, s_cselect_b64, s_not_b64 and s_and_b64.

Review by fuzeofficlal on #3023.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
Author
Owner

@⁠zed6000 on GitHub · 2026-11-26 04:02 UTC · original

Measured offline on the title's shaders (the method in #1247): head 8fc606d merged onto main 63bcca4 (a clean merge, security-reviewed first), victory translate --validate --list over shaders.rpf 1.0.2.1, program by program: 0 gained, 0 lost. All 24,850 programs that validate on main still validate. Since this is the same VCC-branch area where #2405's head lost 1,829 programs (and the hardware-exact variant on #2406 lost 18,170), that's the number that matters here: the wave-uniform reading of scalar VCC doesn't cost this title anything. Offline counts only; no program names or data.

**@⁠zed6000** on GitHub · 2026-11-26 04:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#issuecomment-7182241074) Measured offline on the title's shaders (the method in #1247): head `8fc606d` merged onto `main` `63bcca4` (a clean merge, security-reviewed first), `victory translate --validate --list` over `shaders.rpf` 1.0.2.1, program by program: **0 gained, 0 lost.** All 24,850 programs that validate on `main` still validate. Since this is the same VCC-branch area where #2405's head lost 1,829 programs (and the hardware-exact variant on #2406 lost 18,170), that's the number that matters here: the wave-uniform reading of scalar VCC doesn't cost this title anything. Offline counts only; no program names or data.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 04:03 UTC · original

On 8fc606d, all six checked-in cases passed on the RTX 5080 (621.40), Windows’ built-in WARP and WARP 1.0.22: 0/384 wrong lane values per device. A separate Wave64 test found a remaining issue inside the positive Atom::Nonzero case. An SGPR copied into VCC can already have a different host value in each lane.

The fixture initializes s12 = 0, sets EXEC to just lane 0, and uses s_cbranch_execz to skip s_mov_b32 s12, 1 only if EXEC is empty. Lane 0 exists, so the scalar write executes once for the guest wave. It then restores EXEC, copies s12 to vcc_lo, clears vcc_hi, and branches. The branch should see VCC = 1 for every lane. These are counts read from the UAV on all three devices:

Selected lane Branch Expected taken Actual taken
0, 1, or 32 s_cbranch_vccnz 64 1
0, 1, or 32 s_cbranch_vccz 0 63
64 (absent) s_cbranch_vccnz 0 0
64 (absent) s_cbranch_vccz 64 64

That’s 378/512 wrong lane values per device across the eight cases. With lane 0 selected, WARP 1.0.22 also gives 63/64 wrong on parent fd2b765 for vccnz. RTX and built-in WARP skip that parent Wave64 pipeline. The PR’s original uniform scalar controls pass on all three.

I put a conservative guard and low/high-word regression on the fork. It follows scalar inputs through copies and operations before treating a VCC word as wave-wide. When a contributing scalar phi can select different incoming edges across lanes, it returns an explicit refusal. The regression fails on this PR head and passes with the guard. On all three devices the six original readbacks still pass, along with 1,728/1,728 additional results for constant VCC values under empty, single-lane and full EXEC. This guard covers the joined scalar input. The reviewer’s s_not_b64 and s_cselect_b64 expression cases are separate.

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr3023-vcc-scalar-join
git cherry-pick 6e9e8463cad4b34841543c34968bef93a2dfc022
cargo test -p victory-shader --lib --locked vcc_branch

Shader Clippy with -D warnings and asset policy passed. AI-assisted; synthetic fixtures only. Title coverage is unmeasured.

**@⁠steven-seagull27** on GitHub · 2026-11-26 04:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#issuecomment-7182259123) On `8fc606d`, all six checked-in cases passed on the RTX 5080 (621.40), Windows’ built-in WARP and WARP 1.0.22: **0/384 wrong lane values per device**. A separate Wave64 test found a remaining issue inside the positive `Atom::Nonzero` case. An SGPR copied into VCC can already have a different host value in each lane. The fixture initializes `s12 = 0`, sets EXEC to just lane 0, and uses `s_cbranch_execz` to skip `s_mov_b32 s12, 1` only if EXEC is empty. Lane 0 exists, so the scalar write executes once for the guest wave. It then restores EXEC, copies `s12` to `vcc_lo`, clears `vcc_hi`, and branches. The branch should see VCC = 1 for every lane. These are counts read from the UAV on all three devices: | Selected lane | Branch | Expected taken | Actual taken | |---|---|---:|---:| | 0, 1, or 32 | `s_cbranch_vccnz` | 64 | 1 | | 0, 1, or 32 | `s_cbranch_vccz` | 0 | 63 | | 64 (absent) | `s_cbranch_vccnz` | 0 | 0 | | 64 (absent) | `s_cbranch_vccz` | 64 | 64 | That’s **378/512 wrong lane values per device** across the eight cases. With lane 0 selected, WARP 1.0.22 also gives 63/64 wrong on parent `fd2b765` for `vccnz`. RTX and built-in WARP skip that parent Wave64 pipeline. The PR’s original uniform scalar controls pass on all three. I put a conservative [guard and low/high-word regression on the fork](https://github.com/steven-seagull27/VIctory/commit/6e9e8463cad4b34841543c34968bef93a2dfc022). It follows scalar inputs through copies and operations before treating a VCC word as wave-wide. When a contributing scalar phi can select different incoming edges across lanes, it returns an explicit refusal. The regression fails on this PR head and passes with the guard. On all three devices the six original readbacks still pass, along with **1,728/1,728** additional results for constant VCC values under empty, single-lane and full EXEC. This guard covers the joined scalar input. The reviewer’s `s_not_b64` and `s_cselect_b64` expression cases are separate. ```sh git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr3023-vcc-scalar-join git cherry-pick 6e9e8463cad4b34841543c34968bef93a2dfc022 cargo test -p victory-shader --lib --locked vcc_branch ``` Shader Clippy with `-D warnings` and asset policy passed. AI-assisted; synthetic fixtures only. Title coverage is unmeasured.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 05:47 UTC · original

Thanks @⁠fuzeofficlal, both points were right, and thanks @⁠steven-seagull27 for the guard.

  • Scalar expressions (3228393): a VCC whose diagram tests only atoms held in scalars (opaque pairs, constants, SCC selects) is now one condition for the wave, however it was combined. With constants and SCC alone it is decided in the structure pass, lane by lane over the constants, so s_cselect_b64 vcc, 1, 2 and s_mov_b64 vcc, 1 give TRUE. With an opaque pair (s_not_b64, s_and_b64 with a constant) it becomes Atom::Any, lowered as the mask's two words and tested for zero (VCC_LO alone in wave32). Steven's join guard also runs on the pairs inside it. A VCC from compares or from a mask join (Atom::Phi) still branches per lane, the shortcut already marked in the code.
  • Tests: vcc_branches_test_the_whole_mask now fails if a device runs some cases but makes no pipeline for others. It has 14 cases, including s_mov_b64, s_cselect_b64 (2 and 0), s_not_b64 (hi bit only, and zero) and s_and_b64. The structure test now covers s_mov_b64, s_cselect_b64, s_not_b64 and s_and_b64 directly.
  • steven-seagull27's guard (91f3915) is on the branch with his authorship.

On an RX 6750 XT and WARP, every lane took the expected path in all 14 cases, both ways. Before this, s_cselect_b64 2 and s_and_b64 2 took the branch in lane 1 alone, and s_not_b64 hi 1 in lane 32 alone. victory-shader passed 307 of 307, and Clippy with -D warnings, cargo check -p victory and the xtask tests are clean. lower.rs is 521,058 bytes. The title's shaders are not measured on this head: @⁠zed6000's 0/0 count was on 8fc606d.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 05:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#issuecomment-7183812685) Thanks @⁠fuzeofficlal, both points were right, and thanks @⁠steven-seagull27 for the guard. - **Scalar expressions** (3228393): a VCC whose diagram tests only atoms held in scalars (opaque pairs, constants, SCC selects) is now one condition for the wave, however it was combined. With constants and SCC alone it is decided in the structure pass, lane by lane over the constants, so `s_cselect_b64 vcc, 1, 2` and `s_mov_b64 vcc, 1` give TRUE. With an opaque pair (`s_not_b64`, `s_and_b64` with a constant) it becomes `Atom::Any`, lowered as the mask's two words and tested for zero (VCC_LO alone in wave32). Steven's join guard also runs on the pairs inside it. A VCC from compares or from a mask join (`Atom::Phi`) still branches per lane, the shortcut already marked in the code. - **Tests:** `vcc_branches_test_the_whole_mask` now fails if a device runs some cases but makes no pipeline for others. It has 14 cases, including `s_mov_b64`, `s_cselect_b64` (2 and 0), `s_not_b64` (hi bit only, and zero) and `s_and_b64`. The structure test now covers `s_mov_b64`, `s_cselect_b64`, `s_not_b64` and `s_and_b64` directly. - **steven-seagull27's guard** (91f3915) is on the branch with his authorship. On an RX 6750 XT and WARP, every lane took the expected path in all 14 cases, both ways. Before this, `s_cselect_b64 2` and `s_and_b64 2` took the branch in lane 1 alone, and `s_not_b64 hi 1` in lane 32 alone. victory-shader passed 307 of 307, and Clippy with `-D warnings`, `cargo check -p victory` and the xtask tests are clean. `lower.rs` is 521,058 bytes. The title's shaders are not measured on this head: @⁠zed6000's 0/0 count was on 8fc606d.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:18 UTC · original · edited 2026-11-26 08:25 UTC

Automated triage for the maintainers.

The direction is right and the evidence is cited: RDNA2 ISA 12.5 (VCCZ tests the whole of VCC), with GPU readbacks on an RX 6750 XT and WARP. The change spans structure.rs, emit/lower.rs and the new emit/lower/scalar_vcc.rs:

  • Lanes::whole turns a VCC built only from scalar atoms into one condition for the wave: Atom::Nonzero for an opaque pair, a per-lane fold over constants (Bools::some_lane), or Atom::Any for scalar expressions.
  • Atom::Opaque now carries both dwords of the pair, replacing pair_high's guess at the next register (from #2836).
  • check_scalar_vcc_joins refuses a VCC fed by a scalar phi that can diverge across lanes.
  • The per-lane shortcut for VCC built from compares is marked in the code.

Update after the author's reply: merge order is settled. The first two commits here (64c89b9, fd2b765) are #2836's two commits rebased onto main with the same messages, so reviewing this PR alone and closing #2836 in its favour is the maintainer's call.

What is still needed before it can be recommended:

  • A title measurement on this head. The only shader-pack count (0 gained / 0 lost) was on 8fc606d. Since then the head adds Atom::Any lowering through mask_words and a new refusal ("a scalar VCC branch depending on a divergent scalar join"), and either could cost programs. #2405 lost 1,829 programs in this same area. A program-by-program count on 3228393 (gained/lost) from anyone with the title's shaders would settle it.

CI check: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#issuecomment-7184306314) · edited 2026-11-26 08:25 UTC <!-- victory-triage v1 head=322839300283a9a4561da8303a935b3f1b0c864b verdict=needs-work at=2026-11-26T08:20:18Z --> Automated triage for the maintainers. The direction is right and the evidence is cited: RDNA2 ISA 12.5 (VCCZ tests the whole of VCC), with GPU readbacks on an RX 6750 XT and WARP. The change spans `structure.rs`, `emit/lower.rs` and the new `emit/lower/scalar_vcc.rs`: - `Lanes::whole` turns a VCC built only from scalar atoms into one condition for the wave: `Atom::Nonzero` for an opaque pair, a per-lane fold over constants (`Bools::some_lane`), or `Atom::Any` for scalar expressions. - `Atom::Opaque` now carries both dwords of the pair, replacing `pair_high`'s guess at the next register (from #2836). - `check_scalar_vcc_joins` refuses a VCC fed by a scalar phi that can diverge across lanes. - The per-lane shortcut for VCC built from compares is marked in the code. **Update after the author's reply:** merge order is settled. The first two commits here (`64c89b9`, `fd2b765`) are #2836's two commits rebased onto main with the same messages, so reviewing this PR alone and closing #2836 in its favour is the maintainer's call. What is still needed before it can be recommended: - **A title measurement on this head.** The only shader-pack count (0 gained / 0 lost) was on `8fc606d`. Since then the head adds `Atom::Any` lowering through `mask_words` and a new refusal ("a scalar VCC branch depending on a divergent scalar join"), and either could cost programs. #2405 lost 1,829 programs in this same area. A program-by-program count on `3228393` (gained/lost) from anyone with the title's shaders would settle it. CI `check`: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 08:09 UTC · original

Thanks for the triage.

Merge order: #3023 carries #2836's two commits unchanged, so I'd suggest closing #2836 in favour of this PR and reviewing one stack. If you'd rather land #2836 first, say so and I'll rebase this PR onto it so only the guard and the whole-VCC commits remain.

Title count: I can't measure the title's shaders on 3228393 (I have no dump here). The new parts since 8fc606d are Atom::Any lowering and the divergent-scalar-join refusal. @⁠zed6000, if you can rerun your offline count on 3228393, a gained/lost number would settle that point. Until then it is unmeasured, and I'm not claiming a safe count.

Unit tests only, no game files.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 08:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#issuecomment-7186249549) Thanks for the triage. Merge order: #3023 carries #2836's two commits unchanged, so I'd suggest closing #2836 in favour of this PR and reviewing one stack. If you'd rather land #2836 first, say so and I'll rebase this PR onto it so only the guard and the whole-VCC commits remain. Title count: I can't measure the title's shaders on 3228393 (I have no dump here). The new parts since 8fc606d are `Atom::Any` lowering and the divergent-scalar-join refusal. @⁠zed6000, if you can rerun your offline count on 3228393, a gained/lost number would settle that point. Until then it is unmeasured, and I'm not claiming a safe count. Unit tests only, no game files.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 03:56 UTC · original · requested changes

Reviewed 8fc606d0 against main (63bcca43; emit/lower.rs stays at 520,714 bytes, safely under the 512 KiB limit). Two concrete issues to fix before merge:

  1. Scalar VCC expressions beyond a single positive Atom::Opaque / Atom::Constant still fall back to a per-lane branch (crates/victory-shader/src/structure.rs:1371-1383)

    • whole only matches Some((Atom::Opaque(lo, hi), Bool::FALSE, Bool::TRUE)) and Some((Atom::Constant(_), Bool::FALSE, Bool::TRUE)).
    • Any scalar wave64 mask operation that produces a negated or compound BDD over scalar atoms — for example:
      • s_not_b64 vcc, s[2:3] (produces (Atom::Opaque(lo, hi), Bool::TRUE, Bool::FALSE)),
      • s_cselect_b64 vcc, 1, 2 (in structure.rs:1120, builds ite(Atom::Uniform(scc), Atom::Constant(1), Atom::Constant(2)), whose root is Atom::Uniform(scc)), or
      • scalar masks merged at a CFG join (Atom::Phi)
        misses whole and falls through to self.b.and(vcc, exec). For s_cselect_b64 vcc, 1, 2 + s_cbranch_vccnz, the whole wave must take the branch for either SCC value, but falling back to per-lane vcc & exec causes only lane 0 or lane 1 to take it (and a CFG join can produce a mask PHI whose scalar inputs the wave64 emitter rejects).
  2. Test coverage gaps (crates/victory-shader/src/emit/synthetic_tests.rs:681-684, crates/victory-shader/src/structure.rs:1767)

    • In vcc_branches_test_the_whole_mask, host.compute_pipeline(&shader) errors continue and assert!(ran > 0) is only checked once across all 6 cases. If the key vcc_hi = 1 case fails pipeline creation while vcc = 0 succeeds, the test still passes silently. Tracking a per-case run count (or failing on pipeline creation once a valid SM 6.6 device is created) avoids hiding regressions.
    • In structure.rs:1767, the second fixture sets vcc_lo = 0 and vcc_hi = -1 via two s_mov_b32 instructions, which creates Atom::Opaque(lo, hi) rather than Atom::Constant, so the Atom::Constant arm at structure.rs:1377 isn't actually exercised (and the assertion accepts either Bool::TRUE or Atom::Nonzero). Using a 64-bit constant move (e.g. s_mov_b64 vcc, 1) or testing s_cselect_b64 / s_not_b64 would directly cover the non-Opaque paths.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 03:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#pullrequestreview-6068343460) · **requested changes** Reviewed `8fc606d0` against `main` (`63bcca43`; `emit/lower.rs` stays at 520,714 bytes, safely under the 512 KiB limit). Two concrete issues to fix before merge: 1. **Scalar `VCC` expressions beyond a single positive `Atom::Opaque` / `Atom::Constant` still fall back to a per-lane branch (`crates/victory-shader/src/structure.rs:1371-1383`)** - `whole` only matches `Some((Atom::Opaque(lo, hi), Bool::FALSE, Bool::TRUE))` and `Some((Atom::Constant(_), Bool::FALSE, Bool::TRUE))`. - Any scalar wave64 mask operation that produces a negated or compound BDD over scalar atoms — for example: - `s_not_b64 vcc, s[2:3]` (produces `(Atom::Opaque(lo, hi), Bool::TRUE, Bool::FALSE)`), - `s_cselect_b64 vcc, 1, 2` (in `structure.rs:1120`, builds `ite(Atom::Uniform(scc), Atom::Constant(1), Atom::Constant(2))`, whose root is `Atom::Uniform(scc)`), or - scalar masks merged at a CFG join (`Atom::Phi`) misses `whole` and falls through to `self.b.and(vcc, exec)`. For `s_cselect_b64 vcc, 1, 2` + `s_cbranch_vccnz`, the whole wave must take the branch for either `SCC` value, but falling back to per-lane `vcc & exec` causes only lane 0 or lane 1 to take it (and a CFG join can produce a mask PHI whose scalar inputs the wave64 emitter rejects). 2. **Test coverage gaps (`crates/victory-shader/src/emit/synthetic_tests.rs:681-684`, `crates/victory-shader/src/structure.rs:1767`)** - In `vcc_branches_test_the_whole_mask`, `host.compute_pipeline(&shader)` errors `continue` and `assert!(ran > 0)` is only checked once across all 6 cases. If the key `vcc_hi = 1` case fails pipeline creation while `vcc = 0` succeeds, the test still passes silently. Tracking a per-case run count (or failing on pipeline creation once a valid SM 6.6 device is created) avoids hiding regressions. - In `structure.rs:1767`, the second fixture sets `vcc_lo = 0` and `vcc_hi = -1` via two `s_mov_b32` instructions, which creates `Atom::Opaque(lo, hi)` rather than `Atom::Constant`, so the `Atom::Constant` arm at `structure.rs:1377` isn't actually exercised (and the assertion accepts either `Bool::TRUE` or `Atom::Nonzero`). Using a 64-bit constant move (e.g. `s_mov_b64 vcc, 1`) or testing `s_cselect_b64` / `s_not_b64` would directly cover the non-`Opaque` paths.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 04:41 UTC · original · approved these changes

LGTM — making Atom::Opaque carry the pair (lo,hi) explicitly removes the fragile pair_high lookup; Nonzero ORs both dwords under wave64 with the hi!=lo dedup. cbranch_vccz/vccnz on a scalar VCC deciding on pair-nonzero matches hardware.

**@⁠kotekompotek** on GitHub · 2026-11-26 04:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3023#pullrequestreview-6068641335) · **approved these changes** LGTM — making Atom::Opaque carry the pair (lo,hi) explicitly removes the fragile pair_high lookup; Nonzero ORs both dwords under wave64 with the hi!=lo dedup. cbranch_vccz/vccnz on a scalar VCC deciding on pair-nonzero matches hardware.
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/3023/head:github-bot/gh-3023'
git switch 'github-bot/gh-3023'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3023'
git switch 'github-bot/gh-3023'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3023'
git switch 'github-bot/gh-3023'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3023'
git switch 'main'
git merge --squash 'github-bot/gh-3023'
git switch 'main'
git merge --ff-only 'github-bot/gh-3023'
git switch 'main'
git merge 'github-bot/gh-3023'
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!3023
No description provided.