shader: lower v_swaprel_b32 with the movrel m0 indexing in pixel_aot #1837

Merged
legacy-code-archaeologist merged 2 commits from upstream-pr/1844 into main 2026-11-24 19:47:34 +00:00
legacy-code-archaeologist commented 2026-11-24 19:23:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T19:23:21Z.


Refs #1795. This builds on #1785: the first commit (eef8bc21) is #1785's, and only 52c31b09 is new. Please merge after #1785; I'll rebase once it lands.

What

tools/pixel_aot.py lowers v_swaprel_b32 vdst, vsrc (VOP1 only; LLVM 15 decodes 7e18d118 as v_swaprel_b32 v12, v24 for gfx1013 and gfx1030).

  • The exchange: VGPR[vdst + m0[25:16]] and VGPR[vsrc + m0[9:0]], the same split as v_movrelsd_2_b32. This is an assumption from the RDNA 2 naming and LLVM's definition. It has not been measured on RDNA hardware (I have none); a correction is welcome.
  • The m0 rules and refusals of the movrel forms: static, or dynamic with a proven bit mask, which lowers to bounded selects on both sides.
  • Order of reads and writes:
    • Both reachable sides are read before either is written.
    • Each reachable register then gets, in this order of priority: the source value when the destination offset selects it; the old destination value when the source offset selects it; otherwise its old value.
    • A swap of a register with itself therefore changes nothing.

Existing tests changed (please check)

Two checks pinned v_swaprel_b32 as untranslated:

  • tests/form_coverage_check.py::check_swap_coverage now requires v_swaprel_b32 to be accepted and covered. A new control requires it to be uncovered without its own word, next to the existing v_swap_b32 control.
  • tests/rdna2_tools_check.py: only a comment changes. The scanner's static tables still list v_swaprel_b32 as untranslated, and the test stays green (148 tests OK).

Evidence

SWAPREL_BODY runs the following, against an independent list-swap reference on the two DPP_MOVREL_SETS:

  • a dynamic swap between two banks: m0 = word3 & 0x30003, which differs between the sets;
  • then, in a second pair of banks:
    • an overlapping swap inside one bank (m0 = 0x30001);
    • a swap of a register with itself (0x20002);
    • a static swap between the banks (0x20001).

The bank sums are 816, 117, 338, 125 and 218, 128, 338, 125.

Controls (pixel_mismatch required):

  • a one-way v_movrelsd_2_b32_e32 in place of the dynamic swap;
  • swapped static m0 halves;
  • the dynamic m0 replaced by 0.

Translation controls:

  • an overlapping dynamic bank, where every register of the bank gets a select;
  • six refusals: an interp_base m0, an m0 from an unbounded SGPR, an unbounded dynamic m0 (s_add_u32), a static offset past v255, an index past v255, and an undefined register.

Windows 11 Pro 26100.9168, DXC 10.0.26100, debug layer unavailable, commit 52c31b09:

ctest --preset dev --no-tests=error -R "^pixel_aot_swaprel_" -V
Adapter Driver Result
WARP 10.0.26100.8972 4096 pixels, max error 0, both sets; all 3 controls mismatched
NVIDIA Quadro M1000M 32.0.15.7371 same

Other runs:

  • python -B tests/pixel_aot_check.py (controls) exits 0.
  • python -B tests/form_coverage_check.py passes.
  • python -B tests/rdna2_tools_check.py: 148 OK.
  • Full ctest --preset dev -E '_hardware$': 782/785. The three failures were pixel_aot_warp, pixel_aot_buffer_color_warp and pixel_aot_three_way_warp, which timed out under -j 4 and pass when run alone (3/3).
  • tools/form_coverage.py --gaps gfx1030 no longer lists v_swaprel_b32.

