cpu: lift scalar SSE/SSE2 leaf functions #265

Merged
Vonsek merged 5 commits from upstream-pr/269 into main 2026-11-22 08:52:40 +00:00
Vonsek commented 2026-11-21 19:51:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T19:51:33Z.


Change

The instruction-form map showed no covered x64 SSE or SSE2 form. This adds tools/cpu_sse_aot.py, a translator for Windows x64 leaf functions that keep float and double values in XMM registers, with a source fixture and a CTest test.

Supported forms:

  • MOVSS, MOVSD between registers and memory; register MOVAPS/MOVAPD/MOVUPS/MOVUPD copies;
  • ADDSS, SUBSS, MULSS, DIVSS and the SD forms, with register or memory sources;
  • CVTSI2SS, CVTSI2SD from 32- and 64-bit registers or memory; CVTTSS2SI, CVTTSD2SI to 32- and 64-bit registers; CVTSS2SD, CVTSD2SS;
  • UCOMISS, COMISS, UCOMISD, COMISD feeding JE, JNE, JB, JAE, JBE, JA, JP, JNP;
  • MOVD between XMM and a 32-bit register or memory, MOVQ between XMM registers and memory;
  • XORPS, XORPD, PXOR of a register with itself.

Design:

  • Each export is named with its signature, name=<result>:<slots> with f, d or q per slot (for example blend_ss=f:ffqf). Slot N is XMM0-XMM3 when floating point and RCX/RDX/R8/R9 otherwise, and the generated function has the matching C++ signature. A PE does not record this, so it cannot be inferred.
  • Only the low quadword of each XMM register is modelled, as a 64-bit integer. The must-defined pass tracks the two dwords separately: a float argument defines the low dword only, a register copy carries undefined parts, and reading an undefined part is rejected.
  • NaN operands are handled before the arithmetic (quieted destination NaN first, then the source NaN, default NaN with the sign set for an invalid operation). A host compiler may commute a + b, which changes the payload when both operands are NaN.
  • The truncating conversions test the range and return the integer indefinite (0x80000000, 0x8000000000000000); the plain C++ cast is undefined there.
  • A float compare stores ZF, PF and CF, and may feed a run of conditional jumps (JP then JNE). Integer flags keep the existing rule.
  • XMM6-XMM15 are rejected, as the leaf profile has no frame to save them.

The translator is a separate module that imports Function, Lifter and the prelude from cpu_switch_aot.py and does not edit that file, so it does not conflict with #173, #242 or #246. It overrides Function.constants() to return nothing, so every jump table is rejected in this profile. Its lift() repeats the label and must-defined loops of cpu_switch_aot.lift(); these can be shared once the open changes to that function have landed.

Other files: tests/cpu/scalar_float.asm/.def (six exports: blend_ss, blend_sd, convert, from_int, classify_ss, classify_sd; SWAP_OPERANDS builds the control); tests/cpu/scalar_float_check.py (CTest cpu_aot_scalar_float); tools/form_coverage.py (scalar_float maps to cpu_aot_scalar_float) and check_scalar_float in tests/form_coverage_check.py; docs/experiments.md (new section); README.md (CPU translation row). With the new test passing, the fixture adds 11 SSE and 11 SSE2 forms (plus movd, movq, pxor, filed under MMX, and movsd, jp, jnp, filed under Integer).

Verification

  • Windows: ctest --preset dev --no-tests=error -R '^cpu_aot_scalar_float$' -V at 399617c (rebased on main d311159, with the round_trip conversion fix; the runs at 8c8fa8f and 5d0c75c gave the same output for the existing exports) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207, ML64 14.44.35230), Windows SDK 10.0.26100, Python 3.12: passed in Debug (the dev preset) and in a Release build (cmake --preset dev -B out/build/rel -DCMAKE_BUILD_TYPE=Release), with identical output: 23 fixed results and {'blend_ss': 2916, 'blend_sd': 3481, 'convert': 432, 'from_int': 61, 'classify_ss': 2916, 'classify_sd': 3481} calls match on the result and the guarded buffer for the original and the swapped-operand build; swapped operands changed {'blend_ss': 42, 'blend_sd': 1503, 'convert': 273, 'from_int': 53, 'classify_ss': 2160, 'classify_sd': 2650} and 13 patched-instruction rejections and 8 signature rejections passed. The original DLLs are called through ctypes, and the signalling-NaN cases still match, so that path does not quiet them. The full ctest --preset dev --no-tests=error passed 137/137, with bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp skipped.
  • ML64 14.44.35230 assembles tests/cpu/scalar_float.asm unchanged, with and without /DSWAP_OPERANDS. llvm-ml 18 (--m64) also accepts the file unchanged.
  • Linux stand-in: llvm-ml + lld-link build both DLLs. The original code is called in-process through a Windows-ABI trampoline; the lifted C++ is built with clang 18 at -O0, -O2 and -O3 (-Wall -Wextra -Werror). check() and check_rejections() run unchanged:
    • 23 fixed results (integer indefinites, default NaN sign, quieted signalling NaN, destination-over-source NaN, signed zeros, ties to even) hold for the original and the translation;
    • 13,287 calls match on result bits and the guarded buffer, for the original build and for the swapped-operand build against its own translation;
    • the swapped build differs from the original in every function (42, 1503, 273, 53, 2160 and 2650 calls); in blend_ss, where only a + b becomes b + a, the 42 differences are exactly inputs with two NaN operands;
    • 13 patched-instruction rejections and 8 signature rejections pass.
  • Inputs: zeros of both signs, denormals, infinities, quiet and signalling NaNs with distinct payloads, values around ±2^31 and ±2^63, narrowing ties, random patterns.
  • Generated sources compile with clang for x86_64-pc-windows-msvc under -Wall -Wextra -Werror and with clang-cl /W4 /WX.
  • Sensitivity: removing the destination-NaN test, removing both NaN tests, treating unordered as ordered, changing the JBE condition, dropping the sign extension in CVTSI2SS, or making a single-precision result or a register MOVSS overwrite bits 32-63 each fails check().
  • tests/form_coverage_check.py passes; with the CPU_FIXTURES entry removed it fails in check_scalar_float.

