cpu: lower overflow and parity conditions #330

Manually merged
github merged 2 commits from gh-pr/330/head into gh-pr/330/base 2026-11-26 21:43:33 +00:00
Owner

@⁠Joacoorandom on GitHub · 2026-11-21 22:21 UTC · original
Joacoorandom:cpu/overflow-parity-conditions → main · +619 −10 · 10 files · 2 commits · merged 2026-11-22 03:05 UTC

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.
**@⁠Joacoorandom** on GitHub · 2026-11-21 22:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/330) `Joacoorandom:cpu/overflow-parity-conditions` → `main` · +619 −10 · 10 files · 2 commits · merged 2026-11-22 03:05 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:43:30 +00:00
github manually merged commit 0b2e8b30d4 into gh-pr/330/base 2026-11-26 21:43:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.