shader: lower v_swaprel_b32 with the movrel m0 indexing in pixel_aot #1844
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1844
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1844/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@legacy-code-archaeologist on GitHub · 2026-11-24 19:23 UTC · original
legacy-code-archaeologist:shader/swaprel→main· +392 −22 · 6 files · 2 commits · merged 2026-11-24 19:47 UTCRefs #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.pylowersv_swaprel_b32 vdst, vsrc(VOP1 only; LLVM 15 decodes7e18d118asv_swaprel_b32 v12, v24for gfx1013 and gfx1030).VGPR[vdst + m0[25:16]]andVGPR[vsrc + m0[9:0]], the same split asv_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.m0rules and refusals of the movrel forms: static, or dynamic with a proven bit mask, which lowers to bounded selects on both sides.Existing tests changed (please check)
Two checks pinned
v_swaprel_b32as untranslated:tests/form_coverage_check.py::check_swap_coveragenow requiresv_swaprel_b32to be accepted and covered. A new control requires it to be uncovered without its own word, next to the existingv_swap_b32control.tests/rdna2_tools_check.py: only a comment changes. The scanner's static tables still listv_swaprel_b32as untranslated, and the test stays green (148 tests OK).Evidence
SWAPREL_BODYruns the following, against an independent list-swap reference on the twoDPP_MOVREL_SETS:m0 = word3 & 0x30003, which differs between the sets;m0 = 0x30001);0x20002);0x20001).The bank sums are 816, 117, 338, 125 and 218, 128, 338, 125.
Controls (
pixel_mismatchrequired):v_movrelsd_2_b32_e32in place of the dynamic swap;m0halves;m0replaced by 0.Translation controls:
interp_basem0, anm0from an unbounded SGPR, an unbounded dynamicm0(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:
Other runs:
python -B tests/pixel_aot_check.py(controls) exits 0.python -B tests/form_coverage_check.pypasses.python -B tests/rdna2_tools_check.py: 148 OK.ctest --preset dev -E '_hardware$': 782/785. The three failures werepixel_aot_warp,pixel_aot_buffer_color_warpandpixel_aot_three_way_warp, which timed out under-j 4and pass when run alone (3/3).tools/form_coverage.py --gaps gfx1030no longer listsv_swaprel_b32.Not run locally:
tests/pixel_aot_check.py binary, because there is nollvm-mchere.🤖 Generated with 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]>@tedin7 on GitHub · 2026-11-24 19:38 UTC · original · reviewed
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_b32branch and the plainv_movrel*branch): read in full, no defect.swap_sval/swap_dvalbefore 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 cases0x30001,0x20002and0x20001; each register gets the right value.m0, static offset past 255, indexed VGPR past v255, undefined indexed source, outstanding sample.kindand 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_dpppath is unchanged.v_swaprel_b32 v12, v24as0x7e18d118.P2: the Linux-mode
tests/pixel_aot_check.pydoes 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 thedraw-swaprelanddraw-plain-movrelmodes, which need dxc and a D3D12 adapter. I applied one-line mutations totools/pixel_aot.py, one at a time, and ran the check with no arguments. The check returned rc=0 for these four:swap_svalinstead ofswap_dvalfor the source-side registers[m0_u & 0x3ff]and[(m0_u >> 16) & 0x3ff]exchanged)m0_mask >> 16value = value)It returned rc=1 for one: forcing
kindtov_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 emittedswap_*/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 newv_swaprel_b32accepted-word control: pass.main(8e2923ae) has no content conflicts (git merge-tree).binary llvm-mc-19 ...modes ofpixel_aot_check.pyandrdna2_tools_check.pyfail with the same assertions on the PR's merge base (for examplev_cvt_f16_i16_e32 v1, 0xfff0decodes 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: cleantests/docs_links_check.py: pass (18 files, 370 links)tests/bidi_controls_check.py: passtests/pixel_aot_check.py: passtests/rdna2_tools_check.py: pass (148 tests, 18 skipped)tests/form_coverage_check.py: passtests/pixel_aot_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.soandtests/rdna2_tools_check.py binary ...: fail identically on the merge base (see above)llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encodingon the three new spellingsgit checkout -- .AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-24 19:47 UTC · original · reviewed
Follow-up Win2025 verification on head
7a75c9ab72ebb12b25a34e0ca22cbc88cf4b110f:--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_warp4.57s,pixel_aot_plain_movrel_warp6.55s,rdna2_tools_check11.77s,pixel_aot_warp14.71s)./O2(--preset release): 4/4 passed (pixel_aot_swaprel_warp3.33s,pixel_aot_plain_movrel_warp6.38s,rdna2_tools_check10.99s,pixel_aot_warp14.26s).tests/pixel_aot_check.pyok (9.9s),tests/form_coverage_check.pyok (17.0s).v_swaprel_b32m0shift>> 16->>> 17intools/pixel_aot.pyfailed cleanly (rc=1,tests/form_coverage_check.pyrc=1).No P1/P2 defects found.
AI-assisted; commands listed were executed locally.