Skip to content

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

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:sse-controls
Nov 22, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:sse-controls

Conversation

@Leyukaka

Copy link
Copy Markdown
Contributor

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.

probe_ss copies a full XMM register with movaps, runs addss with a
memory operand and cvtsi2ss from a negative dword, all of which keep
the upper bits of the low quadword, and then reloads movss from memory,
which clears them. It ends with comiss on equal, unordered and ordered
operands in both operand orders. Each case covers a cpu_sse_aot mutation
that passed every cpu_ test before.
@R0Y00
R0Y00 merged commit 68723ab into R0Y00:main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants