compute: classify remaining scalar ops in direct SCC liveness #3611

Manually merged
github merged 2 commits from github-bot/gh-3609 into gh-pr/3609/base 2026-11-30 15:55:56 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-11-30 13:36 UTC · original
Ammmae0x:compute/direct-scc-liveness → main · +982 −3 · 6 files · 2 commits · merged 2026-11-30 15:51 UTC

Refs #3226, #2935

Issue #3226's census still lists the "numeric SCC from a symbolic descriptor field" refusal (2 shaders / 203,617 dispatches in 8ecd30fe) after #3229 and #3303.

Change

uses_scc_after() (src/gfx1013_direct_compute.inl) treated every SOPK op except s_movk_i32 as uncertain and missed SCC writers and readers, so programs that kill or preserve SCC through those ops were refused as if SCC were still live at a symbolic descriptor field:

  • Overwriters: s_bfe_i32, s_addk_i32, all twelve s_cmpk_* (they write SCC from the extracted value, the signed overflow, or the comparison result, without reading incoming SCC).
  • Preservers: s_mulk_i32, the four counter waits (s_waitcnt_vscnt/vmcnt/expcnt/lgkmcnt), s_setreg_b32, s_setreg_imm32_b32 (new preserves_sopk list; the Sopk uncertain clause now excludes overwriters and preservers).
  • Readers: s_addc_u32, s_subb_u32 (they consume SCC through read(128)).

Unimplemented scalar ops stay uncertain. SOPP ops are not listed: the uncertain test never matches them, so lowered ones fall through and preserve SCC. s_setreg_b32 is classified as a preserver although consume_half_mode() never accepts it in compute, so any program containing it still refuses at lowering. s_wqm_b32/s_wqm_b64 stay in mask_scc although arithmetic() does not lower them.

WIN-VERIFY fix (f4d347b1)

Windows dev verification of c60704bf compiled the C++ cleanly and caught three fixture bugs in tests/native_scc_liveness_check.py (the translator change itself is untouched):

  1. The field was extracted in prologue(), before group_base(), whose s_lshl_b32 overwrites SCC, so all 15 SCC refusals returned rc=0 instead of refusing. The field now comes after the group base and the SGPR initializations (new base_words() helper), so the field's SCC is the one the tested instruction sees.
  2. s24 and s27 were read unbound in several controls programs (pass-mode, pass-nop, pass-branch-over-reader, refuse-cbranch-scc1, refuse-diamond-one-overwrite). The base now initializes them (movk(24, 1) + movk(27, 0); movk(24, 6) for the one-arm-overwrite diamond), and the stride-bound positive control uses the same base.
  3. hardware_program() stored s25 numerically, but the stride field value is symbolic. Slot 15 now re-extracts the field and proves the mode writes (s_round_mode 0, s_denorm_mode 0xf, s_setreg_imm32_b32) preserve its SCC into s_cselect_b32.

The no-arg audit now also pins the base initializations and the pass/refusal split itself: between the field and the first SCC reader, every pass program has an overwriter (except the branch-over-reader, which passes by skipping the reader) and every SCC refusal program has none (except the diamond that refuses on its preserving arm, and the three mode refusals, which refuse on the mode op).

Verification (Linux)

No-arg audit, run from the repository root:

python3 -B tests/native_scc_liveness_check.py
encodings: 29 controls programs and the hardware program disassemble as written, with branch targets pinned and the pass/refusal split pinned to the overwriter window
audit: 199 scalar ops in the ISA tables match the census; 53 CFG programs agree between the parsed classification, the census and the hand-computed expectations; mutation audit killed 25/25; native_direct_container scc_overwrite_names still parses

Full Linux check suite (the python-linux job shape):

python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linux <inline list>
all 277 checks passed

Plus tests/form_coverage_check.py, tests/docs_links_check.py (187 files, 738 links), tests/bidi_controls_check.py (2728 files), py_compile, git diff --check — all clean; git merge-tree --write-tree origin/main HEAD exits 0.

controls and hardware modes (native_scc_liveness_controls, native_scc_liveness_hardware) need compile_dxil and native_store_replay on Windows and are not covered by the Linux run above.

Windows Verification (f4d347b1)

Commit: f4d347b1ace35394f5350d40b60480829929e938 (merge-tree upstream/main -> clean, exit 0)
Host: Windows 11 build 26100.7623, NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186, XBOX2WINDOWS_ADAPTER=NVIDIA)
dev: cmake --build --preset dev --target compile_dxil native_store_replay
dev: ctest --preset dev --no-tests=error -R '^(native_scc_liveness_(controls|hardware)|native_direct_container|native_descriptor_scc.*)$' --output-on-failure -> 4 passed, 1 skipped (23.77s; controls 1.84s, hardware 1.06s)
release: cmake --build --preset release --target compile_dxil native_store_replay
release: ctest --preset release --no-tests=error -R '^(native_scc_liveness_(controls|hardware)|native_direct_container|native_descriptor_scc.*)$' -E 'cpu_native_archive_' --output-on-failure -> 4 passed, 1 skipped (21.46s; controls 1.47s, hardware 1.24s)
Skips (exit 77): Win11 inbox WARP has no 32-lane waves (native_descriptor_scc_warp)
Replay: controls (8 pass, 21 refusal pinned, stride-bound pass) and hardware (stride 0 & 4, 16 output words + guards) -> passed
Checks: native_scc_liveness_check.py (199 ISA ops, 53 CFG, 25/25 mutants), form_coverage_check.py, docs_links_check.py (187 files, 738 links), bidi_controls_check.py (2728 files) -> passed

AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-11-30 13:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3609) `Ammmae0x:compute/direct-scc-liveness` → `main` · +982 −3 · 6 files · 2 commits · merged 2026-11-30 15:51 UTC Refs #3226, #2935 Issue #3226's census still lists the "numeric SCC from a symbolic descriptor field" refusal (2 shaders / 203,617 dispatches in 8ecd30fe) after #3229 and #3303. ## Change `uses_scc_after()` (`src/gfx1013_direct_compute.inl`) treated every SOPK op except `s_movk_i32` as uncertain and missed SCC writers and readers, so programs that kill or preserve SCC through those ops were refused as if SCC were still live at a symbolic descriptor field: - Overwriters: `s_bfe_i32`, `s_addk_i32`, all twelve `s_cmpk_*` (they write SCC from the extracted value, the signed overflow, or the comparison result, without reading incoming SCC). - Preservers: `s_mulk_i32`, the four counter waits (`s_waitcnt_vscnt`/`vmcnt`/`expcnt`/`lgkmcnt`), `s_setreg_b32`, `s_setreg_imm32_b32` (new `preserves_sopk` list; the Sopk uncertain clause now excludes overwriters and preservers). - Readers: `s_addc_u32`, `s_subb_u32` (they consume SCC through `read(128)`). Unimplemented scalar ops stay uncertain. SOPP ops are not listed: the uncertain test never matches them, so lowered ones fall through and preserve SCC. `s_setreg_b32` is classified as a preserver although `consume_half_mode()` never accepts it in compute, so any program containing it still refuses at lowering. `s_wqm_b32`/`s_wqm_b64` stay in `mask_scc` although `arithmetic()` does not lower them. ## WIN-VERIFY fix (f4d347b1) Windows dev verification of `c60704bf` compiled the C++ cleanly and caught three fixture bugs in `tests/native_scc_liveness_check.py` (the translator change itself is untouched): 1. The field was extracted in `prologue()`, before `group_base()`, whose `s_lshl_b32` overwrites SCC, so all 15 SCC refusals returned `rc=0` instead of refusing. The field now comes after the group base and the SGPR initializations (new `base_words()` helper), so the field's SCC is the one the tested instruction sees. 2. `s24` and `s27` were read unbound in several controls programs (`pass-mode`, `pass-nop`, `pass-branch-over-reader`, `refuse-cbranch-scc1`, `refuse-diamond-one-overwrite`). The base now initializes them (`movk(24, 1)` + `movk(27, 0)`; `movk(24, 6)` for the one-arm-overwrite diamond), and the stride-bound positive control uses the same base. 3. `hardware_program()` stored `s25` numerically, but the stride field value is symbolic. Slot 15 now re-extracts the field and proves the mode writes (`s_round_mode 0`, `s_denorm_mode 0xf`, `s_setreg_imm32_b32`) preserve its SCC into `s_cselect_b32`. The no-arg audit now also pins the base initializations and the pass/refusal split itself: between the field and the first SCC reader, every pass program has an overwriter (except the branch-over-reader, which passes by skipping the reader) and every SCC refusal program has none (except the diamond that refuses on its preserving arm, and the three mode refusals, which refuse on the mode op). ## Verification (Linux) No-arg audit, run from the repository root: ``` python3 -B tests/native_scc_liveness_check.py ``` ``` encodings: 29 controls programs and the hardware program disassemble as written, with branch targets pinned and the pass/refusal split pinned to the overwriter window audit: 199 scalar ops in the ISA tables match the census; 53 CFG programs agree between the parsed classification, the census and the hand-computed expectations; mutation audit killed 25/25; native_direct_container scc_overwrite_names still parses ``` Full Linux check suite (the `python-linux` job shape): ``` python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linux <inline list> all 277 checks passed ``` Plus `tests/form_coverage_check.py`, `tests/docs_links_check.py` (187 files, 738 links), `tests/bidi_controls_check.py` (2728 files), `py_compile`, `git diff --check` — all clean; `git merge-tree --write-tree origin/main HEAD` exits 0. `controls` and `hardware` modes (`native_scc_liveness_controls`, `native_scc_liveness_hardware`) need `compile_dxil` and `native_store_replay` on Windows and are not covered by the Linux run above. ### Windows Verification (f4d347b1) ```text Commit: f4d347b1ace35394f5350d40b60480829929e938 (merge-tree upstream/main -> clean, exit 0) Host: Windows 11 build 26100.7623, NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186, XBOX2WINDOWS_ADAPTER=NVIDIA) dev: cmake --build --preset dev --target compile_dxil native_store_replay dev: ctest --preset dev --no-tests=error -R '^(native_scc_liveness_(controls|hardware)|native_direct_container|native_descriptor_scc.*)$' --output-on-failure -> 4 passed, 1 skipped (23.77s; controls 1.84s, hardware 1.06s) release: cmake --build --preset release --target compile_dxil native_store_replay release: ctest --preset release --no-tests=error -R '^(native_scc_liveness_(controls|hardware)|native_direct_container|native_descriptor_scc.*)$' -E 'cpu_native_archive_' --output-on-failure -> 4 passed, 1 skipped (21.46s; controls 1.47s, hardware 1.24s) Skips (exit 77): Win11 inbox WARP has no 32-lane waves (native_descriptor_scc_warp) Replay: controls (8 pass, 21 refusal pinned, stride-bound pass) and hardware (stride 0 & 4, 16 output words + guards) -> passed Checks: native_scc_liveness_check.py (199 ISA ops, 53 CFG, 25/25 mutants), form_coverage_check.py, docs_links_check.py (187 files, 738 links), bidi_controls_check.py (2728 files) -> passed ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=f4d347b1ace35394f5350d40b60480829929e938 -->
Refs #3224, #2935

