cpu: lower 16 VEX.256 AVX2 cross-lane extend and dword/qword unpack forms #2606

Merged
Ammmae0x merged 1 commit from upstream-pr/2614 into main 2026-11-25 23:31:06 +00:00
Ammmae0x commented 2026-11-25 23:21:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T23:21:59Z.


Change

Lower 16 register-only VEX.256 (L=1, AVX2) packed-integer forms in tools/cpu_avx_int_aot.py and add MASM differential/refusal/mutation coverage in tests/cpu/avx_int_ymm_widen_unpack.{asm,def,_check.py} (registered as cpu_aot_avx_int_ymm_widen_unpack in CMakeLists.txt with SKIP_RETURN_CODE 77 and FORM_COVERAGE_RECORD):

  • 12 cross-lane XMM->YMM sign/zero-extend moves: VPMOVSX{BW,BD,BQ,WD,WQ,DQ} and VPMOVZX{BW,BD,BQ,WD,WQ,DQ} (modeling exact Intel SDM cross-lane slicing, ignored upper XMM/YMM bytes, stale destination overwrite, aliased dst == src, and VEX.256->128 upper-half zeroing).
  • 4 in-lane YMM unpacks: VPUNPCK{L,H}{DQ,QDQ} via wide128.
  • Refuse memory operands, nonvolatile YMM6-15/XMM6-15, EVEX, and unlowered YMM unpacks (VPUNPCK{L,H}{BW,WD}).
  • Update tests/cpu/avx_int_regs_check.py and tests/cpu/avx_int_ymm_abs_sign_shuf_check.py to replace newly lowered forms in their VEX.256 refusal lists with genuinely unlowered VEX.256 shift forms (vpsrld/vpsllq/vpsrlq).

AI-assisted.

Verification

Tested on commit 905ffec8 (rebased on upstream/main) with MSVC 19.50 + ML64 14.50 and out\pe-env\Scripts\python.exe -B:

  • ctest --preset dev -N: Total Tests: 2082 (no dropped tests).
  • cmake --build --preset dev --target cpu_avx_int_regs_original cpu_avx_int_regs_original_lifted cpu_avx_int_regs_altered cpu_avx_int_regs_altered_lifted cpu_avx_int_ymm_abs_sign_shuf cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted: 0 errors, 0 warnings.
  • ctest --preset dev --output-on-failure --no-tests=error -R "^(cpu_aot_avx_int_regs|cpu_aot_avx_int_ymm_abs_sign_shuf|cpu_aot_avx_int_ymm_widen_unpack)$" -E "cpu_native_archive_" -V: 3/3 passed (cpu_aot_avx_int_ymm_widen_unpack: 16 forms accepted, 31 rejection controls, 4,536 native/lifted/reference cases across 24 exports matched bit for bit, 13 mutant + 16 altered-build controls caught; 0 capability skips on AVX2 host).
  • cmake --build --preset release --target ... (/O2): 0 errors, 0 warnings; same targeted CTest in release: 3/3 passed.
  • Verified FORM_COVERAGE_RECORD written in both dev and release containing all 16 mnemonics plus ret, vmovdqu, vzeroupper.
  • Spot-mutation negative control: temporarily disabled 4 translator guards one by one in tools/cpu_avx_int_aot.py (wide_extend, VPUNPCKLDQ code, memory-operand guard, EVEX guard); 4/4 mutations killed by check_translator() and restored cleanly.
  • out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py: passed (exit 0).
  • out\pe-env\Scripts\python.exe -B tests\docs_links_check.py: passed (exit 0).
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py: passed (exit 0).

Evidence and follow-up

