cpu: lower AVX VEX FP compare instructions #973

Closed
github-bot wants to merge 1 commit from gh-pr/973/head into gh-pr/973/base
Owner

@⁠Ammmae0x on GitHub · 2026-11-23 19:22 UTC · original
Ammmae0x:cpu/avx-cmp-fp → main · +1236 −0 · 6 files · 1 commits · closed without merging

Change

Add VEX AVX floating-point compare lowering (tools/ffx_version_query.py) and differential fixture coverage (tests/cpu/avx_cmp_fp.{asm,def,py}, CMakeLists.txt, docs/experiments.md) for four uncovered x64 Zen 2 AVX mnemonics:

  • vcmpps (VEX.128 and VEX.256, register and unaligned m128/m256 operands)
  • vcmppd (VEX.128 and VEX.256, register and unaligned m128/m256 operands)
  • vcmpss (VEX.128, register and unaligned m32 operands)
  • vcmpsd (VEX.128, register and unaligned m64 operands)

The lowering (avx_cmp_pred, avx_cmp_f32, avx_cmp_f64 in INTEGER_HEADER plus lower_avx_cmp_fp) implements all 32 AVX predicate immediates (imm8 & 0x1f) using portable SSE2 _mm_comi*/_mm_ucomi* intrinsics and bit-level NaN checks (compatible with non-/arch:AVX MSVC builds), preserving ordered/unordered NaN semantics, quiet vs. signaling MXCSR #I, DAZ handling, upper-lane preservation (4..15 on vcmpss, 8..15 on vcmpsd), and upper-128-bit zeroing on XMM destinations. EVEX encodings, legacy SSE encodings, untracked vector registers (xmm3/ymm3), segment prefixes, EIP-relative operands, mixed XMM/YMM widths, mismatched memory operand sizes, and non-imm8 predicates are rejected.

Verification

Tested on commit 75dd03f (branch cpu/avx-cmp-fp, x64 Windows host with AVX):

  • ctest --preset dev -N: 503 total tests (cpu_aot_avx_cmp_fp registered as Test #216 with SKIP_RETURN_CODE 77; no test drops or regressions).
  • cmake --preset dev + cmake --build --preset dev --clean-first --target cpu_avx_cmp_fp_lifted cpu_avx_horiz_fp_lifted cpu_avx_scalar_fp_lifted cpu_version_query_lifted: succeeded with 0 errors, 0 warnings.
  • cmake --preset release + cmake --build --preset release --target cpu_avx_cmp_fp_lifted cpu_avx_horiz_fp_lifted cpu_avx_scalar_fp_lifted cpu_version_query_lifted: succeeded with 0 errors, 0 warnings.
  • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_cmp_fp|cpu_aot_avx_horiz_fp|cpu_aot_avx_scalar_fp|cpu_aot_version_query)$" -V: 4/4 passed (cpu_aot_avx_cmp_fp: 1760 VEX AVX FP compare cases across 217 exports and 2 MXCSR modes + guard-page bounds + 18 byte-decoded & 11 synthetic rejections + 4 mutated controls; cpu_aot_avx_horiz_fp: 632 cases + 2 mutated controls; cpu_aot_avx_scalar_fp: 39 cases; cpu_aot_version_query: passed).
  • ctest --preset release --no-tests=error -R "^(cpu_aot_avx_cmp_fp|cpu_aot_avx_horiz_fp|cpu_aot_avx_scalar_fp|cpu_aot_version_query)$" -V: 4/4 passed with matching counts.
  • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py, tests/docs_links_check.py, tests/bidi_controls_check.py: all passed (13 Markdown files / 195 links; 796 tracked files).
  • tools/form_coverage.py on cpu_aot_avx_cmp_fp JUnit XML: vcmpps, vcmppd, vcmpss, vcmpsd all counted as covered in AVX.

Evidence and follow-up

  • Source-built MASM fixture (tests/cpu/avx_cmp_fp.asm) and Python differential check (tests/cpu/avx_cmp_fp.py) with an independent IEEE-754 comparison reference model, unaligned memory offsets, VirtualAlloc guard-page bounds checks, 18 byte-decoded + 11 synthetic rejection controls, and 4 mutated C++ negative controls.
  • Remaining uncovered AVX forms in docs/coverage/x64_zen2.tsv (vaddsubps/pd, vptest, vtestps/pd, vldmxcsr, vstmxcsr, vmovq, vmaskmovdqu) are out of scope for this PR.

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.

