feat(relinker): split 256-bit lane-local integer instructions under --to-avx #17132
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17132"
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:50:33Z.
What
An AVX host has no 256-bit integer instructions. Under
--to-avx(#17084, #17108), a VEX.256 integer instruction whose result lanes depend only on the same source lanes now runs in a stub as two VEX.128 instructions:RFLAGS is not written. The stub uses relocatable-window placement, because most of these instructions are 4 bytes long.
Covered: the 0F, 0F38 and 0F3A opcodes in
_shape:Not covered yet, listed in
docs/dev/debt/relinker.mdfor the next PRs: cross-lane VPERMD/VPERMQ/VPERMPS/VPERMPD, widening PMOVZX/PMOVSX, variable shifts, VPBLENDVB, VMPSADBW, VPMOVMSKB, gathers, masked moves and register-source broadcasts.Tested
lane_split_loweringpasses. Its execution part runs each split on this CPU for 20 representative forms, 7 register patterns (including destination = source and all three registers equal) and 4 immediates, and compares the result with the 128-bit instruction run on each half.avx2_twin_loweringpasses.lane_split_lowering(decoding and matching),avx2_twin_loweringandamd64_only_converterpass.--macos --to-avx --skip-sce-module. Counting AVX2 instructions with Capstone over the executable segments, 43,568 remain after--to-rosettaand 13,299 after this. The rest are the uncovered groups above: 6,906 cross-lane permutes, about 2,900 widening moves, about 2,100 register broadcasts and about 1,200 variable shifts.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:06Z.
Review: COMMENTED
Windows run of head
a7614d3fcf(which contains #17108 and #17084), merged ontomain105c9e4d91(clean merge), with the execution part turned on and checked against native AVX2.Setup: Windows 11, i7-12800H (AVX2, BMI1/2, LZCNT, MOVBE), WinLibs GCC 15.2, Release, relinker-only with
BUILD_TESTING=ON.As pushed:
lane_split_lowering,avx2_twin_lowering,count_lowering,movbe_lowering,amd64_only_converter,cli_argsand the other lowering tests pass, but the execution parts are compiled out on Windows.Execution on Windows (local change only, not for this PR): I gave
LoweringExecution.hppa_WIN32branch:VirtualAlloc/VirtualProtectin place ofmmap/mprotect, and the generated code called through a__attribute__((sysv_abi))pointer, since the wrappers take their argument inrdi. With that, the execution part of every lowering test runs and passes here, yours included.Native oracle. Your execution check compares the stub with the 128-bit instruction run on each half. That can't catch an opcode in
_shapethat isn't really lane-local, and it runs only register sources. This CPU has AVX2, so I added a local check that runs the original VEX.256 instruction and the stub on the same random machine state. It then compares all 16 YMM registers, the memory operand and the red zone.ppand opcode, plus each/extfor the shifts, thatDecodeLaneSplitaccepts. That is 100 forms.[rax]and through[rsp-128]. The second exercises thekFrameadjustment and the 128-bit load for shift counts.To check that this oracle can fail, I made
_shapetakeVPBROADCASTB ymm, xmm(0F38 78) asUnary. It then stops at once onnative mismatch for C4 E2 7D 78 C2. With the source restored, it passes.Full relinker-only suite: 813 / 819. The 6 failures are
select_tests_*andstubgen, Python tests intools/that fail on symlink and temp-file handling on this machine (WinError 183,No usable temporary file name found). This stack doesn't touchtools/.The local test changes aren't pushed anywhere. If you want the Windows execution path in the tree, the
LoweringExecution.hppchange above is all it takes.