x64_recomp: the 0F SIMD ranges skip eight ModRM opcodes (X64-RECOMP-SIMD-TABLE) #1485
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1485
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/1485"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: X64-RECOMP-SIMD-TABLE
Depends on: #1488 (conflicts with in
tests/test_x64_recomp.py; whichever lands second needs a rebase)The
0FSIMD opcode list intools/x64_recomp.pyis generated from opcode ranges, and theranges left out eight opcodes that take a ModRM byte:
7C/7D, HADDPD/HADDPS and HSUBPD/HSUBPS (66andF2forms)D0, ADDSUBPD/ADDSUBPSD7, PMOVMSKB (66form; the MMX form has no prefix)E6, CVTDQ2PD, CVTTPD2DQ, CVTPD2DQE7, MOVNTDQF0, LDDQUF7, MASKMOVDQUWith no table entry each decoded as the unknown
op0f_XXof its two opcode bytes, so the byteafter them was read as the next instruction and the rest of the function was decoded from the
wrong offset.
Measurement
The image is
game_scarlett_master.exe, SHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993. REA measured the sectionranges with
gnu.objdumpsection_headers, evidenceev_e29cbdffd0dc7c46889b2a1f955011ce9f2795017233c97107ded73f9186dd90:.textVMA0x140001000, file0x400, size0x5f3f966;.pdataVMA0x14abcf000, file0x6e03a00..pdatafunction (299,257) with the unfixed decoder, 6 functions stop on one ofthese opcodes. The first unknown in each is
op0f_7d(RVA0x17e1060),op0f_e6(
0x277a710,0x3137ab0,0x562bc40),op0f_e7(0x3081860) andop0f_f7(0x3e2aad0).With the fix they decode 852 instructions further and 3 reach the end of the function with no
unknown left.
.text: objdump's linear walk and thedecoder's walk read the same bytes and the instruction lengths are compared (26,674,180
objdump instructions). It drops 6 length mismatches, 4
F3 0F E6(CVTDQ2PD, RVAs0x562ad45,0x562ad6e,0x562e320,0x562e395) and 266 REX.W 0F D7(PMOVMSKB, RVAs0x564df78,0x565191f), and adds none. The totals are 52,638 before and 52,632 after.Enumerating the
0Fopcodes against the set of legacy SSE/MMX instructions that take a ModRMbyte leaves none out after the change;
movnti(0F C3) is already its own entry.Test
tests/test_x64_recomp.py::DecodeTests::test_simd_opcodes_outside_the_ranges_carry_modrmcoversthe eight opcodes in the register and memory forms. Against the unfixed decoder the first case
(
f3 0f e6 c9) decodes asunknown; with the fix each keeps its ModRM/SIB/displacement length.python -I tests/test_x64_recomp.py: 33 tests OK, 26 skipped (this host has noqemu-system-aarch64).
python -I tests/test_recomp_census.py: 11 tests OK.python3 -m compileall -q make_game.py tools testsexits 0.python -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp.py docs/mobile.mdexits0 with no output.
docs/mobile.mdrecords both counts and the evidence ID. The differential is local analysis ofthe shipped file; nothing was executed. No game files, no GPU, nothing online. Tested on Linux
(openSUSE Tumbleweed, Python 3.13.18, binutils 2.47), 12 cores.
GPUs tested: n/a (decoder and census are CPU-only)
AI-assisted: yes (DeepSeek V4.1 Flash)
Checklist
mainand merges cleanly.docs/design.mdcontract row.[KEEP]
_OF_SIMD_NORMintools/x64_recomp.pygains 7C/7D, D0, D7, E6, E7, F0 and F7, with a 12-case decode test and a measured differential recorded indocs/mobile.md.change-scopeandno-game-dataare still QUEUED, so there is no green result yet.tests/test_x64_recomp.py, samedocs/mobile.md). #1428 also editstools/x64_recomp.py. A maintainer should pick a merge order, then rebase the rest.Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). The eight added opcodes are all ModRM forms in the 0F map: 7C/7D haddp*/hsubp*, D0 addsubp*, D7 pmovmskb, E6 cvt*dq2pd/pd2dq, E7 movntdq/movntq, F0 lddqu, F7 maskmovdqu/maskmovq.
AI-assisted (Claude).
Independent run. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, QEMU 11.1.3 from Homebrew, so the 26 exec tests ran rather than skipped. I merged
mainatd3b8251bcinto the branch locally (635 commits behind, no conflicts).mainalone decodesf3 0f e6 c9as unknownop0f_e6, size 3, and66 48 0f d7 d0as unknownop0f_d7, size 4. This branch givessimdat sizes 4 and 5.tests/test_x64_recomp.py: 34/34 (33 onmain), so the new test fails onmainand passes here.tests/test_recomp_census.py: 11/11.tests/test_*.pyunderpython -I: 510 run, 506 pass; the 4 that fail are the same 4 that fail on plainmain.I only ran the synthetic byte fixtures. I did not reproduce the retail-image counts in the
docs/mobile.mdparagraph. No game files used. AI-assisted.Hi @kett1m, thanks for this pull request. It currently conflicts with
main(conflicting file(s):tests/test_x64_recomp.py), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
#1485 | head f285f09b9052854fcdd4ae88553c826c13a2decc (merged cleanly with main adfb3821a2) |
python -I tests/test_x64_recomp.py -v+python -I tests/test_recomp_census.py+python -I tests/test_docs_links.py+python -I tests/test_docs_repo_paths.py| red on main:FAILED (failures=1, skipped=32)(AssertionError: True is not false : f3 0f e6 c9—_OF_SIMD_NORMomitted0x7C/0x7D,0xD0,0xD7,0xE6,0xE7,0xF0, and0xF7, decoding them as 2-byte unknownop0f_XXwithout their ModRM byte) | green on PR+main:46 ran, OK (skipped=32)(test_x64_recomp.py),11 ran, OK(test_recomp_census.py),17 ran, OK(test_docs_links.py), and5 ran, OK(test_docs_repo_paths.py) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited
f285f09b90(tools/x64_recomp.py,tests/test_x64_recomp.py, anddocs/mobile.md) on Windows 11, confirming all 12 SSE/MMX ModRM encodings across7C/7D,D0,D7,E6,E7,F0, andF7decode withunknown == False,kind == "simd", and exact byte lengths (3..5bytes). Also verifiedtests/test_docs_cli_flags.py,tests/test_docs_encoding.py,tests/test_ci_registration.py, andscripts/check_no_game_data.py.Tested
f285f09b9merged (no commit) withmain829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_x64_recomp.py, 46 tests pass (32 skipped:qemu-system-aarch64 not installed).tools/x64_recomp.pyback tomain, 1 failure (f3 0f e6 c9is still taken as a ModRM opcode).tests/test_x64_recomp.py(git merge-tree), so the second to land needs a rebase.No blocker from my side.
AI-assisted (Claude Code).
Tested green here earlier on this same head (see my comment above). Two things before a merge: your claim in the coordination issue #2570 is missing, and this PR conflicts with #1488 in
tests/test_x64_recomp.py, so whichever lands second needs a rebase.AI-assisted (Claude Code).
Ready for testing: merges cleanly with
main3535eb5c4. Not inmainyet:git cherryfinds 1 commit(s) not there, and 2 of the 38 lines it adds are already present. No duplicate found: its claimX64-RECOMP-SIMD-TABLEappears in no other open pull request and in nomaincommit.AI-assisted (Claude Code).
RUN comment, PR #1485 (x64_recomp: the 0F SIMD ranges skip eight ModRM opcodes)
Heads: PR f285f09b9, main 91bab934d (local merge of the PR into it, not pushed).
Kind: Python (tools/x64_recomp.py) + tests/test_x64_recomp.py + docs/mobile.md. Against current main the PR changes these 3 files (the PR's file list on GitHub also shows bcpack_tool files, which are already in main through #1422).
Commands (repo root):
python -I tests/test_x64_recomp.py
every tests/test_x64_recomp*.py, one process each (15 at the PR head, 18 on main)
the 14 docs test files (tests/test_docs_*.py, tests/test_design_contract_rows.py)
RED (behavioural, no new API): tools/x64_recomp.py and docs/mobile.md put back to the merge-base version, test kept.
test_x64_recomp.py: 1 failure, test_simd_opcodes_outside_the_ranges_carry_modrm ("True is not false : f3 0f e6 c9", i.e. decoded as unknown).
GREEN at the PR head: test_x64_recomp 46 tests OK, the new test runs (not skipped); the other 14 test_x64_recomp_* files pass; docs tests pass.
GREEN merged into main: test_x64_recomp 48 tests OK, new test runs; all 18 test_x64_recomp*.py pass; docs tests pass.
Note: most other tests in these files are skipped on this machine (qemu-system-aarch64 not installed), before and after the PR. The PR's numbers over the retail image (299,257 functions, objdump walk) cannot be reproduced here (no package).
Machine: Windows 11 Pro, RTX 3090 24 GB, NVIDIA 621.40, Python 3.13.12 (uv build), run with
python -I, one process per test file.Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, qemu-system-aarch64 11.1.3 on PATH, main 4755667f5, PR head f285f09b9 : red 1 failure / green 48 OK
python3.12 -I tests/test_x64_recomp.py:test_simd_opcodes_outside_the_ranges_carry_modrm. Green: 48/48 OK.git merge-tree). main changedtests/test_x64_recomp.py(+36) andtools/x64_recomp.pysince the PR base 30fc2d68c, so red = the merged test file against main's code.tests/test_x64_recomp_*.pygive identical results per file on main and on the merge (14 of them already fail on main under qemu because ofrun_kernelvsrun_result, see the finding in #2570).tests/test_x64_recomp.py/tools/x64_recomp.py; whichever lands second needs a rebase. It does not force a rebase of #2566.Verdict: READY
AI-assisted: Claude Code
Reviewed the diff against
main:tools/x64_recomp.py:208-211cleanly adds the eight missing 0F SIMD ModRM opcodes (7C,7D,D0,D7,E6,E7,F0,F7), with 12 unit cases intests/test_x64_recomp.pyand documentation indocs/mobile.md. Clean-room verified. Approving; please merge/rebase currentmainfor a fresh green CI run before merge.(AI-assisted review.)
For information: this pull request is carried in #3118, which merges your head
867ce542e24982567e098f679d9ffef1f5735101(your commits are kept) into currentmainand resolves the conflict in tests/test_x64_recomp.py. If you rebase this one yourself, say so and #3118 can be closed.AI-assisted (Claude Code).
Closing: this pull request no longer applies to current
main(merge conflict intests/test_x64_recomp.py). Your work is not lost: it is carried in #3118 together with #1485, #1488 and #1246, which keeps your commits and resolves the conflict on currentmain.AI-assisted (Claude Code).