cpu: lower legacy SSE2 CMPSD, MOVLPD, MOVHPD, and MOVNTPD in cpu_sse_fp_aot #2377

Merged
Ammmae0x merged 1 commit from upstream-pr/2385 into main 2026-11-25 14:49:17 +00:00
Ammmae0x commented 2026-11-25 14:40:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T14:40:29Z.


Change

Lower four additional legacy SSE2 double-precision forms in tools/cpu_sse_fp_aot.py:

  • CMPSD (Code.CMPSD_XMM_XMMM64_IMM8): predicates 0..7 with XMM or flat m64 source (unaligned m64 accepted), preserving bits [127:64] and writing 0xFFFFFFFFFFFFFFFF/0 into [63:0] via host SSE2 op_cmpsd_q with volatile operand copies so runtime MXCSR (DAZ) and NaN rules match hardware; rejects imm8 >= 8.
  • MOVLPD / MOVHPD (MOVLPD_XMM_M64, MOVLPD_M64_XMM, MOVHPD_XMM_M64, MOVHPD_M64_XMM): flat m64 load-merge preserving the untouched 64-bit lane and r8-rooted m64 store (unaligned displacements accepted; reg-reg encodings rejected).
  • MOVNTPD (MOVNTPD_M128_XMM): 16-byte-aligned r8-rooted non-temporal store (rejects disp % 16 != 0 and non-r8 stores).
  • Update tests/cpu/sse_fp_check.py and tests/cpu/sse_fp_pd_check.py to replace now-supported negative assertions for these four forms with still-unsupported legacy SSE2 forms (unpcklpd, unpckhpd, shufpd, movupd).
  • Add source-built MASM fixture tests/cpu/sse_fp_pd_moves_cmp.{asm,def,_check.py} (; coverage: record cpu_aot_sse_fp_pd_moves_cmp) and register cpu_aot_sse_fp_pd_moves_cmp in CMakeLists.txt.

Verification

