shader: lower the plain VOP1/VOP3 v_movrel* forms in pixel_aot #1785

Manually merged
github merged 1 commit from gh-pr/1785/head into gh-pr/1785/base 2026-11-26 23:33:28 +00:00
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-24 18:38 UTC · original
legacy-code-archaeologist:shader/plain-movrel → main · +199 −16 · 4 files · 1 commits · merged 2026-11-24 19:47 UTC

Refs #1739. I built this before the issue had a maintainer reply; if you want the scope narrowed, I'll adjust.

What

tools/pixel_aot.py now lowers the plain VOP1 (_e32) and VOP3 (_e64) encodings of the four relative VGPR-indexing moves:

  • v_movreld_b32, v_movrels_b32, v_movrelsd_b32, v_movrelsd_2_b32;
  • LLVM 15 prints them as v_movrels_b32_e32 v12, v24 / _e64 for both gfx1013 and gfx1030. I checked this with LLVMDisasmInstruction on both targets: words 7e1885/87/89/91… and d5c2/c3/c4/c8….

They go through the existing DPP movrel block (PLAIN_MOVREL_PATTERN). The block uses the same m0 indexing with no quad swizzle (perm=None), so each lane reads and writes its own VGPRs. Everything else is the DPP forms' code:

  • static and bounded-dynamic m0;
  • source-before-destination reads for overlapping banks;
  • the entry-mask requirement;
  • the refusals.

The DPP path is unchanged: its op == "…_dpp" comparisons became kind == …, with kind == op for DPP. Refusal messages for the plain forms name the plain instruction, for example Unsupported m0 value for v_movrels_b32.

Not in this PR: v_swaprel_b32, the SDWA forms and the scalar s_movrel*.

Evidence

PLAIN_MOVREL_BODY (tests/pixel_aot_check.py) runs each move once with a dynamic m0 and once with a static m0. The dynamic m0 comes from s_bfe_u32, or from s_and_b64 … 0x30003 for v_movrelsd_2. check_plain_movrel_draw draws it twice: as written (_e32 dynamic, _e64 static), and with the spellings exchanged. So all eight forms run with both kinds of m0, on the two DPP_MOVREL_SETS. Their channel results differ between the sets: (60, 133, 805, 193) and (80, 84, 233, 165).

  • Mutations, four per variant, each of which must give pixel_mismatch:
    • the dynamic m0 replaced by 0, separately for v_movrels, v_movreld and v_movrelsd;
    • the static m0 halves swapped for v_movrelsd_2 (0x20001 → 0x10002).
  • Translation controls, in the no-argument pixel_aot_check.py run:
    • bounded selects (dpp_soff/dpp_doff) and no QuadRead;
    • an overlapping dynamic v_movrelsd_2_b32_e32 v12, v12;
    • five refusals: an interp_base m0, an unbounded dynamic m0, a static offset past v255, an indexed VGPR past v255, and an undefined indexed source.
  • Both variants are added to the check_binary fixture list.

Windows 11 Pro 26100.9168, DXC 10.0.26100, debug layer unavailable, commit eef8bc21 on b4c961cd:

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

Other runs:

  • pixel_aot_dpp_movrel_{warp,hardware} still pass.
  • python -B tests/pixel_aot_check.py (controls) exits 0.
  • Full ctest --preset dev -E '_hardware$' before the rebase: 781/781.
  • After the rebase, the movrel tests and the controls were rerun and pass.
  • tools/form_coverage.py --gaps gfx1030 no longer lists the eight VOP1/VOP3 movrel forms.

Not run locally: tests/pixel_aot_check.py binary. This PC has no llvm-mc, so the LLVM 15 assemble/disassemble round trip of the new bodies relies on the Ubuntu job.

