wave64_halves: recognize UVOTE under non-zero EXEC and boolean UVOTE combinations (SHADER-10) #805

Merged
madhyn merged 2 commits from upstream-pr/805 into main 2026-11-28 11:08:46 +00:00
madhyn commented 2026-11-24 14:02:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T14:02:00Z.


What and why

In tools/wave64_halves.py, several wave-uniform compare/branch idioms in the retail 1.0.2.1 graphics corpus were conservatively marked Tier C (tainted-branch):

  1. Non-zero EXEC after s_cbranch_execz / s_cbranch_execnz (st["nz"]): when a block narrows EXEC and immediately skips empty halves with s_cbranch_execz (or enters the non-empty edge via s_cbranch_execnz), every 32-lane half reaching the non-zero edge has EXEC != 0. A subsequent uniform v_cmp_* (all scalar/immediate non-tainted operands) ANDed with EXEC produces the exact same branch decision in each reaching half as in the full 64-lane wave.
  2. Wave64 SGPR pair writes with n=1: disassemblies often print v_cmp_*_e64 sN, ... with a single-register operand (n=1), whereas wave64 v_cmp writes the 64-bit pair s[N:N+1]. Propagate UVOTE and taint to s[N+1] as well so s_and_b64 vcc, exec, s[N:N+1] sees UVOTE on both halves of the pair.
  3. Boolean UVOTE combinations: s_cselect_b64 dst, exec, 0 (or 0, exec) from an untainted SCC under launch/non-zero EXEC, and s_and_b64 / s_or_b64 combining UVOTE masks (e.g., two uniform compares combined before s_and_b64 vcc, exec, ...), preserve UVOTE.

Testing

  • Added 4 tests in tests/semantic/test_wave64_halves.py:
    • test_a_uvote_under_nonzero_exec
    • test_c_uvote_under_narrowed_exec_without_execz_guard (negative control: without s_cbranch_execz, stays Tier C)
    • test_a_uvote_and_or_combine
    • test_a_uvote_cselect_from_uniform_scc
  • python3 -m unittest tests/semantic/test_wave64_halves*.py tests/test_w64_graphics*.py: 190/190 passed.
  • Corpus check on the 745 retail 1.0.2.1 VS/PS shaders that previously had wave64_graphics_reasons == ['tainted-branch']: 276 shaders moved out of Tier C (11 Tier A, 265 Tier B).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473619422 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/805). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T14:02:00Z. --- ### What and why In `tools/wave64_halves.py`, several wave-uniform compare/branch idioms in the retail 1.0.2.1 graphics corpus were conservatively marked Tier C (`tainted-branch`): 1. **Non-zero EXEC after `s_cbranch_execz` / `s_cbranch_execnz` (`st["nz"]`):** when a block narrows `EXEC` and immediately skips empty halves with `s_cbranch_execz` (or enters the non-empty edge via `s_cbranch_execnz`), every 32-lane half reaching the non-zero edge has `EXEC != 0`. A subsequent uniform `v_cmp_*` (all scalar/immediate non-tainted operands) ANDed with `EXEC` produces the exact same branch decision in each reaching half as in the full 64-lane wave. 2. **Wave64 SGPR pair writes with `n=1`:** disassemblies often print `v_cmp_*_e64 sN, ...` with a single-register operand (`n=1`), whereas wave64 `v_cmp` writes the 64-bit pair `s[N:N+1]`. Propagate `UVOTE` and taint to `s[N+1]` as well so `s_and_b64 vcc, exec, s[N:N+1]` sees `UVOTE` on both halves of the pair. 3. **Boolean `UVOTE` combinations:** `s_cselect_b64 dst, exec, 0` (or `0, exec`) from an untainted `SCC` under launch/non-zero `EXEC`, and `s_and_b64` / `s_or_b64` combining `UVOTE` masks (e.g., two uniform compares combined before `s_and_b64 vcc, exec, ...`), preserve `UVOTE`. ### Testing - Added 4 tests in `tests/semantic/test_wave64_halves.py`: - `test_a_uvote_under_nonzero_exec` - `test_c_uvote_under_narrowed_exec_without_execz_guard` (negative control: without `s_cbranch_execz`, stays Tier C) - `test_a_uvote_and_or_combine` - `test_a_uvote_cselect_from_uniform_scc` - `python3 -m unittest tests/semantic/test_wave64_halves*.py tests/test_w64_graphics*.py`: **190/190 passed**. - Corpus check on the 745 retail 1.0.2.1 VS/PS shaders that previously had `wave64_graphics_reasons == ['tainted-branch']`: **276 shaders** moved out of Tier C (**11 Tier A**, **265 Tier B**). AI-assisted: yes
