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

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/1785 into main 2026-11-24 19:47:37 +00:00
legacy-code-archaeologist commented 2026-11-24 18:38:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T18:38:28Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588835976 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1785). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-24T18:38:28Z. --- 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)
KelboLive commented 2026-11-24 19:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-24T18:51:34Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045362856 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1785#pullrequestreview-6045362856). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-24T18:51:34Z. **Review:** APPROVED --- ## 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.
tedin7 commented 2026-11-24 19:01:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:50:06Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141217635 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1785#issuecomment-7141217635). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:50:06Z. --- 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.
upstream-sync closed this pull request 2026-11-24 20:00:35 +00:00
tedin7 commented 2026-11-24 20:00:35 +00:00 (Migrated from github.com)

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

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045946910 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1785#pullrequestreview-6045946910). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:29:49Z. **Review:** COMMENTED --- 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.
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!1778
No description provided.