cpu: lower SAL instructions in cpu_switch_aot #1526

Merged
Ammmae0x merged 6 commits from upstream-pr/1533 into main 2026-11-25 06:31:46 +00:00
Ammmae0x commented 2026-11-24 13:43:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-24T13:43:36Z.


Change

Extends tools/cpu_switch_aot.py (SHIFTS and Lifter.lower) to lower x64 SAL (the ModR/M /6 encoding alias of SHL across docs/coverage/x64_zen2.tsv Integer sal) across 8-, 16-, 32-, and 64-bit register and memory destinations with 1, imm8, and CL counts:

  • Non-flag-producing SAL masks the shift count to 5 bits (6 bits for 64-bit operands), preserves upper register/memory bytes for 8- and 16-bit writes, and zero-extends 32-bit register writes.
  • Flag-producing SAL produces CF, ZF, SF, and PF for immediate masked counts 1 .. width*8 - 1 (and OF when the masked count is 1), rejecting CL counts, masked count 0, counts >= width*8, and OF-reading conditions (O/NO/L/GE/LE/G) after counts > 1.
  • Adds the source-built MASM fixture and differential test suite (tests/cpu/switch_sal.asm, tests/cpu/switch_sal.def, tests/cpu/switch_sal_check.py), registers cpu_switch_sal / cpu_switch_sal_lifted / cpu_aot_switch_sal in CMakeLists.txt with FORM_COVERAGE_RECORD, and documents measured results in docs/experiments.md.

Verification

Verified on commit 1d461d0e (rebased onto upstream/main 1ca0dec1):

  • & .\tools\dev.ps1; ctest --preset dev -N -> Total Tests: 981
  • cmake --build --preset dev --target cpu_register_probe cpu_switch_sal cpu_switch_sal_lifted cpu_switch_shift_flags cpu_switch_shift_flags_lifted -> exit 0 (0 errors, 0 warnings)
  • cmake --build --preset release --target cpu_register_probe cpu_switch_sal cpu_switch_sal_lifted cpu_switch_shift_flags cpu_switch_shift_flags_lifted -> exit 0 (0 errors, 0 warnings)
  • ctest --preset dev --no-tests=error -R "^(cpu_aot_switch_sal|cpu_aot_switch_shift_flags)$" -E "cpu_native_archive_" -V -> 2 passed, 0 skipped, 0 failed (cpu_aot_switch_shift_flags: 28,548 differential checks + 16 rejections; cpu_aot_switch_sal: 28,024 dev + 28,024 /O2 differential checks across all 12 SAL /6 Code encodings + 4 /O2 C++ mutants + 11 MASM / 4 unit / 7 PE-patched rejections; sal recorded in form_coverage/cpu_aot_switch_sal.txt)
  • ctest --preset release --no-tests=error -R "^(cpu_aot_switch_sal|cpu_aot_switch_shift_flags)$" -E "cpu_native_archive_" -V -> 2 passed, 0 skipped, 0 failed (same differential, mutant, and rejection counts; sal recorded in form_coverage/cpu_aot_switch_sal.txt)
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py -> form coverage checks passed (exit 0)
  • .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py -> Checked 16 Markdown files and 343 links. (exit 0)
  • .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py -> Checked 1242 tracked source, script and build/CI files: no bidirectional controls. (exit 0)