Evidence and follow-up

  • The default-NaN sign and the truncation range test are not distinguishable from plain C++ on an x64 host at the optimisation levels tried; they are kept because the C++ results are otherwise unspecified or undefined.
  • Exceptions are assumed masked. Rounding follows the thread's MXCSR in both the original and the translation (one host instruction per operation, fp_contract off).
  • Not covered and rejected: RIP-relative constants (the most common source of float constants in compiled code), packed operations, SQRTSS, MINSS/MAXSS, CVTSS2SI/CVTSD2SI, MOVQ with an integer register, SETcc/CMOVcc after a compare (depends on #173), stack frames, calls, and saving XMM6-XMM15.
  • The coverage dashboard is not regenerated here, to avoid a conflict with the regeneration in #257.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533629333 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T19:51:33Z. --- ## Change The instruction-form map showed no covered x64 SSE or SSE2 form. This adds `tools/cpu_sse_aot.py`, a translator for Windows x64 leaf functions that keep `float` and `double` values in XMM registers, with a source fixture and a CTest test. Supported forms: - `MOVSS`, `MOVSD` between registers and memory; register `MOVAPS`/`MOVAPD`/`MOVUPS`/`MOVUPD` copies; - `ADDSS`, `SUBSS`, `MULSS`, `DIVSS` and the `SD` forms, with register or memory sources; - `CVTSI2SS`, `CVTSI2SD` from 32- and 64-bit registers or memory; `CVTTSS2SI`, `CVTTSD2SI` to 32- and 64-bit registers; `CVTSS2SD`, `CVTSD2SS`; - `UCOMISS`, `COMISS`, `UCOMISD`, `COMISD` feeding `JE`, `JNE`, `JB`, `JAE`, `JBE`, `JA`, `JP`, `JNP`; - `MOVD` between XMM and a 32-bit register or memory, `MOVQ` between XMM registers and memory; - `XORPS`, `XORPD`, `PXOR` of a register with itself. Design: - Each export is named with its signature, `name=<result>:<slots>` with `f`, `d` or `q` per slot (for example `blend_ss=f:ffqf`). Slot N is XMM0-XMM3 when floating point and RCX/RDX/R8/R9 otherwise, and the generated function has the matching C++ signature. A PE does not record this, so it cannot be inferred. - Only the low quadword of each XMM register is modelled, as a 64-bit integer. The must-defined pass tracks the two dwords separately: a `float` argument defines the low dword only, a register copy carries undefined parts, and reading an undefined part is rejected. - NaN operands are handled before the arithmetic (quieted destination NaN first, then the source NaN, default NaN with the sign set for an invalid operation). A host compiler may commute `a + b`, which changes the payload when both operands are NaN. - The truncating conversions test the range and return the integer indefinite (`0x80000000`, `0x8000000000000000`); the plain C++ cast is undefined there. - A float compare stores ZF, PF and CF, and may feed a run of conditional jumps (`JP` then `JNE`). Integer flags keep the existing rule. - XMM6-XMM15 are rejected, as the leaf profile has no frame to save them. The translator is a separate module that imports `Function`, `Lifter` and the prelude from `cpu_switch_aot.py` and does not edit that file, so it does not conflict with #173, #242 or #246. It overrides `Function.constants()` to return nothing, so every jump table is rejected in this profile. Its `lift()` repeats the label and must-defined loops of `cpu_switch_aot.lift()`; these can be shared once the open changes to that function have landed. Other files: `tests/cpu/scalar_float.asm`/`.def` (six exports: `blend_ss`, `blend_sd`, `convert`, `from_int`, `classify_ss`, `classify_sd`; `SWAP_OPERANDS` builds the control); `tests/cpu/scalar_float_check.py` (CTest `cpu_aot_scalar_float`); `tools/form_coverage.py` (`scalar_float` maps to `cpu_aot_scalar_float`) and `check_scalar_float` in `tests/form_coverage_check.py`; `docs/experiments.md` (new section); `README.md` (CPU translation row). With the new test passing, the fixture adds 11 SSE and 11 SSE2 forms (plus `movd`, `movq`, `pxor`, filed under MMX, and `movsd`, `jp`, `jnp`, filed under Integer). ## Verification - Windows: `ctest --preset dev --no-tests=error -R '^cpu_aot_scalar_float$' -V` at 399617c (rebased on main d311159, with the round_trip conversion fix; the runs at 8c8fa8f and 5d0c75c gave the same output for the existing exports) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207, ML64 14.44.35230), Windows SDK 10.0.26100, Python 3.12: passed in Debug (the `dev` preset) and in a Release build (`cmake --preset dev -B out/build/rel -DCMAKE_BUILD_TYPE=Release`), with identical output: `23 fixed results and {'blend_ss': 2916, 'blend_sd': 3481, 'convert': 432, 'from_int': 61, 'classify_ss': 2916, 'classify_sd': 3481} calls match on the result and the guarded buffer for the original and the swapped-operand build; swapped operands changed {'blend_ss': 42, 'blend_sd': 1503, 'convert': 273, 'from_int': 53, 'classify_ss': 2160, 'classify_sd': 2650}` and `13 patched-instruction rejections and 8 signature rejections passed`. The original DLLs are called through ctypes, and the signalling-NaN cases still match, so that path does not quiet them. The full `ctest --preset dev --no-tests=error` passed 137/137, with `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp` skipped. - ML64 14.44.35230 assembles `tests/cpu/scalar_float.asm` unchanged, with and without `/DSWAP_OPERANDS`. `llvm-ml` 18 (`--m64`) also accepts the file unchanged. - Linux stand-in: `llvm-ml` + `lld-link` build both DLLs. The original code is called in-process through a Windows-ABI trampoline; the lifted C++ is built with clang 18 at `-O0`, `-O2` and `-O3` (`-Wall -Wextra -Werror`). `check()` and `check_rejections()` run unchanged: - 23 fixed results (integer indefinites, default NaN sign, quieted signalling NaN, destination-over-source NaN, signed zeros, ties to even) hold for the original and the translation; - 13,287 calls match on result bits and the guarded buffer, for the original build and for the swapped-operand build against its own translation; - the swapped build differs from the original in every function (42, 1503, 273, 53, 2160 and 2650 calls); in `blend_ss`, where only `a + b` becomes `b + a`, the 42 differences are exactly inputs with two NaN operands; - 13 patched-instruction rejections and 8 signature rejections pass. - Inputs: zeros of both signs, denormals, infinities, quiet and signalling NaNs with distinct payloads, values around ±2^31 and ±2^63, narrowing ties, random patterns. - Generated sources compile with clang for `x86_64-pc-windows-msvc` under `-Wall -Wextra -Werror` and with clang-cl `/W4 /WX`. - Sensitivity: removing the destination-NaN test, removing both NaN tests, treating unordered as ordered, changing the `JBE` condition, dropping the sign extension in `CVTSI2SS`, or making a single-precision result or a register `MOVSS` overwrite bits 32-63 each fails `check()`. - `tests/form_coverage_check.py` passes; with the `CPU_FIXTURES` entry removed it fails in `check_scalar_float`. ## Evidence and follow-up - The default-NaN sign and the truncation range test are not distinguishable from plain C++ on an x64 host at the optimisation levels tried; they are kept because the C++ results are otherwise unspecified or undefined. - Exceptions are assumed masked. Rounding follows the thread's MXCSR in both the original and the translation (one host instruction per operation, `fp_contract` off). - Not covered and rejected: RIP-relative constants (the most common source of float constants in compiled code), packed operations, `SQRTSS`, `MINSS`/`MAXSS`, `CVTSS2SI`/`CVTSD2SI`, `MOVQ` with an integer register, `SETcc`/`CMOVcc` after a compare (depends on #173), stack frames, calls, and saving XMM6-XMM15. - The coverage dashboard is not regenerated here, to avoid a conflict with the regeneration in #257.
upstream-sync closed this pull request 2026-11-24 06:42:08 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:42:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:01:01Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c8fa8fbe2

ℹ️ 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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6007817870 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#pullrequestreview-6007817870). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T20:01:01Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `8c8fa8fbe2` <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>
Vonsek commented 2026-11-24 06:42:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:38:20Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6008004787 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#pullrequestreview-6008004787). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:38:20Z. **Review:** COMMENTED --- _No description provided._
R0Y00 commented 2026-11-24 06:47:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T19:59:19Z.


At 8c8fa8f, only CMakeLists.txt and tools/form_coverage.py conflict. Please keep the recently merged shift/address fixture registrations alongside cpu_aot_scalar_float, then rerun the scalar-float and form-coverage checks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068421643 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7068421643). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T19:59:19Z. --- At `8c8fa8f`, only `CMakeLists.txt` and `tools/form_coverage.py` conflict. Please keep the recently merged shift/address fixture registrations alongside `cpu_aot_scalar_float`, then rerun the scalar-float and form-coverage checks.
chatgpt-codex-connector[bot commented 2026-11-24 06:47:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T19:53:40Z.


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-21T20:01:03.968071Z 8c8fa8f 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068354891 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7068354891). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T19:53:40Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8c8fa8fbe2e911455f74bccd7b1333161aa64435","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-21T20:01:03.968071Z">2026-11-21T20:01:03.968071Z</relative-time> | `8c8fa8f` | 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>
Vonsek commented 2026-11-24 06:47:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:35:31Z.


Rebased on main 496fc28 (5d0c75c). Only CMakeLists.txt and tools/form_coverage.py conflicted: the cpu_aot_switch_addr32 fixture registration and its CPU_FIXTURES entry from main are kept beside cpu_aot_scalar_float. On Windows 11 26200.9974 (MSVC 14.44.35207, ML64 14.44.35230): cpu_aot_scalar_float and cpu_aot_switch_addr32 pass, tests/form_coverage_check.py passes, and the full suite passed 127/127.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068864118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7068864118). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:35:31Z. --- Rebased on main 496fc28 (5d0c75c). Only `CMakeLists.txt` and `tools/form_coverage.py` conflicted: the `cpu_aot_switch_addr32` fixture registration and its `CPU_FIXTURES` entry from main are kept beside `cpu_aot_scalar_float`. On Windows 11 26200.9974 (MSVC 14.44.35207, ML64 14.44.35230): `cpu_aot_scalar_float` and `cpu_aot_switch_addr32` pass, `tests/form_coverage_check.py` passes, and the full suite passed 127/127.
R0Y00 commented 2026-11-24 06:48:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T20:57:45Z.


