cpu: add legacy SSE4.1 FP AOT lifter and test suite #2683

Merged
Ammmae0x merged 2 commits from upstream-pr/2691 into main 2026-11-26 03:18:31 +00:00
Ammmae0x commented 2026-11-26 02:09:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T02:09:25Z.


Change

Add a bounded AOT lifter (tools/cpu_sse41_fp_aot.py) and source-built MASM/differential verification suite (tests/cpu/sse41_fp_aot.{asm,def,_check.py}, CTest cpu_aot_sse41_fp) covering all 8 legacy SSE4.1 floating-point instructions in register and flat [rcx|rdx|r8] memory forms:

  • ROUNDPS, ROUNDPD, ROUNDSS, ROUNDSD: models imm8[1:0] when imm8[2]==0 or host MXCSR RC when imm8[2]==1, handling -0.0, +/-Inf, qNaN/sNaN quieting, MXCSR DAZ, and scalar destination upper-lane preservation.
  • DPPS, DPPD: source masks imm8[7:4] / imm8[5:4], pairwise SSE2 reduction under host MXCSR (RC, DAZ, FTZ), and destination masks imm8[3:0] / imm8[1:0] (disabled outputs set to +0.0).
  • INSERTPS: selects count_s = imm8[7:6] from register or lane 0 from m32, inserts at count_d = imm8[5:4], and applies zmask = imm8[3:0] last.
  • EXTRACTPS: extracts lane imm8[1:0] to volatile scratch r32/r64 (zero-extending [63:32]) or flat m32 [r8].
  • Bounded transport glue (MOVAPS/D/UPS/D/DQA/DQU/SS/SD, scratch 32/64-bit MOV, terminal RET) with strict refusal of VEX/EVEX encodings, nonvolatile XMM6..15 and nonvolatile GPRs, argument GPR writes, undefined reads, non-flat/displaced/indexed/RIP-relative memory operands, non-[r8] stores, prefixes, and missing/trailing ret.

Verification

Verified on commit f294a2c0 (based on upstream/main f02ebd66) on Windows x64 (MSVC, both dev Debug and release /O2):

  • ctest --preset dev -N -> 2178 total tests, cpu_aot_sse41_fp registered with SKIP_RETURN_CODE 77 and FORM_COVERAGE_RECORD.
  • cmake --build --preset dev --clean-first --target cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted -> exit 0, 0 errors, 0 warnings.
  • ctest --preset dev --no-tests=error -R '^cpu_aot_sse41_fp$' -E 'cpu_native_archive_' -V -> 1/1 passed: 33 forms accepted, 33 refusal controls, 5 CLI negative checks, 2263 differential cases across 57 exports and 7 MXCSR modes (RN/RD/RU/RZ, DAZ, FTZ, DAZ+FTZ), 8 ALTER_SSE41_FP altered controls diverged, FORM_COVERAGE_RECORD emitted 18 forms (dppd, dpps, extractps, insertps, mov, movapd, movaps, movdqa, movdqu, movsd, movss, movupd, movups, ret, roundpd, roundps, roundsd, roundss).
  • cmake --build --preset release --clean-first --target cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted -> exit 0, 0 errors, 0 warnings.
  • ctest --preset release --no-tests=error -R '^cpu_aot_sse41_fp$' -E 'cpu_native_archive_' -V -> 1/1 passed (same 2263 cases + 8 altered controls + 18 forms under /O2).
  • out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py, tests\docs_links_check.py, tests\bidi_controls_check.py -> all exit 0.
  • On-disk spot-mutation negative controls (3/3 killed by tests/cpu/sse41_fp_aot_check.py): disabling legacy-only encoding check, disabling non-[r8] store guard, and disabling argument GPR write guard.
  • Capability skip path: host checks CPUID.01H:ECX[19] (SSE4.1) and exits 77 when unavailable; 0 capability skips on this host.

