cpu: lower 56 packed and scalar float/double instructions (SSE, SSE2, AVX) #719

Merged
MrSkelee merged 2 commits from upstream-pr/725 into main 2026-11-22 23:53:56 +00:00
MrSkelee commented 2026-11-22 23:13:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-22T23:13:25Z.


Summary

Lowers 56 packed and scalar floating point instructions across legacy SSE/SSE2 and AVX (VEX.128) encodings with full native differential coverage.

Highlights

  • 56 Instructions Lowered:
    • Packed single precision: ADDPS, SUBPS, MULPS, DIVPS, MAXPS, MINPS, SQRTPS, ANDPS, ANDNPS, ORPS, XORPS
    • Scalar single precision: SQRTSS, MAXSS, MINSS
    • Packed double precision: ADDPD, SUBPD, MULPD, DIVPD, MAXPD, MINPD, SQRTPD, ANDPD, ANDNPD, ORPD, XORPD
    • Scalar double precision: SQRTSD, MAXSD, MINSD
    • VEX.128 packed single: VADDPS, VSUBPS, VMULPS, VDIVPS, VMAXPS, VMINPS, VSQRTPS, VANDPS, VANDNPS, VORPS, VXORPS
    • VEX.128 packed double: VADDPD, VSUBPD, VMULPD, VDIVPD, VMAXPD, VMINPD, VSQRTPD, VANDPD, VANDNPD, VORPD, VXORPD
    • VEX.128 scalar single: VSQRTSS, VMAXSS, VMINSS
    • VEX.128 scalar double: VSQRTSD, VMAXSD, VMINSD
  • Full 256-bit Vector State Validation: Verifies that legacy 128-bit XMM operations preserve the upper 128 bits of YMM, while VEX.128 zero them out.
  • Architectural Floating-Point Semantics: Conforms to IEEE-754 / x86 rules for NaNs, signed zeros, and edge cases.
  • In-Place and Aliased Operands: Fully tested with aliased inputs and self-referencing registers.
  • Differential Suite: All 784 operations verified across native MASM execution and lifted C++ DLLs in both dev (/Od) and release (/O2) presets.

Verification

ctest --preset dev -R "(cpu_aot_float_packed|cpu_aot_float_shuffles|cpu_aot_heap_layout)" -V
ctest --preset release -R "(cpu_aot_float_packed|cpu_aot_float_shuffles|cpu_aot_heap_layout)" -V
  • Local results: 3/3 passed across both presets (0 failures).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6549069578 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/725). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-22T23:13:25Z. --- ### Summary Lowers 56 packed and scalar floating point instructions across legacy SSE/SSE2 and AVX (VEX.128) encodings with full native differential coverage. ### Highlights - **56 Instructions Lowered**: - Packed single precision: `ADDPS`, `SUBPS`, `MULPS`, `DIVPS`, `MAXPS`, `MINPS`, `SQRTPS`, `ANDPS`, `ANDNPS`, `ORPS`, `XORPS` - Scalar single precision: `SQRTSS`, `MAXSS`, `MINSS` - Packed double precision: `ADDPD`, `SUBPD`, `MULPD`, `DIVPD`, `MAXPD`, `MINPD`, `SQRTPD`, `ANDPD`, `ANDNPD`, `ORPD`, `XORPD` - Scalar double precision: `SQRTSD`, `MAXSD`, `MINSD` - VEX.128 packed single: `VADDPS`, `VSUBPS`, `VMULPS`, `VDIVPS`, `VMAXPS`, `VMINPS`, `VSQRTPS`, `VANDPS`, `VANDNPS`, `VORPS`, `VXORPS` - VEX.128 packed double: `VADDPD`, `VSUBPD`, `VMULPD`, `VDIVPD`, `VMAXPD`, `VMINPD`, `VSQRTPD`, `VANDPD`, `VANDNPD`, `VORPD`, `VXORPD` - VEX.128 scalar single: `VSQRTSS`, `VMAXSS`, `VMINSS` - VEX.128 scalar double: `VSQRTSD`, `VMAXSD`, `VMINSD` - **Full 256-bit Vector State Validation**: Verifies that legacy 128-bit XMM operations preserve the upper 128 bits of YMM, while VEX.128 zero them out. - **Architectural Floating-Point Semantics**: Conforms to IEEE-754 / x86 rules for NaNs, signed zeros, and edge cases. - **In-Place and Aliased Operands**: Fully tested with aliased inputs and self-referencing registers. - **Differential Suite**: All 784 operations verified across native MASM execution and lifted C++ DLLs in both `dev` (/Od) and `release` (/O2) presets. ### Verification ```powershell ctest --preset dev -R "(cpu_aot_float_packed|cpu_aot_float_shuffles|cpu_aot_heap_layout)" -V ctest --preset release -R "(cpu_aot_float_packed|cpu_aot_float_shuffles|cpu_aot_heap_layout)" -V ``` - Local results: 3/3 passed across both presets (0 failures).
