Shaders: follow EXEC set from a scalar the section made constant #90

Closed
github-bot wants to merge 1 commit from gh-pr/90/head into gh-pr/90/base
Owner

@⁠dutch2005 on GitHub · 2026-11-25 13:45 UTC · original
fix/shader-exec-scalar → main · +65 −3 · 1 files · 1 commits · closed without merging

Why

A whole-wave section that sets EXEC from a scalar it computed itself (s_mov_b32 s5, -1 then s_mov_b32 exec_lo, s5) stopped the section simulation at the EXEC write, because only inline constants and literals were followed. The lanes after it then lost their shape. Ported from the open upstream PR Marvisak/VIctory#2382 (by Calvix2k); this tree still stops at the scalar copy.

What

  • The section simulation remembers scalars it set to a constant (sconst) and follows an EXEC write from one of them.
  • A non-constant write to a scalar drops what it held.
  • Adds the upstream regression test: s_or_saveexec, s_mov s5, -1, s_mov exec_lo, s5, v_mov v2, 7, restore; v2 keeps shape K(7).

Review fix

gut0to found that a 64-bit scalar move writes two SGPR halves but inst.writes carries one constant value, so tracking it per half could seed the wrong value for a later s_mov_b32 exec_hi. Only plain s_mov_b32 moves now seed the map; a pure seeds_scalar_constant helper and test lock that rule.

Testing

  • cargo test -p victory-shader --lib scalar_constant -- --test-threads=1 — 2 passed, 0 failed: the original EXEC-from-scalar case and the wide-move exclusion.
  • Mutation coverage on the diff: 9 caught, 1 equivalent. The equivalent mutant is the code != NULL guard in constant (the null SGPR is not readable and sconst never holds it); documented in PR #108's policy.
  • Full workspace on all fixes: 562 passed, 0 failed (before the latest test additions).

Notes

No change for sections whose EXEC is set directly from an inline constant or literal; only the scalar-copy form is newly followed.

**@⁠dutch2005** on GitHub · 2026-11-25 13:45 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/90) `fix/shader-exec-scalar` → `main` · +65 −3 · 1 files · 1 commits · closed without merging ## Why A whole-wave section that sets `EXEC` from a scalar it computed itself (`s_mov_b32 s5, -1` then `s_mov_b32 exec_lo, s5`) stopped the section simulation at the `EXEC` write, because only inline constants and literals were followed. The lanes after it then lost their shape. Ported from the open upstream PR Marvisak/VIctory#2382 (by Calvix2k); this tree still stops at the scalar copy. ## What - The section simulation remembers scalars it set to a constant (`sconst`) and follows an `EXEC` write from one of them. - A non-constant write to a scalar drops what it held. - Adds the upstream regression test: `s_or_saveexec`, `s_mov s5, -1`, `s_mov exec_lo, s5`, `v_mov v2, 7`, restore; v2 keeps shape `K(7)`. ## Review fix gut0to found that a 64-bit scalar move writes two SGPR halves but `inst.writes` carries one constant value, so tracking it per half could seed the wrong value for a later `s_mov_b32 exec_hi`. Only plain `s_mov_b32` moves now seed the map; a pure `seeds_scalar_constant` helper and test lock that rule. ## Testing - `cargo test -p victory-shader --lib scalar_constant -- --test-threads=1` — 2 passed, 0 failed: the original EXEC-from-scalar case and the wide-move exclusion. - Mutation coverage on the diff: **9 caught, 1 equivalent**. The equivalent mutant is the `code != NULL` guard in `constant` (the null SGPR is not readable and `sconst` never holds it); documented in PR #108's policy. - Full workspace on all fixes: 562 passed, 0 failed (before the latest test additions). ## Notes No change for sections whose `EXEC` is set directly from an inline constant or literal; only the scalar-copy form is newly followed.
A whole-wave section that copies a computed all-ones scalar into EXEC stopped the simulation there, losing the shapes after it. The simulation now remembers constant scalars and follows the copy; a non-constant write drops what the scalar held. Only plain 32-bit moves seed the map: a 64-bit move's two writes share one value, so it must not be tracked per half.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:29 +00:00
github-bot closed this pull request 2026-11-26 03:35:29 +00:00
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:35 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at d64ca87: cargo test -p victory-shader --lib --locked: 267 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). The PR has moved to 8b89fe8 since. Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:35 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/90#issuecomment-7168229997) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `d64ca87`: `cargo test -p victory-shader --lib --locked`: **267 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). The PR has moved to `8b89fe8` since. Workspace tests only; not run in the title.
@ -375,0 +379,4 @@
// what the scalar held. A 64-bit move is not tracked here: both
// halves are in `inst.writes` with the same constant, but only
// the low half holds it (review on #90).
for &(_, w) in &inst.writes {
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 14:49 UTC · original

Could this track each written dword separately for s_mov_b64? inst.writes contains both SGPR halves, but this loop stores the same u64 in each. For s_mov_b64 s[4:5], 1, the upper SGPR is 0; recording it as 1 can make a later s_mov_b32 exec_hi, s5 simulate the wrong lanes. Please add a 64-bit move regression case and split the tracked value into low/high halves. AI-assisted review.

**@⁠gut0to** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/90#discussion_r4696638090) Could this track each written dword separately for s_mov_b64? inst.writes contains both SGPR halves, but this loop stores the same u64 in each. For s_mov_b64 s[4:5], 1, the upper SGPR is 0; recording it as 1 can make a later s_mov_b32 exec_hi, s5 simulate the wrong lanes. Please add a 64-bit move regression case and split the tracked value into low/high halves. AI-assisted review.
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 14:49 UTC · original · reviewed

AI-assisted review: I checked the IR write expansion and the affected EXEC path.

**@⁠gut0to** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/90#pullrequestreview-6059864091) · **reviewed** AI-assisted review: I checked the IR write expansion and the affected EXEC path.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.