Evidence and follow-up

  • Source-built MASM fixture tests/cpu/sse41_fp_aot.asm and module definition tests/cpu/sse41_fp_aot.def are original repository files under MIT License (no external dumps or binaries).
  • Header line 1 declares ; coverage: record cpu_aot_sse41_fp for automated x64 form coverage tracking.

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:6617945904 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2691). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-26T02:09:25Z. --- ## Change Add a bounded AOT lifter (`tools/cpu_sse41_fp_aot.py`) and source-built MASM/differential verification suite (`tests/cpu/sse41_fp_aot.{asm,def,_check.py}`, CTest `cpu_aot_sse41_fp`) covering all 8 legacy SSE4.1 floating-point instructions in register and flat `[rcx|rdx|r8]` memory forms: - `ROUNDPS`, `ROUNDPD`, `ROUNDSS`, `ROUNDSD`: models `imm8[1:0]` when `imm8[2]==0` or host MXCSR RC when `imm8[2]==1`, handling `-0.0`, `+/-Inf`, qNaN/sNaN quieting, MXCSR DAZ, and scalar destination upper-lane preservation. - `DPPS`, `DPPD`: source masks `imm8[7:4]` / `imm8[5:4]`, pairwise SSE2 reduction under host MXCSR (RC, DAZ, FTZ), and destination masks `imm8[3:0]` / `imm8[1:0]` (disabled outputs set to `+0.0`). - `INSERTPS`: selects `count_s = imm8[7:6]` from register or lane 0 from `m32`, inserts at `count_d = imm8[5:4]`, and applies `zmask = imm8[3:0]` last. - `EXTRACTPS`: extracts lane `imm8[1:0]` to volatile scratch `r32`/`r64` (zero-extending `[63:32]`) or flat `m32` `[r8]`. - Bounded transport glue (`MOVAPS/D/UPS/D/DQA/DQU/SS/SD`, scratch 32/64-bit `MOV`, terminal `RET`) with strict refusal of VEX/EVEX encodings, nonvolatile `XMM6..15` and nonvolatile GPRs, argument GPR writes, undefined reads, non-flat/displaced/indexed/RIP-relative memory operands, non-`[r8]` stores, prefixes, and missing/trailing `ret`. ## Verification Verified on commit `f294a2c0` (based on `upstream/main` `f02ebd66`) on Windows x64 (MSVC, both `dev` Debug and `release` `/O2`): - `ctest --preset dev -N` -> 2178 total tests, `cpu_aot_sse41_fp` registered with `SKIP_RETURN_CODE 77` and `FORM_COVERAGE_RECORD`. - `cmake --build --preset dev --clean-first --target cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted` -> exit 0, 0 errors, 0 warnings. - `ctest --preset dev --no-tests=error -R '^cpu_aot_sse41_fp$' -E 'cpu_native_archive_' -V` -> 1/1 passed: 33 forms accepted, 33 refusal controls, 5 CLI negative checks, 2263 differential cases across 57 exports and 7 MXCSR modes (RN/RD/RU/RZ, DAZ, FTZ, DAZ+FTZ), 8 `ALTER_SSE41_FP` altered controls diverged, `FORM_COVERAGE_RECORD` emitted 18 forms (`dppd, dpps, extractps, insertps, mov, movapd, movaps, movdqa, movdqu, movsd, movss, movupd, movups, ret, roundpd, roundps, roundsd, roundss`). - `cmake --build --preset release --clean-first --target cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted` -> exit 0, 0 errors, 0 warnings. - `ctest --preset release --no-tests=error -R '^cpu_aot_sse41_fp$' -E 'cpu_native_archive_' -V` -> 1/1 passed (same 2263 cases + 8 altered controls + 18 forms under `/O2`). - `out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py`, `tests\docs_links_check.py`, `tests\bidi_controls_check.py` -> all exit 0. - On-disk spot-mutation negative controls (3/3 killed by `tests/cpu/sse41_fp_aot_check.py`): disabling legacy-only encoding check, disabling non-`[r8]` store guard, and disabling argument GPR write guard. - Capability skip path: host checks `CPUID.01H:ECX[19]` (SSE4.1) and exits `77` when unavailable; 0 capability skips on this host. ## Evidence and follow-up - Source-built MASM fixture `tests/cpu/sse41_fp_aot.asm` and module definition `tests/cpu/sse41_fp_aot.def` are original repository files under MIT License (no external dumps or binaries). - Header line 1 declares `; coverage: record cpu_aot_sse41_fp` for automated x64 form coverage tracking. ## 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-26 04:04:22 +00:00
tedin7 commented 2026-11-26 04:04:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:18:00Z.