All fixtures in tests/cpu/avx_int_ymm_widen_unpack.{asm,def} are source-built synthetic MASM routines (MIT License). Native execution is CPUID AVX2 gated (exit 77 on non-AVX2 hosts). Remaining unlowered VEX.256 integer shifts, multiplies, blends, and aligns remain follow-ups.

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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6615803915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2614). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T23:21:59Z. --- ## Change Lower 16 register-only VEX.256 (L=1, AVX2) packed-integer forms in `tools/cpu_avx_int_aot.py` and add MASM differential/refusal/mutation coverage in `tests/cpu/avx_int_ymm_widen_unpack.{asm,def,_check.py}` (registered as `cpu_aot_avx_int_ymm_widen_unpack` in `CMakeLists.txt` with `SKIP_RETURN_CODE 77` and `FORM_COVERAGE_RECORD`): - 12 cross-lane XMM->YMM sign/zero-extend moves: `VPMOVSX{BW,BD,BQ,WD,WQ,DQ}` and `VPMOVZX{BW,BD,BQ,WD,WQ,DQ}` (modeling exact Intel SDM cross-lane slicing, ignored upper XMM/YMM bytes, stale destination overwrite, aliased `dst == src`, and VEX.256->128 upper-half zeroing). - 4 in-lane YMM unpacks: `VPUNPCK{L,H}{DQ,QDQ}` via `wide128`. - Refuse memory operands, nonvolatile YMM6-15/XMM6-15, EVEX, and unlowered YMM unpacks (`VPUNPCK{L,H}{BW,WD}`). - Update `tests/cpu/avx_int_regs_check.py` and `tests/cpu/avx_int_ymm_abs_sign_shuf_check.py` to replace newly lowered forms in their VEX.256 refusal lists with genuinely unlowered VEX.256 shift forms (`vpsrld`/`vpsllq`/`vpsrlq`). AI-assisted. ## Verification Tested on commit `905ffec8` (rebased on `upstream/main`) with MSVC 19.50 + ML64 14.50 and `out\pe-env\Scripts\python.exe -B`: - `ctest --preset dev -N`: Total Tests: 2082 (no dropped tests). - `cmake --build --preset dev --target cpu_avx_int_regs_original cpu_avx_int_regs_original_lifted cpu_avx_int_regs_altered cpu_avx_int_regs_altered_lifted cpu_avx_int_ymm_abs_sign_shuf cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted`: 0 errors, 0 warnings. - `ctest --preset dev --output-on-failure --no-tests=error -R "^(cpu_aot_avx_int_regs|cpu_aot_avx_int_ymm_abs_sign_shuf|cpu_aot_avx_int_ymm_widen_unpack)$" -E "cpu_native_archive_" -V`: 3/3 passed (`cpu_aot_avx_int_ymm_widen_unpack`: 16 forms accepted, 31 rejection controls, 4,536 native/lifted/reference cases across 24 exports matched bit for bit, 13 mutant + 16 altered-build controls caught; 0 capability skips on AVX2 host). - `cmake --build --preset release --target ...` (/O2): 0 errors, 0 warnings; same targeted CTest in `release`: 3/3 passed. - Verified `FORM_COVERAGE_RECORD` written in both `dev` and `release` containing all 16 mnemonics plus `ret`, `vmovdqu`, `vzeroupper`. - Spot-mutation negative control: temporarily disabled 4 translator guards one by one in `tools/cpu_avx_int_aot.py` (`wide_extend`, `VPUNPCKLDQ` code, memory-operand guard, EVEX guard); 4/4 mutations killed by `check_translator()` and restored cleanly. - `out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py`: passed (exit 0). - `out\pe-env\Scripts\python.exe -B tests\docs_links_check.py`: passed (exit 0). - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py`: passed (exit 0). ## Evidence and follow-up All fixtures in `tests/cpu/avx_int_ymm_widen_unpack.{asm,def}` are source-built synthetic MASM routines (MIT License). Native execution is CPUID AVX2 gated (exit 77 on non-AVX2 hosts). Remaining unlowered VEX.256 integer shifts, multiplies, blends, and aligns remain follow-ups. ## 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.
upstream-sync closed this pull request 2026-11-26 00:00:58 +00:00
tedin7 commented 2026-11-26 00:00:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:30:10Z.

Review: COMMENTED


Review of head 905ffec8 (comment only).

Result: no blocking findings in the code.

