rdna2spirv: fix Wave64 halves partial destination read-modify-write #265

Manually merged
github merged 1 commit from gh-pr/265/head into gh-pr/265/base 2026-11-26 08:51:12 +00:00
Owner

@⁠kotekompotek on GitHub · 2026-11-24 02:55 UTC · original
kotekompotek:contribution/wave64-halves-partial-dst-rmw → main · +443 −3 · 2 files · 1 commits · merged 2026-11-24 03:28 UTC

…t asymmetric DPP row_mask

Fixes partial-destination writes in tools/wave64_halves.py that dropped prior taint and falsely marked divergent VGPRs uniform (miscompiling v_readlane_b32 in rdna2spirv.py):

  • Track destination read in operands() for SDWA dst_unused:UNUSED_PRESERVE with sub-dword dst_sel, single-half 16-bit VALU ops (including 8-byte VOP3 / _nc_16 / v_interp_p2_f16), partial-lane DPP (row_mask/bank_mask != 0xf or bound_ctrl:0), v_fmac_legacy_f32, and partial d16 loads.
  • Flag half-asymmetric DPP row_mask ((row_mask & 3) != (row_mask >> 2)) and dpp8 in transfer().

Verified locally (CPU-only):

  • tests/semantic/test_wave64_halves_partial_dst.py (13 OK)
  • tests/semantic/test_wave64_halves_soundness.py (30 OK)
  • tests/semantic/test_wave64_halves.py (73 OK)
  • tests/semantic/test_wave64_cross_half.py (9 OK)
  • tests/semantic/test_wave64_subgroup_ops.py (6 OK)
  • pytest tests/test_wave64_halves_fixtures.py tests/test_wave64_graphics_scan.py (25 passed, 1 skipped)
  • docs, line-ending, resource hygiene, tool startup, compileall, git diff --check

Conflicts:

docs/design.md

Conflicts:

tools/wave64_halves.py

Claimed in the coordination issue as:

Depends on:

What and why

Tested

AI-assisted:

Checklist

  • 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.
**@⁠kotekompotek** on GitHub · 2026-11-24 02:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/265) `kotekompotek:contribution/wave64-halves-partial-dst-rmw` → `main` · +443 −3 · 2 files · 1 commits · merged 2026-11-24 03:28 UTC …t asymmetric DPP row_mask Fixes partial-destination writes in tools/wave64_halves.py that dropped prior taint and falsely marked divergent VGPRs uniform (miscompiling v_readlane_b32 in rdna2spirv.py): - Track destination read in operands() for SDWA dst_unused:UNUSED_PRESERVE with sub-dword dst_sel, single-half 16-bit VALU ops (including 8-byte VOP3 / _nc_16 / v_interp_p2_f16), partial-lane DPP (row_mask/bank_mask != 0xf or bound_ctrl:0), v_fmac_legacy_f32, and partial d16 loads. - Flag half-asymmetric DPP row_mask ((row_mask & 3) != (row_mask >> 2)) and dpp8 in transfer(). Verified locally (CPU-only): - tests/semantic/test_wave64_halves_partial_dst.py (13 OK) - tests/semantic/test_wave64_halves_soundness.py (30 OK) - tests/semantic/test_wave64_halves.py (73 OK) - tests/semantic/test_wave64_cross_half.py (9 OK) - tests/semantic/test_wave64_subgroup_ops.py (6 OK) - pytest tests/test_wave64_halves_fixtures.py tests/test_wave64_graphics_scan.py (25 passed, 1 skipped) - docs, line-ending, resource hygiene, tool startup, compileall, git diff --check # Conflicts: # docs/design.md # Conflicts: # tools/wave64_halves.py Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (the coordination issue's Commands section, AGENTS.md); delete the line if it builds on none and conflicts with none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### Checklist - [ ] 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.
Fixes partial-destination writes in tools/wave64_halves.py that dropped prior taint and falsely marked divergent VGPRs uniform (miscompiling v_readlane_b32 in rdna2spirv.py):
- Track destination read in operands() for SDWA dst_unused:UNUSED_PRESERVE with sub-dword dst_sel, single-half 16-bit VALU ops (including 8-byte VOP3 / _nc_16 / v_interp_p2_f16), partial-lane DPP (row_mask/bank_mask != 0xf or bound_ctrl:0), v_fmac_legacy_f32, and partial d16 loads.
- Flag half-asymmetric DPP row_mask ((row_mask & 3) != (row_mask >> 2)) and dpp8 in transfer().

