cpu: lower VEX AVX scalar FP, half-register moves, vinsertps/vextractps, and vcomis* #407

Manually merged
github merged 4 commits from gh-pr/407/head into gh-pr/407/base 2026-11-26 21:49:31 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-22 00:33 UTC · original
Vonsek:ag/cpu-lower-avx-scalar-fp → main · +615 −1 · 7 files · 4 commits · merged 2026-11-23 18:23 UTC

Change

  • Lower 28 VEX AVX scalar floating-point, half-register move, vinsertps/vextractps, and scalar compare instructions in tools/ffx_version_query.py:
    • Scalar arithmetic, square root, min/max, and round: vaddss, vsubss, vmulss, vdivss, vsqrtss, vminss, vmaxss, vroundss, vaddsd, vsubsd, vmulsd, vdivsd, vsqrtsd, vminsd, vmaxsd, vroundsd
    • Scalar and half-register moves: vmovss, vmovhlps, vmovlhps, vmovlps, vmovhps, vmovlpd
    • Extract/insert and scalar compares (updating ZF and CF): vinsertps, vextractps, vcomiss, vucomiss, vcomisd, vucomisd
  • Restrict lowering to EncodingKind.VEX (rejecting EVEX encodings and MXCSR rounding mode) and zero upper YMM bytes for 128-bit XMM destinations.
  • Probe CPUID leaf 1 ECX bits 27 (OSXSAVE) and 28 (AVX) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with SKIP_RETURN_CODE 77 on hosts without AVX).
  • Add source-built MASM differential fixture tests/cpu/avx_scalar_fp.{asm,def,py}, CMake target cpu_avx_scalar_fp_lifted, CTest cpu_aot_avx_scalar_fp, coverage mapping in tools/form_coverage.py, and documentation in docs/experiments.md.

Verification

  • Confirmed pre-fix failure on cmake --build --preset dev --target cpu_avx_scalar_fp_lifted:
    ValueError: unsupported query operation at 0x1008: vaddss xmm0,xmm1,xmm2
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_avx_scalar_fp_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_scalar_fp|cpu_aot_bmi1)$" -V: 2/2 passed (39 VEX AVX scalar FP/move/extract/insert/compare cases matched native and translated DLLs + EVEX vaddss rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 28 AVX-grouped mnemonics in docs/coverage/x64_zen2.tsv using source-built fixtures, gated by a runtime CPUID/XCR0 check.
**@⁠Vonsek** on GitHub · 2026-11-22 00:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407) `Vonsek:ag/cpu-lower-avx-scalar-fp` → `main` · +615 −1 · 7 files · 4 commits · merged 2026-11-23 18:23 UTC ## Change - Lower 28 VEX AVX scalar floating-point, half-register move, `vinsertps`/`vextractps`, and scalar compare instructions in `tools/ffx_version_query.py`: - Scalar arithmetic, square root, min/max, and round: `vaddss`, `vsubss`, `vmulss`, `vdivss`, `vsqrtss`, `vminss`, `vmaxss`, `vroundss`, `vaddsd`, `vsubsd`, `vmulsd`, `vdivsd`, `vsqrtsd`, `vminsd`, `vmaxsd`, `vroundsd` - Scalar and half-register moves: `vmovss`, `vmovhlps`, `vmovlhps`, `vmovlps`, `vmovhps`, `vmovlpd` - Extract/insert and scalar compares (updating ZF and CF): `vinsertps`, `vextractps`, `vcomiss`, `vucomiss`, `vcomisd`, `vucomisd` - Restrict lowering to `EncodingKind.VEX` (rejecting EVEX encodings and MXCSR rounding mode) and zero upper YMM bytes for 128-bit XMM destinations. - Probe CPUID leaf 1 ECX bits 27 (`OSXSAVE`) and 28 (`AVX`) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with `SKIP_RETURN_CODE 77` on hosts without AVX). - Add source-built MASM differential fixture `tests/cpu/avx_scalar_fp.{asm,def,py}`, CMake target `cpu_avx_scalar_fp_lifted`, CTest `cpu_aot_avx_scalar_fp`, coverage mapping in `tools/form_coverage.py`, and documentation in `docs/experiments.md`. ## Verification - Confirmed pre-fix failure on `cmake --build --preset dev --target cpu_avx_scalar_fp_lifted`: `ValueError: unsupported query operation at 0x1008: vaddss xmm0,xmm1,xmm2` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_avx_scalar_fp_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_scalar_fp|cpu_aot_bmi1)$" -V`: 2/2 passed (`39 VEX AVX scalar FP/move/extract/insert/compare cases matched native and translated DLLs` + EVEX `vaddss` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 28 `AVX`-grouped mnemonics in `docs/coverage/x64_zen2.tsv` using source-built fixtures, gated by a runtime CPUID/XCR0 check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:49:29 +00:00
github manually merged commit eb9910cb64 into gh-pr/407/base 2026-11-26 21:49:31 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:37 UTC · original · edited 2026-11-22 00:44 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T00:44:40.099498Z f7932cb Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-22 00:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#issuecomment-7071675019) · edited 2026-11-22 00:44 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"f7932cb562c01859de5c5d6635f688deede3d20e","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-22T00:44:40.099498Z">2026-11-22T00:44:40.099498Z</relative-time> | `f7932cb` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:44 UTC · original

