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

Merged
milk4sale merged 3 commits from upstream-pr/1091 into main 2026-11-24 23:08:11 +00:00
milk4sale commented 2026-11-24 18:14:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by milk4sale on 2026-11-24T18:14:27Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5477794788 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1091). Originally posted by [milk4sale](https://github.com/milk4sale) on 2026-11-24T18:14:27Z. --- 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)
abnalstlll-byte commented 2026-11-24 18:49:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:49:22Z.

Review: APPROVED


Reviewed and verified. Precise analysis in ools/wave64_halves.py recognizing that under whole-quad EXEC (s_wqm_b64 exec, exec), scalar comparisons evaluate identically across quads without lane divergence, safely promoting 452 pixel shaders from Tier C to Tier A without false positives. Validated with ests/semantic/test_wave64_halves_wqm_uvote.py (18/18 PASS) and semantic test runner. 100% clean-room compliant.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045332266 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1091#pullrequestreview-6045332266). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:49:22Z. **Review:** APPROVED --- Reviewed and verified. Precise analysis in ools/wave64_halves.py recognizing that under whole-quad EXEC (s_wqm_b64 exec, exec), scalar comparisons evaluate identically across quads without lane divergence, safely promoting 452 pixel shaders from Tier C to Tier A without false positives. Validated with ests/semantic/test_wave64_halves_wqm_uvote.py (18/18 PASS) and semantic test runner. 100% clean-room compliant.
madhyn commented 2026-11-24 19:24:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:24:29Z.


Tested f03418595 on Arch Linux + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan):

  • python3 -m unittest tests/semantic/test_wave64_halves_wqm_uvote.py tests/semantic/test_wave64_single_sdst.py: 21 tests passed
  • python3 -I runtime/test/shaders/w64_graphics.py runtime/build/linux runtime/build/linux ps_w64_a_wqm_uniform_vote: ps_w64_a_wqm_uniform_vote A ok

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142052018 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1091#issuecomment-7142052018). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:24:29Z. --- Tested `f03418595` on Arch Linux + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan): - `python3 -m unittest tests/semantic/test_wave64_halves_wqm_uvote.py tests/semantic/test_wave64_single_sdst.py`: **21 tests passed** - `python3 -I runtime/test/shaders/w64_graphics.py runtime/build/linux runtime/build/linux ps_w64_a_wqm_uniform_vote`: **`ps_w64_a_wqm_uniform_vote A ok`** AI-assisted: yes
aslan2142 commented 2026-11-24 23:08:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T23:08:17Z.


Merged. Checked locally on main 22372d867 + 6c5c079ef:

  • Claim: valid. SHADER-W64-WQM-UVOTE was posted at 18:13 UTC, before this PR, and is unedited. With #1021 in main, the diff is only this change.
  • The rule is narrow: only s_wqm_b64 exec, exec from the launch mask sets it, and every other EXEC write clears it; a join keeps it only when both paths have it; VGPR sources are refused; and the qr cut-off covers scalars read from lanes the launch mask may not have written.
  • Tests: 14 of 18 in test_wave64_halves_wqm_uvote.py and the fixture tier check fail on main; all pass with this change.
  • GPU: ps_w64_a_wqm_uniform_vote and the other 20 ps_w64_* cases pass on an RDNA2 iGPU (RADV, Mesa 26.3.1). llvmpipe skips them all, since it can't require 32 or 64 lanes.
  • On the merge: the semantic suite passes (475 files, 6,212 tests, 0 files failed); test_run_gpu_tests, test_shader_checks pass; the 13 docs and writer tests pass; check_no_game_data.py is clean on the 6 changed files.
  • CI had not finished on this head.

For #805, which now conflicts in tools/wave64_halves.py, the hand merge is:

  • keep both state keys (nz, and q/qr) in join, entry and block;
  • uniform_cmp and the s_and_b64/s_or_b64 vote test become st["f"] or st["nz"] or st["q"];
  • #805's new elif op == "s_wqm_b64" branch in exec_write must also set st["q"] = quads, or this rule silently stops firing (the new tests here would catch that);
  • the VGPR clause stays st["f"] or (st["nz"] and not st["q"]).

