[PR #1091] [MERGED] wave64_halves: a vote on a scalar compare under whole-quad EXEC is no lane vote (SHADER-W64-WQM-UVOTE) #1127

Closed
opened 2026-11-26 20:20:10 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1091
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: shader-w64-wqm-uvote


📝 Commits (3)

  • bc7143b rdna2spirv: a wave64 VALU mask operand printed as one SGPR is the pair (SHADER-W64-SDST-PAIR)
  • f034185 wave64_halves: a vote on a scalar compare under whole-quad EXEC is no lane vote (SHADER-W64-WQM-UVOTE)
  • 6c5c079 Merge main into shader-w64-wqm-uvote

📊 Changes

8 files changed (+399 additions, -13 deletions)

View changed files

📝 docs/design.md (+2 -0)
➕ runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm (+53 -0)
📝 runtime/test/shaders/w64_graphics.py (+2 -0)
➕ tests/semantic/test_wave64_halves_wqm_uvote.py (+188 -0)
➕ tests/semantic/test_wave64_single_sdst.py (+87 -0)
📝 tests/test_wave64_halves_fixtures.py (+1 -0)
📝 tools/rdna2spirv.py (+26 -0)
📝 tools/wave64_halves.py (+40 -13)

📄 Description

Item: SHADER-W64-WQM-UVOTE

Depends on: #1021 (its commit is the first one in this branch; only the second is this change)

A pixel shader that needs derivatives starts with s_wqm_b64 exec, exec. LLVM branches on wave-uniform conditions inside that region the way it does anywhere: v_cmp_* sN of scalars, s_and_b64 vcc, exec, s[N:N+1], s_cbranch_vccnz. SHADER-10 took that for no lane vote only while EXEC was the launch mask, so under the whole quads it was tier C unsafe-vote-branch.

Why it is exact

  • The compare reads immediates and scalars only, so it is the same in every lane: its mask is every lane of EXEC or none.
  • EXEC is the whole quads of the launch mask. A quad is four consecutive lanes and never straddles the two 32-lane halves, and a half that runs has a launch lane. So EXEC has a lane in every half that runs, and each half votes as the wave does.

What stays tier C

  • A VGPR source, even one SHADER-10 calls uniform: it was written under the launch mask and the helper lanes never got it.
  • The whole quads of a narrowed EXEC, and any narrowing after the s_wqm_b64: a half can be empty.
  • Whole quads saved and put back, or made in a register and copied to EXEC: only the write by s_wqm_b64 exec, exec is modelled.
  • A path on which a scalar was read out of a uniform VGPR from a lane the launch mask may not have written (v_readlane_b32, or v_readfirstlane_b32 while EXEC is not the launch mask).

Corpus (1.0.2.1, all 26,503, wave64_halves.analyse on every wave64 VS/PS/GS)

Baseline is #1021 on main 3ed8e50b7. Without #1021 the listings' one-register destinations hide the vote behind tainted-branch.

A B C
#1021 5,267 397 7,741
#1021 + this 5,719 397 7,289

452 pixel shaders go from C to A. No shader moves from A or B to C, and no vertex or geometry shader moves. unsafe-vote-branch 7,362 -> 6,861, tainted-exec 5,829 -> 5,793, stale-scalar 3,287 -> 3,254.

Tested

  • tests/semantic/test_wave64_halves_wqm_uvote.py (new, 18 tests): the accepted forms in both printed forms of the destination, ten near misses that stay tier C, and a vertex and a pixel shader run on the wave interpreter as one wave of 64 lanes and as two of 32, equal and equal to the derived words. With #1021 alone 14 of them fail.
  • GPU: ps_w64_a_wqm_uniform_vote through runtime/test/shaders/w64_graphics.py on an NVIDIA GeForce RTX 4070 Ti, Linux, driver 620.70.06, subgroup 32 only: the words its header derives. That device has one subgroup size, so the 64-lane image was not drawn, and the full-screen draw has no partly covered quad. It confirms the translated SPIR-V against the ISA reference, not native RDNA2 behaviour.
  • python -I scripts/run_semantic_tests.py tests/semantic: 472 files, 6,186 tests, 0 files failed. tests/test_wave64_halves_fixtures.py and the test_w64_graphics*.py files: 22 passed.

Overlap

#805 edits the same lines of uniform_cmp and the state dict. It handles EXEC after it is put back from whole quads; this handles the compare under them. They merge by hand; whichever lands second needs a rebase.

No game data: counts and opcode names only. AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 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/1091 **Author:** [@milk4sale](https://github.com/milk4sale) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `shader-w64-wqm-uvote` --- ### 📝 Commits (3) - [`bc7143b`](https://github.com/ubiquitarianism/leonida/commit/bc7143b5f18ba8fbaaac8ece425d80893c9fa1bb) rdna2spirv: a wave64 VALU mask operand printed as one SGPR is the pair (SHADER-W64-SDST-PAIR) - [`f034185`](https://github.com/ubiquitarianism/leonida/commit/f03418595c85cf0dd2a9dcf0d6bc76a50aa85f6d) wave64_halves: a vote on a scalar compare under whole-quad EXEC is no lane vote (SHADER-W64-WQM-UVOTE) - [`6c5c079`](https://github.com/ubiquitarianism/leonida/commit/6c5c079ef16b649495e3f682f48649c2cfdf9adb) Merge main into shader-w64-wqm-uvote ### 📊 Changes **8 files changed** (+399 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+2 -0) ➕ `runtime/test/shaders/ps_w64_a_wqm_uniform_vote.asm` (+53 -0) 📝 `runtime/test/shaders/w64_graphics.py` (+2 -0) ➕ `tests/semantic/test_wave64_halves_wqm_uvote.py` (+188 -0) ➕ `tests/semantic/test_wave64_single_sdst.py` (+87 -0) 📝 `tests/test_wave64_halves_fixtures.py` (+1 -0) 📝 `tools/rdna2spirv.py` (+26 -0) 📝 `tools/wave64_halves.py` (+40 -13) </details> ### 📄 Description Item: [SHADER-W64-WQM-UVOTE](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140349095) Depends on: #1021 (its commit is the first one in this branch; only the second is this change) A pixel shader that needs derivatives starts with `s_wqm_b64 exec, exec`. LLVM branches on wave-uniform conditions inside that region the way it does anywhere: `v_cmp_* sN` of scalars, `s_and_b64 vcc, exec, s[N:N+1]`, `s_cbranch_vccnz`. SHADER-10 took that for no lane vote only while EXEC was the launch mask, so under the whole quads it was tier C `unsafe-vote-branch`. ### Why it is exact - The compare reads immediates and scalars only, so it is the same in every lane: its mask is every lane of EXEC or none. - EXEC is the whole quads of the launch mask. A quad is four consecutive lanes and never straddles the two 32-lane halves, and a half that runs has a launch lane. So EXEC has a lane in every half that runs, and each half votes as the wave does. ### What stays tier C - A VGPR source, even one SHADER-10 calls uniform: it was written under the launch mask and the helper lanes never got it. - The whole quads of a narrowed EXEC, and any narrowing after the `s_wqm_b64`: a half can be empty. - Whole quads saved and put back, or made in a register and copied to EXEC: only the write by `s_wqm_b64 exec, exec` is modelled. - A path on which a scalar was read out of a uniform VGPR from a lane the launch mask may not have written (`v_readlane_b32`, or `v_readfirstlane_b32` while EXEC is not the launch mask). ### Corpus (1.0.2.1, all 26,503, `wave64_halves.analyse` on every wave64 VS/PS/GS) Baseline is #1021 on `main` `3ed8e50b7`. Without #1021 the listings' one-register destinations hide the vote behind `tainted-branch`. | | A | B | C | |---|---|---|---| | #1021 | 5,267 | 397 | 7,741 | | #1021 + this | 5,719 | 397 | 7,289 | 452 pixel shaders go from C to A. No shader moves from A or B to C, and no vertex or geometry shader moves. `unsafe-vote-branch` 7,362 -> 6,861, `tainted-exec` 5,829 -> 5,793, `stale-scalar` 3,287 -> 3,254. ### Tested - `tests/semantic/test_wave64_halves_wqm_uvote.py` (new, 18 tests): the accepted forms in both printed forms of the destination, ten near misses that stay tier C, and a vertex and a pixel shader run on the wave interpreter as one wave of 64 lanes and as two of 32, equal and equal to the derived words. With #1021 alone 14 of them fail. - GPU: `ps_w64_a_wqm_uniform_vote` through `runtime/test/shaders/w64_graphics.py` on an NVIDIA GeForce RTX 4070 Ti, Linux, driver 620.70.06, subgroup 32 only: the words its header derives. That device has one subgroup size, so the 64-lane image was not drawn, and the full-screen draw has no partly covered quad. It confirms the translated SPIR-V against the ISA reference, not native RDNA2 behaviour. - `python -I scripts/run_semantic_tests.py tests/semantic`: 472 files, 6,186 tests, 0 files failed. `tests/test_wave64_halves_fixtures.py` and the `test_w64_graphics*.py` files: 22 passed. ### Overlap #805 edits the same lines of `uniform_cmp` and the state dict. It handles EXEC after it is put back from whole quads; this handles the compare under them. They merge by hand; whichever lands second needs a rebase. No game data: counts and opcode names only. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:10 +01:00
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#1127
No description provided.