At 1b186f29, Git reports conflicts in CMakeLists.txt and README.md. Please retain the newly merged CPU fixture registrations and the SSE/SSE2 capability and reproduction entries when rebasing.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069133890 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7069133890). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T20:57:45Z. --- At `1b186f29`, Git reports conflicts in `CMakeLists.txt` and `README.md`. Please retain the newly merged CPU fixture registrations and the SSE/SSE2 capability and reproduction entries when rebasing.
MarlomMedeiros commented 2026-11-24 06:48:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-21T21:03:32Z.


Heads up on coverage split: I am taking the AVX2 group in a separate tool (), scoped to register-domain forms (broadcast/permute i128, vpbroadcast, vperm{,2}, variable shifts, vpblendd) with gathers and vpmaskmov explicitly rejected pending a memory model. It shares only the registration points (CMakeLists, README, experiments, form_coverage) with your scalar SSE work, so the two can land in either order. The memory-domain AVX2 forms and the FP AVX/FMA groups stay open for whoever wants them.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069204143 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7069204143). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-21T21:03:32Z. --- Heads up on coverage split: I am taking the AVX2 group in a separate tool (), scoped to register-domain forms (broadcast/permute i128, vpbroadcast, vperm{,2}, variable shifts, vpblendd) with gathers and vpmaskmov explicitly rejected pending a memory model. It shares only the registration points (CMakeLists, README, experiments, form_coverage) with your scalar SSE work, so the two can land in either order. The memory-domain AVX2 forms and the FP AVX/FMA groups stay open for whoever wants them.
R0Y00 commented 2026-11-24 06:48:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:27:55Z.


At 399617c, the merge conflicts are in CMakeLists.txt. The conversion review is resolved. Please retain both cpu_aot_scalar_float and #285's narrow-return target and test registration.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069492456 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7069492456). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T21:27:55Z. --- At `399617c`, the merge conflicts are in `CMakeLists.txt`. The conversion review is resolved. Please retain both `cpu_aot_scalar_float` and #285's narrow-return target and test registration.
Leyukaka commented 2026-11-24 06:48:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T22:35:26Z.


A coverage note from reading the diff at 399617c, without building it.

The self-zeroing forms xorps xmm0,xmm0, pxor xmm1,xmm1 and xorpd xmm2,xmm2 appear only in from_int, and nothing there can observe them:

  • from_int is d:qq, so its XMM locals are declared = 0;
  • cvtsi2ss keeps bits 32–63 of xmm0 and xmm1, but movss stores only the low dword;
  • cvtsi2sd then replaces the whole modelled quadword of xmm2 and xmm0 before they are stored or returned.

