feat(relinker): rewrite AVX2 instructions with an AVX twin under --to-avx #17108
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17108"
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 ycbuzi on 2026-11-08T10:19:21Z.
What
Under
--to-avx(#17084), this rewrites in place the AVX2 instructions whose AVX form moves the same bits at the same encoding length:Only the opcode byte changes, plus the map and
ppfor VMOVDDUP. There is no stub, and the instruction can also be emitted inside a moved window. Register-source broadcasts, VPERMQ/VPERMD/VPERMPS/VPERMPD, variable shifts, gathers, masked moves and 256-bit integer arithmetic have no same-length twin; they are listed indocs/dev/debt/relinker.mdfor the following PRs.Tested
avx2_twin_loweringpasses. Its execution part runs each replacement on this CPU, with 11 immediates for the immediate forms, and compares ymm0 with the SDM result of the original AVX2 instruction, including the zeroed upper half of the 128-bit forms.count_loweringandmovbe_loweringpass.avx2_twin_lowering(decoding, matching, out-of-line emission),amd64_only_converter,count_loweringandcli_argspass.--macos --to-avx --skip-sce-module. Compared with--to-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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T11:56:04Z.
Review: COMMENTED
Windows run of this head as part of #17132's head
a7614d3fcf, which contains1ac3219840unchanged, merged ontomain105c9e4d91. Setup: Windows 11, i7-12800H (AVX2), WinLibs GCC 15.2, Release, relinker-only.avx2_twin_loweringpasses as pushed. Its execution part is compiled out on Windows. With a local, unpushed_WIN32branch inLoweringExecution.hpp(VirtualAlloc/VirtualProtectand asysv_abicall), it runs and passes here too. The details are in my comment on #17132.This CPU has AVX2, so I also checked each twin against the original instruction instead of the SDM model. Each of the 10 cases in
cases()ran, the original AVX2 bytes and the AVX replacement, for all 256 immediates. Each pair ran on 4 random states ofymm0–ymm2and the memory operand, and I comparedymm0. That's 10,240 runs, all bit-identical. This includes the xmm forms, so it also covers the zeroed upper half, andVMOVDDUPforVPBROADCASTQ xmm, m64.