fix(relinker): move legacy CMPSS and CMPSD out of line for Rosetta #5762
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5762"
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 boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-14T09:50:25Z.
What
Follow-up to #5683 for #5642. The Rosetta split there covers only VEX scalar compares, because legacy compares were thought not to reach the matcher intact. They do:
InstructionScannerpasses every instruction with its decoded length, andX64InstructionDecoderdecodesF3/F2 0F C2 /r ibwith the right length and RIP offset (checked against iced-x86 in #5642's follow-up audit). #5642 measured the same lost load after the legacy forms.DecodeScalarComparenow also recognisesF3orF2, segment overrides and an optional REX before0F C2 /r ib, with the same rule as the VEX forms: predicates 0 to 2 stay inline, every other predicate moves out of line unchanged, with a RIP-relative source relocated. A66,67orLOCKprefix, or bothF2andF3, keeps the instruction inline as before.This branch contains #5683's commit; only the last commit is new. I will rebase it onto
mainonce #5683 is merged.Tested
Linux, relinker-only build on #5683: ctest passes 158/158 with
--timeout 30. Newamd64_only_convertercases cover the legacy register, REX, segment-prefixed memory and RIP-relative forms, the predicates that stay inline, the prefixes that are rejected, the fmax shape through the converter and the Intel target; six parser faults each fail them. A differential run ofDecodeScalarCompareagainst iced-x86 over 15,264 valid legacy and VEX encodings (21 prefix sets, 7 REX values, 9 ModRM forms, 8 predicates) finds no case where it moves anything but a hazard CMPSS/CMPSD or misses one, and all 704 RIP-relative relocation targets match. Not run under Rosetta.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T10:52:18Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/codegen/tests/Amd64OnlyConverterTests.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T14:54:09Z.
Measured under Rosetta 2 on an M2 Max, macOS 27.2 (26B5091g).
Relinker-only build of this branch (
ba4b2db23)AppleClang, Ninja, Release: 149/149 tests pass with
--timeout 30.Legacy compares under Rosetta
Each case runs legacy
cmpss/cmpsd $imm, then a 128-bit load into the compare destination, then a scalar compare of that register. I tested predicates 0–7, each with a true and a false result.CMPSSfailuresCMPSDfailuresmovaps/movapdvmovaps/vmovapdCMPSDfail in this pattern. Moving it out of line is still harmless.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-14T18:31:35Z.
Verified on macOS 27.0.1 (26A434), Apple M4, x86-64 under Rosetta 2, Apple clang 21: the relinker-only build passes
ctest149/149 with this change applied to currentmain.Imported from boykopovar/AnyPS5. Originally posted by JoaoPauloCMarra on 2026-10-15T10:05:35Z.
ran the relinker output end to end under Rosetta, since the PR says it wasnt run there
M4 Pro, macOS 27.0.1 (26A434), Apple clang 21, PR head
ba4b2db23, relinker-only buildctest 149/149 on arm64 and on an x86_64 build under Rosetta (--timeout 30)
same synthetic check as on #5683: 40 sites, each a compare, a vmovaps load and a vucomiss, relinked and then called from an x86_64 harness under Rosetta
legacy cmpss with --to-rosetta: predicates 3-7 move out of line and 0/8 lose the load. on main and on #5683 alone, 3/8 lose it (predicates 3, 4 and 6)
vcmpss stays fixed, 0/32
without --to-rosetta: 15/32 vcmpss and 3/8 cmpss still lose the load, so the repro holds on this branch too
AI-assisted (Claude Code), I ran all of the above on my machine
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:12:11Z.
Checked the prefix/REX/segment decoding in
DecodeScalarCompare(F3/F2 exclusivity, bounds, RIP-relative relocation), the newamd64_only_convertercases (they fail without the change) and the relinker ctest on the PR merged onto main (134/134). Rosetta runs by @jotitadev, @011010 and @JoaoPauloCMarra confirm legacycmpsswith predicates 3-7 no longer loses the load. Merging.