KernelSmoker commented 2026-11-24 14:09:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:09:12Z.

Review: COMMENTED


Linux CPU review of the Wave64 classifier change. On this exact head, these four focused modules passed: tests/semantic/test_wave64_halves.py (130), test_wave64_halves_soundness.py (33), test_wave64_halves_partial_dst.py (13), and test_wave64_halves_readlane_uniform.py (2), for 178/178 total. git diff --check also passed.

The new nz fact is propagated only along the non-empty branch of s_cbranch_execz / the taken branch of s_cbranch_execnz, and is intersected at joins. I found no issue in that flow by inspection.

tests/test_wave64_halves_fixtures.py was not run: it requires pytest, which is absent from the local Python/tool image; installing it in a temporary container stalled on network access. No GPU or game data was used, and no GPU result is claimed.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6040711515 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/805#pullrequestreview-6040711515). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:09:12Z. **Review:** COMMENTED --- Linux CPU review of the Wave64 classifier change. On this exact head, these four focused modules passed: `tests/semantic/test_wave64_halves.py` (130), `test_wave64_halves_soundness.py` (33), `test_wave64_halves_partial_dst.py` (13), and `test_wave64_halves_readlane_uniform.py` (2), for 178/178 total. `git diff --check` also passed. The new `nz` fact is propagated only along the non-empty branch of `s_cbranch_execz` / the taken branch of `s_cbranch_execnz`, and is intersected at joins. I found no issue in that flow by inspection. `tests/test_wave64_halves_fixtures.py` was not run: it requires pytest, which is absent from the local Python/tool image; installing it in a temporary container stalled on network access. No GPU or game data was used, and no GPU result is claimed.
GeorgiyDemo commented 2026-11-24 14:11:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-24T14:11:35Z.


Tested 3986b73a on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against main d42773d07:

  • tests/semantic/test_wave64_halves.py: 130 tests OK at this head.
  • The same file against main's tools/wave64_halves.py fails 2 of 130, so the two new UVOTE classifications are covered.

No GPU leg: no w64_graphics tier fixture exercises UVOTE, and I did not run the tier harness on this head. AI-assisted; synthetic fixtures only, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7133983413 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7133983413). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-24T14:11:35Z. --- Tested `3986b73a` on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against `main` `d42773d07`: - `tests/semantic/test_wave64_halves.py`: 130 tests OK at this head. - The same file against `main`'s `tools/wave64_halves.py` fails 2 of 130, so the two new UVOTE classifications are covered. No GPU leg: no `w64_graphics` tier fixture exercises UVOTE, and I did not run the tier harness on this head. AI-assisted; synthetic fixtures only, no game data.
KernelSmoker commented 2026-11-24 14:18:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:18:46Z.


Follow-up on the latest PR head 3f7e9f2d3a7eb3d2ec1c80f3ef480bf7362f6699 (including the WQM/EXEC restore change): I reran the full semantic suite in an isolated Fedora 45 tool container with Python 3.15.2, LLVM and SPIRV-Tools. Result: 465 files, 6,113 tests, 0 files failed in 105 seconds with 16 jobs. This is CPU/interpreter validation only; no Vulkan/GPU execution or game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7134171136 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7134171136). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:18:46Z. --- Follow-up on the latest PR head `3f7e9f2d3a7eb3d2ec1c80f3ef480bf7362f6699` (including the WQM/EXEC restore change): I reran the full semantic suite in an isolated Fedora 45 tool container with Python 3.15.2, LLVM and SPIRV-Tools. Result: 465 files, 6,113 tests, 0 files failed in 105 seconds with 16 jobs. This is CPU/interpreter validation only; no Vulkan/GPU execution or game data.
Sangonapou commented 2026-11-24 16:41:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Sangonapou on 2026-11-24T16:41:58Z.


Tested 3f7e9f2d on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, GPU regression check

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51); shaders from runtime/test/shaders/build.py at this head (llvm-mc 23.1.6, SPIRV-Tools 2026.4); then python -I runtime/test/shaders/w64_graphics.py <spirv dir> runtime\build, exit 0. No game files.

  • Tier A 9/9 and tier B 8/8 ok, running as two 32-lane halves on this device.
  • Tier C 12/12 SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF).