Checked:

  • tools/cpu_avx_int_aot.py: the 12 YMM extend forms and the 4 YMM vpunpck{l,h}{dq,qdq} forms are added to WIDE_* tables and to ALLOWED_CODES. The lift_code branch for extends reads the XMM source and writes a YMM destination, so the upper half is written and not left stale. Operand/ABI refusals (memory operands, nonvolatile YMM6-15, EVEX, unlowered vpunpck{l,h}{bw,wd}) are unchanged.
  • The shared extend_* helpers replace the twelve old 128-bit helpers. I compared them by hand: the counts (8/4/2 for XMM, 16/8/4 for YMM) and the sign/zero rules match the previous per-form code, so the 128-bit forms keep their behaviour.
  • Siblings: the two older refusal lists (avx_int_regs_check.py, avx_int_ymm_abs_sign_shuf_check.py) are updated to forms that are still unlowered (vpsrld, vpsllq, vpsrlq). New test is registered with SKIP_RETURN_CODE 77. No other open or merged PR lowers these forms.
  • The new check has differential, refusal and mutation cases for the 16 forms.

Commands run (Linux, exact head in a worktree):

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: ok
  • python3 tests/bidi_controls_check.py: ok
  • The three CPU checks need iced_x86, pefile and MASM, which are not on Linux, so they and the mutation cases are run on Windows. The receipt will follow.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066432932 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2614#pullrequestreview-6066432932). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T23:30:10Z. **Review:** COMMENTED --- Review of head 905ffec8 (comment only). Result: no blocking findings in the code. Checked: - `tools/cpu_avx_int_aot.py`: the 12 YMM extend forms and the 4 YMM `vpunpck{l,h}{dq,qdq}` forms are added to `WIDE_*` tables and to `ALLOWED_CODES`. The `lift_code` branch for extends reads the XMM source and writes a YMM destination, so the upper half is written and not left stale. Operand/ABI refusals (memory operands, nonvolatile YMM6-15, EVEX, unlowered `vpunpck{l,h}{bw,wd}`) are unchanged. - The shared `extend_*` helpers replace the twelve old 128-bit helpers. I compared them by hand: the counts (8/4/2 for XMM, 16/8/4 for YMM) and the sign/zero rules match the previous per-form code, so the 128-bit forms keep their behaviour. - Siblings: the two older refusal lists (`avx_int_regs_check.py`, `avx_int_ymm_abs_sign_shuf_check.py`) are updated to forms that are still unlowered (`vpsrld`, `vpsllq`, `vpsrlq`). New test is registered with `SKIP_RETURN_CODE 77`. No other open or merged PR lowers these forms. - The new check has differential, refusal and mutation cases for the 16 forms. Commands run (Linux, exact head in a worktree): - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: ok - `python3 tests/bidi_controls_check.py`: ok - The three CPU checks need `iced_x86`, `pefile` and MASM, which are not on Linux, so they and the mutation cases are run on Windows. The receipt will follow. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 00:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T23:30:51Z.


