cpu: lower 256-bit packed abs, sign and word shuffle forms #1335
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1342"
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-24T08:38:01Z.
Change
Lower the VEX.256 (AVX2) register forms of
vpabsb/w/d,vpsignb/w/d,vpshufhwandvpshuflwintools/cpu_avx_int_aot.py. Before this change these eight were rejected withunsupported VEX.256 (L=1) packed-integer encodingalthough their 128-bit helpers already existed. Each existing 128-bit helper now runs on the two 128-bit halves on its own, so no sign control, shuffle selector or absolute value crosses the middle of the register;vpshufhw/vpshuflwuse the sameimm8for both halves, 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. Refs the AVX2 YMM series started by #1197.Still rejected with the previous diagnostics: memory sources, every other VEX.256 packed-integer form, EVEX, nonvolatile or never-written vector registers. The 128-bit encodings keep their single-helper path.
Test changes: new fixture
tests/cpu/avx_int_ymm_abs_sign_shuf.asm(+.def) and checktests/cpu/avx_int_ymm_abs_sign_shuf_check.py, wired as CTestcpu_aot_avx_int_ymm_abs_sign_shuf(exits 77 without AVX2). The four refusal controls inavx_int_regs_check.pyforvpabsd,vpshufhw,vpshuflwandvpsigndwith YMM operands are removed because those forms are now supported, and thevpabsdcontrol inavx_int_ymm_minmax_check.pynow usesvpmulld(still unsupported).docs/experiments.mdis updated.PR #1342 fuori preset pr:
ctest --preset dev -R '^cpu_aot_avx_int_ymm_abs_sign_shuf$'(and--preset release).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, MinGW):llvm-mc-19, run natively, and the translator output built withg++ -O2:python3 -B tests/cpu/avx_int_ymm_abs_sign_shuf_check.py native.so lifted.soprinted8 256-bit forms accepted; 12 rejection controls passedand2820 native/lifted/reference cases across 15 exports matched bit for bit; 58 negative controls were caught.llvm-ml-19and links withlld-link-19; the translator lifted the resulting PE, and that output was built withg++ -O0(same two result lines) and compiled withx86_64-w64-mingw32-g++at -O0 and -O2.origin/main's translator: fails at the first form (unsupported VEX.256 (L=1) packed-integer encoding ... vpabsb ymm0,ymm1).vpsigndusingvpsignw,vpabsbusingvpabsw,vpshufhwwith the immediate 0x1b changed to 0x93,vpshuflwusingvpshufhw: each fails the check (op_vpsignd_ymm,op_vpabsb_ymm,op_vpshufhw_ymm_1bandop_vpshuflw_ymm_93, word 0 or 1).avx_int_regs_check.py(check_rejectionsagainst a PE built with llvm-ml/lld-link): 102 unit and 11 PE-patched rejection controls passed.avx_int_ymm_minmax_check.pytranslator controls: passed.python3 -B tests/form_coverage_check.pyandpython3 -B tests/docs_links_check.py: passed.Evidence and follow-up
The reference is an independent Python model that works on one 16-byte half and one element at a time. Inputs: signed and unsigned edge values for every element width (including the most negative value), halves that differ, distinct 16-bit words for the shuffles, 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: models that drop the upper half, reuse one half's input for the other half, apply the shuffle immediate to one half only, swap
vpshufhwandvpshuflw, saturate the absolute value, invert the sign control or use another element width must each differ in the expected 64-bit words;vpabsbof0x80must stay0x80; a flipped bit must be reported at its own 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_abs_sign_shuf$' -Vis still needed. Follow-up for others: YMM memory sources and the remaining 256-bit packed-integer forms.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:47:35Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit
9e35fe29544575c23cdae594da0f33ec9580f2a5:--preset dev):cpu_avx_int_ymm_abs_sign_shuf,cpu_avx_int_ymm_abs_sign_shuf_lifted):3.37s(configure1.53s)ctest --preset dev -R '^cpu_aot_avx_int_ymm_abs_sign_shuf$' --no-tests=error --output-on-failure): 1/1 passed (0.31s)/O2(--preset release):cpu_avx_int_ymm_abs_sign_shuf,cpu_avx_int_ymm_abs_sign_shuf_lifted):0.74s(configure1.57s)ctest --preset release -R '^cpu_aot_avx_int_ymm_abs_sign_shuf$' --no-tests=error --output-on-failure): 1/1 passed (0.29s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:47:53Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
9e35fe2ℹ️ 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.