cpu: lower legacy SSE MMX-domain conversion, shuffle, and non-temporal store ops #1000

Merged
Ammmae0x merged 2 commits from upstream-pr/1007 into main 2026-11-23 21:28:59 +00:00
Ammmae0x commented 2026-11-23 20:57:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T20:57:21Z.


Change

Add the SSE/MMX leaf translator and differential fixture (cpu_aot_sse_mmx) covering five previously uncovered SSE mnemonics from docs/coverage/x64_zen2.tsv:

  • cvtpi2ps: converts two int32_t values from mm/m64 to float32 in xmm[63:0] while preserving xmm[127:64].
  • cvtps2pi: converts two float32 values from xmm[63:0]/m64 to int32_t in mm using round-to-nearest-even (0x80000000 on NaN, +/-Inf, or out-of-int32_t range after rounding).
  • cvttps2pi: converts two float32 values from xmm[63:0]/m64 to int32_t in mm using truncation toward zero (0x80000000 on NaN, +/-Inf, or out-of-int32_t range).
  • pshufw: performs imm8 16-bit word permutation from mm/m64 into mm.
  • movntq: performs a 64-bit non-temporal store from mm to [r8 + disp].

The translator uses the leaf ABI void fn(word rcx, word rdx, word r8) with XMM0..XMM5 (Vec128), MM0..MM7 (std::uint64_t mm[8]), volatile scratch GPRs (rax, r9, r10, r11) for movq bridges, movaps/movdqa (16-byte aligned), movdqu, emms state tracking (rejecting ret while mmx_active), std::atomic_signal_fence + volatile load64/load128 for dead-read fault ordering at /O2, and r8-only stores.

Verification

All checks ran on x64 Windows (& .\tools\dev.ps1) with 0 errors and 0 warnings across both dev and release (/O2) presets:

  • cmake --build --preset dev --clean-first --target cpu_sse_mmx_original cpu_sse_mmx_original_lifted cpu_sse_mmx_altered cpu_sse_mmx_altered_lifted cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered cpu_sse_fp_altered_lifted -> 0 errors, 0 warnings.
  • cmake --build --preset release --clean-first --target cpu_sse_mmx_original cpu_sse_mmx_original_lifted cpu_sse_mmx_altered cpu_sse_mmx_altered_lifted cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered cpu_sse_fp_altered_lifted -> 0 errors, 0 warnings.
  • ctest --preset dev --no-tests=error -R "^(cpu_aot_sse_mmx|cpu_aot_sse_fp)$" -V -> 2/2 Passed:
    • cpu_aot_sse_mmx: 237 native/lifted/reference cases across 18 exports matched bit-for-bit plus op_discarded_read fault-ordering check; ALTER_IMM diverged on {'op_cvtps2pi_reg': 3, 'op_cvttps2pi_reg': 3, 'op_pshufw_reg_e4': 7, 'op_pshufw_mem_4e': 7}; output-mutation control caught; 7 alternate-encoding lift checks, 59 unit rejection controls (7 VEX/EVEX, 12 unsupported instructions, 40 ABI/state/addressing/prefix/stream), and 10 PE-patched DLL rejection controls passed.
    • cpu_aot_sse_fp: 720 cases across 34 exports passed.
  • ctest --preset release --no-tests=error -R "^(cpu_aot_sse_mmx|cpu_aot_sse_fp)$" -V -> 2/2 Passed (same counts at /O2).
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py -> passed.
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py -> Checked 13 Markdown files and 214 links. passed.
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py -> Checked 840 tracked source, script and build/CI files: no bidirectional controls. passed.
  • tools/form_coverage.py on cpu_aot_sse_mmx JUnit XML -> sse_mmx.asm classified pass, covering cvtpi2ps, cvtps2pi, cvttps2pi, pshufw, and movntq.