Lowering the three forms to no assignment at all would still pass. A d:d leaf such as xorps xmm0,xmm0; ret, called with 1.0 and expected to return +0.0, would pin it, and the same applies to pxor/xorpd. Because check() requires every export to differ in the SWAP_OPERANDS build, such a leaf also needs a control variant.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070287455 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#issuecomment-7070287455). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T22:35:26Z. --- A coverage note from reading the diff at `399617c`, without building it. The self-zeroing forms `xorps xmm0,xmm0`, `pxor xmm1,xmm1` and `xorpd xmm2,xmm2` appear only in `from_int`, and nothing there can observe them: - `from_int` is `d:qq`, so its XMM locals are declared `= 0`; - `cvtsi2ss` keeps bits 32–63 of `xmm0` and `xmm1`, but `movss` stores only the low dword; - `cvtsi2sd` then replaces the whole modelled quadword of `xmm2` and `xmm0` before they are stored or returned. Lowering the three forms to no assignment at all would still pass. A `d:d` leaf such as `xorps xmm0,xmm0; ret`, called with 1.0 and expected to return +0.0, would pin it, and the same applies to `pxor`/`xorpd`. Because `check()` requires every export to differ in the `SWAP_OPERANDS` build, such a leaf also needs a control variant. _AI-assisted._
chatgpt-codex-connector[bot commented 2026-11-24 06:50:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T20:01:01Z.

Code review location: tools/cpu_sse_aot.py; line 197

@@ -0,0 +1,395 @@
+"""Recompile bounded Windows x64 leaf functions that use scalar SSE/SSE2 arithmetic to C++.
+
+Each export is named with its Windows x64 signature, `name=<result>:<slots>`, where every
+letter is `f` (float), `d` (double) or `q` (a 64-bit integer or pointer). Slot N arrives in
+XMM0-XMM3 when it is floating point and in RCX, RDX, R8 or R9 otherwise; the result leaves in
+XMM0 or RAX. Control flow and the integer instructions are those of cpu_switch_aot.
+
+Only the low quadword of an XMM register is modelled. Every supported instruction computes
+that quadword from low quadwords alone, so the upper half never reaches a result. The two
+dwords of the low quadword are tracked separately as defined or undefined: a float argument
+defines the low dword only, and a read of an undefined part is rejected.
+"""
+
+import argparse
+from pathlib import Path
+import re
+
+import pefile
+from iced_x86 import ConditionCode as CC, FlowControl, MemorySizeExt, Mnemonic as M, OpKind, Register as R, RegisterExt
+
+from cpu_leaf_aot import export_rva
+from cpu_switch_aot import ALU, Function, Lifter, NAMES, PRELUDE, VOLATILE, full, signed, unsigned
+
+
+SLOTS = (R.RCX, R.RDX, R.R8, R.R9)
+XMM_SLOTS = (R.XMM0, R.XMM1, R.XMM2, R.XMM3)
+XMM = {getattr(R, f"XMM{number}"): f"xmm{number}" for number in range(16)}
+VOLATILE_XMM = {getattr(R, f"XMM{number}") for number in range(6)}
+TYPES = {4: "float", 8: "double"}
+MOVES = {M.MOVSS: 4, M.MOVSD: 8}
+COPIES = {M.MOVAPS, M.MOVAPD, M.MOVUPS, M.MOVUPD}
+ARITHMETIC = {M.ADDSS: ("+", 4), M.SUBSS: ("-", 4), M.MULSS: ("*", 4), M.DIVSS: ("/", 4),
+              M.ADDSD: ("+", 8), M.SUBSD: ("-", 8), M.MULSD: ("*", 8), M.DIVSD: ("/", 8)}
+FROM_INTEGER = {M.CVTSI2SS: 4, M.CVTSI2SD: 8}
+TRUNCATIONS = {M.CVTTSS2SI: 4, M.CVTTSD2SI: 8}
+RESIZES = {M.CVTSS2SD: 4, M.CVTSD2SS: 8}
+COMPARES = {M.UCOMISS: 4, M.COMISS: 4, M.UCOMISD: 8, M.COMISD: 8}
+ZEROING = {M.XORPS, M.XORPD, M.PXOR}
+SCALAR = {*MOVES, *COPIES, *ARITHMETIC, *FROM_INTEGER, *TRUNCATIONS, *RESIZES, *COMPARES, *ZEROING, M.MOVD, M.MOVQ}
+# fc holds ZF, PF and CF of the last compare as bits 2, 1 and 0. An unordered compare sets all three.
+CONDITIONS = {CC.E: "(fc & 4u) != 0", CC.NE: "(fc & 4u) == 0", CC.B: "(fc & 1u) != 0", CC.AE: "(fc & 1u) == 0",
+              CC.BE: "(fc & 5u) != 0", CC.A: "(fc & 5u) == 0", CC.P: "(fc & 2u) != 0", CC.NP: "(fc & 2u) == 0"}
+
+
+def parts(register, width):
+    """Definedness keys of the low dword and, for a double, of bits 32-63."""
+    return {(register, 0)} if width == 4 else {(register, 0), (register, 1)}
+
+
+def describe(key):
+    if isinstance(key, tuple):
+        return XMM[key[0]] + ("[63:32]" if key[1] else "")
+    return NAMES[key]
+
+
+def parse_export(text):
+    match = re.fullmatch(r"(\w+)=([fdq]):([fdq]{0,4})", text)
+    if not match:
+        raise ValueError(f"invalid signature {text!r}: expected name=<result>:<slots> of f, d and q")
+    return match.groups()
+
+
+class LeafFunction(Function):
+    def constants(self):
+        """No register is tracked as a table base, so every indirect jump is rejected."""
+        return {}
+
+
+class ScalarLifter(Lifter):
+    def __init__(self, result):
+        super().__init__()
+        self.result = result
+        self.vectors = set()
+        self.compare = False
+        self.merges = []
+
+    def xmm(self, ins, number):
+        register = ins.op_register(number)
+        if ins.op_kind(number) != OpKind.REGISTER or register not in XMM:
+            raise ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}")
+        self.vectors.add(register)
+        return register
+
+    def pointer(self, ins, reads):
+        address = self.address(ins)
+        reads.update(full(r) for r in (ins.memory_base, ins.memory_index) if r != R.NONE)
+        return address
+
+    def source(self, ins, number, width, reads):
+        """The bits of a float or double operand, from an XMM register or from memory."""
+        if ins.op_kind(number) == OpKind.MEMORY and MemorySizeExt.size(ins.memory_size) == width:
+            return f"load<{unsigned(width)}>({self.pointer(ins, reads)})"
+        register = self.xmm(ins, number)
+        reads.update(parts(register, width))
+        return XMM[register] if width == 8 else f"static_cast<std::uint32_t>({XMM[register]})"
+
+    def assign(self, register, width, bits):
+        name = XMM[register]
+        return f"{name} = {bits};" if width == 8 else f"{name} = low({name}, {bits});"
+
+    def statement(self, ins, next_ins):
+        mnemonic = ins.mnemonic
+        reads, writes = set(), set()
+        self.merges = []
+        if mnemonic == M.RET and self.result != "q":
+            width = 4 if self.result == "f" else 8
+            self.vectors.add(R.XMM0)
+            bits = "xmm0" if width == 8 else "static_cast<std::uint32_t>(xmm0)"
+            return f"return cast<{TYPES[width]}>({bits});", parts(R.XMM0, width), writes
+        vector = any(ins.op_kind(n) == OpKind.REGISTER and not RegisterExt.is_gpr(ins.op_register(n))
+                     for n in range(ins.op_count))
+        unsupported = ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}")
+        if mnemonic not in SCALAR or ins.op_count != 2 or not all(
+                ins.op_kind(n) in (OpKind.REGISTER, OpKind.MEMORY) for n in range(2)):
+            if vector:
+                raise unsupported
+            return super().statement(ins, next_ins)
+
+        if mnemonic in MOVES or mnemonic in (M.MOVD, M.MOVQ):
+            width = MOVES.get(mnemonic, 4 if mnemonic == M.MOVD else 8)
+            if ins.op0_kind == OpKind.MEMORY:
+                if MemorySizeExt.size(ins.memory_size) != width:
+                    raise unsupported
+                bits = self.source(ins, 1, width, reads)
+                return f"store<{unsigned(width)}>({self.pointer(ins, reads)}, {bits});", reads, writes
+            if ins.op0_register not in XMM:
+                # MOVD r32, xmm zero-extends like any 32-bit write. MOVQ to or from an integer
+                # register is left out: ML64 versions disagree on how to spell it in a fixture.
+                if mnemonic != M.MOVD:
+                    raise unsupported
+                bits = self.source(ins, 1, 4, reads)
+                writes.add(full(ins.op0_register))
+                return self.write(ins, 4, bits), reads, writes
+            destination = self.xmm(ins, 0)
+            if ins.op1_kind == OpKind.REGISTER and ins.op1_register not in XMM:
+                if mnemonic != M.MOVD:
+                    raise unsupported
+                reads.add(full(ins.op1_register))
+                bits = self.operand(ins, 1, 4)
+            else:
+                bits = self.source(ins, 1, width, reads)
+            if mnemonic == M.MOVSS and ins.op1_kind == OpKind.REGISTER:
+                writes.update(parts(destination, 4))
+                return self.assign(destination, 4, bits), reads, writes
+            # Loads, MOVD, MOVQ and MOVSD between registers define the whole low quadword.
+            writes.update(parts(destination, 8))
+            return f"{XMM[destination]} = {bits};", reads, writes
+        if mnemonic in TRUNCATIONS:
+            width = RegisterExt.size(ins.op0_register) if ins.op0_kind == OpKind.REGISTER else 0
+            if width not in (4, 8) or not RegisterExt.is_gpr(ins.op0_register):
+                raise unsupported
+            source = TRUNCATIONS[mnemonic]
+            bits = self.source(ins, 1, source, reads)
+            writes.add(full(ins.op0_register))
+            value = f"truncate<{signed(width)}>(cast<{TYPES[source]}>({bits}))"
+            return self.write(ins, width, value), reads, writes
+
+        destination = self.xmm(ins, 0)
+        name = XMM[destination]
+        if mnemonic in COPIES or mnemonic in ZEROING:
+            source = self.xmm(ins, 1)
+            if mnemonic in ZEROING:
+                # Only the zeroing idiom: any other use combines the two registers bit by bit.
+                if source != destination:
+                    raise unsupported
+                writes.update(parts(destination, 8))
+                return f"{name} = 0;", reads, writes
+            # A register copy may carry undefined parts, which stay undefined in the copy.
+            self.merges = [((destination, half), (source, half)) for half in (0, 1)]
+            return f"{name} = {XMM[source]};", reads, writes
+        if mnemonic in ARITHMETIC:
+            operator, width = ARITHMETIC[mnemonic]
+            reads.update(parts(destination, width))
+            a = name if width == 8 else f"static_cast<std::uint32_t>({name})"
+            b = self.source(ins, 1, width, reads)
+            return self.assign(destination, width, f"arith<{TYPES[width]}>({a}, {b}, '{operator}')"), reads, writes
+        if mnemonic in FROM_INTEGER:
+            width = FROM_INTEGER[mnemonic]
+            if ins.op1_kind == OpKind.REGISTER:
+                source = RegisterExt.size(ins.op1_register)
+                if source not in (4, 8) or not RegisterExt.is_gpr(ins.op1_register):
+                    raise unsupported
+                reads.add(full(ins.op1_register))
+                integer = self.operand(ins, 1, source)
+            else:
+                source = MemorySizeExt.size(ins.memory_size)
+                integer = f"load<{unsigned(source)}>({self.pointer(ins, reads)})"
+            writes.update(parts(destination, width))
+            value = f"static_cast<{TYPES[width]}>(static_cast<{signed(source)}>({integer}))"
+            return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes
+        if mnemonic in RESIZES:
+            source = RESIZES[mnemonic]
+            width = 12 - source
+            bits = self.source(ins, 1, source, reads)
+            writes.update(parts(destination, width))
+            value = f"static_cast<{TYPES[width]}>(cast<{TYPES[source]}>({bits}))"
+            return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes

P2 Badge Preserve scalar conversions through host optimization