🤖 Generated with Claude Code

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1785) `legacy-code-archaeologist:shader/plain-movrel` → `main` · +199 −16 · 4 files · 1 commits · merged 2026-11-24 19:47 UTC Refs #1739. I built this before the issue had a maintainer reply; if you want the scope narrowed, I'll adjust. ## What `tools/pixel_aot.py` now lowers the plain VOP1 (`_e32`) and VOP3 (`_e64`) encodings of the four relative VGPR-indexing moves: - `v_movreld_b32`, `v_movrels_b32`, `v_movrelsd_b32`, `v_movrelsd_2_b32`; - LLVM 15 prints them as `v_movrels_b32_e32 v12, v24` / `_e64` for both gfx1013 and gfx1030. I checked this with `LLVMDisasmInstruction` on both targets: words `7e1885/87/89/91…` and `d5c2/c3/c4/c8…`. They go through the existing DPP movrel block (`PLAIN_MOVREL_PATTERN`). The block uses the same `m0` indexing with no quad swizzle (`perm=None`), so each lane reads and writes its own VGPRs. Everything else is the DPP forms' code: - static and bounded-dynamic `m0`; - source-before-destination reads for overlapping banks; - the entry-mask requirement; - the refusals. The DPP path is unchanged: its `op == "…_dpp"` comparisons became `kind == …`, with `kind == op` for DPP. Refusal messages for the plain forms name the plain instruction, for example `Unsupported m0 value for v_movrels_b32`. **Not in this PR:** `v_swaprel_b32`, the SDWA forms and the scalar `s_movrel*`. ## Evidence `PLAIN_MOVREL_BODY` (`tests/pixel_aot_check.py`) runs each move once with a dynamic `m0` and once with a static `m0`. The dynamic `m0` comes from `s_bfe_u32`, or from `s_and_b64 … 0x30003` for `v_movrelsd_2`. `check_plain_movrel_draw` draws it twice: as written (`_e32` dynamic, `_e64` static), and with the spellings exchanged. So all eight forms run with both kinds of `m0`, on the two `DPP_MOVREL_SETS`. Their channel results differ between the sets: (60, 133, 805, 193) and (80, 84, 233, 165). - **Mutations**, four per variant, each of which must give `pixel_mismatch`: - the dynamic `m0` replaced by 0, separately for `v_movrels`, `v_movreld` and `v_movrelsd`; - the static `m0` halves swapped for `v_movrelsd_2` (`0x20001` → `0x10002`). - **Translation controls**, in the no-argument `pixel_aot_check.py` run: - bounded selects (`dpp_soff`/`dpp_doff`) and no `QuadRead`; - an overlapping dynamic `v_movrelsd_2_b32_e32 v12, v12`; - five refusals: an `interp_base` `m0`, an unbounded dynamic `m0`, a static offset past v255, an indexed VGPR past v255, and an undefined indexed source. - Both variants are added to the `check_binary` fixture list. Windows 11 Pro 26100.9168, DXC 10.0.26100, debug layer unavailable, commit eef8bc21 on b4c961cd: ``` ctest --preset dev --no-tests=error -R "^pixel_aot_plain_movrel_" -V ``` | Adapter | Driver | Result | |---|---|---| | WARP | 10.0.26100.8972 | 4096 pixels, max error 0, both sets, both variants; all 8 mutations mismatched | | NVIDIA Quadro M1000M | 32.0.15.7371 | same | **Other runs:** - `pixel_aot_dpp_movrel_{warp,hardware}` still pass. - `python -B tests/pixel_aot_check.py` (controls) exits 0. - Full `ctest --preset dev -E '_hardware$'` before the rebase: 781/781. - After the rebase, the movrel tests and the controls were rerun and pass. - `tools/form_coverage.py --gaps gfx1030` no longer lists the eight VOP1/VOP3 movrel forms. **Not run locally:** `tests/pixel_aot_check.py binary`. This PC has no `llvm-mc`, so the LLVM 15 assemble/disassemble round trip of the new bodies relies on the Ubuntu job. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The VOP1 (_e32) and VOP3 (_e64) encodings of v_movreld_b32, v_movrels_b32,
v_movrelsd_b32 and v_movrelsd_2_b32, which LLVM 15 prints with two VGPR
operands for gfx1013 and gfx1030 alike, now lower through the existing
DPP movrel m0 indexing without a quad swizzle: each lane reads and writes
its own VGPRs. Static and bounded-dynamic m0, source-before-destination
reads for overlapping banks, the entry-mask requirement and the refusals
are the DPP forms' code path. v_swaprel_b32, the SDWA forms and s_movrel*
stay outside.

PLAIN_MOVREL_BODY runs each move with a dynamic and a static m0 and is
drawn twice, as written and with _e32/_e64 exchanged, so all eight forms
see both kinds of m0, on the two DPP_MOVREL_SETS constant sets. Four
mutations per variant (dynamic m0 ignored for three moves, swapped static
m0 halves for v_movrelsd_2) must produce a pixel mismatch. The
translation controls check the bounded selects, an overlapping bank and
five refusals; both variants join the check_binary round trip.

Windows 11 26100: pixel_aot_plain_movrel_warp (WARP 10.0.26100.8972) and
_hardware (Quadro M1000M, 32.0.15.7371, debug layer unavailable) pass,
4096 pixels with zero error for both sets and variants; every mutation
mismatched. pixel_aot_dpp_movrel_{warp,hardware} still pass. Full dev
suite without _hardware: 781/781. check_binary was not run locally (no
llvm-mc here).