This is the GPU leg the CPU checks above did not cover, but as noted there no w64_graphics fixture uses the new UVOTE patterns, so it shows the tier harness still passes on a 32-wide device at this head rather than exercising the new classifications themselves.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138070372 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7138070372). Originally posted by [Sangonapou](https://github.com/Sangonapou) on 2026-11-24T16:41:58Z. --- Tested 3f7e9f2d on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, GPU regression check Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51); shaders from `runtime/test/shaders/build.py` at this head (`llvm-mc` 23.1.6, SPIRV-Tools 2026.4); then `python -I runtime/test/shaders/w64_graphics.py <spirv dir> runtime\build`, exit 0. No game files. - Tier A 9/9 and tier B 8/8 `ok`, running as two 32-lane halves on this device. - Tier C 12/12 `SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF)`. This is the GPU leg the CPU checks above did not cover, but as noted there no `w64_graphics` fixture uses the new UVOTE patterns, so it shows the tier harness still passes on a 32-wide device at this head rather than exercising the new classifications themselves.
madhyn commented 2026-11-25 01:56:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-25T01:56:09Z.


Rebased onto current main (871e4b8b9, head 62e547220), resolving the tools/wave64_halves.py conflict with SHADER-W64-WQM-UVOTE (#1091):

  • Preserved st["q"] / st["qr"] and uniform_cmp's VGPR refusal outside launch EXEC.
  • Kept st["q"] = quads on the s_wqm_b64 exec, exec path alongside wqm_base tracking so restoring launch EXEC via s_and_b64 exec, exec, s[saved] still restores st["f"] while clearing st["q"].

Verified after rebase (Python 3.14, Arch Linux):

  • python3 -I scripts/check_no_game_data.py tools/wave64_halves.py tests/semantic/test_wave64_halves.py: pass
  • python3 -m unittest tests/semantic/test_wave64_halves*.py tests/test_w64_graphics*.py: 210/210 passed (including all test_wave64_halves_wqm_uvote.py cases and NearMisses)
  • python3 -I scripts/run_semantic_tests.py tests/semantic: 484 files, 6,267 tests, 0 failures

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7150129818 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7150129818). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-25T01:56:09Z. --- Rebased onto current `main` (`871e4b8b9`, head `62e547220`), resolving the `tools/wave64_halves.py` conflict with `SHADER-W64-WQM-UVOTE` (#1091): - Preserved `st["q"]` / `st["qr"]` and `uniform_cmp`'s VGPR refusal outside launch `EXEC`. - Kept `st["q"] = quads` on the `s_wqm_b64 exec, exec` path alongside `wqm_base` tracking so restoring launch `EXEC` via `s_and_b64 exec, exec, s[saved]` still restores `st["f"]` while clearing `st["q"]`. Verified after rebase (Python 3.14, Arch Linux): - `python3 -I scripts/check_no_game_data.py tools/wave64_halves.py tests/semantic/test_wave64_halves.py`: pass - `python3 -m unittest tests/semantic/test_wave64_halves*.py tests/test_w64_graphics*.py`: **210/210 passed** (including all `test_wave64_halves_wqm_uvote.py` cases and NearMisses) - `python3 -I scripts/run_semantic_tests.py tests/semantic`: **484 files, 6,267 tests, 0 failures** AI-assisted: yes
potatoe0100 commented 2026-11-25 10:12:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T10:12:54Z.


Tested the rebased head 62e547220 merged onto main 57ba40bd6 (clean merge) on Windows 11 Pro 26300, Python 3.14: tests/semantic/test_wave64_halves.py 132 passed. On the same machine (RTX 4060, 621.14) w64_graphics.py on today's main gives 18 ok / 12 tier C SKIP / 0 failed; this change touches no GPU fixture, so I didn't rerun it per head.

No game files. AI-assisted (Claude Code), run for a non-developer tester.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159388236 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7159388236). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-25T10:12:54Z. --- Tested the rebased head `62e547220` merged onto `main` `57ba40bd6` (clean merge) on Windows 11 Pro 26300, Python 3.14: `tests/semantic/test_wave64_halves.py` 132 passed. On the same machine (RTX 4060, 621.14) `w64_graphics.py` on today's `main` gives 18 ok / 12 tier C SKIP / 0 failed; this change touches no GPU fixture, so I didn't rerun it per head. No game files. AI-assisted (Claude Code), run for a non-developer tester.
MoonEyes commented 2026-11-28 11:08:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T11:08:43Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238356268 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/805#issuecomment-7238356268). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T11:08:43Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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
ProjectLeonida/mandy!805
No description provided.