x64_recomp: fix short-form xchg (0x91..0x97) and movnti (0F C3) widths/emission (X64-RECOMP-SHORT-XCHG-MOVNTI) #1428

Merged
quietfold merged 1 commit from upstream-pr/1428 into main 2026-12-01 15:15:44 +00:00
quietfold commented 2026-11-25 00:02:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by quietfold on 2026-11-25T00:02:48Z.


Item ID: X64-RECOMP-SHORT-XCHG-MOVNTI
AI-assisted: yes

Summary

Fixes two bugs in tools/x64_recomp.py:

  1. Short-form xchg rAX, r (0x91..0x97) decoded as Oq Oq (a 64-bit self-swap no-op):
    • PRIMARY[0x91..0x97] had opspec "Oq Oq", which decoded both operands as the opcode register (opcode & 7) | (rexb << 3) at fixed 64-bit width — making xchg eax, r / xchg ax, r / xchg rax, r swap r with itself and never touch RAX, while also ignoring 32-bit zero-extension and 16-bit upper-48-bit preservation.
    • Normalizing xchg short-form opspec ("Oq Oq" or "Oq Rq" from #847) to "Ov Av" in decode_one before _finish() gives the exact opcode register (O, REX.B-extended) and fixed accumulator (A = r0, never REX.B-extended) at operand width v (2/4/8 bytes), with zero merge conflict against #847 (X64-RECOMP-PRIMARY-90).
  2. movnti (0F C3) width and emission:
    • OF[0xC3] had opspec "Ev Gv", so 66 0F C3 decoded as 16-bit even though x86-64 movnti ignores 0x66 and only has 32-bit (0F C3) and 64-bit (48 0F C3) memory-store forms.
    • decode_one now sets "Eq Gq" if rexw else "Ed Gd" for movnti, and _emit_mov emits memory movnti stores directly (and rejects non-memory mod=3 forms).

Verification (macOS Apple M5, arm64, Python 3.14; no game files)

  • python3 -m compileall -q make_game.py tools tests — OK
  • python3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp_xchg_movnti.py — OK
  • python3 -I tests/test_x64_recomp_xchg_movnti.py (standalone) — 6 decode/translate tests OK (5 exec tests skipped without #1174 runner)
  • python3 -I tests/test_text_write_line_endings.py — 3/3 OK
  • python3 -I tests/test_ci_registration.py — 16/16 OK
  • Live Apple M5 arm64 mutation proof (unpatched upstream/main 364ab4eab + #1174 runner + new test file): Ran 11 tests — FAILED (failures=10, errors=1) (all 11 decode + native execution tests fail without this fix).
  • 24-way merge on Apple M5 arm64 (#1174 + all 22 prior x64_recomp PR branches + this PR): 0 conflicts, all 24 tests/test_x64_recomp*.py suites (208/208 tests OK, 0 skips).
  • External PR #847 conflict check: merged pull/847/head on top of the 24-way merge with 0 conflicts; verified 41 90, 66 41 90, 49 90, and 66 48 91 all decode with exact operand widths.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482480068 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428). Originally posted by [quietfold](https://github.com/quietfold) on 2026-11-25T00:02:48Z. --- Item ID: `X64-RECOMP-SHORT-XCHG-MOVNTI` AI-assisted: yes ### Summary Fixes two bugs in `tools/x64_recomp.py`: 1. **Short-form `xchg rAX, r` (`0x91..0x97`) decoded as `Oq Oq` (a 64-bit self-swap no-op)**: - `PRIMARY[0x91..0x97]` had opspec `"Oq Oq"`, which decoded **both** operands as the opcode register `(opcode & 7) | (rexb << 3)` at fixed 64-bit width — making `xchg eax, r` / `xchg ax, r` / `xchg rax, r` swap `r` with itself and never touch `RAX`, while also ignoring 32-bit zero-extension and 16-bit upper-48-bit preservation. - Normalizing `xchg` short-form opspec (`"Oq Oq"` or `"Oq Rq"` from #847) to `"Ov Av"` in `decode_one` before `_finish()` gives the exact opcode register (`O`, REX.B-extended) and fixed accumulator (`A` = `r0`, never REX.B-extended) at operand width `v` (2/4/8 bytes), with zero merge conflict against #847 (`X64-RECOMP-PRIMARY-90`). 2. **`movnti` (`0F C3`) width and emission**: - `OF[0xC3]` had opspec `"Ev Gv"`, so `66 0F C3` decoded as 16-bit even though x86-64 `movnti` ignores `0x66` and only has 32-bit (`0F C3`) and 64-bit (`48 0F C3`) memory-store forms. - `decode_one` now sets `"Eq Gq" if rexw else "Ed Gd"` for `movnti`, and `_emit_mov` emits memory `movnti` stores directly (and rejects non-memory `mod=3` forms). ### Verification (macOS Apple M5, arm64, Python 3.14; no game files) - `python3 -m compileall -q make_game.py tools tests` — OK - `python3 -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp_xchg_movnti.py` — OK - `python3 -I tests/test_x64_recomp_xchg_movnti.py` (standalone) — 6 decode/translate tests OK (5 exec tests skipped without #1174 runner) - `python3 -I tests/test_text_write_line_endings.py` — 3/3 OK - `python3 -I tests/test_ci_registration.py` — 16/16 OK - **Live Apple M5 arm64 mutation proof** (unpatched `upstream/main` `364ab4eab` + #1174 runner + new test file): `Ran 11 tests — FAILED (failures=10, errors=1)` (all 11 decode + native execution tests fail without this fix). - **24-way merge on Apple M5 arm64** (#1174 + all 22 prior `x64_recomp` PR branches + this PR): **0 conflicts**, all 24 `tests/test_x64_recomp*.py` suites (**208/208 tests OK, 0 skips**). - **External PR #847 conflict check**: merged `pull/847/head` on top of the 24-way merge with **0 conflicts**; verified `41 90`, `66 41 90`, `49 90`, and `66 48 91` all decode with exact operand widths.
copilot-pull-request-reviewer[bot] commented 2026-11-25 00:03:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T00:03:00Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6049448457 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#pullrequestreview-6049448457). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T00:03:00Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
kevincommits commented 2026-11-25 22:37:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kevincommits on 2026-11-25T22:37:03Z.


Independent run with QEMU. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, QEMU 11.1.3 from Homebrew. I merged main at 1bf5eeafd into the branch locally (713 commits behind, no textual conflicts). Head tested: 41db94513.

The change is right on every case I ran, but it now disagrees with a test that landed on main after this branch was cut, and its own exec tests never run.

1. Merged with current main, tests/test_x64_recomp.py goes 33/33 to 32/33. DecodeTests.test_opcode_90_nop_pause_and_rex_xchg (from #847, merged as be7478f5b) expects 41 90 to decode with 8-byte operands:

- ('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False)      <- this branch
+ ('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False)  <- main's test

This branch has the x86 answer: 41 90 has no REX.W, so it is xchg r8d, eax. It is main's expectation that is off, and main executes it that way too (table below). So the test needs updating in whichever lands second; after a merge of main here that is one assertion: (("r", 8, 4, False), ("r", 0, 4)).

2. The five exec tests are skipped everywhere on this branch, QEMU included. CAN_EXEC requires xr.CAN_RUN_MACHO, which only exists with #1174. The tests call xr.run_result, which works under QEMU on main today. As shipped: 11 run, 5 skipped. With the class skip lifted in memory (no file changed): 11/11 pass under QEMU. Suggested gate: runnable when CAN_RUN_MACHO or QEMU is found, as tests/test_x64_recomp.py does with HAS_QEMU.

Under QEMU, rax=aaaabbbb11112222, other register=ccccdddd33334444, reading rax afterwards:

bytes want main this branch
91 (xchg ecx,eax) 0000000033334444 aaaabbbb11112222 (no swap) 0000000033334444
48 91 (xchg rcx,rax) ccccdddd33334444 aaaabbbb11112222 (no swap) ccccdddd33334444
41 90 (xchg r8d,eax) 0000000033334444 ccccdddd33334444 (64-bit swap) 0000000033334444
41 90, then r8 0000000011112222 aaaabbbb11112222 0000000011112222
66 41 90 (xchg r8w,ax) aaaabbbb11114444 ccccdddd33334444 aaaabbbb11114444
49 90 (xchg r8,rax) ccccdddd33334444 ccccdddd33334444 ccccdddd33334444
90 unchanged unchanged unchanged

90 and f3 90 still decode as nop and pause.

Counts. tests/test_recomp_census.py 11/11. Full standalone suite: 512 run, 507 pass; the 5 that fail are main's 4 plus test_x64_recomp.py for the reason in point 1.

No game files used. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176583376 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1428#issuecomment-7176583376). Originally posted by [kevincommits](https://github.com/kevincommits) on 2026-11-25T22:37:03Z. --- Independent run with QEMU. Apple M5 Pro, macOS 27.2.1 (26B131), Python 3.14.2, QEMU 11.1.3 from Homebrew. I merged `main` at `1bf5eeafd` into the branch locally (713 commits behind, no textual conflicts). Head tested: `41db94513`. The change is right on every case I ran, but it now disagrees with a test that landed on `main` after this branch was cut, and its own exec tests never run. **1. Merged with current `main`, `tests/test_x64_recomp.py` goes 33/33 to 32/33.** `DecodeTests.test_opcode_90_nop_pause_and_rex_xchg` (from #847, merged as `be7478f5b`) expects `41 90` to decode with 8-byte operands: ``` - ('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False) <- this branch + ('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False) <- main's test ``` This branch has the x86 answer: `41 90` has no REX.W, so it is `xchg r8d, eax`. It is `main`'s expectation that is off, and `main` executes it that way too (table below). So the test needs updating in whichever lands second; after a merge of `main` here that is one assertion: `(("r", 8, 4, False), ("r", 0, 4))`. **2. The five exec tests are skipped everywhere on this branch, QEMU included.** `CAN_EXEC` requires `xr.CAN_RUN_MACHO`, which only exists with #1174. The tests call `xr.run_result`, which works under QEMU on `main` today. As shipped: 11 run, 5 skipped. With the class skip lifted in memory (no file changed): **11/11 pass under QEMU.** Suggested gate: runnable when `CAN_RUN_MACHO` or QEMU is found, as `tests/test_x64_recomp.py` does with `HAS_QEMU`. **Under QEMU**, rax=`aaaabbbb11112222`, other register=`ccccdddd33334444`, reading rax afterwards: | bytes | want | `main` | this branch | |---|---|---|---| | `91` (xchg ecx,eax) | `0000000033334444` | `aaaabbbb11112222` (no swap) | `0000000033334444` | | `48 91` (xchg rcx,rax) | `ccccdddd33334444` | `aaaabbbb11112222` (no swap) | `ccccdddd33334444` | | `41 90` (xchg r8d,eax) | `0000000033334444` | `ccccdddd33334444` (64-bit swap) | `0000000033334444` | | `41 90`, then r8 | `0000000011112222` | `aaaabbbb11112222` | `0000000011112222` | | `66 41 90` (xchg r8w,ax) | `aaaabbbb11114444` | `ccccdddd33334444` | `aaaabbbb11114444` | | `49 90` (xchg r8,rax) | `ccccdddd33334444` | `ccccdddd33334444` | `ccccdddd33334444` | | `90` | unchanged | unchanged | unchanged | `90` and `f3 90` still decode as `nop` and `pause`. **Counts.** `tests/test_recomp_census.py` 11/11. Full standalone suite: 512 run, 507 pass; the 5 that fail are `main`'s 4 plus `test_x64_recomp.py` for the reason in point 1. No game files used. AI-assisted.
zmasi commented 2026-11-28 22:29:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:29:14Z.


Native Windows 11 Verification & main Merge-Interaction Catch (41db945135)

Verified 41db9451357e52ba9cab7fbde4749d03adfa2e7a merged onto origin/main (adfb3821a23612263c1c5b195453ed01c4c114db, git merge-tree --write-tree rc=0) on native Windows 11 (26200):

  • Red -> Green on PR's new suite (tests/test_x64_recomp_xchg_movnti.py):
    • Red (origin/main adfb3821a): FAILED (failures=5, skipped=5) out of 11 tests (0x91..0x97 short-form xchg decoded as 64-bit "Oq Rq" instead of "Ov Av" and 0F C3 movnti was unhandled).
    • Green (origin/main + 41db945135): python -I tests/test_x64_recomp_xchg_movnti.py passed (11 ran, OK (skipped=5) — 16/32/64-bit xchg, REX.B r8..r15 with unextended eax/ax/rax, and movnti 32/64-bit + ignored 0x66 prefix).
  • Blocking CI interaction with tests/test_x64_recomp.py on current main:
    • Running python -I tests/test_x64_recomp.py on origin/main + 41db945135 fails 1 existing assertion at tests/test_x64_recomp.py:88-90 (DecodeTests.test_opcode_90_nop_pause_and_rex_xchg):
      AssertionError: Tuples differ:
        ('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False)
        != ('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False)
      
    • That test on main encoded the old pre-fix 64-bit operand size for 41 90 (xchg r8d, eax, where REX.W == 0 so the architectural operand size is 32-bit 4 bytes, whereas 49 90 is 64-bit xchg r8, rax). Updating tests/test_x64_recomp.py:88-90 to expect (('r', 8, 4, False), ('r', 0, 4)) for 41 90 (and optionally adding 49 90 for the 64-bit case) will make test_x64_recomp.py pass cleanly on merge.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246768753 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7246768753). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:29:14Z. --- ### Native Windows 11 Verification & `main` Merge-Interaction Catch (`41db945135`) Verified `41db9451357e52ba9cab7fbde4749d03adfa2e7a` merged onto `origin/main` (`adfb3821a23612263c1c5b195453ed01c4c114db`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`)**: - **Red -> Green on PR's new suite (`tests/test_x64_recomp_xchg_movnti.py`)**: - **Red (`origin/main` `adfb3821a`)**: `FAILED (failures=5, skipped=5)` out of `11` tests (`0x91..0x97` short-form `xchg` decoded as 64-bit `"Oq Rq"` instead of `"Ov Av"` and `0F C3` `movnti` was unhandled). - **Green (`origin/main + 41db945135`)**: `python -I tests/test_x64_recomp_xchg_movnti.py` passed (`11 ran, OK (skipped=5)` — 16/32/64-bit `xchg`, `REX.B` `r8..r15` with unextended `eax`/`ax`/`rax`, and `movnti` 32/64-bit + ignored `0x66` prefix). - **Blocking CI interaction with `tests/test_x64_recomp.py` on current `main`**: - Running `python -I tests/test_x64_recomp.py` on `origin/main + 41db945135` fails 1 existing assertion at `tests/test_x64_recomp.py:88-90` (`DecodeTests.test_opcode_90_nop_pause_and_rex_xchg`): ``` AssertionError: Tuples differ: ('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False) != ('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False) ``` - That test on `main` encoded the old pre-fix 64-bit operand size for `41 90` (`xchg r8d, eax`, where `REX.W == 0` so the architectural operand size is 32-bit `4` bytes, whereas `49 90` is 64-bit `xchg r8, rax`). Updating `tests/test_x64_recomp.py:88-90` to expect `(('r', 8, 4, False), ('r', 0, 4))` for `41 90` (and optionally adding `49 90` for the 64-bit case) will make `test_x64_recomp.py` pass cleanly on merge. AI-assisted.
TheGeogeo commented 2026-11-29 00:17:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:29Z.


Tested 41db94513 merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_x64_recomp_xchg_movnti.py, 11 tests pass (5 QEMU tests skipped).
  • Red: with tools/x64_recomp.py back to main, the 5 encoding checks fail (e.g. (('r', 9, 8, False), ('r', 9, 8, False)) != (('r', 9, 4, False), ('r', 0, 4))). The QEMU run itself is not checked here.

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248009867 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7248009867). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:29Z. --- Tested `41db94513` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_x64_recomp_xchg_movnti.py`, 11 tests pass (5 QEMU tests skipped). - Red: with `tools/x64_recomp.py` back to `main`, the 5 encoding checks fail (e.g. `(('r', 9, 8, False), ('r', 9, 8, False)) != (('r', 9, 4, False), ('r', 0, 4))`). The QEMU run itself is not checked here. No blocker from my side. AI-assisted (Claude Code).
TheGeogeo commented 2026-11-29 11:52:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T11:52:01Z.


Tested green here earlier on this same head (see my comment above). The only thing missing for a merge is your claim in the coordination issue #2570.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7255403605 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7255403605). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T11:52:01Z. --- Tested green here earlier on this same head (see my comment above). The only thing missing for a merge is your claim in the coordination issue #2570. AI-assisted (Claude Code).
TheGeogeo commented 2026-11-29 14:18:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:18:39Z.


Ready for testing: merges cleanly with main 3535eb5c4. Not in main yet: git cherry finds 1 commit(s) not there, and 1 of the 126 lines it adds are already present. No duplicate found: its claim X64-RECOMP-SHORT-XCHG-MOVNTI appears in no other open pull request and in no main commit.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257203556 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7257203556). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:18:39Z. --- Ready for testing: merges cleanly with `main` `3535eb5c4`. Not in `main` yet: `git cherry` finds 1 commit(s) not there, and 1 of the 126 lines it adds are already present. No duplicate found: its claim `X64-RECOMP-SHORT-XCHG-MOVNTI` appears in no other open pull request and in no `main` commit. AI-assisted (Claude Code).
enlight3d commented 2026-11-29 15:51:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T15:51:58Z.


RUN report for #1428 (X64-RECOMP-SHORT-XCHG-MOVNTI)

Heads: PR head 41db94513 (base 364ab4eab); origin/main c22a0a732, merged locally with git merge --no-ff (clean, 2 files).

Kind: Python (tools/x64_recomp.py plus a new test file).

Commands (one process per file): python -I -B tests/<file> for test_x64_recomp_xchg_movnti.py, every tests/test_x64_recomp*.py (19 files on current main), test_text_write_line_endings.py, test_ci_registration.py.

Results:

  • RED (tools/x64_recomp.py reverted to the PR base, new test kept; behavioural, there is no new API): test_x64_recomp_xchg_movnti.py Ran 11, FAILED (failures=6, skipped=5).
  • GREEN at PR head: test_x64_recomp_xchg_movnti.py Ran 11, OK (skipped=5); test_text_write_line_endings.py 3 OK; test_ci_registration.py 16 OK; test_x64_recomp.py (older at this base) 32 OK.
  • The 5 skips are the native execution cases (native arm64 Mach-O runner unavailable); they cannot run on Windows x64. The description's 10 failures plus 1 error need that runner (macOS arm64).
  • GREEN merged into origin/main: NOT fully green. The 18 other test_x64_recomp*.py files, the new file (11 OK, 5 skipped), test_text_write_line_endings.py (3 OK) and test_ci_registration.py (18 OK) pass, but tests/test_x64_recomp.py fails one test: DecodeTests.test_opcode_90_nop_pause_and_rex_xchg. It passes on plain main c22a0a732 (47 tests OK, 34 skipped) and fails only with the PR merged.
    • Cause: the existing assertion for 41 90 expects ("xchg", (("r", 8, 8, False), ("r", 0, 8, False)), 2, False), the old 8-byte width. With the PR it decodes as (("r", 8, 4, False), ("r", 0, 4)), i.e. 32-bit xchg r8d, eax, which is the correct x86-64 form of 41 90 and the width the PR intends. So the stale expectation in tests/test_x64_recomp.py needs updating in this PR (it merges without textual conflict).

Machine: Windows 11 Pro x64, RTX 3090 24 GB, NVIDIA 621.40, Python 3.13.12 (python -I).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258429019 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7258429019). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T15:51:58Z. --- RUN report for #1428 (X64-RECOMP-SHORT-XCHG-MOVNTI) Heads: PR head `41db94513` (base `364ab4eab`); origin/main `c22a0a732`, merged locally with `git merge --no-ff` (clean, 2 files). Kind: Python (`tools/x64_recomp.py` plus a new test file). Commands (one process per file): `python -I -B tests/<file>` for `test_x64_recomp_xchg_movnti.py`, every `tests/test_x64_recomp*.py` (19 files on current main), `test_text_write_line_endings.py`, `test_ci_registration.py`. Results: - RED (`tools/x64_recomp.py` reverted to the PR base, new test kept; behavioural, there is no new API): `test_x64_recomp_xchg_movnti.py` Ran 11, FAILED (failures=6, skipped=5). - GREEN at PR head: `test_x64_recomp_xchg_movnti.py` Ran 11, OK (skipped=5); `test_text_write_line_endings.py` 3 OK; `test_ci_registration.py` 16 OK; `test_x64_recomp.py` (older at this base) 32 OK. - The 5 skips are the native execution cases (`native arm64 Mach-O runner unavailable`); they cannot run on Windows x64. The description's 10 failures plus 1 error need that runner (macOS arm64). - GREEN merged into origin/main: NOT fully green. The 18 other `test_x64_recomp*.py` files, the new file (11 OK, 5 skipped), `test_text_write_line_endings.py` (3 OK) and `test_ci_registration.py` (18 OK) pass, but `tests/test_x64_recomp.py` fails one test: `DecodeTests.test_opcode_90_nop_pause_and_rex_xchg`. It passes on plain main `c22a0a732` (47 tests OK, 34 skipped) and fails only with the PR merged. - Cause: the existing assertion for `41 90` expects `("xchg", (("r", 8, 8, False), ("r", 0, 8, False)), 2, False)`, the old 8-byte width. With the PR it decodes as `(("r", 8, 4, False), ("r", 0, 4))`, i.e. 32-bit `xchg r8d, eax`, which is the correct x86-64 form of `41 90` and the width the PR intends. So the stale expectation in `tests/test_x64_recomp.py` needs updating in this PR (it merges without textual conflict). Machine: Windows 11 Pro x64, RTX 3090 24 GB, NVIDIA 621.40, Python 3.13.12 (`python -I`).
MoonEyes commented 2026-11-29 17:08:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T17:08:53Z.


Correction (my earlier verdict here was incomplete): not ready to merge.

Tested 41db94513 merged (no commit) with main 4364a4fa6: Python 3.12, Windows 11 10.0.26300, CPU only.

  • The PR's own test: python -I tests/test_x64_recomp_xchg_movnti.py gives 11 OK (5 skipped) with the PR, and FAILED (failures=5, skipped=5) with tools/x64_recomp.py back to main.
  • But I ran only that file. Across the other x64_recomp test files, DecodeTests.test_opcode_90_nop_pause_and_rex_xchg passes on main and fails on the merge: 41 90 now decodes as xchg r8d, eax (32-bit, REX.B without REX.W), while the test still expects 8 bytes. See the comment from TheGeogeo's review above. The expectation needs updating in this PR.
  • The 5 skipped tests are execution tests: not covered here.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259460069 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7259460069). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T17:08:53Z. --- **Correction (my earlier verdict here was incomplete):** not ready to merge. Tested `41db94513` merged (no commit) with `main` `4364a4fa6`: Python 3.12, Windows 11 10.0.26300, CPU only. - The PR's own test: `python -I tests/test_x64_recomp_xchg_movnti.py` gives 11 OK (5 skipped) with the PR, and `FAILED (failures=5, skipped=5)` with `tools/x64_recomp.py` back to `main`. - But I ran only that file. Across the other `x64_recomp` test files, `DecodeTests.test_opcode_90_nop_pause_and_rex_xchg` passes on `main` and fails on the merge: `41 90` now decodes as `xchg r8d, eax` (32-bit, REX.B without REX.W), while the test still expects 8 bytes. See the comment from TheGeogeo's review above. The expectation needs updating in this PR. - The 5 skipped tests are execution tests: not covered here. AI-assisted (Claude Code).
TheGeogeo commented 2026-11-29 17:11:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T17:11:42Z.


Tested 41db94513 merged (no commit) with main 4364a4fa6: Python 3.12.4, Windows 11 10.0.26300, CPU only.

Not green once merged: an existing test on main fails with this change.

  • Green on its own test: tests/test_x64_recomp_xchg_movnti.py runs 11 tests: OK, 5 skipped (no arm64 runner here).
  • Red: with tools/x64_recomp.py back to main, 5 of them fail (the short xchg widths for 16, 32 and 64 bits, REX.B with rax, and the movnti widths).
  • Regression: tests/test_x64_recomp.py fails DecodeTests.test_opcode_90_nop_pause_and_rex_xchg on the merge (it passes on main).
    • For 41 90, the merge decodes ('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False).
    • The test still expects ('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False).
  • The new decode looks right: 41 90 is REX.B without REX.W, so xchg r8d, eax at 32 bits. The fix is to update that expectation in test_x64_recomp.py in this PR.
  • The other 17 tests/test_x64_recomp*.py files give the same results on main and on the merge.
  • No game data check passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259497844 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#issuecomment-7259497844). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T17:11:42Z. --- Tested 41db94513 merged (no commit) with main 4364a4fa6: Python 3.12.4, Windows 11 10.0.26300, CPU only. **Not green once merged:** an existing test on main fails with this change. - Green on its own test: `tests/test_x64_recomp_xchg_movnti.py` runs 11 tests: OK, 5 skipped (no arm64 runner here). - Red: with `tools/x64_recomp.py` back to main, 5 of them fail (the short `xchg` widths for 16, 32 and 64 bits, REX.B with `rax`, and the `movnti` widths). - Regression: `tests/test_x64_recomp.py` fails `DecodeTests.test_opcode_90_nop_pause_and_rex_xchg` on the merge (it passes on main). - For `41 90`, the merge decodes `('xchg', (('r', 8, 4, False), ('r', 0, 4)), 2, False)`. - The test still expects `('xchg', (('r', 8, 8, False), ('r', 0, 8, False)), 2, False)`. - The new decode looks right: `41 90` is REX.B without REX.W, so `xchg r8d, eax` at 32 bits. The fix is to update that expectation in `test_x64_recomp.py` in this PR. - The other 17 `tests/test_x64_recomp*.py` files give the same results on main and on the merge. - No game data check passes. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 11:41:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:41:26Z.

Review: APPROVED


Reviewed the diff against main: tools/x64_recomp.py:616-619 cleanly fixes short-form xchg (Ov Av, avoiding REX.B extending rAX) and movnti (Eq Gq/Ed Gd, ignoring 0x66), and tools/x64_recomp.py:1804-1808 emits memory-only movnti stores, covered by tests/test_x64_recomp_xchg_movnti.py. Clean-room verified. Approving; awaiting a green CI run before merge.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130512389 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1428#pullrequestreview-6130512389). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:41:26Z. **Review:** APPROVED --- Reviewed the diff against `main`: `tools/x64_recomp.py:616-619` cleanly fixes short-form `xchg` (`Ov Av`, avoiding REX.B extending `rAX`) and `movnti` (`Eq Gq`/`Ed Gd`, ignoring `0x66`), and `tools/x64_recomp.py:1804-1808` emits memory-only `movnti` stores, covered by `tests/test_x64_recomp_xchg_movnti.py`. Clean-room verified. Approving; awaiting a green CI run before merge. *(AI-assisted review.)*
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
ProjectLeonida/mandy!1428
No description provided.