Win2025 WARP receipt for head 905ffec8.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 905ffec8c6c424ac31d3018c9fbff210142f06c0:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted -- -j 2): 5.94s (configure 1.82s)
    • Test (ctest --preset dev -R 'avx_int' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.32s: cpu_aot_avx_int_shifts_pack 0.39s, cpu_aot_avx_int_ymm_mul_sad 0.46s, cpu_aot_avx_int_ymm_pack 0.48s, cpu_aot_avx_int_ymm_horizontal 0.49s, cpu_aot_avx_int_ymm_abs_sign_shuf 0.71s, cpu_aot_avx_int_ymm_sat 0.71s, cpu_aot_avx_int_extend_hadd 0.43s, cpu_aot_avx_int_minmax_mul 0.42s, cpu_aot_avx_int_regs 0.55s, cpu_aot_avx_int_ymm_minmax 0.55s, cpu_aot_avx_int_ymm_addsub 0.45s, cpu_aot_avx_int_ymm_widen_unpack 0.46s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted -- -j 2): 7.27s (configure 1.90s)
    • Test (ctest --preset release -R 'avx_int' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.21s: cpu_aot_avx_int_ymm_mul_sad 0.43s, cpu_aot_avx_int_ymm_addsub 0.50s, cpu_aot_avx_int_ymm_sat 0.54s, cpu_aot_avx_int_ymm_minmax 0.53s, cpu_aot_avx_int_regs 0.56s, cpu_aot_avx_int_ymm_abs_sign_shuf 0.64s, cpu_aot_avx_int_extend_hadd 0.36s, cpu_aot_avx_int_ymm_horizontal 0.52s, cpu_aot_avx_int_minmax_mul 0.44s, cpu_aot_avx_int_ymm_pack 0.51s, cpu_aot_avx_int_shifts_pack 0.42s, cpu_aot_avx_int_ymm_widen_unpack 0.54s)
  • sccache: 3/35 hits; wall 23.4s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7177665889 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2614#issuecomment-7177665889). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T23:30:51Z. --- Win2025 WARP receipt for head 905ffec8. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `905ffec8c6c424ac31d3018c9fbff210142f06c0`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted -- -j 2`): `5.94s` (configure `1.82s`) - Test (`ctest --preset dev -R 'avx_int' --parallel 6 --no-tests=error --output-on-failure`): **12/12 passed** (`1.32s`: `cpu_aot_avx_int_shifts_pack` `0.39s`, `cpu_aot_avx_int_ymm_mul_sad` `0.46s`, `cpu_aot_avx_int_ymm_pack` `0.48s`, `cpu_aot_avx_int_ymm_horizontal` `0.49s`, `cpu_aot_avx_int_ymm_abs_sign_shuf` `0.71s`, `cpu_aot_avx_int_ymm_sat` `0.71s`, `cpu_aot_avx_int_extend_hadd` `0.43s`, `cpu_aot_avx_int_minmax_mul` `0.42s`, `cpu_aot_avx_int_regs` `0.55s`, `cpu_aot_avx_int_ymm_minmax` `0.55s`, `cpu_aot_avx_int_ymm_addsub` `0.45s`, `cpu_aot_avx_int_ymm_widen_unpack` `0.46s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target cpu_avx_int_regs_altered_lifted cpu_avx_int_regs_original_lifted cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_horizontal_altered_lifted cpu_avx_int_ymm_horizontal_original_lifted cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_mul_sad_altered_lifted cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_pack_altered_lifted cpu_avx_int_ymm_pack_original_lifted cpu_avx_int_ymm_sat_lifted cpu_avx_int_ymm_widen_unpack_altered cpu_avx_int_ymm_widen_unpack_altered_lifted cpu_avx_int_ymm_widen_unpack_original cpu_avx_int_ymm_widen_unpack_original_lifted -- -j 2`): `7.27s` (configure `1.90s`) - Test (`ctest --preset release -R 'avx_int' --parallel 6 --no-tests=error --output-on-failure`): **12/12 passed** (`1.21s`: `cpu_aot_avx_int_ymm_mul_sad` `0.43s`, `cpu_aot_avx_int_ymm_addsub` `0.50s`, `cpu_aot_avx_int_ymm_sat` `0.54s`, `cpu_aot_avx_int_ymm_minmax` `0.53s`, `cpu_aot_avx_int_regs` `0.56s`, `cpu_aot_avx_int_ymm_abs_sign_shuf` `0.64s`, `cpu_aot_avx_int_extend_hadd` `0.36s`, `cpu_aot_avx_int_ymm_horizontal` `0.52s`, `cpu_aot_avx_int_minmax_mul` `0.44s`, `cpu_aot_avx_int_ymm_pack` `0.51s`, `cpu_aot_avx_int_shifts_pack` `0.42s`, `cpu_aot_avx_int_ymm_widen_unpack` `0.54s`) - `sccache`: 3/35 hits; wall `23.4s` AI-assisted; commands listed were executed locally.
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!2606
No description provided.