Refs #1739

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:33:26 +00:00
github manually merged commit cf547ed40b into gh-pr/1785/base 2026-11-26 23:33:28 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 18:50 UTC · original

This PR currently has merge conflicts with main at eef8bc2113bb08253313ad1e8648e9b414f26fdb; could you please rebase it onto the latest main so we can verify and review it?
AI-assisted.

**@⁠tedin7** on GitHub · 2026-11-24 18:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1785#issuecomment-7141217635) This PR currently has merge conflicts with `main` at `eef8bc2113bb08253313ad1e8648e9b414f26fdb`; could you please rebase it onto the latest `main` so we can verify and review it? AI-assisted.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-24 18:51 UTC · original · approved these changes

Overview

Excellent PR. The approach of normalizing through kind to reuse the DPP movrel indexing logic is elegant, and the test coverage is outstanding for a 199-line change.

Specific observations

  • The normalization chain kind = op if op.endswith("_dpp") else f"{op}_dpp" correctly maps plain forms to the same indexing rule. The subsequent kind == "v_movreld_b32_dpp" checks then work for both encodings without duplication.
  • The PLAIN_MOVREL_BODY fixture is well-designed: R/G/B/A channels exercise each instruction variant (v_movrels, v_movreld, v_movrelsd, v_movrelsd_2) with distinct m0 sources, and both constant sets produce different channel outputs to catch incorrect indexing.
  • Mutation testing is thorough -- four mutations per variant all correctly produce pixel mismatches.
  • Refusal coverage (interp_base m0, unbounded dynamic m0, static offset past v255, indexed VGPR > 255, undefined indexed source) matches the DPP forms' expectations.
  • swap_movrel_encodings() is correct -- _e32 and _e64 are hardware-interchangeable for these instructions.
  • The out-of-scope items (v_swaprel_b32, SDWA forms, s_movrel*) are well-documented.

Minor notes

  • The docs/experiments.md entry is dense but matches the existing style.
  • Error messages for plain forms now name the actual instruction, which improves diagnostics.

Verdict

No blocking issues. Scope is well-contained -- 4 instruction encodings with ~20 lines of code changes. Ready to merge.

**@⁠KelboLive** on GitHub · 2026-11-24 18:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1785#pullrequestreview-6045362856) · **approved these changes** ## Overview Excellent PR. The approach of normalizing through `kind` to reuse the DPP movrel indexing logic is elegant, and the test coverage is outstanding for a 199-line change. ## Specific observations - The normalization chain `kind = op if op.endswith("_dpp") else f"{op}_dpp"` correctly maps plain forms to the same indexing rule. The subsequent `kind == "v_movreld_b32_dpp"` checks then work for both encodings without duplication. - The PLAIN_MOVREL_BODY fixture is well-designed: R/G/B/A channels exercise each instruction variant (`v_movrels`, `v_movreld`, `v_movrelsd`, `v_movrelsd_2`) with distinct m0 sources, and both constant sets produce different channel outputs to catch incorrect indexing. - Mutation testing is thorough -- four mutations per variant all correctly produce pixel mismatches. - Refusal coverage (interp_base m0, unbounded dynamic m0, static offset past v255, indexed VGPR > 255, undefined indexed source) matches the DPP forms' expectations. - swap_movrel_encodings() is correct -- `_e32` and `_e64` are hardware-interchangeable for these instructions. - The out-of-scope items (`v_swaprel_b32`, SDWA forms, `s_movrel*`) are well-documented. ## Minor notes - The `docs/experiments.md` entry is dense but matches the existing style. - Error messages for plain forms now name the actual instruction, which improves diagnostics. ## Verdict No blocking issues. Scope is well-contained -- 4 instruction encodings with ~20 lines of code changes. Ready to merge.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 19:29 UTC · original · reviewed

Review of eef8bc21 (head of this PR). Comment only, no approval.

Verdict: no correctness problems found. One test gap (P3) and one note.

Semantics (tools/pixel_aot.py). The plain _e32/_e64 forms are routed into the existing DPP movrel code by mapping the op to its _dpp name (kind). So the indexing is the same code the DPP forms already use: v_movreld writes VGPR[dst + m0], v_movrels reads VGPR[src + m0], v_movrelsd does both, v_movrelsd_2 reads with m0[9:0] and writes with m0[25:16]. That matches the public RDNA 2 ISA text the PR cites. Operand order (dst first, src second), the 0..255 base check, the static and bounded-dynamic m0 rules and the read-all-sources-before-any-write rule are all inherited unchanged. With no swizzle the source is used as asuint(vN), a bit-exact copy. The regex only matches two plain VGPR operands, so e64 spellings with a source modifier, clamp or omod do not match and fall to the generic refusal. plain is only read in the branch where it was assigned (walrus in the or), so there is no unbound-name path.

