cpu: lower VEX AVX packed integer ALU instructions #395

Manually merged
github merged 5 commits from gh-pr/395/head into gh-pr/395/base 2026-11-26 21:48:34 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-22 00:15 UTC · original
Vonsek:ag/cpu-lower-avx-packed-int → main · +522 −0 · 6 files · 5 commits · merged 2026-11-23 15:11 UTC

Change

  • Lower 26 VEX 128-bit and 256-bit AVX packed integer ALU instructions in tools/ffx_version_query.py:
    • Wrapping add/sub: vpaddb, vpaddw, vpaddq, vpsubb, vpsubw, vpsubd, vpsubq
    • Bitwise: vpand, vpandn, vpor
    • Comparisons: vpcmpeqb, vpcmpeqw, vpcmpeqd, vpcmpeqq, vpcmpgtb, vpcmpgtw, vpcmpgtd, vpcmpgtq
    • Abs, sign, byte shuffle, and byte align: vpabsb, vpabsw, vpabsd, vpsignb, vpsignw, vpsignd, vpshufb, vpalignr
  • 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_packed_int.{asm,def,py}, CMake target cpu_avx_packed_int_lifted, CTest cpu_aot_avx_packed_int, 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_packed_int_lifted:
    ValueError: unsupported query operation at 0x1008: vpaddb xmm0,xmm1,xmm2
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_avx_packed_int_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_packed_int|cpu_aot_bmi1)$" -V: 2/2 passed (26 VEX AVX packed integer ALU cases matched native and translated DLLs + EVEX vpaddb rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 26 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:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/395) `Vonsek:ag/cpu-lower-avx-packed-int` → `main` · +522 −0 · 6 files · 5 commits · merged 2026-11-23 15:11 UTC ## Change - Lower 26 VEX 128-bit and 256-bit AVX packed integer ALU instructions in `tools/ffx_version_query.py`: - Wrapping add/sub: `vpaddb`, `vpaddw`, `vpaddq`, `vpsubb`, `vpsubw`, `vpsubd`, `vpsubq` - Bitwise: `vpand`, `vpandn`, `vpor` - Comparisons: `vpcmpeqb`, `vpcmpeqw`, `vpcmpeqd`, `vpcmpeqq`, `vpcmpgtb`, `vpcmpgtw`, `vpcmpgtd`, `vpcmpgtq` - Abs, sign, byte shuffle, and byte align: `vpabsb`, `vpabsw`, `vpabsd`, `vpsignb`, `vpsignw`, `vpsignd`, `vpshufb`, `vpalignr` - 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_packed_int.{asm,def,py}`, CMake target `cpu_avx_packed_int_lifted`, CTest `cpu_aot_avx_packed_int`, 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_packed_int_lifted`: `ValueError: unsupported query operation at 0x1008: vpaddb xmm0,xmm1,xmm2` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_avx_packed_int_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_packed_int|cpu_aot_bmi1)$" -V`: 2/2 passed (`26 VEX AVX packed integer ALU cases matched native and translated DLLs` + EVEX `vpaddb` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 26 `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:48:32 +00:00
github manually merged commit 39010d49cc into gh-pr/395/base 2026-11-26 21:48:34 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:19 UTC · original · edited 2026-11-22 00:23 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:23:46.833991Z 0fd139b 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:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/395#issuecomment-7071473983) · edited 2026-11-22 00:23 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0fd139b9179da71fc94965e58cf6153b8701b681","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:23:46.833991Z">2026-11-22T00:23:46.833991Z</relative-time> | `0fd139b` | 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 14:52 UTC · original

I resolved the shared vector and CMake conflicts on the current branch after #666. All 26 original VEX.128 exports still match. The added VEX.256 VPSHUFB uses a 32-byte memory source and different reference patterns for its two lanes. The translator now rejects a register outside the shared profile with a normal error and preserves the memory operand's width. Both Debug and Release passed seven focused CPU CTests. GitHub CI is rerunning.

**@⁠R0Y00** on GitHub · 2026-11-23 14:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/395#issuecomment-7104663451) I resolved the shared vector and CMake conflicts on the current branch after #666. All 26 original VEX.128 exports still match. The added VEX.256 VPSHUFB uses a 32-byte memory source and different reference patterns for its two lanes. The translator now rejects a register outside the shared profile with a normal error and preserves the memory operand's width. Both Debug and Release passed seven focused CPU CTests. GitHub CI is rerunning.
This discussion has been locked. Commenting is limited to contributors.
No description provided.