Evidence and follow-up

  • tests/cpu/switch_sal.asm is an original MIT-licensed MASM fixture written for this repository. Because ML64 assembles the sal mnemonic as /4 (SHL), all SAL instructions are emitted as explicit /6 byte sequences and verified via iced_x86.Decoder (Code.SAL_RM{8,16,32,64}_{1,CL,IMM8} with zero SHL instructions in the translated exports).
  • Scope not covered here: SAL outside leaf/switch-lifted functions, and title CPU code execution.

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.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583158794 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1533). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-24T13:43:36Z. --- ## Change Extends `tools/cpu_switch_aot.py` (`SHIFTS` and `Lifter.lower`) to lower x64 `SAL` (the ModR/M `/6` encoding alias of `SHL` across `docs/coverage/x64_zen2.tsv` `Integer` `sal`) across 8-, 16-, 32-, and 64-bit register and memory destinations with `1`, `imm8`, and `CL` counts: - Non-flag-producing `SAL` masks the shift count to 5 bits (6 bits for 64-bit operands), preserves upper register/memory bytes for 8- and 16-bit writes, and zero-extends 32-bit register writes. - Flag-producing `SAL` produces `CF`, `ZF`, `SF`, and `PF` for immediate masked counts `1 .. width*8 - 1` (and `OF` when the masked count is `1`), rejecting `CL` counts, masked count `0`, counts `>= width*8`, and `OF`-reading conditions (`O`/`NO`/`L`/`GE`/`LE`/`G`) after counts `> 1`. - Adds the source-built MASM fixture and differential test suite (`tests/cpu/switch_sal.asm`, `tests/cpu/switch_sal.def`, `tests/cpu/switch_sal_check.py`), registers `cpu_switch_sal` / `cpu_switch_sal_lifted` / `cpu_aot_switch_sal` in `CMakeLists.txt` with `FORM_COVERAGE_RECORD`, and documents measured results in `docs/experiments.md`. ## Verification Verified on commit `1d461d0e` (rebased onto `upstream/main` `1ca0dec1`): - `& .\tools\dev.ps1; ctest --preset dev -N` -> `Total Tests: 981` - `cmake --build --preset dev --target cpu_register_probe cpu_switch_sal cpu_switch_sal_lifted cpu_switch_shift_flags cpu_switch_shift_flags_lifted` -> exit 0 (0 errors, 0 warnings) - `cmake --build --preset release --target cpu_register_probe cpu_switch_sal cpu_switch_sal_lifted cpu_switch_shift_flags cpu_switch_shift_flags_lifted` -> exit 0 (0 errors, 0 warnings) - `ctest --preset dev --no-tests=error -R "^(cpu_aot_switch_sal|cpu_aot_switch_shift_flags)$" -E "cpu_native_archive_" -V` -> **2 passed, 0 skipped, 0 failed** (`cpu_aot_switch_shift_flags`: 28,548 differential checks + 16 rejections; `cpu_aot_switch_sal`: 28,024 dev + 28,024 `/O2` differential checks across all 12 `SAL` `/6` `Code` encodings + 4 `/O2` C++ mutants + 11 MASM / 4 unit / 7 PE-patched rejections; `sal` recorded in `form_coverage/cpu_aot_switch_sal.txt`) - `ctest --preset release --no-tests=error -R "^(cpu_aot_switch_sal|cpu_aot_switch_shift_flags)$" -E "cpu_native_archive_" -V` -> **2 passed, 0 skipped, 0 failed** (same differential, mutant, and rejection counts; `sal` recorded in `form_coverage/cpu_aot_switch_sal.txt`) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py` -> `Checked 16 Markdown files and 343 links.` (exit 0) - `.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py` -> `Checked 1242 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) ## Evidence and follow-up - `tests/cpu/switch_sal.asm` is an original MIT-licensed MASM fixture written for this repository. Because ML64 assembles the `sal` mnemonic as `/4` (`SHL`), all `SAL` instructions are emitted as explicit `/6` byte sequences and verified via `iced_x86.Decoder` (`Code.SAL_RM{8,16,32,64}_{1,CL,IMM8}` with zero `SHL` instructions in the translated exports). - Scope not covered here: `SAL` outside leaf/switch-lifted functions, and title CPU code execution. ## 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. AI-assisted.
tedin7 commented 2026-11-24 16:03:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:37:07Z.

Review: COMMENTED


Technical review (Linux only; the Windows pipeline was not run). The differential test cpu_aot_switch_sal needs the MASM-built images and Windows execution, so the numbers quoted in the docs (28,024 comparisons, the four C++ mutation controls, the PE-patched rejections) are not reproduced here.

