x64_recomp: handle 16-bit operand-size override (66) in push and pop (X64-RECOMP-PUSH-POP-16) #1408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1408"
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 ubiquitarianism/leonida. Originally posted by quietfold on 2026-11-24T23:34:55Z.
Item ID:
X64-RECOMP-PUSH-POP-16Summary
Fixes 16-bit operand-size override (
66prefix withoutREX.W) in_emit_pushpopintools/x64_recomp.py:push(66 50..57,66 41 50..57,66 68 iw,66 6A ib,66 FF /6): loads 2 bytes (or sign-extendedimm8masked to 16 bits) and emitsstr_pre(T0, rsp, -2, size=2)(STRH W0, [X23, #-2]!) instead of always decrementingRSPby 8 and writing 8 bytes.pop(66 58..5F,66 41 58..5F,66 8F /0): emitsldr_post(T0, rsp, 2, size=2)(LDRH W0, [X23], #2), inserts only the low 16 bits viabfi(..., 0, 16)for register destinations (preserving upper 48 bits), and stores exactly 2 bytes viastr(..., size=2)for memory destinations (after the post-increment ofRSP, matching Intel SDM forpop word ptr [rsp+disp]).66+REX.Wprecedence (66 48 50,66 48 58):REX.Woverrides66, preserving full 64-bitpush/pop(±8).Tests & Verification
upstream/main(3a0af1f15):python3 -m compileall -q make_game.py tools tests— OKpython3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp_push_pop_16.py— OKpython3 -I tests/test_x64_recomp_push_pop_16.py -v— 1 static OK (2 exec skip cleanly without#1174runner)python3 -I tests/test_x64_recomp.py— 6 static OK (26 exec skipped)python3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I tests/test_ci_registration.py— 16/16 OKtests/test_x64_recomp_push_pop_16.pyon unpatchedupstream/main+#1174): 2 failures, 1 error.upstream/main3a0af1f15with#1174+ all 20 other openx64_recompPR branches):tests/test_x64_recomp_push_pop_16.py: 3/3 OK (0 skipped) on native Apple M5 arm64tests/test_x64_recomp_*.pysuites combined: 148/148 OK (0 skipped)Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T23:35:02Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by kevincommits on 2026-11-25T22:28:03Z.
Independent run with QEMU. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, QEMU 11.1.3 from Homebrew. I merged
mainatd601736ceinto the branch locally (702 commits behind, no conflicts). Head tested:c6d1639d4.The emitter change is right as far as I could test it. The new test file has one wiring bug.
The exec tests error wherever QEMU is installed.
python -I tests/test_x64_recomp_push_pop_16.py: 3 run, 2 errors, bothIt is the same cause as in #1409:
_find_runner's QEMU branch returnsxr.run_kernel, which gives back(raw output bytes, translator).xr.run_resultis the one that parsesR=xxxxxxxx.CAN_RUN_MACHOonly exists with #1174, so on this branch the tests are skipped without QEMU and error with it. Suggested fix: usexr.run_resultin both branches.With
RUNNERswapped forxr.run_result(in memory, no file changed): 3/3 pass under QEMU. So every assertion in the file holds, including thepop word ptr [rsp+4]post-increment case and the66 48 50/66 48 58REX.W case.Extra cases, each run under QEMU on
mainand on this branch:mainpush rax; pushw 0xBEEF; pop word [rsp]; pop rax, rax=1122334455667788112233445566beefffffffffffffbeef112233445566beef66 50, then rsp deltaxor rax,rax; pushw -2; pop ax000000000000fffefffffffffffffffe000000000000fffe66 54; 66 58(push sp, pop ax), ax == old sp66 54; 66 5c(push sp, pop sp), rsp unchangedCounts.
tests/test_x64_recomp.py33/33 andtests/test_recomp_census.py11/11, the same asmain. Full standalone suite: 512 run, 507 pass; the 5 that fail aremain's 4 plus this new file, for the reason above.I found nothing wrong in
_emit_pushpopitself. No game files used. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:40:34Z.
Red/green: classified READY by dada-lotF (red on main, green on head merged with main); head
c6d1639d45unchanged since 2026-11-24, before that run.Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)