For a supported f:f leaf containing cvtss2sd xmm0,xmm0; cvtsd2ss xmm0,xmm0; ret, these plain C++ casts allow the host compiler to eliminate both conversions. Using the emitted statements and prelude, Clang 17 and GCC 13 on Linux reduce the function to ret at -O2: input 0x7f800001 returns unchanged instead of the native instructions' quieted 0x7fc00001. With DAZ enabled, denormal inputs also incorrectly survive instead of becoming zero. Disabling FP contraction does not prevent this optimization. Preserve instruction-level conversion semantics, for example through strict-FP controls, and add a chained-conversion regression case; Clang's strict-FP mode restores the native results in this reproducer.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4654705757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#discussion_r4654705757). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T20:01:01Z. **Code review location:** `tools/cpu_sse_aot.py`; line 197 ~~~~diff @@ -0,0 +1,395 @@ +"""Recompile bounded Windows x64 leaf functions that use scalar SSE/SSE2 arithmetic to C++. + +Each export is named with its Windows x64 signature, `name=<result>:<slots>`, where every +letter is `f` (float), `d` (double) or `q` (a 64-bit integer or pointer). Slot N arrives in +XMM0-XMM3 when it is floating point and in RCX, RDX, R8 or R9 otherwise; the result leaves in +XMM0 or RAX. Control flow and the integer instructions are those of cpu_switch_aot. + +Only the low quadword of an XMM register is modelled. Every supported instruction computes +that quadword from low quadwords alone, so the upper half never reaches a result. The two +dwords of the low quadword are tracked separately as defined or undefined: a float argument +defines the low dword only, and a read of an undefined part is rejected. +""" + +import argparse +from pathlib import Path +import re + +import pefile +from iced_x86 import ConditionCode as CC, FlowControl, MemorySizeExt, Mnemonic as M, OpKind, Register as R, RegisterExt + +from cpu_leaf_aot import export_rva +from cpu_switch_aot import ALU, Function, Lifter, NAMES, PRELUDE, VOLATILE, full, signed, unsigned + + +SLOTS = (R.RCX, R.RDX, R.R8, R.R9) +XMM_SLOTS = (R.XMM0, R.XMM1, R.XMM2, R.XMM3) +XMM = {getattr(R, f"XMM{number}"): f"xmm{number}" for number in range(16)} +VOLATILE_XMM = {getattr(R, f"XMM{number}") for number in range(6)} +TYPES = {4: "float", 8: "double"} +MOVES = {M.MOVSS: 4, M.MOVSD: 8} +COPIES = {M.MOVAPS, M.MOVAPD, M.MOVUPS, M.MOVUPD} +ARITHMETIC = {M.ADDSS: ("+", 4), M.SUBSS: ("-", 4), M.MULSS: ("*", 4), M.DIVSS: ("/", 4), + M.ADDSD: ("+", 8), M.SUBSD: ("-", 8), M.MULSD: ("*", 8), M.DIVSD: ("/", 8)} +FROM_INTEGER = {M.CVTSI2SS: 4, M.CVTSI2SD: 8} +TRUNCATIONS = {M.CVTTSS2SI: 4, M.CVTTSD2SI: 8} +RESIZES = {M.CVTSS2SD: 4, M.CVTSD2SS: 8} +COMPARES = {M.UCOMISS: 4, M.COMISS: 4, M.UCOMISD: 8, M.COMISD: 8} +ZEROING = {M.XORPS, M.XORPD, M.PXOR} +SCALAR = {*MOVES, *COPIES, *ARITHMETIC, *FROM_INTEGER, *TRUNCATIONS, *RESIZES, *COMPARES, *ZEROING, M.MOVD, M.MOVQ} +# fc holds ZF, PF and CF of the last compare as bits 2, 1 and 0. An unordered compare sets all three. +CONDITIONS = {CC.E: "(fc & 4u) != 0", CC.NE: "(fc & 4u) == 0", CC.B: "(fc & 1u) != 0", CC.AE: "(fc & 1u) == 0", + CC.BE: "(fc & 5u) != 0", CC.A: "(fc & 5u) == 0", CC.P: "(fc & 2u) != 0", CC.NP: "(fc & 2u) == 0"} + + +def parts(register, width): + """Definedness keys of the low dword and, for a double, of bits 32-63.""" + return {(register, 0)} if width == 4 else {(register, 0), (register, 1)} + + +def describe(key): + if isinstance(key, tuple): + return XMM[key[0]] + ("[63:32]" if key[1] else "") + return NAMES[key] + + +def parse_export(text): + match = re.fullmatch(r"(\w+)=([fdq]):([fdq]{0,4})", text) + if not match: + raise ValueError(f"invalid signature {text!r}: expected name=<result>:<slots> of f, d and q") + return match.groups() + + +class LeafFunction(Function): + def constants(self): + """No register is tracked as a table base, so every indirect jump is rejected.""" + return {} + + +class ScalarLifter(Lifter): + def __init__(self, result): + super().__init__() + self.result = result + self.vectors = set() + self.compare = False + self.merges = [] + + def xmm(self, ins, number): + register = ins.op_register(number) + if ins.op_kind(number) != OpKind.REGISTER or register not in XMM: + raise ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}") + self.vectors.add(register) + return register + + def pointer(self, ins, reads): + address = self.address(ins) + reads.update(full(r) for r in (ins.memory_base, ins.memory_index) if r != R.NONE) + return address + + def source(self, ins, number, width, reads): + """The bits of a float or double operand, from an XMM register or from memory.""" + if ins.op_kind(number) == OpKind.MEMORY and MemorySizeExt.size(ins.memory_size) == width: + return f"load<{unsigned(width)}>({self.pointer(ins, reads)})" + register = self.xmm(ins, number) + reads.update(parts(register, width)) + return XMM[register] if width == 8 else f"static_cast<std::uint32_t>({XMM[register]})" + + def assign(self, register, width, bits): + name = XMM[register] + return f"{name} = {bits};" if width == 8 else f"{name} = low({name}, {bits});" + + def statement(self, ins, next_ins): + mnemonic = ins.mnemonic + reads, writes = set(), set() + self.merges = [] + if mnemonic == M.RET and self.result != "q": + width = 4 if self.result == "f" else 8 + self.vectors.add(R.XMM0) + bits = "xmm0" if width == 8 else "static_cast<std::uint32_t>(xmm0)" + return f"return cast<{TYPES[width]}>({bits});", parts(R.XMM0, width), writes + vector = any(ins.op_kind(n) == OpKind.REGISTER and not RegisterExt.is_gpr(ins.op_register(n)) + for n in range(ins.op_count)) + unsupported = ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}") + if mnemonic not in SCALAR or ins.op_count != 2 or not all( + ins.op_kind(n) in (OpKind.REGISTER, OpKind.MEMORY) for n in range(2)): + if vector: + raise unsupported + return super().statement(ins, next_ins) + + if mnemonic in MOVES or mnemonic in (M.MOVD, M.MOVQ): + width = MOVES.get(mnemonic, 4 if mnemonic == M.MOVD else 8) + if ins.op0_kind == OpKind.MEMORY: + if MemorySizeExt.size(ins.memory_size) != width: + raise unsupported + bits = self.source(ins, 1, width, reads) + return f"store<{unsigned(width)}>({self.pointer(ins, reads)}, {bits});", reads, writes + if ins.op0_register not in XMM: + # MOVD r32, xmm zero-extends like any 32-bit write. MOVQ to or from an integer + # register is left out: ML64 versions disagree on how to spell it in a fixture. + if mnemonic != M.MOVD: + raise unsupported + bits = self.source(ins, 1, 4, reads) + writes.add(full(ins.op0_register)) + return self.write(ins, 4, bits), reads, writes + destination = self.xmm(ins, 0) + if ins.op1_kind == OpKind.REGISTER and ins.op1_register not in XMM: + if mnemonic != M.MOVD: + raise unsupported + reads.add(full(ins.op1_register)) + bits = self.operand(ins, 1, 4) + else: + bits = self.source(ins, 1, width, reads) + if mnemonic == M.MOVSS and ins.op1_kind == OpKind.REGISTER: + writes.update(parts(destination, 4)) + return self.assign(destination, 4, bits), reads, writes + # Loads, MOVD, MOVQ and MOVSD between registers define the whole low quadword. + writes.update(parts(destination, 8)) + return f"{XMM[destination]} = {bits};", reads, writes + if mnemonic in TRUNCATIONS: + width = RegisterExt.size(ins.op0_register) if ins.op0_kind == OpKind.REGISTER else 0 + if width not in (4, 8) or not RegisterExt.is_gpr(ins.op0_register): + raise unsupported + source = TRUNCATIONS[mnemonic] + bits = self.source(ins, 1, source, reads) + writes.add(full(ins.op0_register)) + value = f"truncate<{signed(width)}>(cast<{TYPES[source]}>({bits}))" + return self.write(ins, width, value), reads, writes + + destination = self.xmm(ins, 0) + name = XMM[destination] + if mnemonic in COPIES or mnemonic in ZEROING: + source = self.xmm(ins, 1) + if mnemonic in ZEROING: + # Only the zeroing idiom: any other use combines the two registers bit by bit. + if source != destination: + raise unsupported + writes.update(parts(destination, 8)) + return f"{name} = 0;", reads, writes + # A register copy may carry undefined parts, which stay undefined in the copy. + self.merges = [((destination, half), (source, half)) for half in (0, 1)] + return f"{name} = {XMM[source]};", reads, writes + if mnemonic in ARITHMETIC: + operator, width = ARITHMETIC[mnemonic] + reads.update(parts(destination, width)) + a = name if width == 8 else f"static_cast<std::uint32_t>({name})" + b = self.source(ins, 1, width, reads) + return self.assign(destination, width, f"arith<{TYPES[width]}>({a}, {b}, '{operator}')"), reads, writes + if mnemonic in FROM_INTEGER: + width = FROM_INTEGER[mnemonic] + if ins.op1_kind == OpKind.REGISTER: + source = RegisterExt.size(ins.op1_register) + if source not in (4, 8) or not RegisterExt.is_gpr(ins.op1_register): + raise unsupported + reads.add(full(ins.op1_register)) + integer = self.operand(ins, 1, source) + else: + source = MemorySizeExt.size(ins.memory_size) + integer = f"load<{unsigned(source)}>({self.pointer(ins, reads)})" + writes.update(parts(destination, width)) + value = f"static_cast<{TYPES[width]}>(static_cast<{signed(source)}>({integer}))" + return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes + if mnemonic in RESIZES: + source = RESIZES[mnemonic] + width = 12 - source + bits = self.source(ins, 1, source, reads) + writes.update(parts(destination, width)) + value = f"static_cast<{TYPES[width]}>(cast<{TYPES[source]}>({bits}))" + return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve scalar conversions through host optimization** For a supported `f:f` leaf containing `cvtss2sd xmm0,xmm0; cvtsd2ss xmm0,xmm0; ret`, these plain C++ casts allow the host compiler to eliminate both conversions. Using the emitted statements and prelude, Clang 17 and GCC 13 on Linux reduce the function to `ret` at `-O2`: input `0x7f800001` returns unchanged instead of the native instructions' quieted `0x7fc00001`. With DAZ enabled, denormal inputs also incorrectly survive instead of becoming zero. Disabling FP contraction does not prevent this optimization. Preserve instruction-level conversion semantics, for example through strict-FP controls, and add a chained-conversion regression case; Clang's strict-FP mode restores the native results in this reproducer. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Vonsek commented 2026-11-24 06:50:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:38:20Z.

