cpu: cover eight scalar SSE translator semantics that no test observed #571

Merged
Leyukaka merged 1 commit from upstream-pr/577 into main 2026-11-22 13:53:10 +00:00
Leyukaka commented 2026-11-22 13:27:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T13:27:53Z.


Change

This closes eight coverage gaps in the scalar SSE/SSE2 translator, tools/cpu_sse_aot.py (#269). Each was a mutation of the translator that passed every cpu_ test on main. Only the cpu_aot_scalar_float fixture, its check and its CMake signature list change; the translator does not.

tests/cpu/scalar_float.asm gains probe_ss (unsigned probe_ss(void* buffer, float a, float b)):

  • movq loads a seed quadword whose high dword is nonzero, and movaps copies the whole register;
  • addss with a memory operand, cvtsi2ss from a negative dword in memory, and movss from memory are each followed by a movq store of the low quadword, so the high dword they keep (or, for the movss load, clear) is observed;
  • comiss xmm1, xmm2 with jp, ja and jb returns 0, 1, 2 or 3 for equal, unordered, above and below. The SWAP_OPERANDS build compares in the other order.

scalar_float_check.py adds the signature q:qff, two known answers (equal operands, and a NaN), and a differential case with a > b that the swapped build must change.

Verification

On 19f89a5 (branch on 079120c), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R '^cpu_aot_scalar_float$' -V

It passes. In the full suite, 274 of 275 tests pass. The exception is pixel_aot_hardware, which fails the same way on main (reported on #408) and does not involve the CPU translators.

Each mutation was applied to tools/cpu_sse_aot.py one at a time, followed by a rebuild and the whole cpu_ family. On main, every cpu_ test passed for each one. A control that swapped the e and ne conditions was caught by cpu_aot_scalar_float, so the run does detect a broken translator. On this branch, each mutation fails cpu_aot_scalar_float:

Mutation Caught through
a register-to-register copy keeps only the low dword quadword after movaps
a scalar arithmetic result overwrites the whole low quadword quadword after addss
an integer-to-float conversion overwrites the whole low quadword quadword after cvtsi2ss
a (above) ignores ZF equal operands
b (below) also takes ZF equal operands
comiss treats an unordered result as equal NaN operand
a 32-bit integer memory source is read as 64 bits quadword after cvtsi2ss
a movss load keeps the old high dword quadword after the movss load

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. (No capability changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6542945531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/577). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T13:27:53Z. --- ## Change This closes eight coverage gaps in the scalar SSE/SSE2 translator, `tools/cpu_sse_aot.py` (#269). Each was a mutation of the translator that passed every `cpu_` test on `main`. Only the `cpu_aot_scalar_float` fixture, its check and its CMake signature list change; the translator does not. `tests/cpu/scalar_float.asm` gains `probe_ss` (`unsigned probe_ss(void* buffer, float a, float b)`): - `movq` loads a seed quadword whose high dword is nonzero, and `movaps` copies the whole register; - `addss` with a memory operand, `cvtsi2ss` from a negative dword in memory, and `movss` from memory are each followed by a `movq` store of the low quadword, so the high dword they keep (or, for the `movss` load, clear) is observed; - `comiss xmm1, xmm2` with `jp`, `ja` and `jb` returns 0, 1, 2 or 3 for equal, unordered, above and below. The `SWAP_OPERANDS` build compares in the other order. `scalar_float_check.py` adds the signature `q:qff`, two known answers (equal operands, and a NaN), and a differential case with `a > b` that the swapped build must change. ## Verification On `19f89a5` (branch on `079120c`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R '^cpu_aot_scalar_float$' -V ``` It passes. In the full suite, 274 of 275 tests pass. The exception is `pixel_aot_hardware`, which fails the same way on `main` (reported on #408) and does not involve the CPU translators. Each mutation was applied to `tools/cpu_sse_aot.py` one at a time, followed by a rebuild and the whole `cpu_` family. On `main`, every `cpu_` test passed for each one. A control that swapped the `e` and `ne` conditions was caught by `cpu_aot_scalar_float`, so the run does detect a broken translator. On this branch, each mutation fails `cpu_aot_scalar_float`: | Mutation | Caught through | |---|---| | a register-to-register copy keeps only the low dword | quadword after `movaps` | | a scalar arithmetic result overwrites the whole low quadword | quadword after `addss` | | an integer-to-float conversion overwrites the whole low quadword | quadword after `cvtsi2ss` | | `a` (above) ignores ZF | equal operands | | `b` (below) also takes ZF | equal operands | | `comiss` treats an unordered result as equal | NaN operand | | a 32-bit integer memory source is read as 64 bits | quadword after `cvtsi2ss` | | a `movss` load keeps the old high dword | quadword after the `movss` load | ## 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. - [ ] I updated README/docs when a capability or build requirement changed. (No capability 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:43:46 +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!571
No description provided.