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

Merged
kotekompotek merged 1 commit from upstream-pr/265 into main 2026-11-24 03:28:20 +00:00
kotekompotek commented 2026-11-24 02:55:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T02:55:47Z.


…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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465208873 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/265). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T02:55:47Z. --- …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.
akimfomin commented 2026-11-24 10:16:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by akimfomin on 2026-11-24T10:16:33Z.


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?

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7128554846 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/265#issuecomment-7128554846). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-24T10:16:33Z. --- [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?
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!265
No description provided.