cpu: cover six packed FMA3 lowerings #671

Merged
Leyukaka merged 1 commit from upstream-pr/677 into main 2026-11-22 20:12:37 +00:00
Leyukaka commented 2026-11-22 19:26:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T19:26:54Z.


Change

This closes six coverage gaps in the packed FMA3 lowering of tools/ffx_version_query.py. Each was a one-line mutation that passed every cpu_ test on main. Only the packed FMA fixture (tests/cpu/fma_packed.{asm,def,py}) and its description in docs/experiments.md change; the translator does not.

The existing cases feed NaN operands, so they check NaN selection but not the arithmetic. Six new exports run on broadcast finite operands, and the check compares the full 32 result bytes of the native and translated functions:

New case Mutation it covers
vfmsub132ps ymm0, ymm1, ymmword ptr [r8] memory source forms use the 213 operand order
vfnmadd132ps xmm0, xmm1, xmm2 128-bit vfnmadd negates the addend instead of the product
vfmaddsub132ps xmm0, xmm1, xmm2 128-bit vfmaddsub lane parity inverted
vfmadd132pd on 1+2^-52, -1, 1-2^-52 pd 132 computed with two roundings (gives 0 instead of -2^-104)
vfmadd213pd xmm0, xmm1, xmm2 128-bit pd write keeps the old upper half
vfmadd132ps xmm0, xmm0, xmm2 an aliased first source read after the write

The inputs 2, 3 and 5 give different results for the three operand orders. Every existing NaN case is unchanged (190 to 196 compared cases).

Verification

On 4865fd0 (branch on ff7f68a), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, on an FMA3-capable host:

ctest --preset dev --no-tests=error -j 4

All 295 tests pass. tests/docs_links_check.py passes.

Each mutation was applied to tools/ffx_version_query.py one at a time, and all cpu_ tests were run. On main, all of them passed for each mutation. A control that dropped the product negation for vfnmadd was caught by cpu_aot_fma_packed, so the run does detect a broken translator. On this branch, each of the six mutations fails cpu_aot_fma_packed.

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. (Export count and case list.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6546710243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/677). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T19:26:54Z. --- ## Change This closes six coverage gaps in the packed FMA3 lowering of `tools/ffx_version_query.py`. Each was a one-line mutation that passed every `cpu_` test on `main`. Only the packed FMA fixture (`tests/cpu/fma_packed.{asm,def,py}`) and its description in `docs/experiments.md` change; the translator does not. The existing cases feed NaN operands, so they check NaN selection but not the arithmetic. Six new exports run on broadcast finite operands, and the check compares the full 32 result bytes of the native and translated functions: | New case | Mutation it covers | |---|---| | `vfmsub132ps ymm0, ymm1, ymmword ptr [r8]` | memory source forms use the `213` operand order | | `vfnmadd132ps xmm0, xmm1, xmm2` | 128-bit `vfnmadd` negates the addend instead of the product | | `vfmaddsub132ps xmm0, xmm1, xmm2` | 128-bit `vfmaddsub` lane parity inverted | | `vfmadd132pd` on `1+2^-52`, `-1`, `1-2^-52` | `pd` `132` computed with two roundings (gives 0 instead of -2^-104) | | `vfmadd213pd xmm0, xmm1, xmm2` | 128-bit `pd` write keeps the old upper half | | `vfmadd132ps xmm0, xmm0, xmm2` | an aliased first source read after the write | The inputs 2, 3 and 5 give different results for the three operand orders. Every existing NaN case is unchanged (190 to 196 compared cases). ## Verification On `4865fd0` (branch on `ff7f68a`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, on an FMA3-capable host: ```text ctest --preset dev --no-tests=error -j 4 ``` All 295 tests pass. `tests/docs_links_check.py` passes. Each mutation was applied to `tools/ffx_version_query.py` one at a time, and all `cpu_` tests were run. On `main`, all of them passed for each mutation. A control that dropped the product negation for `vfnmadd` was caught by `cpu_aot_fma_packed`, so the run does detect a broken translator. On this branch, each of the six mutations fails `cpu_aot_fma_packed`. ## 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. (Export count and case list.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:16 +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!671
No description provided.