x64_recomp: SHLD and SHRD (0F A4/A5/AC/AD) decode with their ModRM and imm8 (X64-RECOMP-SHLD-SHRD-DECODE) #3148
No reviewers
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3148
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3148"
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?
@Kal0s-design on GitHub · 2026-12-02 14:10 UTC · original
Kal0s-design:fix/x64-recomp-shld-shrd→main· +53 −0 · 2 files · 1 commits · merged 2026-12-02 15:25 UTCClaimed in the coordination issue as: X64-RECOMP-SHLD-SHRD-DECODE (#2570)
What and why
tools/x64_recomp.pyhad no0Ftable entry for the double-precision shifts, so0F A4,0F A5,0F ACand0F AD(shld/shrdr/m, reg, imm8 or CL) decoded as the unknownop0f_XXafter the two opcode bytes. Their ModRM byte, any SIB/displacement and the imm8 of theA4/ACforms were then read as the next instructions. Example:48 0F A4 C2 05 C3came out asop0f_a4(3 bytes) followed by a bogusret 0xc305, and the census stopped the function at the decode error. Compilers emit these for 128-bit shifts.The fix adds four table entries using the specs the table already has:
Ev Gv IbforA4/AC(ModRM + imm8) andEv Gv cforA5/AD(ModRM, count in CL).66and REX go through the shared operand parser like every otherEv Gventry.Scope is decoding only. There is no emitter, so the translator reports them as unhandled
shld/shrdand leaves abrk, the same way it handles other instructions it cannot translate yet; the census now names them instead of losing the rest of the function. An emitter (flags, count 0, the 16-bit forms) can follow in its own pull request.The same item was taken earlier by #1349, which also added an emitter; it went stale on a conflict with
mainand its author closed it on 1 December. This one only carries the decode part.Tested
tests/test_x64_recomp.py: newtest_shld_shrd_carry_modrm_and_imm8(register and memory forms, SIB + disp8, RIP + disp32, with and without REX.W and66, and where the next instruction starts) andtest_shld_shrd_are_reported_unhandled_by_the_translator.main(69cd4106c):AssertionError: Tuples differ: ('op0f_a4', 3, True) != ('shld', 5, False)andAssertionError: Lists differ: [] != ['shld'], soFAILED (failures=2, skipped=34)over 53 tests.tests/test_x64_recomp.py53 testsOK (skipped=34),tests/test_recomp_census.py13 testsOK. The othertests/test_x64_recomp_*.pysuites andtests/test_gdk_runtime_calls.pyalso pass (their QEMU cases skip here).scripts/check_no_game_data.pypasses.objdump -D -b binary -m i386:x86-64), reference only.0Ftable, in other lines;git merge-treeof this branch with its head1ca3e4a98is clean.GPUs tested: n/a (CPU-only tests)
AI-assisted: yes
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
@lixonik on GitHub · 2026-12-02 14:44 UTC · original
Verified PR #3148 (
1f158fe57) merged cleanly ontomain(acc350745) on Windows 10 x64 (Pythontests/test_x64_recomp.py):python -I scripts/check_no_game_data.pyPASS.1f158fe57ontoacc350745):python -I tests/test_x64_recomp.py--Ran 19 tests in 2.162s -- OK (skipped=34)(both newSHLD/SHRDtests pass).maintools/x64_recomp.py+ PRtests/test_x64_recomp.py): both new tests fail as expected:test_shld_shrd_carry_modrm_and_imm8:('op0f_a4', 3, True) != ('shld', 5, False)test_shld_shrd_are_reported_unhandled_by_the_translator:[] != ['shld']OF(0xA4/0xA5shld,0xAC/0xADshrdwith"Ev Gv Ib"/"Ev Gv c"), matching the Intel SDM ModRM/SIB/disp/imm8 encodings and leaving translation cleanly marked unhandled until an emitter is added. No issues found.Verdict: PASS (CPU/unit tests only; no game launch).
AI-assisted: yes (Antigravity).
@MoonEyes on GitHub · 2026-12-02 15:11 UTC · original
Merging. Head
1f158fe57merges cleanly withmain83046a713and does not force a rebase of #2566. Third-party verification by lixonik (#3148): new SHLD/SHRD tests red on main and green on head1f158fe577; CI green incl. no-game-data; no open review or question. Merged by MoonEyes.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-02 15:21 UTC · original
Verified on this machine with the repository's own checker:
red then green, and nothing else moved.What that says: the two new tests fail on
mainand pass with the change - the decoder really was losing the instruction - and the other 17 in that file are untouched by it.git merge-treeagainstmain69cd4106cis clean.What I looked at in the diff: the four opcodes with their two forms (imm8 and
CL), the 66 and REX prefixes, and the memory form keeping SIB, displacement and immediate (4c 0f a4 44 24 08 03-> 7 bytes, base 4, disp 8). Those are the cases where a decoder that stops at the opcode silently loses the rest of a function, which is what the test's own comment says.What this does not cover, so nobody reads more into it than it says:
--no-cargo, and there is nothing Rust in the change;AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.