tooling: count accumulator destinations as reads in ps_input_scan #2529

Merged
Asimmimx merged 2 commits from upstream-pr/2537 into main 2026-11-25 20:36:17 +00:00
Asimmimx commented 2026-11-25 20:16:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-25T20:16:57Z.


Summary

parse_instruction in tools/startup/ps_input_scan.py now keeps the destination among the source tokens for the forms that read it: v_mac_, v_fmac_, v_pk_fmac_, v_dot2c_, v_dot4c_, v_dot8c_ and v_writelane_b32. Such a register counts as live-in when nothing wrote it before. Every other form still treats its destination as written only, and an accumulator that is written first stays out of the live-in set.

Fixes #2536

Tests

Windows 11 26300, commit f90804b7:

out\pe-env\Scripts\python.exe -B tests/startup_ps_input_scan_check.py

Passes with "ps_input_scan checks passed". It reports "destination rule: 16 decoded-text cases" (13 existing plus 3 new) and the new "accumulator rule: 5 encoded forms read their destination". The end-to-end, reference, pixel-dir, container, capture and determinism sections are unchanged and pass.

New cases:

  • Decoded text:
    • v_fmac_f32_e64 v2, v0, v1 gives [0, 1, 2].
    • v_writelane_b32 v2, s0, 1 gives [2].
    • v_mov_b32_e32 v2, 0 followed by v_fmac_f32_e32 v2, v0, v1 (accumulator written first) gives [0, 1].
  • gfx1013 VOP2 encodings, read through the disassembler by shader(): v_mac_f32 (0x1f), v_fmac_f32 (0x2b), v_mac_legacy_f32 (0x06), v_fmac_f16 (0x36) and v_pk_fmac_f16 (0x3c). Each gives live-in [0, 1, 2].

Fail-first

With the tool reverted to main, the check exits 1:

AssertionError: (['v_fmac_f32_e64 v2, v0, v1'], [0, 1], [0, 1, 2])

Open

  • SDWA dst_unused:UNUSED_PRESERVE and DPP forms with partial row or bank masks also keep part of their destination. They are not handled.
  • The effect on a real corpus's ranking was not measured.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6612918199 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2537). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-25T20:16:57Z. --- ## Summary `parse_instruction` in `tools/startup/ps_input_scan.py` now keeps the destination among the source tokens for the forms that read it: `v_mac_`, `v_fmac_`, `v_pk_fmac_`, `v_dot2c_`, `v_dot4c_`, `v_dot8c_` and `v_writelane_b32`. Such a register counts as live-in when nothing wrote it before. Every other form still treats its destination as written only, and an accumulator that is written first stays out of the live-in set. Fixes #2536 ## Tests Windows 11 26300, commit `f90804b7`: ``` out\pe-env\Scripts\python.exe -B tests/startup_ps_input_scan_check.py ``` Passes with "ps_input_scan checks passed". It reports "destination rule: 16 decoded-text cases" (13 existing plus 3 new) and the new "accumulator rule: 5 encoded forms read their destination". The end-to-end, reference, pixel-dir, container, capture and determinism sections are unchanged and pass. New cases: - Decoded text: - `v_fmac_f32_e64 v2, v0, v1` gives `[0, 1, 2]`. - `v_writelane_b32 v2, s0, 1` gives `[2]`. - `v_mov_b32_e32 v2, 0` followed by `v_fmac_f32_e32 v2, v0, v1` (accumulator written first) gives `[0, 1]`. - gfx1013 VOP2 encodings, read through the disassembler by `shader()`: `v_mac_f32` (0x1f), `v_fmac_f32` (0x2b), `v_mac_legacy_f32` (0x06), `v_fmac_f16` (0x36) and `v_pk_fmac_f16` (0x3c). Each gives live-in `[0, 1, 2]`. ## Fail-first With the tool reverted to `main`, the check exits 1: ``` AssertionError: (['v_fmac_f32_e64 v2, v0, v1'], [0, 1], [0, 1, 2]) ``` ## Open - SDWA `dst_unused:UNUSED_PRESERVE` and DPP forms with partial row or bank masks also keep part of their destination. They are not handled. - The effect on a real corpus's ranking was not measured. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 21:01:20 +00:00
tedin7 commented 2026-11-25 21:01:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:22:27Z.

Review: COMMENTED


Review of head f90804b7 (comment only, no merge decision beyond the merge rules).

Looks sound. parse_instruction keeps the destination among the sources for v_mac_, v_fmac_, v_pk_fmac_, v_dot2c/4c/8c_ and v_writelane_b32; every other form is unchanged. The new decoded-text and encoded-form cases guard this, including the "written first stays out of live-in" case.

Commands run locally on a worktree of the head:

  • python3 -B tests/startup_ps_input_scan_check.py -> "ps_input_scan checks passed"
  • python3 tests/docs_links_check.py -> passed (478 links)
  • python3 tests/bidi_controls_check.py -> passed
  • git diff --check origin/main...HEAD -> clean
  • Mutation: removed v_writelane_b32 from DESTINATION_READ_PREFIXES -> check fails with AssertionError: (['v_writelane_b32 v2, s0, 1'], [], [2]), as it should.
  • No other open or merged PR covers this slice (search "ps_input_scan accumulator").

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064413743 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2537#pullrequestreview-6064413743). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:22:27Z. **Review:** COMMENTED --- Review of head f90804b7 (comment only, no merge decision beyond the merge rules). Looks sound. `parse_instruction` keeps the destination among the sources for `v_mac_`, `v_fmac_`, `v_pk_fmac_`, `v_dot2c/4c/8c_` and `v_writelane_b32`; every other form is unchanged. The new decoded-text and encoded-form cases guard this, including the "written first stays out of live-in" case. Commands run locally on a worktree of the head: - `python3 -B tests/startup_ps_input_scan_check.py` -> "ps_input_scan checks passed" - `python3 tests/docs_links_check.py` -> passed (478 links) - `python3 tests/bidi_controls_check.py` -> passed - `git diff --check origin/main...HEAD` -> clean - Mutation: removed `v_writelane_b32` from `DESTINATION_READ_PREFIXES` -> check fails with `AssertionError: (['v_writelane_b32 v2, s0, 1'], [], [2])`, as it should. - No other open or merged PR covers this slice (search "ps_input_scan accumulator"). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:26:36Z.


Win2025 WARP receipt for head 0f9251d5 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 0f9251d54677baa33e4b791f7d257a40189a58cb:

  • Windows Python checks: tests/startup_ps_input_scan_check.py ok (6.8s), exit 0.
  • The PR changes no CTest target (Python tooling only), so no CTest tests were selected.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173678733 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2537#issuecomment-7173678733). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:26:36Z. --- Win2025 WARP receipt for head 0f9251d5 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `0f9251d54677baa33e4b791f7d257a40189a58cb`: - **Windows Python checks**: `tests/startup_ps_input_scan_check.py` ok (6.8s), exit 0. - The PR changes no CTest target (Python tooling only), so no CTest tests were selected. AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!2529
No description provided.