cpu: lower SSSE3/SSE4.1/SSE4.2 insert/extract, ptest, misc integer, and crc32 #377

Manually merged
github merged 3 commits from gh-pr/377/head into gh-pr/377/base 2026-11-26 21:47:05 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 23:47 UTC · original
Vonsek:ag/cpu-lower-sse41-42-misc → main · +424 −0 · 6 files · 3 commits · merged 2026-11-22 12:26 UTC

Change

  • Lower 16 SSSE3/SSE4.1/SSE4.2 integer, insert/extract, ptest, and crc32 instructions (plus legacy movdqu) in tools/ffx_version_query.py:
    • Insert/extract: pextrb, pextrw, pextrd, pextrq, pinsrb, pinsrw, pinsrd, pinsrq
    • SSSE3 multiply: pmaddubsw, pmulhrsw
    • SSE4.1 misc: phminposuw, ptest (updating ZF and CF), mpsadbw, movntdqa
    • SSE4.2: pcmpgtq, crc32 (8/16/32/64-bit Castagnoli CRC-32C)
  • Restrict vector lowering to EncodingKind.LEGACY XMM forms, rejecting 64-bit MMX encodings.
  • Probe CPUID leaf 1 ECX bits 9 (SSSE3), 19 (SSE4.1), and 20 (SSE4.2) before invoking the native fixture (exiting 77 with SKIP_RETURN_CODE 77 on hosts without those features).
  • Add source-built MASM differential fixture tests/cpu/sse41_42_misc.{asm,def,py}, CMake target cpu_sse41_42_misc_lifted, CTest cpu_aot_sse41_42_misc, 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_sse41_42_misc_lifted:
    ValueError: unsupported query operation at 0x1000: movdqu xmm0,[rcx]
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_sse41_42_misc_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_sse41_42_misc|cpu_aot_bmi1)$" -V: 2/2 passed (21 SSSE3/SSE4.1/SSE4.2 misc cases matched native and translated DLLs, covering all 4 (ZF, CF) combinations of ptest, 8/32/64-bit crc32, and 64-bit MMX pmulhrsw mm0, mm1 rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 14 SSE3-4-grouped mnemonics and 2 SSE-grouped mnemonics in docs/coverage/x64_zen2.tsv using source-built fixtures, gated by a runtime CPUID check.
**@⁠Vonsek** on GitHub · 2026-11-21 23:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/377) `Vonsek:ag/cpu-lower-sse41-42-misc` → `main` · +424 −0 · 6 files · 3 commits · merged 2026-11-22 12:26 UTC ## Change - Lower 16 SSSE3/SSE4.1/SSE4.2 integer, insert/extract, `ptest`, and `crc32` instructions (plus legacy `movdqu`) in `tools/ffx_version_query.py`: - Insert/extract: `pextrb`, `pextrw`, `pextrd`, `pextrq`, `pinsrb`, `pinsrw`, `pinsrd`, `pinsrq` - SSSE3 multiply: `pmaddubsw`, `pmulhrsw` - SSE4.1 misc: `phminposuw`, `ptest` (updating ZF and CF), `mpsadbw`, `movntdqa` - SSE4.2: `pcmpgtq`, `crc32` (8/16/32/64-bit Castagnoli CRC-32C) - Restrict vector lowering to `EncodingKind.LEGACY` XMM forms, rejecting 64-bit MMX encodings. - Probe CPUID leaf 1 ECX bits 9 (`SSSE3`), 19 (`SSE4.1`), and 20 (`SSE4.2`) before invoking the native fixture (exiting 77 with `SKIP_RETURN_CODE 77` on hosts without those features). - Add source-built MASM differential fixture `tests/cpu/sse41_42_misc.{asm,def,py}`, CMake target `cpu_sse41_42_misc_lifted`, CTest `cpu_aot_sse41_42_misc`, 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_sse41_42_misc_lifted`: `ValueError: unsupported query operation at 0x1000: movdqu xmm0,[rcx]` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_sse41_42_misc_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_sse41_42_misc|cpu_aot_bmi1)$" -V`: 2/2 passed (`21 SSSE3/SSE4.1/SSE4.2 misc cases matched native and translated DLLs`, covering all 4 `(ZF, CF)` combinations of `ptest`, 8/32/64-bit `crc32`, and 64-bit MMX `pmulhrsw mm0, mm1` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 14 `SSE3-4`-grouped mnemonics and 2 `SSE`-grouped mnemonics in `docs/coverage/x64_zen2.tsv` using source-built fixtures, gated by a runtime CPUID check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:47:04 +00:00
github manually merged commit 520aabb203 into gh-pr/377/base 2026-11-26 21:47:05 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 23:51 UTC · original · edited 2026-11-21 23:54 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-21T23:54:34.853981Z 570bbfc 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-21 23:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/377#issuecomment-7071146769) · edited 2026-11-21 23:54 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"570bbfcf1df336684c86a31366428b1e00f9cc84","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-21T23:54:34.853981Z">2026-11-21T23:54:34.853981Z</relative-time> | `570bbfc` | 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-22 12:22 UTC · original

I pushed 520aabb to resolve the shared SIMD conflicts. It reuses the existing MOVDQU path, clears tracked OF/PF on PTEST, and limits packed binary forms to tracked XMM sources. The aligned native MOVNTDQA case is still checked; translation now explicitly rejects that memory form. A separate contribution can establish the alignment and memory-type contract with aligned and misaligned native comparisons. On Windows x64, ctest --preset dev --no-tests=error -R '^cpu_aot_(sse41_42_misc|sse2_int|fma_scalar)$' passed 3/3, with no skips, and python -B tests/form_coverage_check.py passed.

**@⁠R0Y00** on GitHub · 2026-11-22 12:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/377#issuecomment-7079059867) I pushed `520aabb` to resolve the shared SIMD conflicts. It reuses the existing MOVDQU path, clears tracked OF/PF on PTEST, and limits packed binary forms to tracked XMM sources. The aligned native MOVNTDQA case is still checked; translation now explicitly rejects that memory form. A separate contribution can establish the alignment and memory-type contract with aligned and misaligned native comparisons. On Windows x64, `ctest --preset dev --no-tests=error -R '^cpu_aot_(sse41_42_misc|sse2_int|fma_scalar)$'` passed 3/3, with no skips, and `python -B tests/form_coverage_check.py` passed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.