cpu: lower MOVBE in the shared lifter #406
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/412"
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 denn0x on 2026-11-22T00:45:09Z.
Change
Advances CPU translation coverage. MOVBE is an independent problem:
lower()rejects it today, and no open PR or issue claims it. I checked the diffs of the opencpu:PRs for the mnemonic. There is no prerequisite PR.The shared interface is
lower()intools/ffx_version_query.pyandCPU_FIXTURESintools/form_coverage.py. #287, #289, #291, #326, #328, #331, #335, #368, #379, #386 and #403 also extend these. This change adds oneelifbranch afterM.LEA, at an anchor none of them uses. A trial merge into this branch is clean for each of #287, #289, #291, #326, #328, #331 and #335, and for #368, #379, #386 and #403 together. The tree combined with those four passes all 47cpu_tests.Lowering.
movbe r16/r32/r64, mandmovbe m, r16/r32/r64. The bytes are reversed in either direction, by an explicit byte loop at the operand width.write(). The native fixture confirms both.Fixture
tests/cpu/movbe.asmbuilds ten exports:r10wandr11destinations with displacements;r10store through a scaled index;emitasserts that each export contains the expected icedCode. Each export first sets ZF and CF from a preset, so the check sees whether MOVBE leaves them alone. The destination register starts with the second argument, so the upper-bit behaviour of the 16- and 32-bit loads is observed.tests/cpu/movbe.py checkcompares RAX, ZF/CF, the data bytes and 64 guard bytes on each side for 2880 cases. The cases cover nine offsets, including misaligned ones, eight values and four flag presets. Each case runs against the native DLL, the translation and a Python reference.The test exits 77 (capability skip) when CPUID leaf 1 ECX bit 22 (
MOVBE) is clear, ascpu_aot_bmi1does for BMI1.Negative controls. Three translations of the same image are mutated after lowering, and each must mismatch:
noswapclear16flagsOn
main,lower()rejects0f 38 f0 01 c3withunsupported query operation at 0x1000: movbe eax,[rcx]and48 0f 38 f1 11 c3with... movbe [rcx],rdx.Verification
Tested at
4732db9on6549244. Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, Python 3.13, AMD Ryzen 7 7700 (Zen 4, MOVBE present).Full suite:
ctest --preset dev --no-tests=error --output-junit <repo>/out/test-results.xmlgives 143 passed, 2 failed and 2 capability skips (bvh_wave64_warp,wave_shuffle_warp). The run includes the GPU tests.gpu_alias_lookup_writes_hardwareis the RDNA 4 array-atomics probe recorded in #369 and #383, which fails the same way onmain. This change touches no GPU code.docs_linksfailed because it ran before the new fixture was staged in git. After staging,ctest --preset dev --no-tests=error -R '^docs_links$'passes.Pure-Python checks:
tests/form_coverage_check.pyandtests/docs_links_check.pypass.Fork CI: the Windows build-and-test, Linux Python and gfx1013 LLVM jobs passed at
4732db9in the fork'sWindows checksrun 44967785705.cpu_aot_movberan there and passed, so the runner has MOVBE.Coverage.
python tools/form_coverage.py out/test-results.xmlgives x64 56 of 948 forms, 55 withoutcpu_aot_movbe. The added form ismovbe.Evidence
The fixture is synthetic and original to this repository (MIT).
docs/experiments.mddocuments the lowering, the fixture and its controls.Checklist
AI-assisted (Claude Code).