Checked out the PR head in a clean tree. What I could verify independently on Linux:

  • Tool change is complete for the shift path: SHIFTS feeds FLAG_PRODUCERS, the producer lookup in condition() and the shift branch of lower(); the only explicit M.SHL tests (carry position and OF for count 1) are the two the PR widens. No other place in tools/cpu_switch_aot.py names M.SHL alone.
  • Lifter equivalence: for the /6 encodings of 8/16/32/64-bit register forms with imm8, count 1 and CL, and for [rax] memory forms, Lifter().lower() produces text identical to the matching /4 (SHL) encoding, both with sets_flags False and True (144 register pairs plus the memory pairs; every /6 decodes as SAL). So SAL is lowered exactly as SHL, which is what the PR claims.
  • Refusals behave as documented: sal eax, cl (CL may leave flags unchanged), sal al, 8 (count at or above the width), sal eax, 32 (masked count 0) and sal ah, 1 are refused with the same reasons the test expects. sal eax, 1, sal eax, 2 and sal rax, 63 lower with flags; OF is computed only for count 1.
  • Hardware semantics of /6: I ran the raw /6 and /4 encodings natively on an x86-64 host (8/16/32/64-bit, every count 1..width-1, 200 random operands each, 23,200 runs). Result and CF/PF/ZF/SF always match, and OF matches for count 1. This supports treating /6 as an alias of SHL on this CPU family. It is one host, not a statement about every CPU.

Local checks of the reference model in the test: sal_flags() (CF = bit bits-count, OF = MSB(result) xor CF for count 1) matches the lowering and the native runs above.

No problems found in the diff. Small observations, none blocking:

  • The refusal text for a count at or above the width still says "CF is undefined for SHL and SHR" in the message, while the docstring now also names SAL. A test pins only the first half of the message, so this is harmless.
  • docs/experiments.md says SAL is added to "SHIFTS and Lifter.lower"; lower() itself only changed in the carry/OF conditions. Accurate enough, just worded broadly.
  • ML64 assembling sal as /4 is the reason the fixture uses db byte sequences; that choice is explained in the .asm header and is the right call, since a sal mnemonic in the source would silently test /4.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042376545 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1533#pullrequestreview-6042376545). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:37:07Z. **Review:** COMMENTED --- Technical review (Linux only; the Windows pipeline was not run). The differential test `cpu_aot_switch_sal` needs the MASM-built images and Windows execution, so the numbers quoted in the docs (28,024 comparisons, the four C++ mutation controls, the PE-patched rejections) are not reproduced here. Checked out the PR head in a clean tree. What I could verify independently on Linux: - Tool change is complete for the shift path: `SHIFTS` feeds `FLAG_PRODUCERS`, the producer lookup in `condition()` and the shift branch of `lower()`; the only explicit `M.SHL` tests (carry position and OF for count 1) are the two the PR widens. No other place in `tools/cpu_switch_aot.py` names `M.SHL` alone. - Lifter equivalence: for the `/6` encodings of 8/16/32/64-bit register forms with imm8, count 1 and CL, and for `[rax]` memory forms, `Lifter().lower()` produces text identical to the matching `/4` (SHL) encoding, both with `sets_flags` False and True (144 register pairs plus the memory pairs; every `/6` decodes as `SAL`). So SAL is lowered exactly as SHL, which is what the PR claims. - Refusals behave as documented: `sal eax, cl` (CL may leave flags unchanged), `sal al, 8` (count at or above the width), `sal eax, 32` (masked count 0) and `sal ah, 1` are refused with the same reasons the test expects. `sal eax, 1`, `sal eax, 2` and `sal rax, 63` lower with flags; OF is computed only for count 1. - Hardware semantics of `/6`: I ran the raw `/6` and `/4` encodings natively on an x86-64 host (8/16/32/64-bit, every count 1..width-1, 200 random operands each, 23,200 runs). Result and CF/PF/ZF/SF always match, and OF matches for count 1. This supports treating `/6` as an alias of SHL on this CPU family. It is one host, not a statement about every CPU. Local checks of the reference model in the test: `sal_flags()` (CF = bit `bits-count`, OF = MSB(result) xor CF for count 1) matches the lowering and the native runs above. No problems found in the diff. Small observations, none blocking: - The refusal text for a count at or above the width still says "CF is undefined for SHL and SHR" in the message, while the docstring now also names SAL. A test pins only the first half of the message, so this is harmless. - `docs/experiments.md` says SAL is added to "`SHIFTS` and `Lifter.lower`"; `lower()` itself only changed in the carry/OF conditions. Accurate enough, just worded broadly. - ML64 assembling `sal` as `/4` is the reason the fixture uses `db` byte sequences; that choice is explained in the `.asm` header and is the right call, since a `sal` mnemonic in the source would silently test `/4`. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 18:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:17:57Z.

