Repository navigation
shader: lower the SDWA v_movrel* forms in pixel_aot - #1934
Conversation
v_movreld_b32_sdwa, v_movrels_b32_sdwa, v_movrelsd_b32_sdwa and v_movrelsd_2_b32_sdwa (LLVM 15 spells them identically for gfx1013 and gfx1030) now go through the movrel block: the m0 rules, refusals and source-before-destination reads are unchanged. The source selection, with an optional sext(...), applies to the indexed source word and the destination selection to each indexed destination, as v_mov_b32_sdwa applies them; UNUSED_PRESERVE keeps the bits from that destination's own tracked old value, so under a dynamic m0 each reachable destination merges its own word (order read from the RDNA 2 naming, not measured on RDNA hardware). UNUSED_SEXT, UNUSED_PRESERVE into an untracked destination, clamp, 16-bit values, SGPR sources and the movrel refusals are refused. SDWA_MOVREL_BODY runs each move with a dynamic and a static m0 over integer banks with BYTE, WORD and DWORD selections, sext, PAD and PRESERVE, exported through the bit-exact R32G32B32A32_UINT target against an independent SDWA model; five controls must mismatch. The translation controls check nine refusals, the entry mask and a dynamic PRESERVE move inside one bank. Windows 11 26100: pixel_aot_sdwa_movrel_warp (WARP 10.0.26100.8972) and _hardware (Quadro M1000M, 32.0.15.7371) match bit for bit on both sets; every control mismatched. pixel_aot_check.py binary with LLVM 15 passes. Full dev suite without _hardware: 854/854. Refs R0Y00#1917 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head bc03f191030951c765c8d1af26f415b6041fdb7a.
Result: 0 P1, 0 P2. The change is correct and clean-room. I am not merging it, because older open PRs already cover the same files (see "Merge note").
What I read:
tools/pixel_aot.py: SDWAv_movreld/movrels/movrelsd/movrelsd_2are lowered through the existing movrel block.sdwa_sourceapplies to the indexed source word.sdwa_destapplies to each reachable destination, merging that destination's own tracked old value forUNUSED_PRESERVE.UNUSED_SEXTand an unbalancedsext(are refused.CMakeLists.txt: only registerspixel_aot_sdwa_movrel_${adapter}.docs/experiments.md: describes the behavior and says the operand order is not measured on RDNA hardware.- No copied vendor code.
Commands run locally (exit codes):
python3 -B tests/pixel_aot_check.py: 0python3 tests/docs_links_check.py: 0 (18 files, 386 links)python3 tests/bidi_controls_check.py: 0git diff --check origin/main...HEAD: 0git merge-tree --write-tree --name-only origin/main HEAD: no conflicts- Windows Server 2025 node,
x2w_pipe.py win2025 1934scoped to^pixel_aot_(sdwa_movrel|swaprel|smovrel)_: Debug 6/6 and Release /O2 6/6 passed.form_coverage_check.pypassed there.
Mutations (each reverted afterwards):
- Dropped
sdwa_source(...)in the movrel block.pixel_aot_check.pyon Linux still passes, so the translation checks do not pin the source selection. Thepixel_aot_sdwa_movrel_warpandpixel_aot_sdwa_movrel_hardwaredraws on Windows fail, so the GPU test kills it. - Replaced the dynamic-
m0sdwa_dest(...)merge with the raw value.pixel_aot_check.pyfails, so it is killed.
Non-blocking suggestion: pin a source-selection text in the Linux translation controls too. Then mutation 1 fails without a GPU.
CI at the time of review: the Linux Python job passed. The two Windows jobs and the fixtures job were still pending.
Merge note: #1923, #1790, #1612, #1670 and #1572 are older, open and not drafts. They rewrite CMakeLists.txt, docs/experiments.md, tests/pixel_aot_check.py and tools/pixel_aot.py in the same regions. They have no CHANGES_REQUESTED, so the competing-PR gate stays closed. This one will need a rebase after any of them lands.
AI-assisted; commands listed were executed locally.
Ran it, and found one lowering effect the fixture does not pinWindows 11 build 26300.9974, device-free path only: out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py
exit 0( Mutations
The last one is a real behavioural change, not an equivalent mutant. With i.e. the source selection ( Why it passesThe positive case is asserted at line 16481: sdwa_hlsl = translate_int(uncompressed_export(SDWA_MOVREL_BODY))
assert "dpp_soff" in sdwa_hlsl and "dpp_doff" in sdwa_hlsl and "QuadRead" not in sdwa_hlslwhich establishes the instruction is accepted and does not become a quad read, but says nothing about the two selections being Suggested fix, one line each, in the same style the DPP cases already use: assert "((asuint(dpp_src27) >> 24u) & 0xffu)" in sdwa_hlsl # src0_sel:BYTE_3 with sext
assert "((asuint(alu30) & 0xffff0000u) | ((dpp_val37 & 0xffffu) << 0u))" in sdwa_hlsl # dst_sel:WORD_0(Those two substrings come from the unmutated output above; pick whichever cases your body actually contains — the point is that What is good hereThe refusal set is thorough, the VerdictOne blocking-ish gap: the source selection is unpinned. Everything else I could break was caught. Notes
|
Follow-up to ChazY11's review of #1934: the device-free pixel_aot_check.py run only checked that SDWA_MOVREL_BODY translates, so dropping the source selection still passed it (the draw caught it). SDWA_MOVREL_PINS now lists the exact expression each source and destination selection of the body produces, with temporaries as \d+, and how often it must appear (once per static move, once per reachable destination of a dynamic one). Each of five one-line mutations of tools/pixel_aot.py, applied alone, now makes `python -B tests/pixel_aot_check.py` exit 1: the source selection dropped (the reported survivor), sext ignored, the single-destination selection dropped, the dynamic-destination selection dropped, and dynamic UNUSED_PRESERVE treated as UNUSED_PAD. tools/pixel_aot.py is unchanged. Refs #1917, #1934 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1917. I built this before the issue had a maintainer reply; if you want the scope narrowed, I'll adjust. This completes the VGPR movrel encodings: plain (#1785), DPP (already there), SDWA (here), swaprel (#1844) and scalar (#1894).
What
tools/pixel_aot.pylowersv_movreld_b32_sdwa,v_movrels_b32_sdwa,v_movrelsd_b32_sdwaandv_movrelsd_2_b32_sdwathrough the existing movrel block. LLVM 15 spells them identically for gfx1013 and gfx1030, for example7e1886f9 00001518asv_movrels_b32_sdwa v12, v24 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:BYTE_0.Unchanged: the
m0rules, the refusals and the source-before-destination reads.Selections, applied as
v_mov_b32_sdwaapplies them (sdwa_source,sdwa_dest):sext(...), applies to the indexed source word;UNUSED_PRESERVEkeeps the unselected bits from that destination's own tracked old value, so under a dynamicm0each reachable destination merges its own word.Refused:
UNUSED_SEXT;UNUSED_PRESERVEinto an untracked destination;clamp;Under a dynamic
m0, every reachable destination must hold a tracked numeric word, also forUNUSED_PAD, as for the other movrel forms.Evidence
SDWA_MOVREL_BODY(tests/pixel_aot_check.py) runs each move with a dynamic and then a staticm0over integer banks. It mixes BYTE, WORD and DWORD selections,sext,UNUSED_PADandUNUSED_PRESERVE, and exports four words through the bit-exactR32G32B32A32_UINTtarget, where they must equal an independent SDWA model. The expected words on the twoDPP_MOVREL_SETS:pixel_mismatchrequired):UNUSED_PRESERVEturned intoUNUSED_PAD;m0;sext.UNUSED_PRESERVEmove inside one bank in which each reachable register merges its own old word.Windows 11 Pro 26100.9168, DXC 10.0.26100, debug layer unavailable:
Other runs:
tests/pixel_aot_check.py binarypasses.llvm-mcis clang 15.0.7's integrated assembler, withllvm-objcopyandLLVM-C.dllfrom the same build.ctest --preset dev -E '_hardware$': 854/854.tests/form_coverage_check.pypasses;tools/form_coverage.py --gaps gfx1030no longer lists anyv_movrel*form.🤖 Generated with Claude Code