cpu: lower VEX.256 YMM VPACKSSWB, VPACKSSDW, and VPACKUSDW in cpu_avx_int_aot #2345
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2353"
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:22:32Z.
Change
Lower 256-bit (VEX.L=1, AVX2, register-only) packed-integer pack-with-saturation instructions (
VPACKSSWB,VPACKSSDW,VPACKUSDW) intools/cpu_avx_int_aot.pyand add a source-built differential, boundary, mutation, and rejection test suite (tests/cpu/avx_int_ymm_pack.{asm,def},tests/cpu/avx_int_ymm_pack_check.py, registered ascpu_aot_avx_int_ymm_packinCMakeLists.txt):VPACKSSWB,VPACKSSDW, andVPACKUSDWtoWIDE_BINARY_HELPERSandWIDE_BINARY_CODESintools/cpu_avx_int_aot.py, reusingwide128(op_vpack*, src1, src2)so each 128-bit lane saturates independently (register operandsYMM0..YMM5only;m256memory operands, EVEX, and 128-bitVPACKUSWBincpu_vex_aot.pyremain rejected/untouched).tests/cpu/avx_int_regs_check.pyto replace the newly supportedvpackusdw_ymmandvpackssdw_ymmVEX.L=1 rejection controls with still-rejected VEX.L=1 forms (vpmulhuw_ymm,vpunpckhdq_ymm) so rejection coverage remains unchanged.Verification
Verified on commit
cb7acb4f(based onupstream/main214ed093; host supports AVX2, 0 capability skips):cmake --build --preset dev(all 30cpu_avx_int*targets) -> succeeded (exit 0)ctest --preset dev -R "^cpu_aot_avx_int" -E "cpu_native_archive_" --output-on-failure->100% tests passed, 0 tests failed out of 11(3.76 sec)cmake --build --preset release(allcpu_avx_int*targets includingcpu_avx_int_ymm_pack_*) -> succeeded (exit 0)ctest --preset release -R "^cpu_aot_avx_int" -E "cpu_native_archive_" --output-on-failure->100% tests passed, 0 tests failed out of 11(3.57 sec)ctest --preset release -R "^cpu_aot_avx_int_ymm_pack$" --output-on-failure -V->3 256-bit pack forms accepted; 13 rejection controls passed/1728 native/lifted/reference cases across 9 exports matched bit for bit; 6 mutant controls + 3 altered-build controls caught(exit 0;FORM_COVERAGE_RECORDrecordedret,vmovdqu,vpackssdw,vpacksswb,vpackusdw,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 457 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1644 tracked source, script and build/CI files: no bidirectional controls.(exit 0)Evidence and follow-up
tests/cpu/avx_int_ymm_pack.asm(; coverage: source cpu_aot_avx_int_ymm_pack) is a clean-room synthetic MASM fixture coveringvpacksswb,vpackssdw, andvpackusdwacross clamping boundaries ([-32768..32767]->[-128..127],[-2^31..2^31-1]->[-32768..32767], signedint32->[0..65535]clamping negatives to0), register aliasing (dst==src1,dst==src2,dst==src1==src2), VEX.128 upper-lane zeroing after a 256-bit pack, unaligned input/output buffers with guard bytes, and a chained pack pipeline.ALTER_YMMdivergence on 3 exports, 6 Python mutant models (zeroed upper half, cross-lane mixing, signed/unsigned swap, wraparound instead of saturation, missing VEX.128 upper-lane zeroing), and 13 translator rejections (m256memory operands, EVEX, nonvolatileYMM6..15, undefined sources, 128-bit/256-bitVPACKUSWB, missingret). Hosts lacking AVX2 skip cleanly with exit code 77.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:25:56Z.
Review: COMMENTED
Review of head
cb7acb4fdd91fb4fba89f1c8ad1b9882ee9b3b09(comment only).Result: no P1, no P2.
What I checked:
tools/cpu_avx_int_aot.py:VPACKSSWB/SSDW/USDWYMM are added to bothWIDE_BINARY_HELPERSandWIDE_BINARY_CODES. They reusewide128(op_vpack*, ...), so each 128-bit lane packs and saturates on its own, as the ISA requires. The helpersop_vpacksswb/ssdw/usdw(lines ~542-567) use signed-to-signed8, signed-to-signed16 and signed32-to-unsigned16 saturation. All three are correct.VPACKUSWBis untouched. The rejection controls inavx_int_regs_check.pyare swapped for still-unsupported forms (vpmulhuw_ymm,vpunpckhdq_ymm), so reject coverage is kept.cpu_aot_avx_int_ymm_pack: the Python reference is independent of the lowering. It covers clamp boundaries (+-128/129, +-32768/32769, 65535/65536), 160 random pairs, dst==src aliasing, a chain case, an XMM-after-YMM zeroing case, and 13 rejection controls. The altered-fixture variant is wired like its sibling suites.cpu_aot_avx_int_ymm_horizontalpattern (SKIP_RETURN_CODE 77, form coverage record).Commands executed locally (Linux, worktree at the head SHA):
python3 tests/docs_links_check.py-> pass (19 files, 457 links)python3 tests/bidi_controls_check.py-> pass (1644 files)git diff --check origin/main...HEAD-> cleancheck_translator()fromavx_int_ymm_pack_check.py(iced-x86 + pefile in a venv) ->(3, 13): 3 forms accepted, 13 rejection controls passedVPACKUSDWYMM fromWIDE_BINARY_CODESflips the code to unsupported (confirmedTrue -> False). The native suite also carries its own lifted-output mutants (wrong saturation, wrong-half XMM zeroing), with per-word allowed sets.Not run: the native differential (needs a Windows PE fixture build). I did not queue Win2025, since there is no shader or C++ change. At review time the Windows CI jobs were still pending, so merge should wait for them to pass. Linux Python checks were green. The PR is mergeable.
Nit (non-blocking): the first PR bullet says "register operands YMM0..YMM5 only". That matches the existing sibling suites, so no change is needed.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T14:23:09Z.
Win2025 WARP receipt for head
b8a45f3aafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
b8a45f3aae8cb0bd2b671dc7b1ea37dd24e5242b:--preset dev):cmake --build --preset dev --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat cpu_avx_int_ymm_sat_lifted -- -j 2):6.02s(configure2.32s)ctest --preset dev -R '^(cpu_aot_avx_int_regs|cpu_aot_avx_int_ymm_abs_sign_shuf|cpu_aot_avx_int_ymm_addsub|cpu_aot_avx_int_ymm_horizontal|cpu_aot_avx_int_ymm_minmax|cpu_aot_avx_int_ymm_mul_sad|cpu_aot_avx_int_ymm_pack|cpu_aot_avx_int_ymm_sat)$' --parallel 2 --no-tests=error --output-on-failure): 8/8 passed (1.72s:cpu_aot_avx_int_ymm_addsub0.40s,cpu_aot_avx_int_regs0.42s,cpu_aot_avx_int_ymm_minmax0.37s,cpu_aot_avx_int_ymm_sat0.48s,cpu_aot_avx_int_ymm_mul_sad0.33s,cpu_aot_avx_int_ymm_abs_sign_shuf0.48s,cpu_aot_avx_int_ymm_horizontal0.36s,cpu_aot_avx_int_ymm_pack0.35s)/O2(--preset release):cmake --build --preset release --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat cpu_avx_int_ymm_sat_lifted -- -j 2):5.93s(configure2.08s)ctest --preset release -R '^(cpu_aot_avx_int_regs|cpu_aot_avx_int_ymm_abs_sign_shuf|cpu_aot_avx_int_ymm_addsub|cpu_aot_avx_int_ymm_horizontal|cpu_aot_avx_int_ymm_minmax|cpu_aot_avx_int_ymm_mul_sad|cpu_aot_avx_int_ymm_pack|cpu_aot_avx_int_ymm_sat)$' --parallel 2 --no-tests=error --output-on-failure): 8/8 passed (1.72s:cpu_aot_avx_int_ymm_addsub0.40s,cpu_aot_avx_int_regs0.42s,cpu_aot_avx_int_ymm_minmax0.39s,cpu_aot_avx_int_ymm_sat0.48s,cpu_aot_avx_int_ymm_mul_sad0.33s,cpu_aot_avx_int_ymm_abs_sign_shuf0.47s,cpu_aot_avx_int_ymm_horizontal0.34s,cpu_aot_avx_int_ymm_pack0.33s)sccache: 0/31 hits; wall26.0sAI-assisted; commands listed were executed locally.