Review: COMMENTED


Re-review of head e671150aea (comment only, not an approval). My earlier review was at 2c8391916d.

No blocking findings. Since 2c83919 the head is only a merge of upstream main: git diff 2c83919 e671150 is empty for tools/cpu_switch_aot.py and tests/cpu/switch_sal*; only CMakeLists.txt and docs/experiments.md differ, with upstream content.

Earlier points

  • Open (nit): tools/cpu_switch_aot.py:1305 still says "CF is undefined for SHL and SHR" and the test pins only the first half of that message, so a one-word fix is safe.
  • Unchanged and harmless: the docs wording, and the explicit /6 bytes in the fixture.

What I ran

  • The real test cpu_aot_switch_sal needs MASM-built images, a Windows ctypes.CDLL and an MSVC /O2 compile, so the 28,024-comparison differential, the 4 C++ mutants and the 7 PE-patched rejections were not reproduced here.
  • Instead a local script imported the PR's test module and lifter: unit negatives OK; /6 lowers identically to /4 for 14 pairs; and raw /6 bytes executed natively on this x86-64 host for every count 1..bits-1 at all four widths matched the PR's sal_flags() reference (11,600 runs: result, CF, ZF, SF, PF, and OF at count 1).
  • Mutation 1, shift_count(ins) >= width * 8 -> >: the PR's unit negatives fail with accepted sal al, 8. Restored, green.
  • Mutation 2, removing SAL from the carry expression near line 1331: the PR's Linux-runnable unit negatives still pass; only my /6 == /4 comparison caught it (in the PR itself only the Windows differential would). Restored, green.

Non-blocking

  • A small pure-Python test (the unit negatives plus "/6 lowers the same as /4") would let the Linux job catch mutation 2.
  • Question: the test calls ${CMAKE_CXX_COMPILER} with MSVC flags (/O2 /LD /Fo /Fe); is MSVC-only intended?