uses_scc_after() treated every SOPK op except s_movk_i32 as uncertain
and missed SCC writers (s_bfe_i32, s_addk_i32, all twelve s_cmpk_*) and
readers (s_addc_u32, s_subb_u32), so programs that kill or preserve SCC
through those ops were refused as if SCC were still live at a symbolic
descriptor field. The overwrite list now names the three writers, a new
preserves_sopk list names s_mulk_i32, the four counter waits and the mode
writes, and the readers join reads_scc. Unimplemented scalar ops stay
uncertain and SOPP ops keep their fallthrough behavior.

tests/native_scc_liveness_check.py pins the classification without
Windows: its no-arg mode checks all 199 scalar ops in the ISA tables
against the census, runs a Python replica of the backward walk over 53
straight-line and branching programs, and kills 25 of 25 single-condition
mutants. controls and hardware modes compile and replay the pass, refusal
and boundary programs on Windows.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 13:38:08 +00:00
Windows dev verification of c60704bf compiled the C++ cleanly but
caught three fixture bugs in tests/native_scc_liveness_check.py:

- The field was extracted in prologue(), before group_base(), whose
  s_lshl_b32 overwrites SCC, so all 15 SCC refusals returned rc=0.
  The field now comes after the group base and the SGPR initializations
  (new base_words() helper), so the field's SCC is the one the tested
  instruction sees.
- s24 and s27 were read unbound in several controls programs. The base
  now initializes them (movk(24, 1) + movk(27, 0); movk(24, 6) for the
  one-arm-overwrite diamond), and the stride-bound positive control
  uses the same base.
- hardware_program() stored s25 numerically, but the stride field value
  is symbolic. Slot 15 now re-extracts the field and proves the mode
  writes (s_round_mode 0, s_denorm_mode 0xf, s_setreg_imm32_b32)
  preserve its SCC into s_cselect_b32.

The no-arg audit now also pins the base initializations and the
pass/refusal split itself: between the field and the first SCC reader,
every pass program has an overwriter (except the branch-over-reader,
which passes by skipping the reader) and every SCC refusal program
has none (except the diamond that refuses on its preserving arm, and
the three mode refusals, which refuse on the mode op).

Linux: no-arg audit passes (199 scalar ops, 53 CFG programs, 25/25
mutants killed), run_checks_parallel 277/277, form/docs/bidi pass
(187 files/738 links, 2728 files), py_compile and diff --check clean,
merge-tree exits 0.

Refs #3224, #2935
github-bot changed target branch from main to gh-pr/3609/base 2026-11-30 15:55:54 +00:00
github manually merged commit f4d347b1ac into gh-pr/3609/base 2026-11-30 15:55:56 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-30 15:51 UTC · original · approved these changes

Independent Release retest of f4d347b1: built compile_dxil and native_store_replay; ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^(native_scc_liveness_.*|native_direct_container)$' passed 3/3 with zero skips, including the RTX hardware replay. The liveness scan still prioritizes real consumers and only stops on unconditional writes. The fixture keeps carry/borrow reads, the one-arm branch negative and mode-preservation checks.

**@⁠R0Y00** on GitHub · 2026-11-30 15:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3609#pullrequestreview-6115467207) · **approved these changes** Independent Release retest of `f4d347b1`: built `compile_dxil` and `native_store_replay`; `ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^(native_scc_liveness_.*|native_direct_container)$'` passed 3/3 with zero skips, including the RTX hardware replay. The liveness scan still prioritizes real consumers and only stops on unconditional writes. The fixture keeps carry/borrow reads, the one-arm branch negative and mode-preservation checks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.