Pin AVX integer palignr wrap, pmaddwd overflow, wide-source pmovsx, vzeroupper and blend-mask checks #985

Merged
Leyukaka merged 3 commits from upstream-pr/992 into main 2026-11-23 20:30:22 +00:00
Leyukaka commented 2026-11-23 20:13:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-23T20:13:53Z.


Change

This closes five gaps in the test coverage of tools/cpu_avx_int_aot.py. Each is a small mutation of the translator that passes cpu_aot_avx_int_regs on main. The translator does not change; the native fixture DLL and the Python reference model remain the two references.

New case Mutation it covers
op_palignr_255: vpalignr with imm8 0FFh (all zero) the byte index computed in 8 bits, so 255 wraps instead of shifting everything out
op_pmaddwd with words 0 and 1 of both operands at -32768 (dword 0 is 0x80000000) the pairwise sum saturated to 0x7fffffff
op_pmovsxbq_wide_src: vpmovsxbq xmm0, xmm1 after a 32-byte load of ymm1 the upper 128 bits of the destination copied from the source instead of zeroed
op_zeroupper_ymm2: vzeroupper with ymm2 live, then a 32-byte store of ymm2 vzeroupper clearing only ymm0 and ymm1
undef_blend_mask: vpblendvb with defined data sources and an undefined mask register xmm3: undefined vector register ymm3 the definedness check skipped for the mask operand

The three new exports are in tests/cpu/avx_int_regs.{asm,def} and in the CMake export list, and are checked like the others against both the native DLL and the reference model. With them the check runs 1,728 differential cases across 132 exports and 111 unit rejection controls (19 EVEX/ABI/state). docs/experiments.md is updated to those counts; it said 119 exports and 1,568 cases, which were already behind main (129 and 1,688).

Verification

On 9ecdc94 (based on main at b3311bf), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R '^cpu_aot_avx_int_regs$' -V
python -B tests/docs_links_check.py

The test passes and prints 1728 native/lifted/reference AVX packed-integer cases across 132 exports matched bit-for-bit; ... and 111 unit rejection controls (25 VEX.L=1 integer, 25 register-domain memory, 32 carved-out, 10 out-of-scope, 19 EVEX/ABI/state) and 11 PE-patched rejection controls passed. The docs check passes.

Each mutation was applied to tools/cpu_avx_int_aot.py one at a time, the project was rebuilt so the translation was regenerated, and cpu_aot_avx_int_regs was run with the main and the branch versions of avx_int_regs_check.py, both against the branch build (the new exports are only called by the branch version). With the unmutated translator both pass. With main's check, the test passed under all five mutations; with this branch's check it fails under each of them.

The five edits to tools/cpu_avx_int_aot.py:

  1. const unsigned idx = i + static_cast<unsigned>(imm8); -> const std::uint8_t idx = static_cast<std::uint8_t>(i + imm8);
  2. set_lane32(out, i, p0 + p1); -> const std::int64_t sum = static_cast<std::int64_t>(s32(p0)) + s32(p1); set_lane32(out, i, sum > 0x7fffffffll ? 0x7fffffffu : static_cast<std::uint32_t>(sum));
  3. in op_vpmovsxbq, the trailing 0ull, 0ull -> a.q[2], a.q[3]
  4. for idx in sorted(defined_vec): -> for idx in sorted(defined_vec & {0, 1}): in the vzeroupper lowering
  5. if idx not in defined_vec: -> if idx not in defined_vec and op_index != 3:

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. (Counts only.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6567924476 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/992). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-23T20:13:53Z. --- ## Change This closes five gaps in the test coverage of `tools/cpu_avx_int_aot.py`. Each is a small mutation of the translator that passes `cpu_aot_avx_int_regs` on `main`. The translator does not change; the native fixture DLL and the Python reference model remain the two references. | New case | Mutation it covers | |---|---| | `op_palignr_255`: `vpalignr` with imm8 `0FFh` (all zero) | the byte index computed in 8 bits, so 255 wraps instead of shifting everything out | | `op_pmaddwd` with words 0 and 1 of both operands at -32768 (dword 0 is `0x80000000`) | the pairwise sum saturated to `0x7fffffff` | | `op_pmovsxbq_wide_src`: `vpmovsxbq xmm0, xmm1` after a 32-byte load of `ymm1` | the upper 128 bits of the destination copied from the source instead of zeroed | | `op_zeroupper_ymm2`: `vzeroupper` with `ymm2` live, then a 32-byte store of `ymm2` | `vzeroupper` clearing only `ymm0` and `ymm1` | | `undef_blend_mask`: `vpblendvb` with defined data sources and an undefined mask register `xmm3`: `undefined vector register ymm3` | the definedness check skipped for the mask operand | The three new exports are in `tests/cpu/avx_int_regs.{asm,def}` and in the CMake export list, and are checked like the others against both the native DLL and the reference model. With them the check runs 1,728 differential cases across 132 exports and 111 unit rejection controls (19 EVEX/ABI/state). `docs/experiments.md` is updated to those counts; it said 119 exports and 1,568 cases, which were already behind `main` (129 and 1,688). ## Verification On `9ecdc94` (based on `main` at `b3311bf`), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R '^cpu_aot_avx_int_regs$' -V python -B tests/docs_links_check.py ``` The test passes and prints `1728 native/lifted/reference AVX packed-integer cases across 132 exports matched bit-for-bit; ...` and `111 unit rejection controls (25 VEX.L=1 integer, 25 register-domain memory, 32 carved-out, 10 out-of-scope, 19 EVEX/ABI/state) and 11 PE-patched rejection controls passed`. The docs check passes. Each mutation was applied to `tools/cpu_avx_int_aot.py` one at a time, the project was rebuilt so the translation was regenerated, and `cpu_aot_avx_int_regs` was run with the `main` and the branch versions of `avx_int_regs_check.py`, both against the branch build (the new exports are only called by the branch version). With the unmutated translator both pass. With `main`'s check, the test passed under all five mutations; with this branch's check it fails under each of them. The five edits to `tools/cpu_avx_int_aot.py`: 1. `const unsigned idx = i + static_cast<unsigned>(imm8);` -> `const std::uint8_t idx = static_cast<std::uint8_t>(i + imm8);` 2. `set_lane32(out, i, p0 + p1);` -> `const std::int64_t sum = static_cast<std::int64_t>(s32(p0)) + s32(p1); set_lane32(out, i, sum > 0x7fffffffll ? 0x7fffffffu : static_cast<std::uint32_t>(sum));` 3. in `op_vpmovsxbq`, the trailing `0ull, 0ull` -> `a.q[2], a.q[3]` 4. `for idx in sorted(defined_vec):` -> `for idx in sorted(defined_vec & {0, 1}):` in the `vzeroupper` lowering 5. `if idx not in defined_vec:` -> `if idx not in defined_vec and op_index != 3:` ## 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. (Counts only.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:45:44 +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!985
No description provided.