No overlap with other open PRs found.
Linux limits: no Windows, MASM, MSVC, DXC or D3D12 device here; LLVM 19 only (CI uses LLVM 15). Anything that needs them was not run.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044024075 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1533#pullrequestreview-6044024075). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:17:57Z. **Review:** COMMENTED --- Re-review of head e671150aeae64a7432c49fe3e5230b1e6b36352d (comment only, not an approval). My earlier review was at 2c8391916d. No blocking findings. Since 2c83919 the head is only a merge of upstream main: `git diff 2c83919 e671150` is empty for tools/cpu_switch_aot.py and tests/cpu/switch_sal*; only CMakeLists.txt and docs/experiments.md differ, with upstream content. Earlier points - Open (nit): tools/cpu_switch_aot.py:1305 still says "CF is undefined for SHL and SHR" and the test pins only the first half of that message, so a one-word fix is safe. - Unchanged and harmless: the docs wording, and the explicit `/6` bytes in the fixture. What I ran - The real test `cpu_aot_switch_sal` needs MASM-built images, a Windows `ctypes.CDLL` and an MSVC `/O2` compile, so the 28,024-comparison differential, the 4 C++ mutants and the 7 PE-patched rejections were not reproduced here. - Instead a local script imported the PR's test module and lifter: unit negatives OK; `/6` lowers identically to `/4` for 14 pairs; and raw `/6` bytes executed natively on this x86-64 host for every count 1..bits-1 at all four widths matched the PR's `sal_flags()` reference (11,600 runs: result, CF, ZF, SF, PF, and OF at count 1). - Mutation 1, `shift_count(ins) >= width * 8` -> `>`: the PR's unit negatives fail with `accepted sal al, 8`. Restored, green. - Mutation 2, removing SAL from the carry expression near line 1331: the PR's Linux-runnable unit negatives still pass; only my `/6 == /4` comparison caught it (in the PR itself only the Windows differential would). Restored, green. Non-blocking - A small pure-Python test (the unit negatives plus "`/6` lowers the same as `/4`") would let the Linux job catch mutation 2. - Question: the test calls `${CMAKE_CXX_COMPILER}` with MSVC flags (`/O2 /LD /Fo /Fe`); is MSVC-only intended? No overlap with other open PRs found. Linux limits: no Windows, MASM, MSVC, DXC or D3D12 device here; LLVM 19 only (CI uses LLVM 15). Anything that needs them was not run. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 20:00:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:28:35Z.

Review: COMMENTED


Review at 50d0f17fa1830ac6a7d611f754bdb8405f875329 (comment only, not an approval).

What the change does

Adds M.SAL (the ModR/M /6 alias of SHL) to SHIFTS in tools/cpu_switch_aot.py and to the two SHL-only branches that compute CF and OF for a count of 1 (:1332, :1334). A MASM fixture, a differential check, CMake registration and a doc section are added. The flag-consumer path (:1040) and FLAG_PRODUCERS (:259) already iterate SHIFTS, so SAL reaches them without further edits.

Commands run on this branch (Linux, no Windows)

  • SAL decodes from d1 f0 as Mnemonic.SAL with iced-x86 in the review venv.
  • Equivalence check I wrote: for 128 forms (8/16/32/64-bit; register, [rbx] and [rbx+8]; count 1, CL and imm 0, 1, 2, 5, 7, 15, 31, 32, 33, 63; with and without flags) I lowered the /6 bytes and the same bytes with /4 (SHL) through Lifter().lower and compared the result. Result: 128 compared, 0 differences, including identical refusals (CL count, zero count, count >= width).
  • Same script on origin/main's cpu_switch_aot.py: 128 of 128 differ (every SAL form refused), so the script does detect the missing feature.
  • Three real mutations of cpu_switch_aot.py, each caught by that script and reverted with git checkout -- .: SAL dropped from the CF expression (40 differ), SAL dropped from the OF expression (19 differ), SAL mapped to >> (104 differ).
  • git diff --check, tests/docs_links_check.py, tests/bidi_controls_check.py: pass. tests/cpu/switch_sal_check.py byte-compiles.
  • Clean-room: no title names in the new .asm, .def or check file.

Review of the semantics

  • Count masking is 5 bits (6 for 64-bit) for CL and immediate counts, and applies to 8- and 16-bit operands too, which matches the hardware. A wide shift is done in 64 bits and truncated on write, so 8- and 16-bit counts of 9 to 31 give 0.
  • Flags are produced only for an immediate masked count of 1 to width-1. CL, count 0 and count >= width are refused, because count 0 leaves the flags unchanged and CF is undefined from the width up. OF is defined only for count 1 (MSB xor CF); O, NO, L, GE, LE and G are refused after a larger count. I found nothing wrong in these paths, and for SAL they are the SHL paths.
  • The PR treats /6 as a SHL alias based on the repository's coverage table (docs/coverage/x64_zen2.tsv). I did not check that against hardware or a vendor manual.

Not run

  • cpu_aot_switch_sal and its 28,024-comparison differential: it needs the MASM-built native and lifted DLLs and cpu_register_probe, so it did not run here. The four mutated-C++ controls and the PE-patched rejection controls were therefore not run by me either; I read them.

