cpu: lower VEX AVX packed sign/zero-extend, horizontal integer, and phminposuw #402

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

@⁠Vonsek on GitHub · 2026-11-22 00:24 UTC · original
Vonsek:ag/cpu-lower-avx-int-extend-hadd → main · +426 −0 · 6 files · 4 commits · merged 2026-11-23 16:12 UTC

Change

  • Lower 19 VEX 128-bit and 256-bit AVX packed sign/zero-extend, horizontal integer add/sub, and horizontal minimum instructions in tools/ffx_version_query.py:
    • Sign-extend: vpmovsxbw, vpmovsxbd, vpmovsxbq, vpmovsxwd, vpmovsxwq, vpmovsxdq
    • Zero-extend: vpmovzxbw, vpmovzxbd, vpmovzxbq, vpmovzxwd, vpmovzxwq, vpmovzxdq
    • Horizontal add/sub and minpos: vphaddw, vphaddd, vphaddsw, vphsubw, vphsubd, vphsubsw, vphminposuw
  • 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_extend_hadd.{asm,def,py}, CMake target cpu_avx_int_extend_hadd_lifted, CTest cpu_aot_avx_int_extend_hadd, 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_extend_hadd_lifted:
    ValueError: unsupported query operation at 0x1004: vpmovsxbw xmm0,xmm1
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_avx_int_extend_hadd_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_int_extend_hadd|cpu_aot_bmi1)$" -V: 2/2 passed (19 VEX AVX extend/horizontal/minpos cases matched native and translated DLLs + EVEX vpmovsxbw rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 19 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:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/402) `Vonsek:ag/cpu-lower-avx-int-extend-hadd` → `main` · +426 −0 · 6 files · 4 commits · merged 2026-11-23 16:12 UTC ## Change - Lower 19 VEX 128-bit and 256-bit AVX packed sign/zero-extend, horizontal integer add/sub, and horizontal minimum instructions in `tools/ffx_version_query.py`: - Sign-extend: `vpmovsxbw`, `vpmovsxbd`, `vpmovsxbq`, `vpmovsxwd`, `vpmovsxwq`, `vpmovsxdq` - Zero-extend: `vpmovzxbw`, `vpmovzxbd`, `vpmovzxbq`, `vpmovzxwd`, `vpmovzxwq`, `vpmovzxdq` - Horizontal add/sub and minpos: `vphaddw`, `vphaddd`, `vphaddsw`, `vphsubw`, `vphsubd`, `vphsubsw`, `vphminposuw` - 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_extend_hadd.{asm,def,py}`, CMake target `cpu_avx_int_extend_hadd_lifted`, CTest `cpu_aot_avx_int_extend_hadd`, 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_extend_hadd_lifted`: `ValueError: unsupported query operation at 0x1004: vpmovsxbw xmm0,xmm1` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_avx_int_extend_hadd_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_int_extend_hadd|cpu_aot_bmi1)$" -V`: 2/2 passed (`19 VEX AVX extend/horizontal/minpos cases matched native and translated DLLs` + EVEX `vpmovsxbw` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 19 `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:09 +00:00
github manually merged commit 5fbc4ab00a into gh-pr/402/base 2026-11-26 21:49:11 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:28 UTC · original · edited 2026-11-22 00:31 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:31:20.389565Z 5704bd3 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:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/402#issuecomment-7071570012) · edited 2026-11-22 00:31 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5704bd310275fcc4da90bc5f9711defa3e9035a0","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:31:20.389565Z">2026-11-22T00:31:20.389565Z</relative-time> | `5704bd3` | 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 15:59 UTC · original

Maintainer update at 5fbc4ab: resolved the shared-lowerer and CMake conflicts after #401, retaining all 19 original XMM cases. The new YMM controls are AVX2-gated and compare an 8-byte sign-extension read and a 32-byte horizontal add against native plus independent lane references. The shared width-aware memory read is used, and both EVEX and a VEX source outside the register profile produce a diagnostic.

ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_(avx_int_extend_hadd|avx_int_minmax_mul|avx_packed_int|avx_packed_fp)$' passed 4/4 in each preset, with the AVX2 controls exercised. The original PR branch was fast-forwarded and CI is rerunning.

**@⁠R0Y00** on GitHub · 2026-11-23 15:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/402#issuecomment-7106444872) Maintainer update at `5fbc4ab`: resolved the shared-lowerer and CMake conflicts after #401, retaining all 19 original XMM cases. The new YMM controls are AVX2-gated and compare an 8-byte sign-extension read and a 32-byte horizontal add against native plus independent lane references. The shared width-aware memory read is used, and both EVEX and a VEX source outside the register profile produce a diagnostic. `ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_(avx_int_extend_hadd|avx_int_minmax_mul|avx_packed_int|avx_packed_fp)$'` passed 4/4 in each preset, with the AVX2 controls exercised. The original PR branch was fast-forwarded and CI is rerunning.
This discussion has been locked. Commenting is limited to contributors.
No description provided.