Lower equality, jbe/ja and 32-bit immediate operations in cpu_leaf_aot #129

Manually merged
github merged 1 commit from gh-pr/129/head into gh-pr/129/base 2026-11-26 21:28:58 +00:00
Owner

@⁠PrivacyOnion on GitHub · 2026-11-21 16:41 UTC · original
PrivacyOnion:cpu-leaf-aot-comparisons → main · +137 −19 · 3 files · 1 commits · merged 2026-11-21 17:56 UTC

Change

Extends tools/cpu_leaf_aot.py to support the remaining unsigned and equality short conditional branches (je 0x74, jne 0x75, jbe 0x76 and ja 0x77 alongside jb 0x72 and jae 0x73), 32-bit immediate comparisons cmp eax, imm32 (0x3d id), and 32-bit immediate arithmetic add eax, imm32 (0x05 id) / sub eax, imm32 (0x2d id).

tests/cpu/branches.py adds positive translation checks for all six condition codes across both imm8 and imm32 encodings and negative controls for unsupported condition opcodes and truncated 32-bit immediate instructions.

Verification

Verified on Windows 11 with VS Build Tools 2022 17.14 (MSVC 19.44.35228.0), Windows SDK 10.0.26100.0, Python 3.12:

ctest --preset dev -R '^cpu_leaf_aot_branches$' --no-tests=error -V
  • cpu_leaf_aot_branches: passed (263 native/translated matches and 263 inverted-branch differences; 5 below threshold, 258 at or above, plus extended encoding and negative rejection controls).

Evidence and follow-up

All new test cases are self-contained x64 machine-code byte sequences checked in tests/cpu/branches.py.

**@⁠PrivacyOnion** on GitHub · 2026-11-21 16:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/129) `PrivacyOnion:cpu-leaf-aot-comparisons` → `main` · +137 −19 · 3 files · 1 commits · merged 2026-11-21 17:56 UTC ## Change Extends `tools/cpu_leaf_aot.py` to support the remaining unsigned and equality short conditional branches (`je` `0x74`, `jne` `0x75`, `jbe` `0x76` and `ja` `0x77` alongside `jb` `0x72` and `jae` `0x73`), 32-bit immediate comparisons `cmp eax, imm32` (`0x3d id`), and 32-bit immediate arithmetic `add eax, imm32` (`0x05 id`) / `sub eax, imm32` (`0x2d id`). `tests/cpu/branches.py` adds positive translation checks for all six condition codes across both `imm8` and `imm32` encodings and negative controls for unsupported condition opcodes and truncated 32-bit immediate instructions. ## Verification Verified on Windows 11 with VS Build Tools 2022 17.14 (`MSVC 19.44.35228.0`), Windows SDK `10.0.26100.0`, Python `3.12`: ```powershell ctest --preset dev -R '^cpu_leaf_aot_branches$' --no-tests=error -V ``` - `cpu_leaf_aot_branches`: passed (`263 native/translated matches and 263 inverted-branch differences; 5 below threshold, 258 at or above`, plus extended encoding and negative rejection controls). ## Evidence and follow-up All new test cases are self-contained x64 machine-code byte sequences checked in `tests/cpu/branches.py`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:28:57 +00:00
github manually merged commit 74a37958db into gh-pr/129/base 2026-11-26 21:28:58 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-21 17:16 UTC · original

The added checks compare emitted C++ strings. Please execute a lifted fixture against the native result for equality and unsigned jbe/ja, with operands on both sides of the immediate and at equality; include a sign-extended imm8 case.

**@⁠R0Y00** on GitHub · 2026-11-21 17:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/129#issuecomment-7066356090) The added checks compare emitted C++ strings. Please execute a lifted fixture against the native result for equality and unsigned jbe/ja, with operands on both sides of the immediate and at equality; include a sign-extended imm8 case.
Author
Owner

@⁠PrivacyOnion on GitHub · 2026-11-21 17:48 UTC · original

Updated tests/cpu/branch.asm and tests/cpu/branches.py so cpu_leaf_original, cpu_leaf_original_lifted, and cpu_leaf_inverted_lifted assemble, lift, compile, and execute:

  • cmp eax, 5 with jb / jae
  • cmp eax, 15 with je / jne
  • cmp eax, 21 with jne / je
  • cmp eax, 32 with jbe / ja
  • cmp eax, 300 (3d 2c 01 00 00) with ja / jbe, add eax, 512 (05), and sub eax, 260 (2d)
  • cmp eax, -16 (83 f8 f0, sign-extended imm8 0xfffffff0u) with jbe / ja

tests/cpu/branches.py verifies all 355 inputs against native execution and the inverted-branch control, and asserts that every threshold (5, 15, 21, 32, 300, 0xfffffff0) is exercised with operands below (<), equal (==), and above (>) the immediate:

49: 355 native/translated matches and 355 inverted-branch differences across jb/jae, je/jne, jbe/ja, 32-bit immediates and sign-extended imm8
1/1 Test #49: cpu_leaf_aot_branches ............   Passed    0.15 sec
**@⁠PrivacyOnion** on GitHub · 2026-11-21 17:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/129#issuecomment-7066753706) Updated `tests/cpu/branch.asm` and `tests/cpu/branches.py` so `cpu_leaf_original`, `cpu_leaf_original_lifted`, and `cpu_leaf_inverted_lifted` assemble, lift, compile, and execute: - `cmp eax, 5` with `jb` / `jae` - `cmp eax, 15` with `je` / `jne` - `cmp eax, 21` with `jne` / `je` - `cmp eax, 32` with `jbe` / `ja` - `cmp eax, 300` (`3d 2c 01 00 00`) with `ja` / `jbe`, `add eax, 512` (`05`), and `sub eax, 260` (`2d`) - `cmp eax, -16` (`83 f8 f0`, sign-extended `imm8` `0xfffffff0u`) with `jbe` / `ja` `tests/cpu/branches.py` verifies all 355 inputs against native execution and the inverted-branch control, and asserts that every threshold (`5`, `15`, `21`, `32`, `300`, `0xfffffff0`) is exercised with operands below (`<`), equal (`==`), and above (`>`) the immediate: ```text 49: 355 native/translated matches and 355 inverted-branch differences across jb/jae, je/jne, jbe/ja, 32-bit immediates and sign-extended imm8 1/1 Test #49: cpu_leaf_aot_branches ............ Passed 0.15 sec ```
This discussion has been locked. Commenting is limited to contributors.
No description provided.