#187 and #1320 get an easy docs/design.md conflict (adjacent rows).

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147056500 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1091#issuecomment-7147056500). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T23:08:17Z. --- Merged. Checked locally on `main` `22372d867` + `6c5c079ef`: - **Claim:** valid. `SHADER-W64-WQM-UVOTE` was posted at 18:13 UTC, before this PR, and is unedited. With #1021 in `main`, the diff is only this change. - **The rule is narrow:** only `s_wqm_b64 exec, exec` from the launch mask sets it, and every other EXEC write clears it; a join keeps it only when both paths have it; VGPR sources are refused; and the `qr` cut-off covers scalars read from lanes the launch mask may not have written. - **Tests:** 14 of 18 in `test_wave64_halves_wqm_uvote.py` and the fixture tier check fail on `main`; all pass with this change. - **GPU:** `ps_w64_a_wqm_uniform_vote` and the other 20 `ps_w64_*` cases pass on an RDNA2 iGPU (RADV, Mesa 26.3.1). llvmpipe skips them all, since it can't require 32 or 64 lanes. - **On the merge:** the semantic suite passes (475 files, 6,212 tests, 0 files failed); `test_run_gpu_tests`, `test_shader_checks` pass; the 13 docs and writer tests pass; `check_no_game_data.py` is clean on the 6 changed files. - **CI had not finished on this head.** **For #805,** which now conflicts in `tools/wave64_halves.py`, the hand merge is: - keep both state keys (`nz`, and `q`/`qr`) in `join`, `entry` and `block`; - `uniform_cmp` and the `s_and_b64`/`s_or_b64` vote test become `st["f"] or st["nz"] or st["q"]`; - #805's new `elif op == "s_wqm_b64"` branch in `exec_write` must also set `st["q"] = quads`, or this rule silently stops firing (the new tests here would catch that); - the VGPR clause stays `st["f"] or (st["nz"] and not st["q"])`. #187 and #1320 get an easy `docs/design.md` conflict (adjacent rows). AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
ohshitwaddup commented 2026-11-25 01:38:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ohshitwaddup on 2026-11-25T01:38:52Z.


Hardware follow-up on the gap this PR's row records. docs/design.md ends that row with:

"…on an NVIDIA GeForce RTX 4070 Ti (Linux, driver 620.70.06, 32 only). That device has one subgroup size, so the 64-lane image was not drawn there and the full-screen draw has no partly covered quad; the run confirms the translated SPIR-V against the ISA reference, not native RDNA2 behaviour."

I have a card that can draw the 64-lane image. Here is the measurement, on main at b4b7756e (rebased worktree) with a runtime built from the same tree, build.py 288/288 translated and spirv-val clean.

Device

AMD Radeon RX 6900 XT — RDNA2 / GFX1030, Navi 21, PCI 1002:73bf. RADV NAVI21, Mesa 26.2.4, Vulkan 1.4.354 (conformance 1.4.5.3). minSubgroupSize 32, maxSubgroupSize 64, default 64.

w64_graphics.py ps_w64_a_wqm_uniform_vote

ps_w64_a_wqm_uniform_vote    A  ok          (exit 0)

That is the documented command, but "ok" alone does not say whether the 64-lane image was drawn — a fixture whose 64 request was silently ignored would also read "ok". So I called w64_graphics.draw() directly for each size and read the applied flag it derives from the harness's own fragment subgroup size: N line:

size=64     applied=True    pixels=4096   expected_problem('')
size=32     applied=True    pixels=4096   expected_problem('')
size=None   applied=None    pixels=4096   expected_problem('')   (device default = 64)

comparable(64) == comparable(32): True

applied=True at size 64 is the part the RTX 4070 Ti could not produce: the device confirmed the required fragment subgroup size took effect, and 4096 pixels came back. expected_problem is empty at every size, so the words match the header's derivation, and the 64 and 32 images are identical, which is what tier A requires. The default draw (no size requested) also lands on 64 here and gives the same words.

First pixels, identical at all three sizes: (0x7,0xb,0x24,0x1b) (0x8,0xb,0x24,0x1b) (0x9,0xb,0x24,0x1b) (0xa,0xb,0x24,0x1b).

So the two things the row says were not established now are, on this device: the 64-lane image was drawn, and tier A holds on native RDNA2 rather than only against the ISA reference on a 32-only device.

What this does and does not settle

Does: the row's own reservation about RDNA2 is answerable — a native 64-wide RADV device at required size 64 gives the header's words, and the 64/32 partition does not change the image.

Does not: it is one card, one driver (Mesa 26.2.4), one run per size. It says nothing about Intel's narrow-subgroup behaviour, and nothing about the corpus counts in the row, which I did not re-derive. The row's CPU-side reasoning about partly covered quads is confirmed by a full-screen draw on a 64-wide device, not by a partial-quad case — the fixture draws full-screen by design, so that clause still rests on the argument, not on silicon.

Suggested wording for the clause, if you want it: replace "not native RDNA2 behaviour" with the 64-wide result above (RX 6900 XT, RADV Mesa 26.2.4, required fragment subgroup size 64, identical to 32). I have not edited the row — that is this PR's author's call, and a rebase on a docs-only change while the tree moves at ~15 commits/hour would only add work.

Two incidental notes from the same run, offered because they may save someone time:

  • The full suite on this card at b4b7756e is 240/256 passed, 16 skipped, 0 failed. cs_imgload_tfe / cs_imgload_d16_tfe now pass, so PR #892 fixed what several GPU records (including the RX 6900 XT record in #631) list as their only failure.
  • cs_dpp_cmp.asm, merged recently, does not assemble with llvm-mc 22.1.8: v_cmp_gt_f32_dpp ... dpp8:[...] gives error: dpp variant of this instruction is not supported. It needs a 23.x llvm-mc. Because build.py aborts on the first failure, anyone on a distro LLVM 22 cannot build the fixtures directory at all — I had to set that one file aside to get a full build. docs/testing.md says LLVM 21+, so either the documented floor or that fixture probably wants a note.

