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

Open
opened 2026-11-26 20:19:14 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/805
Author: @madhyn
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/shader10-uvote-nonzero-combine


📝 Commits (2)

  • d77ce93 wave64_halves: recognize UVOTE under non-zero EXEC and boolean UVOTE combinations (SHADER-10)
  • 62e5472 wave64_halves: restore EXEC launch mask across s_wqm_b64 + s_and_b64

📊 Changes

2 files changed (+82 additions, -17 deletions)

View changed files

📝 tests/semantic/test_wave64_halves.py (+32 -0)
📝 tools/wave64_halves.py (+50 -17)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/805 **Author:** [@madhyn](https://github.com/madhyn) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader10-uvote-nonzero-combine` --- ### 📝 Commits (2) - [`d77ce93`](https://github.com/ubiquitarianism/leonida/commit/d77ce933aa468564b1ab32f8511f342b7af97185) wave64_halves: recognize UVOTE under non-zero EXEC and boolean UVOTE combinations (SHADER-10) - [`62e5472`](https://github.com/ubiquitarianism/leonida/commit/62e54722010c9057b6798ef7f02559b5f2037895) wave64_halves: restore EXEC launch mask across s_wqm_b64 + s_and_b64 ### 📊 Changes **2 files changed** (+82 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_wave64_halves.py` (+32 -0) 📝 `tools/wave64_halves.py` (+50 -17) </details> ### 📄 Description ### 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#843
No description provided.