cpu: lower VEX.128 VPADDB, VPSUBB, VPCMPEQB, and VPCMPGTB in cpu_vex_aot #2351
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2359"
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 R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T13:35:01Z.
Change
Lower VEX.128 byte-domain arithmetic and compare instructions (
VPADDB,VPSUBB,VPCMPEQB,VPCMPGTB) intools/cpu_vex_aot.pyand add a source-built differential, aliasing, mutation, and rejection test suite (tests/cpu/vex_bytes_arith.{asm,def},tests/cpu/vex_bytes_arith_check.py, registered ascpu_aot_vex_bytes_arithinCMakeLists.txt):M.VPADDB,M.VPSUBB,M.VPCMPEQB, andM.VPCMPGTBtoBINARYintools/cpu_vex_aot.pywith portable 16-byte per-lane C++ helpers (BYTEWISE:uint8_twraparound forpaddb/psubb,0xFF/0x00masks forpcmpeqband signedint8_tpcmpgtb).XMM0..XMM5register operands and flat[rcx|rdx|r8]16-byte memory sources; stores only to[r8]), rejecting VEX.256 (L=1), EVEX, legacy SSE2, nonvolatileXMM6..15, undefined sources, displaced/indexed/non-arg memory operands, and non-[r8]stores.Verification
Verified on commit
424137b9(rebased ontoupstream/main43608f2e; host supports AVX, 0 capability skips):cmake --build --preset dev --target cpu_vex_bytes_arith_original cpu_vex_bytes_arith_original_lifted cpu_vex_bytes_arith_altered cpu_vex_bytes_arith_altered_lifted cpu_vex_bytes_original cpu_vex_bytes_original_lifted cpu_vex_bytes_altered cpu_vex_bytes_altered_lifted-> succeeded (exit 0)ctest --preset dev -R "^cpu_aot_vex_" -E "cpu_native_archive_" --output-on-failure->100% tests passed, 0 tests failed out of 5(5.10 sec;cpu_aot_vex_words,cpu_aot_vex_words_ext,cpu_aot_vex_bytes,cpu_aot_vex_bytes_arith,cpu_aot_vex_parity)cmake --build --preset release --target ...-> succeeded (exit 0)ctest --preset release -R "^cpu_aot_vex_" -E "cpu_native_archive_" --output-on-failure->100% tests passed, 0 tests failed out of 5(5.18 sec)ctest --preset release -R "^cpu_aot_vex_bytes_arith$" --output-on-failure -V->AOT lowering validated (25 rejected encodings + 3 patched PE rejections),1024 pairsacross all 11 exports match native and reference bit for bit, aliased outputs /RCX == RDX/ 8-byte unaligned buffers match native, 6 mutant controls + 4ALTER_BYTE_ARITHcontrols caught (exit 0;FORM_COVERAGE_RECORDrecordedret,vmovdqa,vmovdqu,vpaddb,vpcmpeqb,vpcmpgtb,vpsubb,vzeroupper)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py->Self-test passed. Checked 19 Markdown files and 459 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1648 tracked source, script and build/CI files: no bidirectional controls.(exit 0)Evidence and follow-up
tests/cpu/vex_bytes_arith.asm(; coverage: record cpu_aot_vex_bytes_arith) is a clean-room synthetic MASM fixture exercising register and[rcx|rdx|r8]memory forms ofvpaddb,vpsubb,vpcmpeqb, andvpcmpgtb,dst==src1==src2self-subtraction zeroing, a multi-register store-reload chain, and a 16-byte-alignedvmovdqapath.XMM6..15, undefined sources, displaced/indexed/non-arg memory, non-[r8]stores), 3 patched-PE rejections, 6 faulty Python reference mutants (saturate_add,swap_sub,saturate_sub,eq_one,unsigned_gt,swap_gt), and 4ALTER_BYTE_ARITHbuild controls. Hosts lacking AVX skip cleanly with exit code 77.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:40:07Z.
Review: COMMENTED
Review of head
424137b9b2Scope: adds VEX.128 VPADDB / VPSUBB / VPCMPEQB / VPCMPGTB to the
BINARYtable intools/cpu_vex_aot.py, plus aBYTEWISEhelper, a new MASM fixture (tests/cpu/vex_bytes_arith.asm/.def), a checker, and CMake wiring.Checked
a = src1 (vvvv),b = src2 (rm), which is right for the non-commutative VPSUBB and VPCMPGTB.paddw,pcmpgtw) and use the same dispatch path (cpu_vex_aot.py:263).dst == src1 == src2(psubb_self), a chain, and an aligned variant. The altered build (ALTER_BYTE_ARITH) swaps operands or opcodes for differential controls.unsigned_gt,swap_gt,eq_one).cpu_aot_vex_bytespattern, with aSKIP_RETURN_CODE 77and a coverage record.Commands run locally
git diff --stat origin/main...HEAD: 5 files, +566.git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.py: self-test passed, 19 files, 459 links.python3 tests/bidi_controls_check.py: self-test passed, 1648 files, no bidi controls.python3 -I -c "import ast..."on the checker: syntax OK.python3 -B tests/cpu/vex_bytes_arith_check.py: cannot run on Linux here (iced_x86missing, and it needs the Windows-built DLLs). Not run.Not done
Findings
// cpu_aot_vex_bytes_arithinCMakeLists.txtis a bare label. A one-line description would match the sibling blocks.BYTEWISE). It is fine here, but the sibling helpers are plain functions. Consistency only.Title is neutral and the PR is mergeable. No clean-room concerns seen.
AI-assisted; commands listed were executed locally.