cpu: lower overflow and parity conditions #325

Merged
Joacoorandom merged 2 commits from upstream-pr/330 into main 2026-11-22 03:05:18 +00:00
Joacoorandom commented 2026-11-21 22:21:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Joacoorandom on 2026-11-21T22:21:32Z.


Change

The integer jump-table translator rejects overflow and parity consumers even when their producer is supported. Add JO/JNO/JP/JNP, SETO/SETNO/SETP/SETNP and CMOVO/CMOVNO/CMOVP/CMOVNP after CMP, SUB, ADD, TEST, AND, OR, XOR, INC and DEC.

Compute overflow at the producer's 8/16/32/64-bit width and parity from only the low result byte. Save ADD operands before they are overwritten, preserving its existing zero/sign conditions. The current straight-line, register and unsupported-producer restrictions remain in force.

This touches cpu_switch_aot.Lifter.condition, ADD flag snapshots and the generated C++ prelude. It has no prerequisite PR; other CPU instruction changes such as #291 and #321 touch the same translator.

Record the actual decoded instruction mnemonics from the flag-conditions fixture only after its native/AOT/reference comparison succeeds. Coverage now recognizes these macro-generated forms, clears stale records and does not mark missing, failed or skipped evidence as covered. CPU records are kept separate from shader records.

Verification

Commits 3f77ffd and 0b2e8b3, based on upstream 1606f7b. Rebuilt and reran the selected native tests after rebasing. Native Windows 11 build 26300.9974, x64 MSVC/ML64 19.44.35230, Windows SDK 10.0.26100.0, Python 3.12.8.

From a configured x64 developer environment with requirements-dev.txt installed:

cmake --build out/native --target cpu_flag_conditions_lifted cpu_switch_original_lifted cpu_switch_swapped_lifted cpu_register_probe cpu_switch_addr32_lifted cpu_entry_order_lifted cpu_narrow_lifted cpu_fourth_arg_lifted --parallel 4
ctest --test-dir out/native --no-tests=error -R "^cpu_aot_(flag_conditions|jump_tables|switch_addr32|entry_order|narrow_returns|fourth_argument)$" -V

All six selected CTests passed. The new test passed 294,600 native/AOT/independent-reference comparisons across 160 exports, including guarded writes and 32/64-bit conditional moves. Substituting a variable-count shift for the flag producer is rejected. Existing jump-table, address-size, entry-order and narrow-return regressions passed, including their negative controls.

Linux checks also passed:

python -B tests/form_coverage_check.py
python -B tests/cpu/lower_prefixes_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check

The complete root/GPU suite was not run locally.

Evidence and follow-up

The MASM fixtures and Python arithmetic reference are original source under the repository's MIT license. Both operand registers are overwritten before consumers, so correct results require saved flag inputs. Boundary values, every low byte and deterministic random inputs exercise parity and signed overflow; extra ADD cases check existing zero/sign conditions.

The baseline translator from b53bfb0 rejects the first SETO fixture; this change translates all 160 exports. The old SETO rejection becomes a positive regression. Rejections for high-byte registers, unsupported flag producers, 16-bit CMOV and flags crossing joins are retained.

README and the jump-table experiment notes describe the capability and reproduction commands.

AI-assisted implementation and tests, published with the account owner's approval.

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.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535161028 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/330). Originally posted by [Joacoorandom](https://github.com/Joacoorandom) on 2026-11-21T22:21:32Z. --- ## Change The integer jump-table translator rejects overflow and parity consumers even when their producer is supported. Add `JO/JNO/JP/JNP`, `SETO/SETNO/SETP/SETNP` and `CMOVO/CMOVNO/CMOVP/CMOVNP` after `CMP`, `SUB`, `ADD`, `TEST`, `AND`, `OR`, `XOR`, `INC` and `DEC`. Compute overflow at the producer's 8/16/32/64-bit width and parity from only the low result byte. Save ADD operands before they are overwritten, preserving its existing zero/sign conditions. The current straight-line, register and unsupported-producer restrictions remain in force. This touches `cpu_switch_aot.Lifter.condition`, ADD flag snapshots and the generated C++ prelude. It has no prerequisite PR; other CPU instruction changes such as #291 and #321 touch the same translator. Record the actual decoded instruction mnemonics from the flag-conditions fixture only after its native/AOT/reference comparison succeeds. Coverage now recognizes these macro-generated forms, clears stale records and does not mark missing, failed or skipped evidence as covered. CPU records are kept separate from shader records. ## Verification Commits `3f77ffd` and `0b2e8b3`, based on upstream `1606f7b`. Rebuilt and reran the selected native tests after rebasing. Native Windows 11 build 26300.9974, x64 MSVC/ML64 19.44.35230, Windows SDK 10.0.26100.0, Python 3.12.8. From a configured x64 developer environment with requirements-dev.txt installed: ```powershell cmake --build out/native --target cpu_flag_conditions_lifted cpu_switch_original_lifted cpu_switch_swapped_lifted cpu_register_probe cpu_switch_addr32_lifted cpu_entry_order_lifted cpu_narrow_lifted cpu_fourth_arg_lifted --parallel 4 ctest --test-dir out/native --no-tests=error -R "^cpu_aot_(flag_conditions|jump_tables|switch_addr32|entry_order|narrow_returns|fourth_argument)$" -V ``` All six selected CTests passed. The new test passed **294,600 native/AOT/independent-reference comparisons across 160 exports**, including guarded writes and 32/64-bit conditional moves. Substituting a variable-count shift for the flag producer is rejected. Existing jump-table, address-size, entry-order and narrow-return regressions passed, including their negative controls. Linux checks also passed: ```bash python -B tests/form_coverage_check.py python -B tests/cpu/lower_prefixes_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py git diff --check ``` The complete root/GPU suite was not run locally. ## Evidence and follow-up The MASM fixtures and Python arithmetic reference are original source under the repository's MIT license. Both operand registers are overwritten before consumers, so correct results require saved flag inputs. Boundary values, every low byte and deterministic random inputs exercise parity and signed overflow; extra ADD cases check existing zero/sign conditions. The baseline translator from `b53bfb0` rejects the first `SETO` fixture; this change translates all 160 exports. The old SETO rejection becomes a positive regression. Rejections for high-byte registers, unsupported flag producers, 16-bit CMOV and flags crossing joins are retained. README and the jump-table experiment notes describe the capability and reproduction commands. AI-assisted implementation and tests, published with the account owner's approval. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:42:27 +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!325
No description provided.