Verified on commit a3c94c99 (rebased on upstream/main a31f70a1) across both dev (Debug) and release (/O2) presets:

  • cmake --build --preset dev --target cpu_sse_fp_harness cpu_sse_fp*_original* cpu_sse_fp*_altered* -> exit 0
  • ctest --preset dev -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure -> 100% tests passed, 0 tests failed out of 5 (0 skipped):
    • cpu_aot_sse_fp (5.03s), cpu_aot_sse_fp_logic (0.68s), cpu_aot_sse_fp_pd (15.02s), cpu_aot_sse_fp_pd_logic (0.64s), cpu_aot_sse_fp_pd_moves_cmp (4.66s)
    • cpu_aot_sse_fp_pd_moves_cmp: 6752 lifted + 6752 /O2 cases across 23 exports; 96448 MXCSR CMPSD runs (16 states, 14 quirks); ALTER_IMM diverged on 17 exports + 9 mutants caught; rejections passed: 8 alt + 11 VEX/EVEX + 34 IR + 8 raw + 10 PE-patched + CLI
  • cmake --build --preset release --target cpu_sse_fp_harness cpu_sse_fp*_original* cpu_sse_fp*_altered* -> exit 0
  • ctest --preset release -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure -> 100% tests passed, 0 tests failed out of 5 (0 skipped; 26.52s)
  • FORM_COVERAGE_RECORD verified in both out/build/dev/form_coverage/cpu_aot_sse_fp_pd_moves_cmp.txt and out/build/release/form_coverage/cpu_aot_sse_fp_pd_moves_cmp.txt: cmpsd, movaps, movdqa, movdqu, movhpd, movlpd, movntpd, ret
  • out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py -> form coverage checks passed (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/docs_links_check.py -> Self-test passed. Checked 19 Markdown files and 462 links. (exit 0)
  • out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py -> Self-test passed. Checked 1677 tracked source, script and build/CI files: no bidirectional controls. (exit 0)

Spot mutation checks against tools/cpu_sse_fp_aot.py (8/8 killed by tests/cpu/sse_fp_pd_moves_cmp_check.py, restored cleanly):

  • Relax cmpsd predicate bound (imm > 31), invert op_cmpsd_q predicate 4 (caught by freshly compiled /O2 harness), clobber [127:64] in cmpsd, skip undefined-dst check in cmpsd, swap movlpd/movhpd load lane index, swap movlpd/movhpd store lane index, drop alignment=16 on movntpd, and drop write=True (r8-only store guard) on movntpd (all returned exit 1).

Evidence and follow-up

  • tests/cpu/sse_fp_pd_moves_cmp.{asm,def,_check.py} is a clean-room, source-built MASM fixture (MIT, repo-authored; no game files, dumps, or binaries).
  • Covers all 8 CMPSD predicates on -0.0/+0.0, +/-Inf, +/-qNaN/sNaN, and subnormals across all 16 MXCSR states, [127:64] preservation, MOVLPD/MOVHPD lane preservation and unaligned m64 displacements, MOVNTPD 16-byte aligned stores, faulting discarded m64 read preservation, ALTER_IMM divergence, mutant models, and VEX/EVEX/reserved-predicate/alignment/non-r8/nonvolatile/undefined-register/raw-invalid/PE-patched/CLI rejections.

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:6607016969 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2385). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T14:40:29Z. --- ## Change Lower four additional legacy SSE2 double-precision forms in `tools/cpu_sse_fp_aot.py`: - `CMPSD` (`Code.CMPSD_XMM_XMMM64_IMM8`): predicates `0..7` with XMM or flat `m64` source (unaligned `m64` accepted), preserving bits `[127:64]` and writing `0xFFFFFFFFFFFFFFFF`/`0` into `[63:0]` via host SSE2 `op_cmpsd_q` with volatile operand copies so runtime MXCSR (DAZ) and NaN rules match hardware; rejects `imm8 >= 8`. - `MOVLPD` / `MOVHPD` (`MOVLPD_XMM_M64`, `MOVLPD_M64_XMM`, `MOVHPD_XMM_M64`, `MOVHPD_M64_XMM`): flat `m64` load-merge preserving the untouched 64-bit lane and `r8`-rooted `m64` store (unaligned displacements accepted; reg-reg encodings rejected). - `MOVNTPD` (`MOVNTPD_M128_XMM`): 16-byte-aligned `r8`-rooted non-temporal store (rejects `disp % 16 != 0` and non-`r8` stores). - Update `tests/cpu/sse_fp_check.py` and `tests/cpu/sse_fp_pd_check.py` to replace now-supported negative assertions for these four forms with still-unsupported legacy SSE2 forms (`unpcklpd`, `unpckhpd`, `shufpd`, `movupd`). - Add source-built MASM fixture `tests/cpu/sse_fp_pd_moves_cmp.{asm,def,_check.py}` (`; coverage: record cpu_aot_sse_fp_pd_moves_cmp`) and register `cpu_aot_sse_fp_pd_moves_cmp` in `CMakeLists.txt`. ## Verification Verified on commit `a3c94c99` (rebased on `upstream/main` `a31f70a1`) across both `dev` (Debug) and `release` (`/O2`) presets: - `cmake --build --preset dev --target cpu_sse_fp_harness cpu_sse_fp*_original* cpu_sse_fp*_altered*` -> exit 0 - `ctest --preset dev -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure` -> `100% tests passed, 0 tests failed out of 5` (0 skipped): - `cpu_aot_sse_fp` (5.03s), `cpu_aot_sse_fp_logic` (0.68s), `cpu_aot_sse_fp_pd` (15.02s), `cpu_aot_sse_fp_pd_logic` (0.64s), `cpu_aot_sse_fp_pd_moves_cmp` (4.66s) - `cpu_aot_sse_fp_pd_moves_cmp`: `6752 lifted + 6752 /O2 cases across 23 exports; 96448 MXCSR CMPSD runs (16 states, 14 quirks); ALTER_IMM diverged on 17 exports + 9 mutants caught`; `rejections passed: 8 alt + 11 VEX/EVEX + 34 IR + 8 raw + 10 PE-patched + CLI` - `cmake --build --preset release --target cpu_sse_fp_harness cpu_sse_fp*_original* cpu_sse_fp*_altered*` -> exit 0 - `ctest --preset release -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure` -> `100% tests passed, 0 tests failed out of 5` (0 skipped; 26.52s) - `FORM_COVERAGE_RECORD` verified in both `out/build/dev/form_coverage/cpu_aot_sse_fp_pd_moves_cmp.txt` and `out/build/release/form_coverage/cpu_aot_sse_fp_pd_moves_cmp.txt`: `cmpsd, movaps, movdqa, movdqu, movhpd, movlpd, movntpd, ret` - `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/docs_links_check.py` -> `Self-test passed. Checked 19 Markdown files and 462 links.` (exit 0) - `out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 1677 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) Spot mutation checks against `tools/cpu_sse_fp_aot.py` (8/8 killed by `tests/cpu/sse_fp_pd_moves_cmp_check.py`, restored cleanly): - Relax `cmpsd` predicate bound (`imm > 31`), invert `op_cmpsd_q` predicate 4 (caught by freshly compiled `/O2` harness), clobber `[127:64]` in `cmpsd`, skip undefined-dst check in `cmpsd`, swap `movlpd`/`movhpd` load lane index, swap `movlpd`/`movhpd` store lane index, drop `alignment=16` on `movntpd`, and drop `write=True` (`r8`-only store guard) on `movntpd` (all returned exit 1). ## Evidence and follow-up - `tests/cpu/sse_fp_pd_moves_cmp.{asm,def,_check.py}` is a clean-room, source-built MASM fixture (MIT, repo-authored; no game files, dumps, or binaries). - Covers all 8 `CMPSD` predicates on `-0.0/+0.0`, `+/-Inf`, `+/-qNaN/sNaN`, and subnormals across all 16 MXCSR states, `[127:64]` preservation, `MOVLPD`/`MOVHPD` lane preservation and unaligned `m64` displacements, `MOVNTPD` 16-byte aligned stores, faulting discarded `m64` read preservation, `ALTER_IMM` divergence, mutant models, and VEX/EVEX/reserved-predicate/alignment/non-`r8`/nonvolatile/undefined-register/raw-invalid/PE-patched/CLI rejections. ## 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-25 15:01:55 +00:00
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!2377
No description provided.