cpu: lower legacy SSE FP compare and partial/non-temporal move instructions #978

Merged
Ammmae0x merged 2 commits from upstream-pr/985 into main 2026-11-23 20:37:06 +00:00
Ammmae0x commented 2026-11-23 19:56:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T19:56:28Z.


Change

Add a bounded Windows x64 leaf AOT translator (tools/cpu_sse_fp_aot.py), source-built MASM fixture (tests/cpu/sse_fp.asm, tests/cpu/sse_fp.def), differential/rejection test suite (tests/cpu/sse_fp_check.py), CMake targets/CTest (cpu_aot_sse_fp), and experiment notes (docs/experiments.md) covering five previously uncovered legacy SSE mnemonics in docs/coverage/x64_zen2.tsv:

  • cmpps: all eight imm8 predicates (0..7) on xmm and 16-byte aligned m128 sources
  • cmpss: all eight imm8 predicates (0..7) on xmm and unaligned m32 sources, preserving bits 127:32 of the destination
  • movlps and movhps: m64 load-merge (preserving the other 64 bits) and m64 store
  • movntps: 16-byte aligned m128 non-temporal store

Transport moves (movaps, movdqa, movdqu) and terminal ret are included for ABI glue. Memory stores must target an r8-rooted flat address; VEX/EVEX encodings, imm8 >= 8, nonvolatile registers (xmm6..xmm15), nonvolatile or non-argument base registers, non-r8 stores, unaligned 16-byte operands, undefined register reads/merges, prefixes, unsupported instructions, and malformed streams are rejected.

Verification

Verified on Windows x64 in both dev (Debug) and release (/O2) presets from commit on branch cpu/sse-fp:

  • cmake --preset dev & cmake --preset release + clean builds (--clean-first) of cpu_sse_fp_original, cpu_sse_fp_original_lifted, cpu_sse_fp_altered, cpu_sse_fp_altered_lifted, and cpu_sse2_regs_*: 0 errors, 0 warnings (also verified lifted C++ compiles cleanly with cl /nologo /O2 /W4 /WX).
  • ctest --preset dev --no-tests=error -R "^(cpu_aot_sse_fp|cpu_aot_sse2_regs)$" -V: 2/2 passed (cpu_aot_sse_fp: 720 cases across 34 exports matched native DLL, lifted DLL, and Python IEEE-754 reference bit-for-bit; 6 ALTER_IMM predicate-flip controls diverged on 27 cases each; output mutation control caught; 7 alternate-encoding lift checks, 60 unit rejection controls, and 10 PE-patched rejection controls passed; cpu_aot_sse2_regs: 1,168 cases across 57 exports passed).
  • ctest --preset release --no-tests=error -R "^(cpu_aot_sse_fp|cpu_aot_sse2_regs)$" -V: 2/2 passed with identical counts.
  • .\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: passed (Checked 13 Markdown files and 204 links.).
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: passed (Checked 820 tracked source, script and build/CI files: no bidirectional controls.).
  • ctest --preset dev --no-tests=error -R "^cpu_aot_sse_fp$" --output-junit ... + tools/form_coverage.py: sse_fp.asm passed and covered 9 of 948 x64 forms, including all five new SSE mnemonics (cmpps, cmpss, movlps, movhps, movntps).

Evidence and follow-up

All fixtures are original MASM (tests/cpu/sse_fp.asm, MIT-licensed) and synthetic Python inputs covering signed zeros, infinities, quiet and signaling NaNs with distinct payloads, subnormals, unaligned +1 m32/m64 addresses, 32-byte pre/post buffer guards, ALTER_IMM predicate-flip controls, output mutation negative control, and iced_x86 unit + PE-patched rejection controls.

Not covered: non-default MXCSR modes (FTZ/DAZ or unmasked exceptions), non-temporal cache-bypass hints on movntps, control flow, nonvolatile xmm6..xmm15 prologues, 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:6567622094 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/985). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-23T19:56:28Z. --- ## Change Add a bounded Windows x64 leaf AOT translator (`tools/cpu_sse_fp_aot.py`), source-built MASM fixture (`tests/cpu/sse_fp.asm`, `tests/cpu/sse_fp.def`), differential/rejection test suite (`tests/cpu/sse_fp_check.py`), CMake targets/CTest (`cpu_aot_sse_fp`), and experiment notes (`docs/experiments.md`) covering five previously uncovered legacy `SSE` mnemonics in `docs/coverage/x64_zen2.tsv`: - `cmpps`: all eight `imm8` predicates (`0..7`) on `xmm` and 16-byte aligned `m128` sources - `cmpss`: all eight `imm8` predicates (`0..7`) on `xmm` and unaligned `m32` sources, preserving bits `127:32` of the destination - `movlps` and `movhps`: `m64` load-merge (preserving the other 64 bits) and `m64` store - `movntps`: 16-byte aligned `m128` non-temporal store Transport moves (`movaps`, `movdqa`, `movdqu`) and terminal `ret` are included for ABI glue. Memory stores must target an `r8`-rooted flat address; VEX/EVEX encodings, `imm8 >= 8`, nonvolatile registers (`xmm6`..`xmm15`), nonvolatile or non-argument base registers, non-`r8` stores, unaligned 16-byte operands, undefined register reads/merges, prefixes, unsupported instructions, and malformed streams are rejected. ## Verification Verified on Windows x64 in both `dev` (Debug) and `release` (`/O2`) presets from commit on branch `cpu/sse-fp`: - `cmake --preset dev` & `cmake --preset release` + clean builds (`--clean-first`) of `cpu_sse_fp_original`, `cpu_sse_fp_original_lifted`, `cpu_sse_fp_altered`, `cpu_sse_fp_altered_lifted`, and `cpu_sse2_regs_*`: 0 errors, 0 warnings (also verified lifted C++ compiles cleanly with `cl /nologo /O2 /W4 /WX`). - `ctest --preset dev --no-tests=error -R "^(cpu_aot_sse_fp|cpu_aot_sse2_regs)$" -V`: 2/2 passed (`cpu_aot_sse_fp`: 720 cases across 34 exports matched native DLL, lifted DLL, and Python IEEE-754 reference bit-for-bit; 6 `ALTER_IMM` predicate-flip controls diverged on 27 cases each; output mutation control caught; 7 alternate-encoding lift checks, 60 unit rejection controls, and 10 PE-patched rejection controls passed; `cpu_aot_sse2_regs`: 1,168 cases across 57 exports passed). - `ctest --preset release --no-tests=error -R "^(cpu_aot_sse_fp|cpu_aot_sse2_regs)$" -V`: 2/2 passed with identical counts. - `.\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`: passed (`Checked 13 Markdown files and 204 links.`). - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py`: passed (`Checked 820 tracked source, script and build/CI files: no bidirectional controls.`). - `ctest --preset dev --no-tests=error -R "^cpu_aot_sse_fp$" --output-junit ...` + `tools/form_coverage.py`: `sse_fp.asm` passed and covered 9 of 948 x64 forms, including all five new `SSE` mnemonics (`cmpps`, `cmpss`, `movlps`, `movhps`, `movntps`). ## Evidence and follow-up All fixtures are original MASM (`tests/cpu/sse_fp.asm`, MIT-licensed) and synthetic Python inputs covering signed zeros, infinities, quiet and signaling NaNs with distinct payloads, subnormals, unaligned `+1` `m32`/`m64` addresses, 32-byte pre/post buffer guards, `ALTER_IMM` predicate-flip controls, output mutation negative control, and `iced_x86` unit + PE-patched rejection controls. Not covered: non-default MXCSR modes (FTZ/DAZ or unmasked exceptions), non-temporal cache-bypass hints on `movntps`, control flow, nonvolatile `xmm6`..`xmm15` prologues, 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:43 +00:00
R0Y00 commented 2026-11-24 06:49:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:08:03Z.


The current Release fixture passed all 720 cases here. I also checked the eight packed and scalar compare predicates with masked default MXCSR, sampling qNaN, sNaN and a subnormal. The sampled status and output matched.

A separate accepted leaf exposes an /O2 mismatch. Keep the first aligned output store, add a MOVAPS load to an unused volatile XMM register, then store the original value to the following output vector. With a readable input both DLLs perform both stores. With PAGE_NOACCESS for that load, native raises c0000005 with the first output word written and the second unchanged. The generated DLL performs both stores without a fault because the unused memcpy load is optimized out.

Please preserve every executed guest memory read in this profile, even when the destination is dead. Reuse the established ordered access approach from the packed-string path where it fits, and check the original width and both surrounding writes in /O2. The remaining coverage also overlaps #382 for CMPPS/MOVLPS/MOVHPS, so this can stay the small focused acceptance for those forms.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112611783 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/985#issuecomment-7112611783). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:08:03Z. --- The current Release fixture passed all 720 cases here. I also checked the eight packed and scalar compare predicates with masked default MXCSR, sampling qNaN, sNaN and a subnormal. The sampled status and output matched. A separate accepted leaf exposes an /O2 mismatch. Keep the first aligned output store, add a MOVAPS load to an unused volatile XMM register, then store the original value to the following output vector. With a readable input both DLLs perform both stores. With PAGE_NOACCESS for that load, native raises c0000005 with the first output word written and the second unchanged. The generated DLL performs both stores without a fault because the unused memcpy load is optimized out. Please preserve every executed guest memory read in this profile, even when the destination is dead. Reuse the established ordered access approach from the packed-string path where it fits, and check the original width and both surrounding writes in /O2. The remaining coverage also overlaps #382 for CMPPS/MOVLPS/MOVHPS, so this can stay the small focused acceptance for those forms.
R0Y00 commented 2026-11-24 06:49:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T20:18:59Z.


I pushed 664e411 to preserve executed source reads. The new native/lifted regression fails on the original Release generator, then passes with the fix in Debug and Release, alongside the 720 existing differential cases. The /O2 output performs one 16-byte source load between the two stores. The guarded output shows that the first store survives the read fault and the second remains untouched. The original contribution and controls are intact. Fresh Windows CI is pending.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112895740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/985#issuecomment-7112895740). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T20:18:59Z. --- I pushed 664e411 to preserve executed source reads. The new native/lifted regression fails on the original Release generator, then passes with the fix in Debug and Release, alongside the 720 existing differential cases. The /O2 output performs one 16-byte source load between the two stores. The guarded output shows that the first store survives the read fault and the second remains untouched. The original contribution and controls are intact. Fresh Windows CI is pending.
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!978
No description provided.