cpu: lower all 12 SSE4.1 pmovsx/pmovzx vector extension instructions #358

Merged
Vonsek merged 4 commits from upstream-pr/364 into main 2026-11-22 10:26:51 +00:00
Vonsek commented 2026-11-21 23:24:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T23:24:32Z.


Change

  • Lower 128-bit legacy movdqu and all 12 SSE4.1 sign/zero-extending vector moves (pmovsxbw, pmovsxbd, pmovsxbq, pmovsxwd, pmovsxwq, pmovsxdq, pmovzxbw, pmovzxbd, pmovzxbq, pmovzxwd, pmovzxwq, pmovzxdq) in tools/ffx_version_query.py, reading only the narrow source lane extent (lanes * src_size) for memory operands.
  • Add a source-built MASM fixture (tests/cpu/sse41_extend.asm, tests/cpu/sse41_extend.def) and differential test (tests/cpu/sse41_extend.py) wired into CMakeLists.txt as cpu_aot_sse41_extend with a host_has_sse41() CPUID leaf 1 ECX bit 19 check and SKIP_RETURN_CODE 77 on unsupported hosts.
  • Verify bit-for-bit agreement across all 13 exports (12 register forms plus narrow 4-byte memory-source pmovsxbd_mem).
  • Classify sse41_extend -> cpu_aot_sse41_extend in tools/form_coverage.py (+12 SSE3-4 mnemonics in docs/coverage/x64_zen2.tsv) and document the test in docs/experiments.md.

Verification

Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12):

  • Before the change, cmake --build --preset dev --target cpu_sse41_extend_lifted failed with:
    ValueError: unsupported query operation at 0x1000: movdqu xmm1,[rcx]
    
  • After the change:
    • cmake --build --preset dev --target cpu_sse41_extend_lifted succeeded.
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_sse41_extend|cpu_aot_bmi1|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V: 5/5 passed (13 SSE4.1 pmovsx/pmovzx cases (including narrow memory source) matched native and translated DLLs).
    • python -B tests/form_coverage_check.py: form coverage checks passed.

Evidence and follow-up

  • Adds 12 SSE3-4 mnemonics (pmovsxbw/bd/bq/wd/wq/dq, pmovzxbw/bd/bq/wd/wq/dq) to docs/coverage/x64_zen2.tsv coverage; complements #355 (14 SSSE3) and #359 (14 SSE4.1 integer ops).
  • All binaries are source-built via MASM and CMake; no game files or external dumps are included.

Checklist

  • Focused, single-purpose change
  • Source-built test that fails without the change and passes with it
  • Verified locally on Windows
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535747731 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/364). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T23:24:32Z. --- ## Change - Lower 128-bit legacy `movdqu` and all 12 SSE4.1 sign/zero-extending vector moves (`pmovsxbw`, `pmovsxbd`, `pmovsxbq`, `pmovsxwd`, `pmovsxwq`, `pmovsxdq`, `pmovzxbw`, `pmovzxbd`, `pmovzxbq`, `pmovzxwd`, `pmovzxwq`, `pmovzxdq`) in `tools/ffx_version_query.py`, reading only the narrow source lane extent (`lanes * src_size`) for memory operands. - Add a source-built MASM fixture (`tests/cpu/sse41_extend.asm`, `tests/cpu/sse41_extend.def`) and differential test (`tests/cpu/sse41_extend.py`) wired into `CMakeLists.txt` as `cpu_aot_sse41_extend` with a `host_has_sse41()` CPUID leaf 1 ECX bit 19 check and `SKIP_RETURN_CODE 77` on unsupported hosts. - Verify bit-for-bit agreement across all 13 exports (12 register forms plus narrow 4-byte memory-source `pmovsxbd_mem`). - Classify `sse41_extend` -> `cpu_aot_sse41_extend` in `tools/form_coverage.py` (+12 `SSE3-4` mnemonics in `docs/coverage/x64_zen2.tsv`) and document the test in `docs/experiments.md`. ## Verification Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12): - Before the change, `cmake --build --preset dev --target cpu_sse41_extend_lifted` failed with: ```text ValueError: unsupported query operation at 0x1000: movdqu xmm1,[rcx] ``` - After the change: - `cmake --build --preset dev --target cpu_sse41_extend_lifted` succeeded. - `ctest --preset dev --no-tests=error -R "^(cpu_aot_sse41_extend|cpu_aot_bmi1|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V`: 5/5 passed (`13 SSE4.1 pmovsx/pmovzx cases (including narrow memory source) matched native and translated DLLs`). - `python -B tests/form_coverage_check.py`: `form coverage checks passed`. ## Evidence and follow-up - Adds 12 `SSE3-4` mnemonics (`pmovsxbw/bd/bq/wd/wq/dq`, `pmovzxbw/bd/bq/wd/wq/dq`) to `docs/coverage/x64_zen2.tsv` coverage; complements #355 (14 SSSE3) and #359 (14 SSE4.1 integer ops). - All binaries are source-built via MASM and CMake; no game files or external dumps are included. ## Checklist - [x] Focused, single-purpose change - [x] Source-built test that fails without the change and passes with it - [x] Verified locally on Windows
upstream-sync closed this pull request 2026-11-24 06:42:38 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:48:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T23:28:27Z.


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:32:47.109396Z 4d2953e 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070896858 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/364#issuecomment-7070896858). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T23:28:27Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"4d2953e20630bdea1c12cbbc1d55caba2fd4d68f","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:32:47.109396Z">2026-11-21T23:32:47.109396Z</relative-time> | `4d2953e` | 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>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!358
No description provided.