Findings

  • No P1 or P2 found.
  • P3: none worth listing.

Verdict

The change is small and the SAL lowering is identical to the SHL lowering for all 128 forms I tried, including every refusal. The Windows differential still has to run before merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045928661 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1533#pullrequestreview-6045928661). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:28:35Z. **Review:** COMMENTED --- Review at `50d0f17fa1830ac6a7d611f754bdb8405f875329` (comment only, not an approval). ## What the change does Adds `M.SAL` (the ModR/M /6 alias of SHL) to `SHIFTS` in `tools/cpu_switch_aot.py` and to the two SHL-only branches that compute CF and OF for a count of 1 (`:1332`, `:1334`). A MASM fixture, a differential check, CMake registration and a doc section are added. The flag-consumer path (`:1040`) and `FLAG_PRODUCERS` (`:259`) already iterate `SHIFTS`, so SAL reaches them without further edits. ## Commands run on this branch (Linux, no Windows) - `SAL` decodes from `d1 f0` as `Mnemonic.SAL` with iced-x86 in the review venv. - Equivalence check I wrote: for 128 forms (8/16/32/64-bit; register, `[rbx]` and `[rbx+8]`; count 1, CL and imm 0, 1, 2, 5, 7, 15, 31, 32, 33, 63; with and without flags) I lowered the /6 bytes and the same bytes with /4 (SHL) through `Lifter().lower` and compared the result. Result: 128 compared, 0 differences, including identical refusals (CL count, zero count, count >= width). - Same script on `origin/main`'s `cpu_switch_aot.py`: 128 of 128 differ (every SAL form refused), so the script does detect the missing feature. - Three real mutations of `cpu_switch_aot.py`, each caught by that script and reverted with `git checkout -- .`: SAL dropped from the CF expression (40 differ), SAL dropped from the OF expression (19 differ), SAL mapped to `>>` (104 differ). - `git diff --check`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: pass. `tests/cpu/switch_sal_check.py` byte-compiles. - Clean-room: no title names in the new `.asm`, `.def` or check file. ## Review of the semantics - Count masking is 5 bits (6 for 64-bit) for CL and immediate counts, and applies to 8- and 16-bit operands too, which matches the hardware. A wide shift is done in 64 bits and truncated on write, so 8- and 16-bit counts of 9 to 31 give 0. - Flags are produced only for an immediate masked count of 1 to width-1. CL, count 0 and count >= width are refused, because count 0 leaves the flags unchanged and CF is undefined from the width up. OF is defined only for count 1 (MSB xor CF); O, NO, L, GE, LE and G are refused after a larger count. I found nothing wrong in these paths, and for SAL they are the SHL paths. - The PR treats /6 as a SHL alias based on the repository's coverage table (`docs/coverage/x64_zen2.tsv`). I did not check that against hardware or a vendor manual. ## Not run - `cpu_aot_switch_sal` and its 28,024-comparison differential: it needs the MASM-built native and lifted DLLs and `cpu_register_probe`, so it did not run here. The four mutated-C++ controls and the PE-patched rejection controls were therefore not run by me either; I read them. ## Findings - No P1 or P2 found. - P3: none worth listing. ## Verdict The change is small and the SAL lowering is identical to the SHL lowering for all 128 forms I tried, including every refusal. The Windows differential still has to run before merge. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:00:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:29:45Z.

Review: COMMENTED


Review of head 65f7a05631db950caa0e1af6aed0fc3503f62276 (cpu: lower SAL instructions in cpu_switch_aot).

Verdict: no blocking findings. P1=0, P2=0, 1 nit.