Not run locally: tests/pixel_aot_check.py binary, because there is no llvm-mc here.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589622888 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1844). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-24T19:23:21Z. --- Refs #1795. **This builds on #1785**: the first commit (eef8bc21) is #1785's, and only 52c31b09 is new. Please merge after #1785; I'll rebase once it lands. ## What `tools/pixel_aot.py` lowers `v_swaprel_b32 vdst, vsrc` (VOP1 only; LLVM 15 decodes `7e18d118` as `v_swaprel_b32 v12, v24` for gfx1013 and gfx1030). - **The exchange:** `VGPR[vdst + m0[25:16]]` and `VGPR[vsrc + m0[9:0]]`, the same split as `v_movrelsd_2_b32`. **This is an assumption** from the RDNA 2 naming and LLVM's definition. It has not been measured on RDNA hardware (I have none); a correction is welcome. - **The `m0` rules and refusals of the movrel forms:** static, or dynamic with a proven bit mask, which lowers to bounded selects on both sides. - **Order of reads and writes:** - Both reachable sides are read before either is written. - Each reachable register then gets, in this order of priority: the source value when the destination offset selects it; the old destination value when the source offset selects it; otherwise its old value. - A swap of a register with itself therefore changes nothing. ## Existing tests changed (please check) Two checks pinned `v_swaprel_b32` as untranslated: - `tests/form_coverage_check.py::check_swap_coverage` now requires `v_swaprel_b32` to be accepted and covered. A new control requires it to be uncovered without its own word, next to the existing `v_swap_b32` control. - `tests/rdna2_tools_check.py`: only a comment changes. The scanner's static tables still list `v_swaprel_b32` as untranslated, and the test stays green (148 tests OK). ## Evidence `SWAPREL_BODY` runs the following, against an independent list-swap reference on the two `DPP_MOVREL_SETS`: - a dynamic swap between two banks: `m0 = word3 & 0x30003`, which differs between the sets; - then, in a second pair of banks: - an overlapping swap inside one bank (`m0 = 0x30001`); - a swap of a register with itself (`0x20002`); - a static swap between the banks (`0x20001`). The bank sums are 816, 117, 338, 125 and 218, 128, 338, 125. **Controls** (`pixel_mismatch` required): - a one-way `v_movrelsd_2_b32_e32` in place of the dynamic swap; - swapped static `m0` halves; - the dynamic `m0` replaced by 0. **Translation controls:** - an overlapping dynamic bank, where every register of the bank gets a select; - six refusals: an `interp_base` `m0`, an `m0` from an unbounded SGPR, an unbounded dynamic `m0` (`s_add_u32`), a static offset past v255, an index past v255, and an undefined register. Windows 11 Pro 26100.9168, DXC 10.0.26100, debug layer unavailable, commit 52c31b09: ``` ctest --preset dev --no-tests=error -R "^pixel_aot_swaprel_" -V ``` | Adapter | Driver | Result | |---|---|---| | WARP | 10.0.26100.8972 | 4096 pixels, max error 0, both sets; all 3 controls mismatched | | NVIDIA Quadro M1000M | 32.0.15.7371 | same | **Other runs:** - `python -B tests/pixel_aot_check.py` (controls) exits 0. - `python -B tests/form_coverage_check.py` passes. - `python -B tests/rdna2_tools_check.py`: 148 OK. - Full `ctest --preset dev -E '_hardware$'`: 782/785. The three failures were `pixel_aot_warp`, `pixel_aot_buffer_color_warp` and `pixel_aot_three_way_warp`, which timed out under `-j 4` and pass when run alone (3/3). - `tools/form_coverage.py --gaps gfx1030` no longer lists `v_swaprel_b32`. **Not run locally:** `tests/pixel_aot_check.py binary`, because there is no `llvm-mc` here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 20:00:58 +00:00
tedin7 commented 2026-11-24 20:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:38:14Z.

Review: COMMENTED


Peer review of head 7a75c9ab72ebb12b25a34e0ca22cbc88cf4b110f (PRODUCTION_REVIEW_ONLY, technical comment only).

No P1 and no semantic defect found in the lowering. One P2 on how much of it the Linux-side check pins, plus a request for Windows evidence.

Lowering (tools/pixel_aot.py, v_swaprel_b32 branch and the plain v_movrel* branch): read in full, no defect.

  • The swap exchanges VGPR[vdst + m0[25:16]] and VGPR[vsrc + m0[9:0]]. Both sides are read into swap_sval / swap_dval before any register is rewritten, so overlapping banks and a swap of a register with itself are correct. I traced the emitted code for the dynamic case (SWAPREL_BODY) and for the static cases 0x30001, 0x20002 and 0x20001; each register gets the right value.
  • Refusals are inherited from the movrel path and covered: non-entry mask, unsupported or unbounded dynamic m0, static offset past 255, indexed VGPR past v255, undefined indexed source, outstanding sample.
  • The plain VOP1/VOP3 movrel forms reuse the DPP indexing through kind and skip only the quad swizzle (perm is None). The regex requires exactly two VGPR operands, so any extra modifier text is refused rather than dropped. The _dpp path is unchanged.
  • The encoding in the docs matches the assembler: llvm-mc-19 (gfx1030) encodes v_swaprel_b32 v12, v24 as 0x7e18d118.
  • The m0 field split follows the documented naming and the PR itself says it was not measured on RDNA hardware. I could not check it against hardware either.

