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

Open
github-bot wants to merge 2 commits from github-bot/gh-805 into main AGit
Owner

@⁠madhyn on GitHub · 2026-11-24 14:02 UTC · original
madhyn:fix/shader10-uvote-nonzero-combine → main · +82 −17 · 2 files · 2 commits · open

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

**@⁠madhyn** on GitHub · 2026-11-24 14:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805) `madhyn:fix/shader10-uvote-nonzero-combine` → `main` · +82 −17 · 2 files · 2 commits · open ### 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:22:10 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 14:09 UTC · original · reviewed

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.

**@⁠KernelSmoker** on GitHub · 2026-11-24 14:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#pullrequestreview-6040711515) · **reviewed** 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.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 14:11 UTC · original

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.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 14:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7133983413) 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.
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 14:18 UTC · original

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.

**@⁠KernelSmoker** on GitHub · 2026-11-24 14:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7134171136) 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.
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 16:41 UTC · original

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.

**@⁠Sangonapou** on GitHub · 2026-11-24 16:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7138070372) 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.
Author
Owner

@⁠madhyn on GitHub · 2026-11-25 01:56 UTC · original

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

**@⁠madhyn** on GitHub · 2026-11-25 01:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7150129818) 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
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 10:12 UTC · original

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.

**@⁠potatoe0100** on GitHub · 2026-11-25 10:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/805#issuecomment-7159388236) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/805/head:github-bot/gh-805'
git switch 'github-bot/gh-805'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-805'
git switch 'github-bot/gh-805'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-805'
git switch 'github-bot/gh-805'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-805'
git switch 'main'
git merge --squash 'github-bot/gh-805'
git switch 'main'
git merge --ff-only 'github-bot/gh-805'
git switch 'main'
git merge 'github-bot/gh-805'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.