Commands run locally (worktree at the exact SHA above, Linux)

  • python3 -B tests/pixel_aot_check.py (no arguments, the device-free controls): passed.
  • python3 -B tests/rdna2_tools_check.py: 148 tests, OK (18 skipped).
  • git diff --check origin/main...HEAD, tests/docs_links_check.py (17 files, 366 links), tests/bidi_controls_check.py: clean.
  • Three real mutations of tools/pixel_aot.py, each followed by the controls and then reverted with git checkout -- . (tree clean afterwards):
    • v_movrels static branch swapped to write instead of read: caught (Unbound vector operand v33).
    • dst and src bases swapped: caught (Expected a numeric VGPR at v32).
    • the plain form accepted outside the entry mask (the raise at tools/pixel_aot.py:5191 removed): not caught, controls still pass.

P3 – missing control. The plain branch has its own mask != "entry" refusal at tools/pixel_aot.py:5191, but no control exercises it, as the mutation above shows. The docs say the mask refusals are "shared with the DPP forms", which is true of the DPP message at line 5183 but not of this new line. One short control (a plain v_movrels_b32_e32 inside a non-entry exec region, expecting outside entry mask) would cover it.

Note. The control list does not include an _e64 form with a modifier or an SGPR operand. I believe the regex refuses them, but I did not add a probe.

Not run by me: pixel_aot_plain_movrel_{warp,hardware} (needs Windows with DXC and offscreen_check); I rely on the PR text for the GPU results.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 19:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1785#pullrequestreview-6045946910) · **reviewed** Review of `eef8bc21` (head of this PR). Comment only, no approval. **Verdict: no correctness problems found. One test gap (P3) and one note.** **Semantics (tools/pixel_aot.py).** The plain `_e32`/`_e64` forms are routed into the existing DPP movrel code by mapping the op to its `_dpp` name (`kind`). So the indexing is the same code the DPP forms already use: `v_movreld` writes VGPR[dst + m0], `v_movrels` reads VGPR[src + m0], `v_movrelsd` does both, `v_movrelsd_2` reads with m0[9:0] and writes with m0[25:16]. That matches the public RDNA 2 ISA text the PR cites. Operand order (dst first, src second), the 0..255 base check, the static and bounded-dynamic m0 rules and the read-all-sources-before-any-write rule are all inherited unchanged. With no swizzle the source is used as `asuint(vN)`, a bit-exact copy. The regex only matches two plain VGPR operands, so `e64` spellings with a source modifier, clamp or omod do not match and fall to the generic refusal. `plain` is only read in the branch where it was assigned (walrus in the `or`), so there is no unbound-name path. **Commands run locally** (worktree at the exact SHA above, Linux) - `python3 -B tests/pixel_aot_check.py` (no arguments, the device-free controls): passed. - `python3 -B tests/rdna2_tools_check.py`: 148 tests, OK (18 skipped). - `git diff --check origin/main...HEAD`, `tests/docs_links_check.py` (17 files, 366 links), `tests/bidi_controls_check.py`: clean. - Three real mutations of `tools/pixel_aot.py`, each followed by the controls and then reverted with `git checkout -- .` (tree clean afterwards): - `v_movrels` static branch swapped to write instead of read: **caught** (`Unbound vector operand v33`). - dst and src bases swapped: **caught** (`Expected a numeric VGPR at v32`). - the plain form accepted outside the entry mask (the `raise` at `tools/pixel_aot.py:5191` removed): **not caught**, controls still pass. **P3 – missing control.** The plain branch has its own `mask != "entry"` refusal at `tools/pixel_aot.py:5191`, but no control exercises it, as the mutation above shows. The docs say the mask refusals are "shared with the DPP forms", which is true of the DPP message at line 5183 but not of this new line. One short control (a plain `v_movrels_b32_e32` inside a non-entry exec region, expecting `outside entry mask`) would cover it. **Note.** The control list does not include an `_e64` form with a modifier or an SGPR operand. I believe the regex refuses them, but I did not add a probe. **Not run by me:** `pixel_aot_plain_movrel_{warp,hardware}` (needs Windows with DXC and `offscreen_check`); I rely on the PR text for the GPU results. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.