cpu: lower 256-bit packed integer add, subtract and compare in the AVX translator #1190
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1197"
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 tedin7 on 2026-11-24T03:29:29Z.
Change
Lower the VEX.256 (AVX2) register forms of
vpaddb/w/d/q,vpsubb/w/d/q,vpcmpeqb/w/d/qandvpcmpgtb/w/d/qintools/cpu_avx_int_aot.py. Before this change every VEX.256 packed-integer form was rejected there. Each 128-bit half is computed on its own, so no carry, borrow or compare crosses the middle of the register, and all 256 destination bits are written. A later 128-bit VEX write to the same register still clears bits 128..255. Only YMM0..YMM5 are modeled, as before.Still rejected with the previous diagnostics: memory sources, every other VEX.256 packed-integer form, EVEX, nonvolatile or never-written vector registers, and the 128-bit encodings of
vpaddw,vpadddandvpsubw(owned bycpu_vex_aot.py).Test changes: new fixture
tests/cpu/avx_int_ymm_addsub.asmand checktests/cpu/avx_int_ymm_addsub_check.py(CTestcpu_aot_avx_int_ymm_addsub, exits 77 without AVX2). The four refusal controls inavx_int_regs_check.pyforvpaddq,vpsubb,vpsubdandvpcmpeqdwith YMM operands are removed because those forms are now supported; the two PE-patch controls that used them now usevpaddsbandvpslld(still unsupported).AI-assisted.
Verification
Not run on Windows: the test is outside the
prpreset and the MASM fixture needs ML64 and MSVC. Run on Linux (x86-64 host with AVX2, Python venv fromrequirements-dev.txt, LLVM 19, GCC): the same 25 instruction sequences were assembled withllvm-mc-19, run natively, and the translator output was built withg++ -O1; the real check script then ran on those two shared objects.python3 -B tests/cpu/avx_int_ymm_addsub_check.py native.so lifted.so: 16 forms accepted, 13 rejection controls passed, 5575 native/lifted/reference cases across 25 exports matched bit for bit, 86 negative controls caught.origin/main's translator: fails at the first form (unsupported VEX.256 (L=1) packed-integer encoding ... vpaddb ymm0,ymm1,ymm2).vpcmpgtw;vpsubwoperands swapped): each fails the check, atop_vpaddb_ymmword 2,op_vpcmpgtw_ymmword 0 andop_vpsubw_ymmword 0.python3 -B tests/form_coverage_check.py: passed.python3 -B tests/docs_links_check.py: passed.avx_int_regs_check.pyunit rejection controls: passed (its PE-patch part needs the Windows DLL and was not run).Evidence and follow-up
The reference is an independent Python model that works on one element at a time. Inputs: signed and unsigned edge values for every element width, lower and upper halves that differ, a carry and a borrow at the top of the lower half, equal-lane patterns for the compares, seeded random data, and unaligned input and output pointers. Both 16-byte guards around the output, the bytes next to the 32-byte window and the input buffers must stay unchanged. Negative controls: a model that ignores the upper half must differ only in words 2 or 3; a model that carries or borrows across the halves must differ at word 2; the opposite operation and every other element width must be caught; a flipped bit must be reported at its own 64-bit word.
Fixtures are original MASM written for this repository; nothing comes from a title or a binary. This does not show that any program runs. A Windows run of
ctest --preset dev -R '^cpu_aot_avx_int_ymm_addsub$' -Vis still needed. Follow-up for others: YMM memory sources,vpaddsband the other saturating or min/max forms at 256 bits.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:33:29Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
d61477bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.