**@⁠Ammmae0x** on GitHub · 2026-11-23 19:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/973) `Ammmae0x:cpu/avx-cmp-fp` → `main` · +1236 −0 · 6 files · 1 commits · closed without merging ## Change Add VEX AVX floating-point compare lowering (`tools/ffx_version_query.py`) and differential fixture coverage (`tests/cpu/avx_cmp_fp.{asm,def,py}`, `CMakeLists.txt`, `docs/experiments.md`) for four uncovered x64 Zen 2 `AVX` mnemonics: - `vcmpps` (VEX.128 and VEX.256, register and unaligned `m128`/`m256` operands) - `vcmppd` (VEX.128 and VEX.256, register and unaligned `m128`/`m256` operands) - `vcmpss` (VEX.128, register and unaligned `m32` operands) - `vcmpsd` (VEX.128, register and unaligned `m64` operands) The lowering (`avx_cmp_pred`, `avx_cmp_f32`, `avx_cmp_f64` in `INTEGER_HEADER` plus `lower_avx_cmp_fp`) implements all 32 AVX predicate immediates (`imm8 & 0x1f`) using portable SSE2 `_mm_comi*`/`_mm_ucomi*` intrinsics and bit-level NaN checks (compatible with non-`/arch:AVX` MSVC builds), preserving ordered/unordered NaN semantics, quiet vs. signaling MXCSR `#I`, DAZ handling, upper-lane preservation (`4..15` on `vcmpss`, `8..15` on `vcmpsd`), and upper-128-bit zeroing on XMM destinations. EVEX encodings, legacy SSE encodings, untracked vector registers (`xmm3`/`ymm3`), segment prefixes, EIP-relative operands, mixed XMM/YMM widths, mismatched memory operand sizes, and non-`imm8` predicates are rejected. ## Verification Tested on commit `75dd03f` (branch `cpu/avx-cmp-fp`, x64 Windows host with AVX): - `ctest --preset dev -N`: 503 total tests (`cpu_aot_avx_cmp_fp` registered as Test #216 with `SKIP_RETURN_CODE 77`; no test drops or regressions). - `cmake --preset dev` + `cmake --build --preset dev --clean-first --target cpu_avx_cmp_fp_lifted cpu_avx_horiz_fp_lifted cpu_avx_scalar_fp_lifted cpu_version_query_lifted`: succeeded with 0 errors, 0 warnings. - `cmake --preset release` + `cmake --build --preset release --target cpu_avx_cmp_fp_lifted cpu_avx_horiz_fp_lifted cpu_avx_scalar_fp_lifted cpu_version_query_lifted`: succeeded with 0 errors, 0 warnings. - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_cmp_fp|cpu_aot_avx_horiz_fp|cpu_aot_avx_scalar_fp|cpu_aot_version_query)$" -V`: 4/4 passed (`cpu_aot_avx_cmp_fp`: 1760 VEX AVX FP compare cases across 217 exports and 2 MXCSR modes + guard-page bounds + 18 byte-decoded & 11 synthetic rejections + 4 mutated controls; `cpu_aot_avx_horiz_fp`: 632 cases + 2 mutated controls; `cpu_aot_avx_scalar_fp`: 39 cases; `cpu_aot_version_query`: passed). - `ctest --preset release --no-tests=error -R "^(cpu_aot_avx_cmp_fp|cpu_aot_avx_horiz_fp|cpu_aot_avx_scalar_fp|cpu_aot_version_query)$" -V`: 4/4 passed with matching counts. - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`: all passed (13 Markdown files / 195 links; 796 tracked files). - `tools/form_coverage.py` on `cpu_aot_avx_cmp_fp` JUnit XML: `vcmpps`, `vcmppd`, `vcmpss`, `vcmpsd` all counted as covered in `AVX`. ## Evidence and follow-up - Source-built MASM fixture (`tests/cpu/avx_cmp_fp.asm`) and Python differential check (`tests/cpu/avx_cmp_fp.py`) with an independent IEEE-754 comparison reference model, unaligned memory offsets, VirtualAlloc guard-page bounds checks, 18 byte-decoded + 11 synthetic rejection controls, and 4 mutated C++ negative controls. - Remaining uncovered `AVX` forms in `docs/coverage/x64_zen2.tsv` (`vaddsubps`/`pd`, `vptest`, `vtestps`/`pd`, `vldmxcsr`, `vstmxcsr`, `vmovq`, `vmaskmovdqu`) are out of scope for this PR. ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:32:13 +00:00
github-bot closed this pull request 2026-11-26 22:32:13 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 19:36 UTC · original

Both Windows jobs stop while generating the lifted fixture: mutated control vcmpps_flipped_ord_unord_control changed nothing. The standalone head builds locally. In GitHub's merge candidate, main's existing elif op in avx_compare handles all four mnemonics before the added branch, so the generated body uses the existing compare intrinsic and the mutation never matches. Please keep the stronger all-predicate, guard-page and MXCSR comparisons as a fixture on current main. Make the controls change the actual emitted instruction path, keep their failure assertions, and report any native-versus-main mismatch separately before replacing that lowering.

**@⁠R0Y00** on GitHub · 2026-11-23 19:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/973#issuecomment-7111844449) Both Windows jobs stop while generating the lifted fixture: `mutated control vcmpps_flipped_ord_unord_control changed nothing`. The standalone head builds locally. In GitHub's merge candidate, main's existing `elif op in avx_compare` handles all four mnemonics before the added branch, so the generated body uses the existing compare intrinsic and the mutation never matches. Please keep the stronger all-predicate, guard-page and MXCSR comparisons as a fixture on current main. Make the controls change the actual emitted instruction path, keep their failure assertions, and report any native-versus-main mismatch separately before replacing that lowering.
Author
Owner

@⁠Ammmae0x on GitHub · 2026-11-23 19:43 UTC · original

Closing as superseded by merged #393, which already covers vcmpps, vcmppd, vcmpss, and vcmpsd. AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-11-23 19:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/973#issuecomment-7112013708) Closing as superseded by merged #393, which already covers `vcmpps`, `vcmppd`, `vcmpss`, and `vcmpsd`. AI-assisted.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.