Code review location: tools/cpu_sse_aot.py; line 197

@@ -0,0 +1,395 @@
+"""Recompile bounded Windows x64 leaf functions that use scalar SSE/SSE2 arithmetic to C++.
+
+Each export is named with its Windows x64 signature, `name=<result>:<slots>`, where every
+letter is `f` (float), `d` (double) or `q` (a 64-bit integer or pointer). Slot N arrives in
+XMM0-XMM3 when it is floating point and in RCX, RDX, R8 or R9 otherwise; the result leaves in
+XMM0 or RAX. Control flow and the integer instructions are those of cpu_switch_aot.
+
+Only the low quadword of an XMM register is modelled. Every supported instruction computes
+that quadword from low quadwords alone, so the upper half never reaches a result. The two
+dwords of the low quadword are tracked separately as defined or undefined: a float argument
+defines the low dword only, and a read of an undefined part is rejected.
+"""
+
+import argparse
+from pathlib import Path
+import re
+
+import pefile
+from iced_x86 import ConditionCode as CC, FlowControl, MemorySizeExt, Mnemonic as M, OpKind, Register as R, RegisterExt
+
+from cpu_leaf_aot import export_rva
+from cpu_switch_aot import ALU, Function, Lifter, NAMES, PRELUDE, VOLATILE, full, signed, unsigned
+
+
+SLOTS = (R.RCX, R.RDX, R.R8, R.R9)
+XMM_SLOTS = (R.XMM0, R.XMM1, R.XMM2, R.XMM3)
+XMM = {getattr(R, f"XMM{number}"): f"xmm{number}" for number in range(16)}
+VOLATILE_XMM = {getattr(R, f"XMM{number}") for number in range(6)}
+TYPES = {4: "float", 8: "double"}
+MOVES = {M.MOVSS: 4, M.MOVSD: 8}
+COPIES = {M.MOVAPS, M.MOVAPD, M.MOVUPS, M.MOVUPD}
+ARITHMETIC = {M.ADDSS: ("+", 4), M.SUBSS: ("-", 4), M.MULSS: ("*", 4), M.DIVSS: ("/", 4),
+              M.ADDSD: ("+", 8), M.SUBSD: ("-", 8), M.MULSD: ("*", 8), M.DIVSD: ("/", 8)}
+FROM_INTEGER = {M.CVTSI2SS: 4, M.CVTSI2SD: 8}
+TRUNCATIONS = {M.CVTTSS2SI: 4, M.CVTTSD2SI: 8}
+RESIZES = {M.CVTSS2SD: 4, M.CVTSD2SS: 8}
+COMPARES = {M.UCOMISS: 4, M.COMISS: 4, M.UCOMISD: 8, M.COMISD: 8}
+ZEROING = {M.XORPS, M.XORPD, M.PXOR}
+SCALAR = {*MOVES, *COPIES, *ARITHMETIC, *FROM_INTEGER, *TRUNCATIONS, *RESIZES, *COMPARES, *ZEROING, M.MOVD, M.MOVQ}
+# fc holds ZF, PF and CF of the last compare as bits 2, 1 and 0. An unordered compare sets all three.
+CONDITIONS = {CC.E: "(fc & 4u) != 0", CC.NE: "(fc & 4u) == 0", CC.B: "(fc & 1u) != 0", CC.AE: "(fc & 1u) == 0",
+              CC.BE: "(fc & 5u) != 0", CC.A: "(fc & 5u) == 0", CC.P: "(fc & 2u) != 0", CC.NP: "(fc & 2u) == 0"}
+
+
+def parts(register, width):
+    """Definedness keys of the low dword and, for a double, of bits 32-63."""
+    return {(register, 0)} if width == 4 else {(register, 0), (register, 1)}
+
+
+def describe(key):
+    if isinstance(key, tuple):
+        return XMM[key[0]] + ("[63:32]" if key[1] else "")
+    return NAMES[key]
+
+
+def parse_export(text):
+    match = re.fullmatch(r"(\w+)=([fdq]):([fdq]{0,4})", text)
+    if not match:
+        raise ValueError(f"invalid signature {text!r}: expected name=<result>:<slots> of f, d and q")
+    return match.groups()
+
+
+class LeafFunction(Function):
+    def constants(self):
+        """No register is tracked as a table base, so every indirect jump is rejected."""
+        return {}
+
+
+class ScalarLifter(Lifter):
+    def __init__(self, result):
+        super().__init__()
+        self.result = result
+        self.vectors = set()
+        self.compare = False
+        self.merges = []
+
+    def xmm(self, ins, number):
+        register = ins.op_register(number)
+        if ins.op_kind(number) != OpKind.REGISTER or register not in XMM:
+            raise ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}")
+        self.vectors.add(register)
+        return register
+
+    def pointer(self, ins, reads):
+        address = self.address(ins)
+        reads.update(full(r) for r in (ins.memory_base, ins.memory_index) if r != R.NONE)
+        return address
+
+    def source(self, ins, number, width, reads):
+        """The bits of a float or double operand, from an XMM register or from memory."""
+        if ins.op_kind(number) == OpKind.MEMORY and MemorySizeExt.size(ins.memory_size) == width:
+            return f"load<{unsigned(width)}>({self.pointer(ins, reads)})"
+        register = self.xmm(ins, number)
+        reads.update(parts(register, width))
+        return XMM[register] if width == 8 else f"static_cast<std::uint32_t>({XMM[register]})"
+
+    def assign(self, register, width, bits):
+        name = XMM[register]
+        return f"{name} = {bits};" if width == 8 else f"{name} = low({name}, {bits});"
+
+    def statement(self, ins, next_ins):
+        mnemonic = ins.mnemonic
+        reads, writes = set(), set()
+        self.merges = []
+        if mnemonic == M.RET and self.result != "q":
+            width = 4 if self.result == "f" else 8
+            self.vectors.add(R.XMM0)
+            bits = "xmm0" if width == 8 else "static_cast<std::uint32_t>(xmm0)"
+            return f"return cast<{TYPES[width]}>({bits});", parts(R.XMM0, width), writes
+        vector = any(ins.op_kind(n) == OpKind.REGISTER and not RegisterExt.is_gpr(ins.op_register(n))
+                     for n in range(ins.op_count))
+        unsupported = ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}")
+        if mnemonic not in SCALAR or ins.op_count != 2 or not all(
+                ins.op_kind(n) in (OpKind.REGISTER, OpKind.MEMORY) for n in range(2)):
+            if vector:
+                raise unsupported
+            return super().statement(ins, next_ins)
+
+        if mnemonic in MOVES or mnemonic in (M.MOVD, M.MOVQ):
+            width = MOVES.get(mnemonic, 4 if mnemonic == M.MOVD else 8)
+            if ins.op0_kind == OpKind.MEMORY:
+                if MemorySizeExt.size(ins.memory_size) != width:
+                    raise unsupported
+                bits = self.source(ins, 1, width, reads)
+                return f"store<{unsigned(width)}>({self.pointer(ins, reads)}, {bits});", reads, writes
+            if ins.op0_register not in XMM:
+                # MOVD r32, xmm zero-extends like any 32-bit write. MOVQ to or from an integer
+                # register is left out: ML64 versions disagree on how to spell it in a fixture.
+                if mnemonic != M.MOVD:
+                    raise unsupported
+                bits = self.source(ins, 1, 4, reads)
+                writes.add(full(ins.op0_register))
+                return self.write(ins, 4, bits), reads, writes
+            destination = self.xmm(ins, 0)
+            if ins.op1_kind == OpKind.REGISTER and ins.op1_register not in XMM:
+                if mnemonic != M.MOVD:
+                    raise unsupported
+                reads.add(full(ins.op1_register))
+                bits = self.operand(ins, 1, 4)
+            else:
+                bits = self.source(ins, 1, width, reads)
+            if mnemonic == M.MOVSS and ins.op1_kind == OpKind.REGISTER:
+                writes.update(parts(destination, 4))
+                return self.assign(destination, 4, bits), reads, writes
+            # Loads, MOVD, MOVQ and MOVSD between registers define the whole low quadword.
+            writes.update(parts(destination, 8))
+            return f"{XMM[destination]} = {bits};", reads, writes
+        if mnemonic in TRUNCATIONS:
+            width = RegisterExt.size(ins.op0_register) if ins.op0_kind == OpKind.REGISTER else 0
+            if width not in (4, 8) or not RegisterExt.is_gpr(ins.op0_register):
+                raise unsupported
+            source = TRUNCATIONS[mnemonic]
+            bits = self.source(ins, 1, source, reads)
+            writes.add(full(ins.op0_register))
+            value = f"truncate<{signed(width)}>(cast<{TYPES[source]}>({bits}))"
+            return self.write(ins, width, value), reads, writes
+
+        destination = self.xmm(ins, 0)
+        name = XMM[destination]
+        if mnemonic in COPIES or mnemonic in ZEROING:
+            source = self.xmm(ins, 1)
+            if mnemonic in ZEROING:
+                # Only the zeroing idiom: any other use combines the two registers bit by bit.
+                if source != destination:
+                    raise unsupported
+                writes.update(parts(destination, 8))
+                return f"{name} = 0;", reads, writes
+            # A register copy may carry undefined parts, which stay undefined in the copy.
+            self.merges = [((destination, half), (source, half)) for half in (0, 1)]
+            return f"{name} = {XMM[source]};", reads, writes
+        if mnemonic in ARITHMETIC:
+            operator, width = ARITHMETIC[mnemonic]
+            reads.update(parts(destination, width))
+            a = name if width == 8 else f"static_cast<std::uint32_t>({name})"
+            b = self.source(ins, 1, width, reads)
+            return self.assign(destination, width, f"arith<{TYPES[width]}>({a}, {b}, '{operator}')"), reads, writes
+        if mnemonic in FROM_INTEGER:
+            width = FROM_INTEGER[mnemonic]
+            if ins.op1_kind == OpKind.REGISTER:
+                source = RegisterExt.size(ins.op1_register)
+                if source not in (4, 8) or not RegisterExt.is_gpr(ins.op1_register):
+                    raise unsupported
+                reads.add(full(ins.op1_register))
+                integer = self.operand(ins, 1, source)
+            else:
+                source = MemorySizeExt.size(ins.memory_size)
+                integer = f"load<{unsigned(source)}>({self.pointer(ins, reads)})"
+            writes.update(parts(destination, width))
+            value = f"static_cast<{TYPES[width]}>(static_cast<{signed(source)}>({integer}))"
+            return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes
+        if mnemonic in RESIZES:
+            source = RESIZES[mnemonic]
+            width = 12 - source
+            bits = self.source(ins, 1, source, reads)
+            writes.update(parts(destination, width))
+            value = f"static_cast<{TYPES[width]}>(cast<{TYPES[source]}>({bits}))"
+            return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes

Fixed in 1b186f2. CVTSS2SD and CVTSD2SS now go through a resize() helper that reads its input from a volatile, so each conversion is performed and a pair cannot be folded to an identity: a signalling NaN is quieted at each step and, with DAZ set, a denormal input is flushed as on hardware.

The fixture gains round_trip=f:f (cvtss2sd xmm0, xmm0; cvtsd2ss xmm0, xmm0; ret), with fixed results 0x7f800001 -> 0x7fc00001 and 0xffa00000 -> 0xffe00000 (quieted), a quiet NaN and -2.75 unchanged, and the full single-precision input set in the differential run. Its SWAP_OPERANDS build replaces the pair with MOVSS and must differ from the original only for signalling NaNs (3 inputs). On Windows 11 26200 the test passes in Debug and Release; MSVC (default /fp:precise) kept both conversions even before the change, so the reported Clang/GCC -O2 folding is not reproducible with MSVC, but the generated source no longer depends on it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4654866221 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/269#discussion_r4654866221). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:38:20Z. **Code review location:** `tools/cpu_sse_aot.py`; line 197 ~~~~diff @@ -0,0 +1,395 @@ +"""Recompile bounded Windows x64 leaf functions that use scalar SSE/SSE2 arithmetic to C++. + +Each export is named with its Windows x64 signature, `name=<result>:<slots>`, where every +letter is `f` (float), `d` (double) or `q` (a 64-bit integer or pointer). Slot N arrives in +XMM0-XMM3 when it is floating point and in RCX, RDX, R8 or R9 otherwise; the result leaves in +XMM0 or RAX. Control flow and the integer instructions are those of cpu_switch_aot. + +Only the low quadword of an XMM register is modelled. Every supported instruction computes +that quadword from low quadwords alone, so the upper half never reaches a result. The two +dwords of the low quadword are tracked separately as defined or undefined: a float argument +defines the low dword only, and a read of an undefined part is rejected. +""" + +import argparse +from pathlib import Path +import re + +import pefile +from iced_x86 import ConditionCode as CC, FlowControl, MemorySizeExt, Mnemonic as M, OpKind, Register as R, RegisterExt + +from cpu_leaf_aot import export_rva +from cpu_switch_aot import ALU, Function, Lifter, NAMES, PRELUDE, VOLATILE, full, signed, unsigned + + +SLOTS = (R.RCX, R.RDX, R.R8, R.R9) +XMM_SLOTS = (R.XMM0, R.XMM1, R.XMM2, R.XMM3) +XMM = {getattr(R, f"XMM{number}"): f"xmm{number}" for number in range(16)} +VOLATILE_XMM = {getattr(R, f"XMM{number}") for number in range(6)} +TYPES = {4: "float", 8: "double"} +MOVES = {M.MOVSS: 4, M.MOVSD: 8} +COPIES = {M.MOVAPS, M.MOVAPD, M.MOVUPS, M.MOVUPD} +ARITHMETIC = {M.ADDSS: ("+", 4), M.SUBSS: ("-", 4), M.MULSS: ("*", 4), M.DIVSS: ("/", 4), + M.ADDSD: ("+", 8), M.SUBSD: ("-", 8), M.MULSD: ("*", 8), M.DIVSD: ("/", 8)} +FROM_INTEGER = {M.CVTSI2SS: 4, M.CVTSI2SD: 8} +TRUNCATIONS = {M.CVTTSS2SI: 4, M.CVTTSD2SI: 8} +RESIZES = {M.CVTSS2SD: 4, M.CVTSD2SS: 8} +COMPARES = {M.UCOMISS: 4, M.COMISS: 4, M.UCOMISD: 8, M.COMISD: 8} +ZEROING = {M.XORPS, M.XORPD, M.PXOR} +SCALAR = {*MOVES, *COPIES, *ARITHMETIC, *FROM_INTEGER, *TRUNCATIONS, *RESIZES, *COMPARES, *ZEROING, M.MOVD, M.MOVQ} +# fc holds ZF, PF and CF of the last compare as bits 2, 1 and 0. An unordered compare sets all three. +CONDITIONS = {CC.E: "(fc & 4u) != 0", CC.NE: "(fc & 4u) == 0", CC.B: "(fc & 1u) != 0", CC.AE: "(fc & 1u) == 0", + CC.BE: "(fc & 5u) != 0", CC.A: "(fc & 5u) == 0", CC.P: "(fc & 2u) != 0", CC.NP: "(fc & 2u) == 0"} + + +def parts(register, width): + """Definedness keys of the low dword and, for a double, of bits 32-63.""" + return {(register, 0)} if width == 4 else {(register, 0), (register, 1)} + + +def describe(key): + if isinstance(key, tuple): + return XMM[key[0]] + ("[63:32]" if key[1] else "") + return NAMES[key] + + +def parse_export(text): + match = re.fullmatch(r"(\w+)=([fdq]):([fdq]{0,4})", text) + if not match: + raise ValueError(f"invalid signature {text!r}: expected name=<result>:<slots> of f, d and q") + return match.groups() + + +class LeafFunction(Function): + def constants(self): + """No register is tracked as a table base, so every indirect jump is rejected.""" + return {} + + +class ScalarLifter(Lifter): + def __init__(self, result): + super().__init__() + self.result = result + self.vectors = set() + self.compare = False + self.merges = [] + + def xmm(self, ins, number): + register = ins.op_register(number) + if ins.op_kind(number) != OpKind.REGISTER or register not in XMM: + raise ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}") + self.vectors.add(register) + return register + + def pointer(self, ins, reads): + address = self.address(ins) + reads.update(full(r) for r in (ins.memory_base, ins.memory_index) if r != R.NONE) + return address + + def source(self, ins, number, width, reads): + """The bits of a float or double operand, from an XMM register or from memory.""" + if ins.op_kind(number) == OpKind.MEMORY and MemorySizeExt.size(ins.memory_size) == width: + return f"load<{unsigned(width)}>({self.pointer(ins, reads)})" + register = self.xmm(ins, number) + reads.update(parts(register, width)) + return XMM[register] if width == 8 else f"static_cast<std::uint32_t>({XMM[register]})" + + def assign(self, register, width, bits): + name = XMM[register] + return f"{name} = {bits};" if width == 8 else f"{name} = low({name}, {bits});" + + def statement(self, ins, next_ins): + mnemonic = ins.mnemonic + reads, writes = set(), set() + self.merges = [] + if mnemonic == M.RET and self.result != "q": + width = 4 if self.result == "f" else 8 + self.vectors.add(R.XMM0) + bits = "xmm0" if width == 8 else "static_cast<std::uint32_t>(xmm0)" + return f"return cast<{TYPES[width]}>({bits});", parts(R.XMM0, width), writes + vector = any(ins.op_kind(n) == OpKind.REGISTER and not RegisterExt.is_gpr(ins.op_register(n)) + for n in range(ins.op_count)) + unsupported = ValueError(f"unsupported instruction at RVA {ins.ip:#x}: {ins}") + if mnemonic not in SCALAR or ins.op_count != 2 or not all( + ins.op_kind(n) in (OpKind.REGISTER, OpKind.MEMORY) for n in range(2)): + if vector: + raise unsupported + return super().statement(ins, next_ins) + + if mnemonic in MOVES or mnemonic in (M.MOVD, M.MOVQ): + width = MOVES.get(mnemonic, 4 if mnemonic == M.MOVD else 8) + if ins.op0_kind == OpKind.MEMORY: + if MemorySizeExt.size(ins.memory_size) != width: + raise unsupported + bits = self.source(ins, 1, width, reads) + return f"store<{unsigned(width)}>({self.pointer(ins, reads)}, {bits});", reads, writes + if ins.op0_register not in XMM: + # MOVD r32, xmm zero-extends like any 32-bit write. MOVQ to or from an integer + # register is left out: ML64 versions disagree on how to spell it in a fixture. + if mnemonic != M.MOVD: + raise unsupported + bits = self.source(ins, 1, 4, reads) + writes.add(full(ins.op0_register)) + return self.write(ins, 4, bits), reads, writes + destination = self.xmm(ins, 0) + if ins.op1_kind == OpKind.REGISTER and ins.op1_register not in XMM: + if mnemonic != M.MOVD: + raise unsupported + reads.add(full(ins.op1_register)) + bits = self.operand(ins, 1, 4) + else: + bits = self.source(ins, 1, width, reads) + if mnemonic == M.MOVSS and ins.op1_kind == OpKind.REGISTER: + writes.update(parts(destination, 4)) + return self.assign(destination, 4, bits), reads, writes + # Loads, MOVD, MOVQ and MOVSD between registers define the whole low quadword. + writes.update(parts(destination, 8)) + return f"{XMM[destination]} = {bits};", reads, writes + if mnemonic in TRUNCATIONS: + width = RegisterExt.size(ins.op0_register) if ins.op0_kind == OpKind.REGISTER else 0 + if width not in (4, 8) or not RegisterExt.is_gpr(ins.op0_register): + raise unsupported + source = TRUNCATIONS[mnemonic] + bits = self.source(ins, 1, source, reads) + writes.add(full(ins.op0_register)) + value = f"truncate<{signed(width)}>(cast<{TYPES[source]}>({bits}))" + return self.write(ins, width, value), reads, writes + + destination = self.xmm(ins, 0) + name = XMM[destination] + if mnemonic in COPIES or mnemonic in ZEROING: + source = self.xmm(ins, 1) + if mnemonic in ZEROING: + # Only the zeroing idiom: any other use combines the two registers bit by bit. + if source != destination: + raise unsupported + writes.update(parts(destination, 8)) + return f"{name} = 0;", reads, writes + # A register copy may carry undefined parts, which stay undefined in the copy. + self.merges = [((destination, half), (source, half)) for half in (0, 1)] + return f"{name} = {XMM[source]};", reads, writes + if mnemonic in ARITHMETIC: + operator, width = ARITHMETIC[mnemonic] + reads.update(parts(destination, width)) + a = name if width == 8 else f"static_cast<std::uint32_t>({name})" + b = self.source(ins, 1, width, reads) + return self.assign(destination, width, f"arith<{TYPES[width]}>({a}, {b}, '{operator}')"), reads, writes + if mnemonic in FROM_INTEGER: + width = FROM_INTEGER[mnemonic] + if ins.op1_kind == OpKind.REGISTER: + source = RegisterExt.size(ins.op1_register) + if source not in (4, 8) or not RegisterExt.is_gpr(ins.op1_register): + raise unsupported + reads.add(full(ins.op1_register)) + integer = self.operand(ins, 1, source) + else: + source = MemorySizeExt.size(ins.memory_size) + integer = f"load<{unsigned(source)}>({self.pointer(ins, reads)})" + writes.update(parts(destination, width)) + value = f"static_cast<{TYPES[width]}>(static_cast<{signed(source)}>({integer}))" + return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes + if mnemonic in RESIZES: + source = RESIZES[mnemonic] + width = 12 - source + bits = self.source(ins, 1, source, reads) + writes.update(parts(destination, width)) + value = f"static_cast<{TYPES[width]}>(cast<{TYPES[source]}>({bits}))" + return self.assign(destination, width, f"cast<{unsigned(width)}>({value})"), reads, writes ~~~~ --- Fixed in 1b186f2. `CVTSS2SD` and `CVTSD2SS` now go through a `resize()` helper that reads its input from a `volatile`, so each conversion is performed and a pair cannot be folded to an identity: a signalling NaN is quieted at each step and, with DAZ set, a denormal input is flushed as on hardware. The fixture gains `round_trip=f:f` (`cvtss2sd xmm0, xmm0; cvtsd2ss xmm0, xmm0; ret`), with fixed results `0x7f800001 -> 0x7fc00001` and `0xffa00000 -> 0xffe00000` (quieted), a quiet NaN and -2.75 unchanged, and the full single-precision input set in the differential run. Its `SWAP_OPERANDS` build replaces the pair with `MOVSS` and must differ from the original only for signalling NaNs (3 inputs). On Windows 11 26200 the test passes in Debug and Release; MSVC (default `/fp:precise`) kept both conversions even before the change, so the reported Clang/GCC `-O2` folding is not reproducible with MSVC, but the generated source no longer depends on it.
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!265
No description provided.