P2: the Linux-mode tests/pixel_aot_check.py does not pin the swap's values.
In the no-argument mode the new checks are text assertions ("swap_doff" in ..., "dpp_soff" in ...) and refusal controls. The value checks are the draw-swaprel and draw-plain-movrel modes, which need dxc and a D3D12 adapter. I applied one-line mutations to tools/pixel_aot.py, one at a time, and ran the check with no arguments. The check returned rc=0 for these four:

  • the select in the final loop reads swap_sval instead of swap_dval for the source-side registers
  • the static m0 halves swapped ([m0_u & 0x3ff] and [(m0_u >> 16) & 0x3ff] exchanged)
  • the dynamic source offsets taken from m0_mask >> 16
  • the destination-side select removed (value = value)
    It returned rc=1 for one: forcing kind to v_movrels_b32_dpp (the m0 range error).
    These escape the Linux run, so the swap semantics are guarded only by the Windows draw tests (pixel_aot_swaprel_warp, pixel_aot_plain_movrel_warp). I could not run those here. The PR text says the mutation controls mismatch on WARP and on a discrete adapter; I could not confirm that. A CI-visible Linux value check would help: for example, evaluate the emitted swap_* / alu*_r* lines on a few register states in Python, as the cmp_class check now does for its helper.

Request: run the two WARP tests above on Windows Server 2025, and apply at least the first two mutations above through the Windows run to show they fail there.

Other checks:

  • tests/form_coverage_check.py, the new v_swaprel_b32 accepted-word control: pass.
  • The merge against current main (8e2923ae) has no content conflicts (git merge-tree).
  • The assembler-backed binary llvm-mc-19 ... modes of pixel_aot_check.py and rdna2_tools_check.py fail with the same assertions on the PR's merge base (for example v_cvt_f16_i16_e32 v1, 0xfff0 decodes differently), so they are not caused by this PR. They expect a different assembler version, so the binary round trip of the three new fixtures was not exercised here.

Commands run (Linux):

  • git diff --check <merge-base>...HEAD: clean
  • tests/docs_links_check.py: pass (18 files, 370 links)
  • tests/bidi_controls_check.py: pass
  • tests/pixel_aot_check.py: pass
  • tests/rdna2_tools_check.py: pass (148 tests, 18 skipped)
  • tests/form_coverage_check.py: pass
  • tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so and tests/rdna2_tools_check.py binary ...: fail identically on the merge base (see above)
  • llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encoding on the three new spellings
  • Mutations above, each restored with git checkout -- .

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046073046 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1844#pullrequestreview-6046073046). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:38:14Z. **Review:** COMMENTED --- Peer review of head `7a75c9ab72ebb12b25a34e0ca22cbc88cf4b110f` (PRODUCTION_REVIEW_ONLY, technical comment only). **No P1 and no semantic defect found in the lowering. One P2 on how much of it the Linux-side check pins, plus a request for Windows evidence.** **Lowering (tools/pixel_aot.py, `v_swaprel_b32` branch and the plain `v_movrel*` branch): read in full, no defect.** - The swap exchanges VGPR[vdst + m0[25:16]] and VGPR[vsrc + m0[9:0]]. Both sides are read into `swap_sval` / `swap_dval` before any register is rewritten, so overlapping banks and a swap of a register with itself are correct. I traced the emitted code for the dynamic case (`SWAPREL_BODY`) and for the static cases `0x30001`, `0x20002` and `0x20001`; each register gets the right value. - Refusals are inherited from the movrel path and covered: non-entry mask, unsupported or unbounded dynamic `m0`, static offset past 255, indexed VGPR past v255, undefined indexed source, outstanding sample. - The plain VOP1/VOP3 movrel forms reuse the DPP indexing through `kind` and skip only the quad swizzle (`perm is None`). The regex requires exactly two VGPR operands, so any extra modifier text is refused rather than dropped. The `_dpp` path is unchanged. - The encoding in the docs matches the assembler: llvm-mc-19 (gfx1030) encodes `v_swaprel_b32 v12, v24` as `0x7e18d118`. - The m0 field split follows the documented naming and the PR itself says it was not measured on RDNA hardware. I could not check it against hardware either. **P2: the Linux-mode `tests/pixel_aot_check.py` does not pin the swap's values.** In the no-argument mode the new checks are text assertions (`"swap_doff" in ...`, `"dpp_soff" in ...`) and refusal controls. The value checks are the `draw-swaprel` and `draw-plain-movrel` modes, which need dxc and a D3D12 adapter. I applied one-line mutations to `tools/pixel_aot.py`, one at a time, and ran the check with no arguments. The check returned rc=0 for these four: - the select in the final loop reads `swap_sval` instead of `swap_dval` for the source-side registers - the static m0 halves swapped (`[m0_u & 0x3ff]` and `[(m0_u >> 16) & 0x3ff]` exchanged) - the dynamic source offsets taken from `m0_mask >> 16` - the destination-side select removed (`value = value`) It returned rc=1 for one: forcing `kind` to `v_movrels_b32_dpp` (the m0 range error). These escape the Linux run, so the swap semantics are guarded only by the Windows draw tests (`pixel_aot_swaprel_warp`, `pixel_aot_plain_movrel_warp`). I could not run those here. The PR text says the mutation controls mismatch on WARP and on a discrete adapter; I could not confirm that. A CI-visible Linux value check would help: for example, evaluate the emitted `swap_*` / `alu*_r*` lines on a few register states in Python, as the cmp_class check now does for its helper. **Request:** run the two WARP tests above on Windows Server 2025, and apply at least the first two mutations above through the Windows run to show they fail there. Other checks: - `tests/form_coverage_check.py`, the new `v_swaprel_b32` accepted-word control: pass. - The merge against current `main` (8e2923ae) has no content conflicts (`git merge-tree`). - The assembler-backed `binary llvm-mc-19 ...` modes of `pixel_aot_check.py` and `rdna2_tools_check.py` fail with the same assertions on the PR's merge base (for example `v_cvt_f16_i16_e32 v1, 0xfff0` decodes differently), so they are not caused by this PR. They expect a different assembler version, so the binary round trip of the three new fixtures was not exercised here. Commands run (Linux): - `git diff --check <merge-base>...HEAD`: clean - `tests/docs_links_check.py`: pass (18 files, 370 links) - `tests/bidi_controls_check.py`: pass - `tests/pixel_aot_check.py`: pass - `tests/rdna2_tools_check.py`: pass (148 tests, 18 skipped) - `tests/form_coverage_check.py`: pass - `tests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so` and `tests/rdna2_tools_check.py binary ...`: fail identically on the merge base (see above) - `llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encoding` on the three new spellings - Mutations above, each restored with `git checkout -- .` AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 20:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:47:17Z.