AI-assisted (Hermes Agent): ran the fixture on the RX 6900 XT, read the applied flag per size, and confirmed the suite total above.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7149791901 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1091#issuecomment-7149791901). Originally posted by [ohshitwaddup](https://github.com/ohshitwaddup) on 2026-11-25T01:38:52Z. --- Hardware follow-up on the gap this PR's row records. `docs/design.md` ends that row with: > "…on an NVIDIA GeForce RTX 4070 Ti (Linux, driver 620.70.06, **32 only**). That device has one subgroup size, **so the 64-lane image was not drawn there** and the full-screen draw has no partly covered quad; the run confirms the translated SPIR-V against the ISA reference, **not native RDNA2 behaviour**." I have a card that can draw the 64-lane image. Here is the measurement, on `main` at `b4b7756e` (rebased worktree) with a runtime built from the same tree, `build.py` 288/288 translated and `spirv-val` clean. ## Device AMD Radeon RX 6900 XT — RDNA2 / GFX1030, Navi 21, PCI 1002:73bf. RADV NAVI21, Mesa 26.2.4, Vulkan 1.4.354 (conformance 1.4.5.3). `minSubgroupSize 32`, `maxSubgroupSize 64`, **default 64**. ## `w64_graphics.py ps_w64_a_wqm_uniform_vote` ``` ps_w64_a_wqm_uniform_vote A ok (exit 0) ``` That is the documented command, but "ok" alone does not say whether the 64-lane image was drawn — a fixture whose 64 request was silently ignored would also read "ok". So I called `w64_graphics.draw()` directly for each size and read the `applied` flag it derives from the harness's own `fragment subgroup size: N` line: ``` size=64 applied=True pixels=4096 expected_problem('') size=32 applied=True pixels=4096 expected_problem('') size=None applied=None pixels=4096 expected_problem('') (device default = 64) comparable(64) == comparable(32): True ``` **`applied=True` at size 64** is the part the RTX 4070 Ti could not produce: the device confirmed the required fragment subgroup size took effect, and 4096 pixels came back. `expected_problem` is empty at every size, so the words match the header's derivation, and the 64 and 32 images are identical, which is what tier A requires. The default draw (no size requested) also lands on 64 here and gives the same words. First pixels, identical at all three sizes: `(0x7,0xb,0x24,0x1b) (0x8,0xb,0x24,0x1b) (0x9,0xb,0x24,0x1b) (0xa,0xb,0x24,0x1b)`. So the two things the row says were not established now are, on this device: the 64-lane image **was** drawn, and tier A holds on **native RDNA2** rather than only against the ISA reference on a 32-only device. ## What this does and does not settle **Does:** the row's own reservation about RDNA2 is answerable — a native 64-wide RADV device at required size 64 gives the header's words, and the 64/32 partition does not change the image. **Does not:** it is one card, one driver (Mesa 26.2.4), one run per size. It says nothing about Intel's narrow-subgroup behaviour, and nothing about the corpus counts in the row, which I did not re-derive. The row's CPU-side reasoning about partly covered quads is confirmed by a full-screen draw on a 64-wide device, not by a partial-quad case — the fixture draws full-screen by design, so that clause still rests on the argument, not on silicon. Suggested wording for the clause, if you want it: replace "not native RDNA2 behaviour" with the 64-wide result above (RX 6900 XT, RADV Mesa 26.2.4, required fragment subgroup size 64, identical to 32). I have not edited the row — that is this PR's author's call, and a rebase on a docs-only change while the tree moves at ~15 commits/hour would only add work. Two incidental notes from the same run, offered because they may save someone time: - The full suite on this card at `b4b7756e` is **240/256 passed, 16 skipped, 0 failed**. `cs_imgload_tfe` / `cs_imgload_d16_tfe` now pass, so PR #892 fixed what several GPU records (including the RX 6900 XT record in #631) list as their only failure. - `cs_dpp_cmp.asm`, merged recently, **does not assemble with llvm-mc 22.1.8**: `v_cmp_gt_f32_dpp ... dpp8:[...]` gives `error: dpp variant of this instruction is not supported`. It needs a 23.x llvm-mc. Because `build.py` aborts on the first failure, anyone on a distro LLVM 22 cannot build the fixtures directory at all — I had to set that one file aside to get a full build. `docs/testing.md` says LLVM 21+, so either the documented floor or that fixture probably wants a note. AI-assisted (Hermes Agent): ran the fixture on the RX 6900 XT, read the `applied` flag per size, and confirmed the suite total above.
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!1091
No description provided.