cpu: lower 64-bit GPR-to-XMM MOVQ transfers in cpu_sse_aot #2309
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2317"
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 Ammmae0x on 2026-11-25T12:02:51Z.
Change
Lowers 64-bit GPR-to-XMM and XMM-to-GPR
MOVQregister transfers (Code.MOVQ_RM64_XMMandCode.MOVQ_XMM_RM64) intools/cpu_sse_aot.pyand extends thescalar_floatdifferential fixture and rejection suite (tests/cpu/scalar_float.{asm,def},tests/cpu/scalar_float_check.py,CMakeLists.txt):GPR_STORE_MOVESandGPR_LOAD_MOVESdispatch tables intools/cpu_sse_aot.pysoScalarLifter.statement()lowersMOVD(32-bit GPR viaRegisterExt.is_gpr32) andMOVQ(64-bit GPR viaRegisterExt.is_gpr64) between XMM and GPRs, enforcing full low-qword XMM definedness (parts(xmm, 8)), full 64-bit GPR definedness (full(gpr)), and bit-exact 64-bit transfers without NaN canonicalization or upper-32 truncation.movq_gpr=q:dqtotests/cpu/scalar_float.asm(using portable MASMDBencodings and aSWAP_OPERANDScontrol switchingxortoadd),tests/cpu/scalar_float.def,CMakeLists.txt, andtests/cpu/scalar_float_check.py.(double, uint64)pairs plus 13 fixed bit-pattern answers (-0.0, SNaNs, QNaNs, subnormals,+/-inf), and adds rejection controls forMOVQreading a 32-bit-only XMM (q:fqand patchedblend_ss), undefinedr11/rdx/xmm5, nonvolatilerbx/xmm6, MMXMOVQ, and width-mismatchedMOVD/MOVQencodings.Verification
Commit:
57d1e034(based onupstream/mainda2c0a9f). Built and verified in bothdev(Debug) andrelease(/O2) with MSVC/ML64 (& .\tools\dev.ps1):cmake --build --preset dev --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness cpu_fuzz_scalar_fp cpu_fuzz_scalar_fp_lifted cpu_fuzz_scalar_fp_mutant cpu_fuzz_scalar_fp_lifted_o2-> exit0(0 errors; 0 warnings oncpu_float_*andcpu_mxcsr_harness)cmake --build --preset release --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness cpu_fuzz_scalar_fp cpu_fuzz_scalar_fp_lifted cpu_fuzz_scalar_fp_mutant cpu_fuzz_scalar_fp_lifted_o2-> exit0(0 errors; 0 warnings oncpu_float_*andcpu_mxcsr_harness)ctest --preset dev --output-on-failure -E "cpu_native_archive_" -R "^(cpu_aot_scalar_float|cpu_aot_fuzz_scalar_fp)$"->2/2 Passed(cpu_aot_fuzz_scalar_fp1.36s,cpu_aot_scalar_float5.18s; 0 skips)ctest --preset release --output-on-failure -E "cpu_native_archive_" -R "^(cpu_aot_scalar_float|cpu_aot_fuzz_scalar_fp)$"->2/2 Passed(cpu_aot_fuzz_scalar_fp1.37s,cpu_aot_scalar_float5.27s; 0 skips)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> exit0(form coverage checks passed)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> exit0(Self-test passed. Checked 18 Markdown files and 448 links.)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> exit0(Self-test passed. Checked 1608 tracked source, script and build/CI files: no bidirectional controls.)tools/cpu_sse_aot.py(is_gpr_width(ins.op0_register),is_gpr_width(ins.op1_register), storegpr_widthnarrowed to4, and omittingreads.add(full(ins.op1_register))) causedtests/cpu/scalar_float_check.pyto fail with exit1in all 4/4 cases.Evidence and follow-up
tests/cpu/scalar_float.asmis a source-built MASM fixture registered with; coverage: source cpu_aot_scalar_floatunder the repository MIT license; no external binaries or game files are added.ctest --preset dev -R "^cpu_aot_scalar_float$"andctest --preset release -R "^cpu_aot_scalar_float$".Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:07:33Z.
Review: COMMENTED
Review of head
57d1e03471fa2f230b79344f32b773c90b9702aa(comment only).Verdict: no blocking findings. P1=0, P2=1, nits=1.
What I checked
tools/cpu_sse_aot.py,tests/cpu/scalar_float.{asm,def},tests/cpu/scalar_float_check.py,CMakeLists.txt(5 files, +96/-14). Title is neutral; PR is not Draft; mergeable.GPR_STORE_MOVES/GPR_LOAD_MOVEStables key on the exact icedCode(not just the mnemonic), and each entry checks the GPR width. This also stops MMXMOVD/MOVQforms from slipping through the oldmnemonic == M.MOVDtest, since they now hitunsupported. Good tightening.parts(xmm, 8)viasource(..., 8)), writesfull(gpr)with no 32-bit zero-extension. 64-bit load: marks the full GPR as read and defines the whole low quadword of the XMM. Matches the ISA (no NaN canonicalisation, upper XMM bits zeroed by MOVQ).tests/cpu/scalar_float_check.py:788-796,:835-836.movq_gpr=q:dqadded to the shared signature string for both the original and swapped variants; theSWAP_OPERANDScontrol (addinstead ofxor) keeps the swapped build a real control.Commands executed locally (Linux, worktree at the head SHA)
git diff --check origin/main...HEAD-> cleanpython3 tests/docs_links_check.py->Checked 18 Markdown files and 448 links.python3 tests/bidi_controls_check.py->no bidirectional controlspython -m py_compile tools/cpu_sse_aot.py tests/cpu/scalar_float_check.py-> OKpython3 x2w_pipe.py win2025 2317 --regex cpu_aot_scalar_float --targets cpu_float_original,cpu_float_original_lifted,cpu_float_swapped,cpu_float_swapped_lifted,cpu_mxcsr_harness-> dev:
cpu_aot_scalar_floatPassed 1/1; release (/O2): Passed 1/1.Mutations (applied via
--patch, rebuilt with reconfigure, then discarded)GPR_STORE_MOVES[MOVQ_RM64_XMM]width 8 -> 4: killed (lifter build step fails, the lifted .cpp is not generated).GPR_LOAD_MOVES[MOVQ_XMM_RM64]width 8 -> 4: survived,cpu_aot_scalar_floatstill Passed on dev.Findings
tools/cpu_sse_aot.py:51(+:162-166): mutation 2 above is not caught. Eitherself.operand(ins, 1, gpr_width)ignores the width argument for a 64-bit register (then the table width is dead for loads and theis_gpr64check is the only real guard), or the fixture does not observe a truncated load. WithINTEGERScontaining values above 2^32 I would expect truncation to show, so please check which one it is. If the width is ignored, say so in a comment or drop the redundant width fromGPR_LOAD_MOVES; if it is observable, add the missing case.AI-assisted; commands listed were executed locally.