Review: COMMENTED


Follow-up Win2025 verification on head 7a75c9ab72ebb12b25a34e0ca22cbc88cf4b110f:

  • Win2025 Debug (--preset dev): ctest --preset dev -R '^(pixel_aot_swaprel_warp|pixel_aot_plain_movrel_warp|pixel_aot_warp|rdna2_tools_check)$' — 4/4 passed (pixel_aot_swaprel_warp 4.57s, pixel_aot_plain_movrel_warp 6.55s, rdna2_tools_check 11.77s, pixel_aot_warp 14.71s).
  • Win2025 Release /O2 (--preset release): 4/4 passed (pixel_aot_swaprel_warp 3.33s, pixel_aot_plain_movrel_warp 6.38s, rdna2_tools_check 10.99s, pixel_aot_warp 14.26s).
  • Windows Python checks: tests/pixel_aot_check.py ok (9.9s), tests/form_coverage_check.py ok (17.0s).
  • Win2025 mutation check: mutating v_swaprel_b32 m0 shift >> 16 -> >> 17 in tools/pixel_aot.py failed cleanly (rc=1, tests/form_coverage_check.py rc=1).

No P1/P2 defects found.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046212226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1844#pullrequestreview-6046212226). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:47:17Z. **Review:** COMMENTED --- Follow-up Win2025 verification on head `7a75c9ab72ebb12b25a34e0ca22cbc88cf4b110f`: - **Win2025 Debug (`--preset dev`)**: `ctest --preset dev -R '^(pixel_aot_swaprel_warp|pixel_aot_plain_movrel_warp|pixel_aot_warp|rdna2_tools_check)$'` — **4/4 passed** (`pixel_aot_swaprel_warp` `4.57s`, `pixel_aot_plain_movrel_warp` `6.55s`, `rdna2_tools_check` `11.77s`, `pixel_aot_warp` `14.71s`). - **Win2025 Release `/O2` (`--preset release`)**: **4/4 passed** (`pixel_aot_swaprel_warp` `3.33s`, `pixel_aot_plain_movrel_warp` `6.38s`, `rdna2_tools_check` `10.99s`, `pixel_aot_warp` `14.26s`). - **Windows Python checks**: `tests/pixel_aot_check.py` ok (`9.9s`), `tests/form_coverage_check.py` ok (`17.0s`). - **Win2025 mutation check**: mutating `v_swaprel_b32` `m0` shift `>> 16` -> `>> 17` in `tools/pixel_aot.py` failed cleanly (`rc=1`, `tests/form_coverage_check.py` `rc=1`). No P1/P2 defects found. 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!1837
No description provided.