Checks

  • Title is neutral. PR is mergeable. CI at this head: Linux Python checks pass, Windows build and test pass, gfx1013 fixtures pass.
  • Scope is small: tools/cpu_switch_aot.py (+12/-12 lines), a new fixture/check pair, a CMake test entry and a docs section.
  • Logic: SAL (/6) is the same operation as SHL. Adding M.SAL to SHIFTS (tools/cpu_switch_aot.py:225) feeds every place that keys on SHIFTS: flag producers (:260), the Jcc/SETcc/CMOV table (:1041) and the count checks (:1316-1328). The carry and overflow selection now treats SAL like SHL (:1355, :1357). This matches the SDM: CF is the last bit out, OF is defined only for count 1, and CF is undefined for counts of the operand width or more.
  • Fixture: ML64 assembles sal as /4, so the .asm emits explicit /6 bytes with db. That is the right way to get real /6 coverage. The check also has mutated-C++ controls (tests/cpu/switch_sal_check.py:258).
  • Docs link check and bidi check pass. git diff --check is clean.

Commands run locally (Linux)

  • python3 tests/docs_links_check.py -> Checked 18 Markdown files and 397 links.
  • python3 tests/bidi_controls_check.py -> Checked 1422 tracked ... files: no bidirectional controls.
  • git diff --check origin/main...HEAD -> no output, rc=0
  • python3 tests/cpu/switch_sal_check.py -> could not run: ModuleNotFoundError: pefile. It needs the Windows-built PE and iced_x86, which are not on this Linux box. I relied on the Windows CI result above.
  • Mutation run: not done. The test needs Windows binaries, so I could not run it here. I did not request a separate Win2025 run, because CI already built and ran it at this head.

Nit

  • tools/cpu_switch_aot.py:1326 and :1328: the comment and the error text still say "SHL and SHR" only. Adding "SAL" would keep the refusal message accurate. It does not change behavior.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050854996 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1533#pullrequestreview-6050854996). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:29:45Z. **Review:** COMMENTED --- Review of head `65f7a05631db950caa0e1af6aed0fc3503f62276` (cpu: lower SAL instructions in cpu_switch_aot). **Verdict: no blocking findings. P1=0, P2=0, 1 nit.** Checks - Title is neutral. PR is mergeable. CI at this head: Linux Python checks pass, Windows build and test pass, gfx1013 fixtures pass. - Scope is small: `tools/cpu_switch_aot.py` (+12/-12 lines), a new fixture/check pair, a CMake test entry and a docs section. - Logic: `SAL` (/6) is the same operation as `SHL`. Adding `M.SAL` to `SHIFTS` (`tools/cpu_switch_aot.py:225`) feeds every place that keys on `SHIFTS`: flag producers (`:260`), the Jcc/SETcc/CMOV table (`:1041`) and the count checks (`:1316-1328`). The carry and overflow selection now treats SAL like SHL (`:1355`, `:1357`). This matches the SDM: CF is the last bit out, OF is defined only for count 1, and CF is undefined for counts of the operand width or more. - Fixture: ML64 assembles `sal` as /4, so the `.asm` emits explicit /6 bytes with `db`. That is the right way to get real /6 coverage. The check also has mutated-C++ controls (`tests/cpu/switch_sal_check.py:258`). - Docs link check and bidi check pass. `git diff --check` is clean. Commands run locally (Linux) - `python3 tests/docs_links_check.py` -> `Checked 18 Markdown files and 397 links.` - `python3 tests/bidi_controls_check.py` -> `Checked 1422 tracked ... files: no bidirectional controls.` - `git diff --check origin/main...HEAD` -> no output, rc=0 - `python3 tests/cpu/switch_sal_check.py` -> could not run: `ModuleNotFoundError: pefile`. It needs the Windows-built PE and `iced_x86`, which are not on this Linux box. I relied on the Windows CI result above. - Mutation run: not done. The test needs Windows binaries, so I could not run it here. I did not request a separate Win2025 run, because CI already built and ran it at this head. Nit - `tools/cpu_switch_aot.py:1326` and `:1328`: the comment and the error text still say "SHL and SHR" only. Adding "SAL" would keep the refusal message accurate. It does not change behavior. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 07:00:39 +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!1526
No description provided.