Evidence and follow-up

  • Fixture source: original source-built MASM assembly (tests/cpu/sse_mmx.asm, tests/cpu/sse_mmx.def) and Python differential/rejection suite (tests/cpu/sse_mmx_check.py), registered in CMakeLists.txt and documented in docs/experiments.md.
  • Negative controls: ALTER_IMM opcode/immediate swaps, single-bit output-mutation check, discarded-read fault-ordering test (op_discarded_read), 59 unit rejection controls, and 10 PE-patched DLL rejection controls.
  • Out of scope: non-default MXCSR rounding modes, non-temporal cache-bypass hints on movntq, x87/MMX aliasing across calls, control flow, and title CPU code execution.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6568681897 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1007). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T20:57:21Z. --- ## Change Add [the SSE/MMX leaf translator](tools/cpu_sse_mmx_aot.py) and differential fixture (`cpu_aot_sse_mmx`) covering five previously uncovered `SSE` mnemonics from `docs/coverage/x64_zen2.tsv`: - `cvtpi2ps`: converts two `int32_t` values from `mm`/`m64` to `float32` in `xmm[63:0]` while preserving `xmm[127:64]`. - `cvtps2pi`: converts two `float32` values from `xmm[63:0]`/`m64` to `int32_t` in `mm` using round-to-nearest-even (`0x80000000` on NaN, `+/-Inf`, or out-of-`int32_t` range after rounding). - `cvttps2pi`: converts two `float32` values from `xmm[63:0]`/`m64` to `int32_t` in `mm` using truncation toward zero (`0x80000000` on NaN, `+/-Inf`, or out-of-`int32_t` range). - `pshufw`: performs `imm8` 16-bit word permutation from `mm`/`m64` into `mm`. - `movntq`: performs a 64-bit non-temporal store from `mm` to `[r8 + disp]`. The translator uses the leaf ABI `void fn(word rcx, word rdx, word r8)` with `XMM0`..`XMM5` (`Vec128`), `MM0`..`MM7` (`std::uint64_t mm[8]`), volatile scratch GPRs (`rax`, `r9`, `r10`, `r11`) for `movq` bridges, `movaps`/`movdqa` (16-byte aligned), `movdqu`, `emms` state tracking (rejecting `ret` while `mmx_active`), `std::atomic_signal_fence` + volatile `load64`/`load128` for dead-read fault ordering at `/O2`, and `r8`-only stores. ## Verification All checks ran on x64 Windows (`& .\tools\dev.ps1`) with 0 errors and 0 warnings across both `dev` and `release` (`/O2`) presets: - `cmake --build --preset dev --clean-first --target cpu_sse_mmx_original cpu_sse_mmx_original_lifted cpu_sse_mmx_altered cpu_sse_mmx_altered_lifted cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered cpu_sse_fp_altered_lifted` -> 0 errors, 0 warnings. - `cmake --build --preset release --clean-first --target cpu_sse_mmx_original cpu_sse_mmx_original_lifted cpu_sse_mmx_altered cpu_sse_mmx_altered_lifted cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered cpu_sse_fp_altered_lifted` -> 0 errors, 0 warnings. - `ctest --preset dev --no-tests=error -R "^(cpu_aot_sse_mmx|cpu_aot_sse_fp)$" -V` -> `2/2 Passed`: - `cpu_aot_sse_mmx`: 237 native/lifted/reference cases across 18 exports matched bit-for-bit plus `op_discarded_read` fault-ordering check; `ALTER_IMM` diverged on `{'op_cvtps2pi_reg': 3, 'op_cvttps2pi_reg': 3, 'op_pshufw_reg_e4': 7, 'op_pshufw_mem_4e': 7}`; output-mutation control caught; 7 alternate-encoding lift checks, 59 unit rejection controls (7 VEX/EVEX, 12 unsupported instructions, 40 ABI/state/addressing/prefix/stream), and 10 PE-patched DLL rejection controls passed. - `cpu_aot_sse_fp`: 720 cases across 34 exports passed. - `ctest --preset release --no-tests=error -R "^(cpu_aot_sse_mmx|cpu_aot_sse_fp)$" -V` -> `2/2 Passed` (same counts at `/O2`). - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py` -> passed. - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py` -> `Checked 13 Markdown files and 214 links.` passed. - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py` -> `Checked 840 tracked source, script and build/CI files: no bidirectional controls.` passed. - `tools/form_coverage.py` on `cpu_aot_sse_mmx` JUnit XML -> `sse_mmx.asm` classified `pass`, covering `cvtpi2ps`, `cvtps2pi`, `cvttps2pi`, `pshufw`, and `movntq`. ## Evidence and follow-up - Fixture source: original source-built MASM assembly ([tests/cpu/sse_mmx.asm](tests/cpu/sse_mmx.asm), [tests/cpu/sse_mmx.def](tests/cpu/sse_mmx.def)) and Python differential/rejection suite ([tests/cpu/sse_mmx_check.py](tests/cpu/sse_mmx_check.py)), registered in [CMakeLists.txt](CMakeLists.txt) and documented in [docs/experiments.md](docs/experiments.md). - Negative controls: `ALTER_IMM` opcode/immediate swaps, single-bit output-mutation check, discarded-read fault-ordering test (`op_discarded_read`), 59 unit rejection controls, and 10 PE-patched DLL rejection controls. - Out of scope: non-default MXCSR rounding modes, non-temporal cache-bypass hints on `movntq`, x87/MMX aliasing across calls, control flow, and title CPU code execution. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:49 +00:00
R0Y00 commented 2026-11-24 06:49:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:09:53Z.


Independent Release cpu_aot_sse_mmx passed at 9d28f08. This includes 237 native/lifted/reference comparisons across 18 exports, the displaced unaligned MOVNTQ output, both fault-order controls, 59 unit refusals and 10 PE-patched refusals. I pushed d763b20 to document the fixed host FP controls and the MOVNTQ boundary: the fixture compares the final output bytes in caller-owned memory. Cache behavior and inter-thread visibility require a separate contract.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7114092043 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1007#issuecomment-7114092043). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T21:09:53Z. --- Independent Release `cpu_aot_sse_mmx` passed at `9d28f08`. This includes 237 native/lifted/reference comparisons across 18 exports, the displaced unaligned MOVNTQ output, both fault-order controls, 59 unit refusals and 10 PE-patched refusals. I pushed `d763b20` to document the fixed host FP controls and the MOVNTQ boundary: the fixture compares the final output bytes in caller-owned memory. Cache behavior and inter-thread visibility require a separate contract.
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!1000
No description provided.