upstream-sync closed this pull request 2026-11-24 06:44:31 +00:00
R0Y00 commented 2026-11-24 06:48:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T23:26:30Z.


The current profile says register-only SSE/SSE2 and VEX.128, but the new branch indexes wide_xmm before validating the operand forms. Valid decoded YMM operands, memory operands and untracked XMM registers can raise KeyError instead of the normal unsupported diagnostic. Please validate width, encoding and all source/destination kinds before selecting a lowering and add rejection controls. Keep the raw-bit readback, and for MIN/MAX add two different signed NaN payloads (quiet and signaling, each operand order) plus opposite signed zeros. Document which MXCSR configuration the comparison establishes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087575688 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/725#issuecomment-7087575688). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T23:26:30Z. --- The current profile says register-only SSE/SSE2 and VEX.128, but the new branch indexes `wide_xmm` before validating the operand forms. Valid decoded YMM operands, memory operands and untracked XMM registers can raise `KeyError` instead of the normal unsupported diagnostic. Please validate width, encoding and all source/destination kinds before selecting a lowering and add rejection controls. Keep the raw-bit readback, and for MIN/MAX add two different signed NaN payloads (quiet and signaling, each operand order) plus opposite signed zeros. Document which MXCSR configuration the comparison establishes.
MrSkelee commented 2026-11-24 06:48:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-22T23:40:54Z.


Updated in c7070e9:

  • Strict Operand Validation: ffx_version_query.py now explicitly verifies encoding, operand count, and that every operand is a tracked register in wide_xmm before selecting lowering, raising descriptive ValueError instead of indexing errors.
  • Rejection Controls: Added negative test checks in tests/cpu/float_packed.py for decoded 256-bit YMM forms (vaddps ymm0, ymm1, ymm2), memory operands (addps xmm0, [rcx], vaddps xmm0, xmm1, [rcx]), and untracked registers (xmm3).
  • Signed NaNs & Opposite Signed Zeros: Expanded differential suite with quiet (+QNaN, -QNaN) and signaling (+SNaN, -SNaN) payloads across both operand orders, along with +0.0 vs -0.0 for single and double precision MIN/MAX.
  • MXCSR Documentation: Documented the established default x64 architectural environment (0x1F80: all exceptions masked, round to nearest, FTZ/DAZ disabled).
  • Verification: All 1,400 comparisons passed across native MASM and lifted C++ DLLs in both dev (/Od) and release (/O2) presets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087753732 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/725#issuecomment-7087753732). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-22T23:40:54Z. --- Updated in c7070e9: - **Strict Operand Validation**: `ffx_version_query.py` now explicitly verifies `encoding`, operand count, and that every operand is a tracked register in `wide_xmm` before selecting lowering, raising descriptive `ValueError` instead of indexing errors. - **Rejection Controls**: Added negative test checks in `tests/cpu/float_packed.py` for decoded 256-bit YMM forms (`vaddps ymm0, ymm1, ymm2`), memory operands (`addps xmm0, [rcx]`, `vaddps xmm0, xmm1, [rcx]`), and untracked registers (`xmm3`). - **Signed NaNs & Opposite Signed Zeros**: Expanded differential suite with quiet (`+QNaN`, `-QNaN`) and signaling (`+SNaN`, `-SNaN`) payloads across both operand orders, along with `+0.0` vs `-0.0` for single and double precision MIN/MAX. - **MXCSR Documentation**: Documented the established default x64 architectural environment (0x1F80: all exceptions masked, round to nearest, FTZ/DAZ disabled). - **Verification**: All 1,400 comparisons passed across native MASM and lifted C++ DLLs in both `dev` (/Od) and `release` (/O2) presets.
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!719
No description provided.