cpu: lower packed SSE arithmetic in the SSE FP translator #1206
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1213"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:35:23Z.
Change
tools/cpu_sse_fp_aot.pynow lowers the packed single-precisionADDPS,SUBPS,MULPS,DIVPS,MINPS,MAXPSandSQRTPSin bounded leaf functions (register source and 16-byte alignedm128source). Before this change the translator refused them withunsupported instruction.xmmintrin.h). Rounding mode, DAZ and FTZ are the host's; the translator never folds a result. A guestldmxcsris still not lifted and exception flags are not observed (declared in the docs and the translator docstring).MINPSandMAXPSuse the host instruction unchanged (second source operand for equal values, signed zeros and any NaN; DAZ follows the host).SQRTPSonly reads its source.rcpps,rsqrtps, unaligned or non-argument memory operands, nonvolatile or undefined registers.Advances the legacy SSE FP translator coverage in
docs/experiments.md. No overlapping open PR (searched open PRs for sse, packed, addps, sqrtps, minps and arith). It touchestools/cpu_sse_fp_aot.pyand thesse_fpfixture only, not the scalar translator of #1168.Verification
Linux x86-64 (QEMU virtual processor): fixture assembled with
llvm-ml-19, linked withlld-link-19, original machine code run through a Windows-ABI caller, translation built withclang++-19at -O0, -O2 and -O3 (-Wall -Wextra, no warnings). The unmodifiedtests/cpu/sse_fp_check.pyentry pointscheck_differential,check_arithmetic_modesandcheck_alt_encodings_and_rejectionswere run with a harness that only replaces the DLL binding with that caller; all three passed at every optimization level:tools/cpu_sse_fp_aot.pyfromorigin/mainthe new fixture fails at translation (unsupported instruction at RVA 0x11f9: addps xmm0,xmm1). Translator mutants built and run: add as subtract (lifted op_addps case 0), multiply as divide (op_mulps case 0), minimum as maximum and swapped MINPS operands (op_minps case 0), SQRTPS not quieting a NaN (op_sqrtps case 5), SQRTPS reading its destination (op_sqrtps case 0) all fail. Dropping the software NaN rule passes on this host (the processor already returns the same NaN), so that rule is defensive and not shown to matter here.python3 -B tests/form_coverage_check.pyandpython3 -B tests/docs_links_check.py: pass.ctestrun ofcpu_aot_sse_fpon Windows (including the faulting-read controlcheck_discarded_read, which needs structured exceptions). CI runs it.Evidence and follow-up
tests/cpu/sse_fp.asm(29 exports plus the native-only harnessop_call_with_mxcsr, which sets the control word for one call and restores it). The referencetests/cpu/sse_fp_ref.pyis exact rational arithmetic with no host floating-point and none of the translator.movapsstores, and every call checks 32-byte guards around all three buffers and that unwritten output bytes keep their fill value. A runtime-unaligned base is outside the leaf contract (16-byte aligned argument pointers), as forcmpps.rcppsandrsqrtps. Whether the processor returns original bits or a flushed zero for MIN/MAX under DAZ, and whether FTZ judges tininess before or after rounding, are left unconstrained in the reference rather than assumed.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:55:26Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
e03a299c6cℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:03:45Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:03:48Z.
AI-assisted update: the native MXCSR driver now lives in its own native-only source (tests/cpu/sse_fp_harness.asm), so translated-form coverage for cpu_aot_sse_fp counts 16 mnemonics (13 SSE forms) again. form_coverage_check.py has a new check that fails if the driver is counted. Fixed in
9b54fdd7.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:13:30Z.
@codex review
AI-assisted: the native-driver coverage finding is fixed in
9b54fdd7and answered in its thread; please re-read the current head.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:19:59Z.
Codex Review: Didn't find any major issues. Can't wait for the next one!
Reviewed commit:
9b54fdd78fℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:47:56Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
9b54fddℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:55:40Z.
Windows Server 2025 verification (
9b54fdd7) — PASS (Debug + Release/O2)--preset dev) (9.41s build+test):cmake --build --preset dev -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harnessctest --test-dir out\build\dev -R "^cpu_aot_sse_fp$" --output-on-failure-> 1/1 passed (0 skipped, 8.14s)/O2(--preset release) (10.65s configure+build+test):cmake --preset release && cmake --build --preset release -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harnessctest --test-dir out\build\release -R "^cpu_aot_sse_fp$" --output-on-failure-> 1/1 passed (0 skipped, 8.06s)python -B tests\form_coverage_check.py-> passedImported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:55:26Z.
Code review location:
tests/cpu/sse_fp.asm; line 734When
cpu_aot_sse_fppasses,tools/form_coverage.py::measurecounts every mnemonic in thiscoverage: sourcefile, including this explicitly native-only driver. Consequently, a report with only that test passing creditsldmxcsr,stmxcsr,call, and the integer glue as translated even thoughcpu_sse_fp_exportsexcludes the driver. I reproduced 22 credited forms instead of 16, including 15 SSE forms instead of 13, so the MXCSR forms appear covered even when their actual translation fixture fails or is absent. Move the driver into an excluded native harness source, as done formxcsr_harness.asm, or record only instructions actually lifted.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:03:45Z.
Code review location:
tests/cpu/sse_fp.asm; line 734Fixed in
9b54fdd7.