Review: COMMENTED


Review of head 82fc6044 (comment only).

Checked:

  • Scope: new bounded legacy SSE4.1 FP lifter (tools/cpu_sse41_fp_aot.py) and source-built MASM/CTest differential suite cpu_aot_sse41_fp (ROUNDPS/PD/SS/SD, DPPS/DPPD, INSERTPS, EXTRACTPS). Same dedicated-suite pattern as the other cpu_*_aot lifters. The earlier lowering PRs in the shared lifter are separate; the nearest open PR (#2390, VEX rounding) covers different encodings.
  • The test compares the original and lifted native DLLs against an IEEE-754 reference and builds an altered variant whose exports must diverge (the negative control).
  • CMake block is self-contained, foreach/endforeach balanced, SKIP_RETURN_CODE 77 and FORM_COVERAGE_RECORD set.

Commands run:

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • Win2025 x2w_pipe.py win2025 2691 --regex cpu_aot_sse41_fp: dev 1/1 and release 1/1 passed (receipt in the next comment)
  • CI on this head: green

Not run: the Python suite on Linux (it needs MASM and the Windows build).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068094956 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2691#pullrequestreview-6068094956). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:18:00Z. **Review:** COMMENTED --- Review of head 82fc6044 (comment only). Checked: - Scope: new bounded legacy SSE4.1 FP lifter (`tools/cpu_sse41_fp_aot.py`) and source-built MASM/CTest differential suite `cpu_aot_sse41_fp` (ROUNDPS/PD/SS/SD, DPPS/DPPD, INSERTPS, EXTRACTPS). Same dedicated-suite pattern as the other `cpu_*_aot` lifters. The earlier lowering PRs in the shared lifter are separate; the nearest open PR (#2390, VEX rounding) covers different encodings. - The test compares the original and lifted native DLLs against an IEEE-754 reference and builds an altered variant whose exports must diverge (the negative control). - CMake block is self-contained, `foreach`/`endforeach` balanced, `SKIP_RETURN_CODE 77` and `FORM_COVERAGE_RECORD` set. Commands run: - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - Win2025 `x2w_pipe.py win2025 2691 --regex cpu_aot_sse41_fp`: dev 1/1 and release 1/1 passed (receipt in the next comment) - CI on this head: green Not run: the Python suite on Linux (it needs MASM and the Windows build). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 04:04:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:18:01Z.


Win2025 WARP receipt for head 82fc6044 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 82fc6044fc4e331854ce53f5882460f2da2640bb:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted -- -j 2): 10.12s (configure 3.99s)
    • Test (ctest --preset dev -R 'cpu_aot_sse41_fp' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.63s: cpu_aot_sse41_fp 1.37s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted -- -j 2): 2.95s (configure 4.95s)
    • Test (ctest --preset release -R 'cpu_aot_sse41_fp' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (1.49s: cpu_aot_sse41_fp 1.24s)
  • sccache: 0/4 hits; wall 41.7s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181586010 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2691#issuecomment-7181586010). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:18:01Z. --- Win2025 WARP receipt for head 82fc6044 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `82fc6044fc4e331854ce53f5882460f2da2640bb`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted -- -j 2`): `10.12s` (configure `3.99s`) - Test (`ctest --preset dev -R 'cpu_aot_sse41_fp' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.63s`: `cpu_aot_sse41_fp` `1.37s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target cpu_sse41_fp_aot_altered cpu_sse41_fp_aot_altered_lifted cpu_sse41_fp_aot_original cpu_sse41_fp_aot_original_lifted -- -j 2`): `2.95s` (configure `4.95s`) - Test (`ctest --preset release -R 'cpu_aot_sse41_fp' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`1.49s`: `cpu_aot_sse41_fp` `1.24s`) - `sccache`: 0/4 hits; wall `41.7s` AI-assisted; commands listed were executed locally.
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!2683
No description provided.