rdna2spirv: SDWA selects of v_{add,sub,subrev}_co_ci_u32 go to the sources, not the carry-out (SHADER-SDWA-CARRY-SEL) #1004

Merged
thesubtleties merged 1 commit from upstream-pr/1004 into main 2026-11-24 22:19:15 +00:00
thesubtleties commented 2026-11-24 16:43:58 +00:00 (Migrated from github.com)

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


Claimed in the coordination issue as: SHADER-SDWA-CARRY-SEL

What and why

v_add_co_ci_u32_sdwa, v_sub_co_ci_u32_sdwa and v_subrev_co_ci_u32_sdwa print the carry-out between the destination and the sources (v4, vcc_lo, v2, v3, vcc_lo). The SDWA setup assumed the sources start at operand 1, so src0_sel went to the carry-out (and was lost) and src1_sel went to src0. Any non-DWORD source selector gave a wrong value with no error. The selects now go to operands 2 and 3 for the printed form.

Tested

  • New tests/semantic/test_sdwa_carry.py (all 49 selector pairs per op in wave32, a sample in wave64, sext(), dst_sel): 164 failures without the fix, all pass with it.
  • scripts/run_semantic_tests.py on base 3ed8e50b: 470 files / 6165 tests, 0 failed; with the fix 471 / 6170, 0 failed. Rebased since; the SDWA and carry tests were rerun after the rebase.
  • run_gpu_tests.py on 3ed8e50b, per-test results identical with and without the fix: 201/252 (3080 native), 233/252 (3080, LEONIDA_W64_EMULATE=1), 234/252 (gfx1036 RADV); the only failures are the two known tfe fixtures (#31). No GPU fixture uses the new path, so these are regression checks.
  • Not measured on RDNA2 hardware, and no corpus run (I don't have the game), so I can't say whether any game shader uses these forms.

GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5476418241 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1004). Originally posted by [thesubtleties](https://github.com/thesubtleties) on 2026-11-24T16:43:58Z. --- Claimed in the coordination issue as: SHADER-SDWA-CARRY-SEL ### What and why `v_add_co_ci_u32_sdwa`, `v_sub_co_ci_u32_sdwa` and `v_subrev_co_ci_u32_sdwa` print the carry-out between the destination and the sources (`v4, vcc_lo, v2, v3, vcc_lo`). The SDWA setup assumed the sources start at operand 1, so `src0_sel` went to the carry-out (and was lost) and `src1_sel` went to src0. Any non-DWORD source selector gave a wrong value with no error. The selects now go to operands 2 and 3 for the printed form. ### Tested - New `tests/semantic/test_sdwa_carry.py` (all 49 selector pairs per op in wave32, a sample in wave64, `sext()`, `dst_sel`): 164 failures without the fix, all pass with it. - `scripts/run_semantic_tests.py` on base `3ed8e50b`: 470 files / 6165 tests, 0 failed; with the fix 471 / 6170, 0 failed. Rebased since; the SDWA and carry tests were rerun after the rebase. - `run_gpu_tests.py` on `3ed8e50b`, per-test results identical with and without the fix: 201/252 (3080 native), 233/252 (3080, `LEONIDA_W64_EMULATE=1`), 234/252 (gfx1036 RADV); the only failures are the two known tfe fixtures (#31). No GPU fixture uses the new path, so these are regression checks. - Not measured on RDNA2 hardware, and no corpus run (I don't have the game), so I can't say whether any game shader uses these forms. GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
KernelSmoker commented 2026-11-24 16:55:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T16:55:33Z.

Review: APPROVED


Reviewed exact head 073b8bb3a8 on current main 82a2aabcc. The new test_sdwa_carry.py passed 5/5, covering all 49 selector pairs per opcode in wave32, wave64 samples, sign extension, destination selection and the short form. The full semantic suite passed 471 files / 6,170 tests / 0 failures in Fedora 45 with SPIRV-Tools. The mutation runner caught all five relevant mutants, including removal of first = 2 (164 test failures). Docs rows 5/5, docs links 16/16, no-game-data scan and diff check passed. Synthetic CPU validation only; the PR notes no GPU fixture exercises these opcodes. Hosted label check was queued.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6043677808 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1004#pullrequestreview-6043677808). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T16:55:33Z. **Review:** APPROVED --- Reviewed exact head 073b8bb3a84c05c739d95760e4d43d3482702698 on current main 82a2aabcc. The new `test_sdwa_carry.py` passed 5/5, covering all 49 selector pairs per opcode in wave32, wave64 samples, sign extension, destination selection and the short form. The full semantic suite passed 471 files / 6,170 tests / 0 failures in Fedora 45 with SPIRV-Tools. The mutation runner caught all five relevant mutants, including removal of `first = 2` (164 test failures). Docs rows 5/5, docs links 16/16, no-game-data scan and diff check passed. Synthetic CPU validation only; the PR notes no GPU fixture exercises these opcodes. Hosted label check was queued.
QemmHD commented 2026-11-24 22:19:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T22:19:12Z.


Merging.

Why merged: SHADER-SDWA-CARRY-SEL: SDWA src selects on v_{add,sub,subrev}_co_ci_u32 skip the carry-out operand, so the select lands on the right source. KernelSmoker checked it.

Why it's good: Its test plus the sdwa_hw, sdwa_broadcast and sdwa_dst_mask tests: 47 passed, 2323 subtests.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146083195 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1004#issuecomment-7146083195). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T22:19:12Z. --- Merging. **Why merged:** SHADER-SDWA-CARRY-SEL: SDWA src selects on v_{add,sub,subrev}_co_ci_u32 skip the carry-out operand, so the select lands on the right source. KernelSmoker checked it. **Why it's good:** Its test plus the sdwa_hw, sdwa_broadcast and sdwa_dst_mask tests: 47 passed, 2323 subtests. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes. 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!1004
No description provided.