startup: lower v_mov_b32_sdwa in gfx2hlsl #2278
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2286"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T10:07:12Z.
Change
tools/startup/gfx2hlsl.pyrefused everyv_mov_b32_sdwawithSDWA form of v_mov_b32.sdwa()nowlowers it through the existing
sdwa_source/sdwa_desthelpers as a one-source operation whose resultis the selected source. Refs #2274 (item "SDWA v_mov").
Lowered (each spelling assembles with llvm-mc 15,
-mcpu=gfx1013):src0_selBYTE_0..3, WORD_0..1, DWORD, zero-extended or undersext();dst_selBYTE_0..3, WORD_0..1, DWORD withdst_unusedUNUSED_PAD or UNUSED_PRESERVE;dst_sel:DWORD, where there are no unused bits;Still refused, with the reason named:
dst_unused:UNUSED_SEXTwith a byte or word destination:SDWA UNUSED_SEXT(unchanged helper);clamp(llvm-mc assembles it):v_mov_b32 with SDWA modifier clamp;exec/vcc/a tracked mask register:v_mov_b32 SDWA <sel> of lane mask <operand>.The translator holds a lane mask as one bit per lane, so a field of it is not the hardware field.
A DWORD selection of a mask stays the plain move.
src0_selordst_sel.No shared interface changes;
VEC_Uand the DPP path are untouched.Verification
Commit
d2f08372onstartup/gfx2hlsl-sdwa-v-mov, Windows 11, Python fromout/pe-env.python -B tests/startup_gfx2hlsl_sdwa_check.pypython -B tests/startup_gfx2hlsl_sdwa_cvt_check.pypython -B tests/startup_gfx2hlsl_handler_arity_check.pypython -B tests/form_coverage_check.pypython -B tests/pso_readiness_check.pypython -B tests/startup_translator_check.pypython -B tests/shader_corpus_report_check.pygit diff --check origin/main...HEADNegative control: the new check against
tools/startup/gfx2hlsl.pyfromorigin/mainexits 1 with 38MISMATCH lines; the first is
v_mov source BYTE_0 zero-extended, emittedrefused: SDWA form of v_mov_b32.Not run: CMake/ctest, the
drawmode of the SDWA conversion check and any GPU test. The evidence here isdevice-free: there is no GPU read-back for this form.
Evidence and follow-up
The new cases are synthetic assembly lines written for this check (MIT, no external input). Each of the 7
source selections (zero- and sign-extended) and 7 destination selections (PAD and PRESERVE) is compared
as a whole statement against a hand-written literal, so a shift, mask or keep-mask off by one fails its
own case. Refusals are matched on their reason text.
Assumptions and gaps another contributor can pick up:
tools/pixel_aot.py; theyare not read back from a device for
v_mov_b32_sdwa.dst_unusedis not printed,sdwa()assumes UNUSED_PAD, while llvm-mc 15 fills inUNUSED_PRESERVE. Pre-existing and not changed here.
VEC_U) do not refuse a byte or word of a lane mask. Not changed here.startup_gfx2hlsl_sdwais registered in CMake only, not in the pure-Python lists of.github/workflows/windows.ymlandAGENTS.md. Left as it was.Checklist
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:10:48Z.
Review: COMMENTED
Review of head
d2f083723b(tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_sdwa_check.py).Findings: 0 P1, 0 P2.
v_mov_b32_sdwareuses the existing SDWA path with the selected source as the result. Zero-extend, sign-extend (byte/word shifts), dst_sel placement and UNUSED_PAD/UNUSED_PRESERVE keep-masks match the RDNA2 SDWA semantics. UNUSED_SEXT with a sub-dword destination, clamp, missing src0_sel/dst_sel are refused.v_mov_b32_sdwa.Commands executed locally:
python3 tests/startup_gfx2hlsl_sdwa_check.py-> PASSpython3 tests/docs_links_check.py-> 18 files, 435 links OKpython3 tests/bidi_controls_check.py-> OKgit diff --check origin/main...HEAD-> cleanif False and ...) -> new tests FAIL (lane-mask refusal cases), reverted.({0} ^ 1u)-> new tests FAIL, reverted.Build and test on Windowspass. Py-only change, so the pure-python fast path applies.AI-assisted; commands listed were executed locally.