Pin x87 fist, fisttp and m16 integer-arithmetic stack-top selection at depth two #1028

Merged
Leyukaka merged 4 commits from upstream-pr/1035 into main 2026-11-23 22:43:27 +00:00
Leyukaka commented 2026-11-23 22:20:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-23T22:20:17Z.


Change

This closes three gaps in the test coverage of tools/x87_lower.py. Each gap is shown by a small mutation of the lowering that still passes the whole ^cpu_ suite on main at ca52bbc. The lowering does not change; the native fixture DLLs stay the reference.

New export Mutation it covers
x87_integers: fist then fisttp with two values on the stack (ST(0) = 2.75, ST(1) = -1.25) fist reading slot 0 instead of the stack top
same export fisttp reading slot 0 instead of the stack top
x87_iarith: fisub with an m16 operand and two values on the stack the m16 integer-arithmetic forms reading slot 0 instead of the stack top

The existing exports run fist, fisttp and the m16 integer-arithmetic forms only at depth 1, where slot 0 is the top, so none of them can tell the two apart. Both exports are added to the SEQUENCES of the generator scripts; the .asm and .def files are the regenerated output. docs/experiments.md is updated to the measured counts (19 exports and 11127 cases; 16 exports and 28513 cases, also in the summary table and its total, 55,809).

Verification

On b6a59ad1 (based on main at ee04692), Windows 11, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R '^cpu_aot_x87_(integers|iarith)$' -V

Both tests pass and print 11127 cases over 19 exports (output block and guards) matched the reference in native and translated DLLs and 28513 cases over 16 exports ....

Each mutation was applied to tools/x87_lower.py one at a time and the project was rebuilt. With main at ca52bbc, the whole ^cpu_ suite passed under all three; with this branch, cpu_aot_x87_integers or cpu_aot_x87_iarith fails under each. With the unmutated lowering everything passes.

The three edits to tools/x87_lower.py:

  1. in the fist store, x87_slot[{top}] -> x87_slot[{0 if op == M.FIST else top}]
  2. the same line, with M.FISTTP
  3. in the integer-arithmetic form, the source x87_slot[{top}] -> x87_slot[{0 if bits == 16 else top}]

Evidence and follow-up

The two exports are generated from SEQUENCES in tests/cpu/x87_integers.py and tests/cpu/x87_iarith.py; the committed .asm and .def match the asm mode output byte for byte. No follow-up is needed.

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

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6570009570 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1035). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-23T22:20:17Z. --- ## Change This closes three gaps in the test coverage of `tools/x87_lower.py`. Each gap is shown by a small mutation of the lowering that still passes the whole `^cpu_` suite on `main` at `ca52bbc`. The lowering does not change; the native fixture DLLs stay the reference. | New export | Mutation it covers | |---|---| | `x87_integers`: `fist` then `fisttp` with two values on the stack (ST(0) = 2.75, ST(1) = -1.25) | `fist` reading slot 0 instead of the stack top | | same export | `fisttp` reading slot 0 instead of the stack top | | `x87_iarith`: `fisub` with an m16 operand and two values on the stack | the m16 integer-arithmetic forms reading slot 0 instead of the stack top | The existing exports run `fist`, `fisttp` and the m16 integer-arithmetic forms only at depth 1, where slot 0 is the top, so none of them can tell the two apart. Both exports are added to the `SEQUENCES` of the generator scripts; the `.asm` and `.def` files are the regenerated output. `docs/experiments.md` is updated to the measured counts (19 exports and 11127 cases; 16 exports and 28513 cases, also in the summary table and its total, 55,809). ## Verification On `b6a59ad1` (based on `main` at `ee04692`), Windows 11, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R '^cpu_aot_x87_(integers|iarith)$' -V ``` Both tests pass and print `11127 cases over 19 exports (output block and guards) matched the reference in native and translated DLLs` and `28513 cases over 16 exports ...`. Each mutation was applied to `tools/x87_lower.py` one at a time and the project was rebuilt. With `main` at `ca52bbc`, the whole `^cpu_` suite passed under all three; with this branch, `cpu_aot_x87_integers` or `cpu_aot_x87_iarith` fails under each. With the unmutated lowering everything passes. The three edits to `tools/x87_lower.py`: 1. in the `fist` store, `x87_slot[{top}]` -> `x87_slot[{0 if op == M.FIST else top}]` 2. the same line, with `M.FISTTP` 3. in the integer-arithmetic form, the source `x87_slot[{top}]` -> `x87_slot[{0 if bits == 16 else top}]` ## Evidence and follow-up The two exports are generated from `SEQUENCES` in `tests/cpu/x87_integers.py` and `tests/cpu/x87_iarith.py`; the committed `.asm` and `.def` match the `asm` mode output byte for byte. No follow-up is needed. ## 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. (Counts only.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:57 +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!1028
No description provided.