P2 Badge Quiet signaling NaNs before returning from round_x86

With a signaling-NaN source and masked invalid exceptions, VROUNDSS/VROUNDSD must return a quiet NaN, but this non-finite fast path returns the original signaling bit pattern. In a Linux/x64 native probe of this exact header with default MXCSR, vroundss with immediate 0x08 converts input bits 0x7f800001 to 0x7fc00001, while round_x86<float>(x, 0) returns 0x7f800001; the double version has the corresponding mismatch. Thus the newly accepted instructions can store different scalar bits from native execution. Handle NaNs separately from infinities and add signaling-NaN differential cases.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-22 00:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#discussion_r4655805625) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Quiet signaling NaNs before returning from round_x86** With a signaling-NaN source and masked invalid exceptions, `VROUNDSS`/`VROUNDSD` must return a quiet NaN, but this non-finite fast path returns the original signaling bit pattern. In a Linux/x64 native probe of this exact header with default MXCSR, `vroundss` with immediate `0x08` converts input bits `0x7f800001` to `0x7fc00001`, while `round_x86<float>(x, 0)` returns `0x7f800001`; the double version has the corresponding mismatch. Thus the newly accepted instructions can store different scalar bits from native execution. Handle NaNs separately from infinities and add signaling-NaN differential cases. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:44 UTC · original

P2 Badge Apply DAZ normalization before selecting min/max results

When MXCSR.DAZ is enabled, these comparisons treat subnormal operands as zero but can copy their original nonzero bits into the result. In an unoptimized Linux/x64 GCC probe with MXCSR 0x1fc0, a=1.0f and b containing float bits 0x00000001, native vminss returns 0x00000000, whereas this expression returns 0x00000001; max and double forms have the same normalization problem. The round_x86 zero fast path likewise returns an unchanged subnormal under DAZ. Normalize DAZ inputs explicitly or use equivalent scalar intrinsics, and add DAZ-enabled differential cases rather than relying on an optimizer to replace the conditional with a native min/max instruction.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-22 00:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#discussion_r4655805629) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Apply DAZ normalization before selecting min/max results** When MXCSR.DAZ is enabled, these comparisons treat subnormal operands as zero but can copy their original nonzero bits into the result. In an unoptimized Linux/x64 GCC probe with MXCSR `0x1fc0`, `a=1.0f` and `b` containing float bits `0x00000001`, native `vminss` returns `0x00000000`, whereas this expression returns `0x00000001`; max and double forms have the same normalization problem. The `round_x86` zero fast path likewise returns an unchanged subnormal under DAZ. Normalize DAZ inputs explicitly or use equivalent scalar intrinsics, and add DAZ-enabled differential cases rather than relying on an optimizer to replace the conditional with a native min/max instruction. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 17:50 UTC · original

I integrated main and repaired the scalar FP findings. Round now quiets signaling NaNs with the original payload, MIN/MAX and directed rounding honor DAZ, and the COMI/UCOMI controls distinguish the masked invalid flag for quiet and signaling NaNs. The 39 original scalar cases, new MXCSR controls and existing shuffle cases passed in both Windows presets. Fresh CI is running.

**@⁠R0Y00** on GitHub · 2026-11-23 17:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#issuecomment-7109272547) I integrated main and repaired the scalar FP findings. Round now quiets signaling NaNs with the original payload, MIN/MAX and directed rounding honor DAZ, and the COMI/UCOMI controls distinguish the masked invalid flag for quiet and signaling NaNs. The 39 original scalar cases, new MXCSR controls and existing shuffle cases passed in both Windows presets. Fresh CI is running.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 18:06 UTC · original

The /O2 log showed one stale SSE test expecting rejection of VEX VEXTRACTPS with XMM0, which this PR now verifies against native execution. I changed that negative case to an untracked XMM3 source. SSE3/4.1, AVX scalar and AVX shuffle passed 3/3 in both Windows presets. CI is rerunning on the new head.

**@⁠R0Y00** on GitHub · 2026-11-23 18:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#issuecomment-7109651321) The /O2 log showed one stale SSE test expecting rejection of VEX VEXTRACTPS with XMM0, which this PR now verifies against native execution. I changed that negative case to an untracked XMM3 source. SSE3/4.1, AVX scalar and AVX shuffle passed 3/3 in both Windows presets. CI is rerunning on the new head.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-22 00:44 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7932cb562

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-22 00:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/407#pullrequestreview-6009222425) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `f7932cb562` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.