fix(relinker): lower legacy packed reciprocal register instructions #3601
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3601"
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 Scramblrrrr on 2026-10-11T14:08:19Z.
What
--to-intelleaves legacy SSE register forms ofRSQRTPSandRCPPSnative, although it already replaces their VEX.128 equivalents to avoid reciprocal approximation differences. This PR extends the existing lowering to those legacy register forms, including REX-extended registers and equal source/destination operands.The gap is recorded in TechnicalDebt: legacy forms retain the host approximation. The same entry documents why the existing VEX lowering uses division and square root: an approximate reciprocal square root of
1.0can remain below1.0after refinement. This change applies the existing policy to SSE code; it does not reproduce AMD's approximation tables.RSQRTPSSQRTPSthenDIVPSlowering; upper YMM bits preservedRCPPSDIVPSlowering; upper YMM bits preservedFor example, a supported legacy
RSQRTPSwith all input lanes equal to1.0now produces exactly1.0in every lane, through the same arithmetic used for its VEX equivalent.Implementation:
DecodeReciprocal, accept legacy register encodings with an optional REX prefix, and record whether the instruction uses VEX.ReciprocalLoweringand the existing scratch-register spill/restore path. Emit a legacy result move forRCPPS, and avoid the final VEX move for legacyRSQRTPS, so upper YMM bits remain intact.RSQRTPS/RCPPSseparately from their VEX equivalents in conversion diagnostics. Support mixed legacy/VEX sequences through the existing out-of-line sequence builder.The substitution remains optional. Sites shorter than the five-byte jump absorb movable following instructions, or stay native when a jump cannot fit safely. Scalar, memory and 256-bit forms retain their existing behavior. No new dependencies or system-library exports are added.
Tested
Head
363d17985e, base maina11c8f7f70. Windows 11, Ryzen 7800X3D, Release MinGW GCC 15.2.Fresh standalone build: amd64_only_converter and amd64_only_windows, 2/2 pass, 0.61 seconds. Covers legacy register forms, overlapping source/destination, extended registers, preserved upper YMM bits, and existing VEX behavior. Conventions and diff checks pass. The rebase retains main's optional Rosetta RDPID handling and its technical-debt entry. Linux and macOS were not run locally; no new title result is claimed.
Replaces closed #2377, whose historical branch cannot be reopened after it was recreated/force-pushed. Its earlier closure was intake, not a code review; the author now has accepted commits on main. No open equivalent reciprocal PR was found. This new PR contains the current tested topic, not the experimental 007 integration.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:20:12Z.
Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON.tools/check_conventions.py --base origin/mainpasses.Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T19:42:25Z.
Thank you for the independent Linux/RADV cross-test and the full 832/832 result. That complements my focused Windows reciprocal-converter checks; I have kept this PR scoped to reciprocal decoding and preserved main's Rosetta matcher entry. No additional code changes since
363d17985e.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T01:16:00Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/codegen/include/codegen/x86/Amd64OnlySubstitutionTable.hppL51core/relinker/codegen/src/x86/Amd64OnlyInstructionMatcher.cppL222-250, L257-258