Verified locally (CPU-only):
- tests/semantic/test_wave64_halves_partial_dst.py (13 OK)
- tests/semantic/test_wave64_halves_soundness.py (30 OK)
- tests/semantic/test_wave64_halves.py (73 OK)
- tests/semantic/test_wave64_cross_half.py (9 OK)
- tests/semantic/test_wave64_subgroup_ops.py (6 OK)
- pytest tests/test_wave64_halves_fixtures.py tests/test_wave64_graphics_scan.py (25 passed, 1 skipped)
- docs, line-ending, resource hygiene, tool startup, compileall, git diff --check

# Conflicts:
#	docs/design.md

# Conflicts:
#	tools/wave64_halves.py
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:51:10 +00:00
github manually merged commit ad1e53e42b into gh-pr/265/base 2026-11-26 08:51:12 +00:00
Author
Owner

@⁠akimfomin on GitHub · 2026-11-24 10:16 UTC · original · edited 2026-11-24 11:13 UTC

PortBridge matched this change to Reforge #15 at the same source commit ad1e53e. The Reforge review has a follow-up that may be useful here too. For a full-EXEC three-component D16 load, X/Y overwrite the first destination word and only the second word retains part of its prior value. The follow-up tracks those words separately and keeps the conservative behavior for masked writes.

I independently reran the focused synthetic suite on Windows 11 / Python 3.12.14. The shared commit passed its original 13 tests. With the Reforge follow-up applied, 15 tests passed. Adding its two tests without its code change reproduced seven failing subchecks, including the three constant-output cases for each of MUBUF and MTBUF. My verification here is CPU test coverage, and the original Reforge review has the GPU readback.

If this follow-up is still useful on current Continued, the two regression tests are a small way to check that before adapting the change. AI-assisted with Codex.

Update on Continued main 21625bca8c67. I repeated the same CPU-only check there. The unmodified branch passed 13/13. The two tests alone exposed the same seven misclassifications. With ecox982745’s code, all 15 tests passed. Would a standalone PR against Continued main, preserving the original authorship, be useful?

**@⁠akimfomin** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/265#issuecomment-7128554846) · edited 2026-11-24 11:13 UTC [PortBridge](https://github.com/akimfomin/PortBridge) matched this change to [Reforge #15](https://github.com/LeonidaReforge/Leonida/pull/15) at the same source commit `ad1e53e`. The Reforge review has a follow-up that may be useful here too. For a full-EXEC three-component D16 load, X/Y overwrite the first destination word and only the second word retains part of its prior value. The follow-up tracks those words separately and keeps the conservative behavior for masked writes. I independently reran the focused synthetic suite on Windows 11 / Python 3.12.14. The shared commit passed its original 13 tests. With [the Reforge follow-up](https://github.com/ecox982745/Leonida/commit/a300ba63d1a9a4cdfde1d64f136728545b4ab7b8) applied, 15 tests passed. Adding its two tests without its code change reproduced seven failing subchecks, including the three constant-output cases for each of MUBUF and MTBUF. My verification here is CPU test coverage, and the [original Reforge review](https://github.com/LeonidaReforge/Leonida/pull/15#issuecomment-7125522634) has the GPU readback. If this follow-up is still useful on current Continued, the two regression tests are a small way to check that before adapting the change. AI-assisted with Codex. **Update on [Continued main `21625bca8c67`](https://github.com/ubiquitarianism/leonida/commit/21625bca8c675c62f9dbffc318ce6a59d57faf31).** I repeated the same CPU-only check there. The unmodified branch passed 13/13. The two tests alone exposed the same seven misclassifications. With ecox982745’s code, all 15 tests passed. Would a standalone PR against Continued main, preserving the original authorship, be useful?
This discussion has been locked. Commenting is limited to contributors.
No description provided.