cpu: lower VEX AVX packed shifts, packs, unpacks, shuffles, blends, and insert/extract #404

Manually merged
github merged 4 commits from gh-pr/404/head into gh-pr/404/base 2026-11-26 21:49:21 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-22 00:30 UTC · original
Vonsek:ag/cpu-lower-avx-int-shifts-pack → main · +716 −0 · 6 files · 4 commits · merged 2026-11-23 16:32 UTC

Change

  • Lower 34 VEX 128-bit and 256-bit AVX packed shift, pack, unpack, shuffle, blend, movemask, and insert/extract instructions in tools/ffx_version_query.py:
    • Packed shifts (immediate and register/memory counts): vpsllw, vpslld, vpsllq, vpsrlw, vpsrlq, vpsraw, vpsrad, vpslldq
    • Saturating packs: vpacksswb, vpackssdw, vpackuswb, vpackusdw
    • Unpack/interleave: vpunpcklbw, vpunpcklwd, vpunpckldq, vpunpcklqdq, vpunpckhbw, vpunpckhwd, vpunpckhdq, vpunpckhqdq
    • Shuffles, blends, and movemask: vpshufd, vpshuflw, vpshufhw, vpblendw, vpblendvb, vpmovmskb
    • Insert/extract: vpextrb, vpextrw, vpextrd, vpextrq, vpinsrb, vpinsrw, vpinsrd, vpinsrq
  • Restrict lowering to EncodingKind.VEX (rejecting EVEX encodings) and zero upper YMM bytes for 128-bit XMM destinations.
  • Probe CPUID leaf 1 ECX bits 27 (OSXSAVE) and 28 (AVX) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with SKIP_RETURN_CODE 77 on hosts without AVX).
  • Add source-built MASM differential fixture tests/cpu/avx_int_shifts_pack.{asm,def,py}, CMake target cpu_avx_int_shifts_pack_lifted, CTest cpu_aot_avx_int_shifts_pack, coverage mapping in tools/form_coverage.py, and documentation in docs/experiments.md.

Verification

  • Confirmed pre-fix failure on cmake --build --preset dev --target cpu_avx_int_shifts_pack_lifted:
    ValueError: unsupported query operation at 0x1004: vpsllw xmm0,xmm1,5
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_avx_int_shifts_pack_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_int_shifts_pack|cpu_aot_bmi1)$" -V: 2/2 passed (34 VEX AVX shift/pack/unpack/shuffle/blend/movemask/insert/extract cases matched native and translated DLLs + EVEX vpshufd rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 34 AVX-grouped mnemonics in docs/coverage/x64_zen2.tsv using source-built fixtures, gated by a runtime CPUID/XCR0 check.
**@⁠Vonsek** on GitHub · 2026-11-22 00:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/404) `Vonsek:ag/cpu-lower-avx-int-shifts-pack` → `main` · +716 −0 · 6 files · 4 commits · merged 2026-11-23 16:32 UTC ## Change - Lower 34 VEX 128-bit and 256-bit AVX packed shift, pack, unpack, shuffle, blend, movemask, and insert/extract instructions in `tools/ffx_version_query.py`: - Packed shifts (immediate and register/memory counts): `vpsllw`, `vpslld`, `vpsllq`, `vpsrlw`, `vpsrlq`, `vpsraw`, `vpsrad`, `vpslldq` - Saturating packs: `vpacksswb`, `vpackssdw`, `vpackuswb`, `vpackusdw` - Unpack/interleave: `vpunpcklbw`, `vpunpcklwd`, `vpunpckldq`, `vpunpcklqdq`, `vpunpckhbw`, `vpunpckhwd`, `vpunpckhdq`, `vpunpckhqdq` - Shuffles, blends, and movemask: `vpshufd`, `vpshuflw`, `vpshufhw`, `vpblendw`, `vpblendvb`, `vpmovmskb` - Insert/extract: `vpextrb`, `vpextrw`, `vpextrd`, `vpextrq`, `vpinsrb`, `vpinsrw`, `vpinsrd`, `vpinsrq` - Restrict lowering to `EncodingKind.VEX` (rejecting EVEX encodings) and zero upper YMM bytes for 128-bit XMM destinations. - Probe CPUID leaf 1 ECX bits 27 (`OSXSAVE`) and 28 (`AVX`) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with `SKIP_RETURN_CODE 77` on hosts without AVX). - Add source-built MASM differential fixture `tests/cpu/avx_int_shifts_pack.{asm,def,py}`, CMake target `cpu_avx_int_shifts_pack_lifted`, CTest `cpu_aot_avx_int_shifts_pack`, coverage mapping in `tools/form_coverage.py`, and documentation in `docs/experiments.md`. ## Verification - Confirmed pre-fix failure on `cmake --build --preset dev --target cpu_avx_int_shifts_pack_lifted`: `ValueError: unsupported query operation at 0x1004: vpsllw xmm0,xmm1,5` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_avx_int_shifts_pack_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_int_shifts_pack|cpu_aot_bmi1)$" -V`: 2/2 passed (`34 VEX AVX shift/pack/unpack/shuffle/blend/movemask/insert/extract cases matched native and translated DLLs` + EVEX `vpshufd` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 34 `AVX`-grouped mnemonics in `docs/coverage/x64_zen2.tsv` using source-built fixtures, gated by a runtime CPUID/XCR0 check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:49:19 +00:00
github manually merged commit afaa07e231 into gh-pr/404/base 2026-11-26 21:49:21 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:37 UTC · original · edited 2026-11-22 00:42 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T00:42:45.976996Z c2a56e8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-22 00:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/404#issuecomment-7071675393) · edited 2026-11-22 00:42 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"c2a56e8925831f45f0d08b98e481a6de328ad384","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-22T00:42:45.976996Z">2026-11-22T00:42:45.976996Z</relative-time> | `c2a56e8` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 16:15 UTC · original

Maintainer update at afaa07e: resolved the CMake and lowerer conflicts after #402 and kept all 34 original MASM comparisons. The existing register-form XMM paths stay in use; the new YMM memory shuffle checks both lane outputs independently. The memory count for packed shifts reads the full m128 operand before using its low 64 bits, which the cross-page fault control now verifies before any result store. The blend control uses a destination that aliases the mask, and the fixture also checks refusal of EVEX and an unsupported source register.

ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_(avx_int_shifts_pack|avx_int_extend_hadd|avx2_permutes|avx_packed_int|avx2_shifts)$' passed 5/5 in each preset. The original branch is fast-forwarded and CI is rerunning.

**@⁠R0Y00** on GitHub · 2026-11-23 16:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/404#issuecomment-7106866438) Maintainer update at `afaa07e`: resolved the CMake and lowerer conflicts after #402 and kept all 34 original MASM comparisons. The existing register-form XMM paths stay in use; the new YMM memory shuffle checks both lane outputs independently. The memory count for packed shifts reads the full m128 operand before using its low 64 bits, which the cross-page fault control now verifies before any result store. The blend control uses a destination that aliases the mask, and the fixture also checks refusal of EVEX and an unsupported source register. `ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_(avx_int_shifts_pack|avx_int_extend_hadd|avx2_permutes|avx_packed_int|avx2_shifts)$'` passed 5/5 in each preset. The original branch is fast-forwarded and CI is rerunning.
This discussion has been locked. Commenting is limited to contributors.
No description provided.