cpu: lower scalar SQRT, MIN and MAX in the scalar SSE translator #1161

Merged
tedin7 merged 5 commits from upstream-pr/1168 into main 2026-11-24 05:40:12 +00:00
tedin7 commented 2026-11-24 02:21:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:21:27Z.


Change

tools/cpu_sse_aot.py now lowers the scalar SQRTSS, SQRTSD, MINSS, MAXSS, MINSD and MAXSD in bounded leaf functions, register and memory source. Before this change the translator refused them with unsupported instruction.

  • SQRT: only the source is read and only the low dword or qword of the destination is replaced. A NaN comes back quieted with its payload, a negative operand other than -0 gives the default NaN (sign set), -0 stays -0.
  • MIN and MAX: the destination is kept only when the compare is true, so equal values (+0 against -0 in either order) and any NaN give the source operand unchanged, with a signalling NaN not quieted.
  • MXCSR: the generated code runs under the host MXCSR. A guest MXCSR write is not lifted, so rounding mode, DAZ and FTZ are the host's and exception flags are not observed. Declared in the docs and in the translator docstring, not covered by the checks.

Advances the scalar SSE translator coverage in docs/experiments.md. No overlapping open PR (searched for sqrt, min, max, scalar and SSE).

Verification

Assembled with llvm-ml-19, linked with lld-link-19, original machine code run through a Windows-ABI trampoline on Linux x86-64, translation built with clang++-19 at -O0, -O2 and -O3:

  • python3 -B tests/cpu/scalar_float_check.py <original.dll> <lifted> <swapped.dll> <swapped lifted>: 82 fixed results and 26,597 calls match on result and guarded buffer, for the original and the control build, at every optimization level. 27 patched-instruction rejections and 12 signature rejections pass.
  • python3 -B tests/form_coverage_check.py: passes (SSE and SSE2 fixture forms 11 to 14 each).
  • python3 -B tests/docs_links_check.py: passes.
  • Negative control: with tools/cpu_sse_aot.py from origin/main the new fixture fails at translation (unsupported instruction at RVA 0x1230: minss xmm2,xmm1). With MINSS lowered to > the check fails at min_ss(2.0, 1.0). With the NaN quieting removed from SQRT it fails at root_ss(0x7f800001).
  • The Windows MASM/MSVC run of cpu_aot_scalar_float has not been run by me. CI runs it.

Evidence and follow-up

  • New fixture code is original MASM in tests/cpu/scalar_float.asm, six new exports (min_ss, max_ss, min_sd, max_sd, root_ss, root_sd). Each applies its instruction with a register operand and with a memory operand at an odd offset over a seeded buffer.
  • Independent reference: exact Python arithmetic in the check, no host instruction and none of the translator. It is compared with the processor on every call, over the whole guarded buffer, so nothing outside the intended words may change (the memory forms are unaligned loads only, no new store forms).
  • Controls: a build with swapped MIN/MAX operands (must differ only for NaN or equal values), a SQRTSS build that zeroes the destination first, a SQRTSD build that copies instead of rooting, and eleven deliberately wrong reference rules that must each disagree with the processor on some call.
  • Not covered: RSQRTSS and RCPSS, packed forms, guest MXCSR (DAZ, FTZ, rounding mode), exception flags.
  • AI-assisted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6573158433 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:21:27Z. --- ## Change `tools/cpu_sse_aot.py` now lowers the scalar `SQRTSS`, `SQRTSD`, `MINSS`, `MAXSS`, `MINSD` and `MAXSD` in bounded leaf functions, register and memory source. Before this change the translator refused them with `unsupported instruction`. - SQRT: only the source is read and only the low dword or qword of the destination is replaced. A NaN comes back quieted with its payload, a negative operand other than -0 gives the default NaN (sign set), -0 stays -0. - MIN and MAX: the destination is kept only when the compare is true, so equal values (+0 against -0 in either order) and any NaN give the source operand unchanged, with a signalling NaN not quieted. - MXCSR: the generated code runs under the host MXCSR. A guest MXCSR write is not lifted, so rounding mode, DAZ and FTZ are the host's and exception flags are not observed. Declared in the docs and in the translator docstring, not covered by the checks. Advances the scalar SSE translator coverage in `docs/experiments.md`. No overlapping open PR (searched for sqrt, min, max, scalar and SSE). ## Verification Assembled with `llvm-ml-19`, linked with `lld-link-19`, original machine code run through a Windows-ABI trampoline on Linux x86-64, translation built with clang++-19 at -O0, -O2 and -O3: - `python3 -B tests/cpu/scalar_float_check.py <original.dll> <lifted> <swapped.dll> <swapped lifted>`: 82 fixed results and 26,597 calls match on result and guarded buffer, for the original and the control build, at every optimization level. 27 patched-instruction rejections and 12 signature rejections pass. - `python3 -B tests/form_coverage_check.py`: passes (SSE and SSE2 fixture forms 11 to 14 each). - `python3 -B tests/docs_links_check.py`: passes. - Negative control: with `tools/cpu_sse_aot.py` from `origin/main` the new fixture fails at translation (`unsupported instruction at RVA 0x1230: minss xmm2,xmm1`). With `MINSS` lowered to `>` the check fails at `min_ss(2.0, 1.0)`. With the NaN quieting removed from SQRT it fails at `root_ss(0x7f800001)`. - The Windows MASM/MSVC run of `cpu_aot_scalar_float` has not been run by me. CI runs it. ## Evidence and follow-up - New fixture code is original MASM in `tests/cpu/scalar_float.asm`, six new exports (min_ss, max_ss, min_sd, max_sd, root_ss, root_sd). Each applies its instruction with a register operand and with a memory operand at an odd offset over a seeded buffer. - Independent reference: exact Python arithmetic in the check, no host instruction and none of the translator. It is compared with the processor on every call, over the whole guarded buffer, so nothing outside the intended words may change (the memory forms are unaligned loads only, no new store forms). - Controls: a build with swapped MIN/MAX operands (must differ only for NaN or equal values), a SQRTSS build that zeroes the destination first, a SQRTSD build that copies instead of rooting, and eleven deliberately wrong reference rules that must each disagree with the processor on some call. - Not covered: RSQRTSS and RCPSS, packed forms, guest MXCSR (DAZ, FTZ, rounding mode), exception flags. - AI-assisted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:46:39 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:46:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:10:53Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b173cede97

ℹ️ 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:6033105460 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#pullrequestreview-6033105460). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:10:53Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `b173cede97` <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>
tedin7 commented 2026-11-24 06:46:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:23:59Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033195914 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#pullrequestreview-6033195914). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:23:59Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:46:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:24:01Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033196174 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#pullrequestreview-6033196174). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:24:01Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 06:46:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:30:37Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d5e7fa2eb

ℹ️ 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:6033243020 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#pullrequestreview-6033243020). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:30:37Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `2d5e7fa2eb` <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>
tedin7 commented 2026-11-24 06:46:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:34:54Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033270878 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#pullrequestreview-6033270878). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:34:54Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 06:50:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:19:16Z.


AI-assisted update for both review findings.

  • Constant SQRT: operands of SQRT, MIN and MAX are now read at run time, so a compiler cannot fold a constant root with the default rounding. New constant-source exports (root of an integer 2 as float, of 3 as double) run under all four rounding controls.
  • MIN and MAX under DAZ: a denormal operand returned by the helper is flushed to a signed zero, for all four forms.
  • Test: the new check sets the host MXCSR around the native call and the translation (rounding controls, DAZ, FTZ) and compares both with an integer reference. Before the change it fails (MINSS(+0, 1) under DAZ at -O0; root_const_ss under round-up at -O2 and -O3); after, it passes at -O0, -O2 and -O3.
  • The PR stays in draft until the four CI jobs are green and the bot has no findings.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120978407 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7120978407). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:19:16Z. --- AI-assisted update for both review findings. - Constant SQRT: operands of SQRT, MIN and MAX are now read at run time, so a compiler cannot fold a constant root with the default rounding. New constant-source exports (root of an integer 2 as float, of 3 as double) run under all four rounding controls. - MIN and MAX under DAZ: a denormal operand returned by the helper is flushed to a signed zero, for all four forms. - Test: the new check sets the host MXCSR around the native call and the translation (rounding controls, DAZ, FTZ) and compares both with an integer reference. Before the change it fails (MINSS(+0, 1) under DAZ at -O0; root_const_ss under round-up at -O2 and -O3); after, it passes at -O0, -O2 and -O3. - The PR stays in draft until the four CI jobs are green and the bot has no findings.
tedin7 commented 2026-11-24 06:50:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:34:56Z.


AI-assisted follow-up: cpu_float_original_lifted and cpu_float_swapped_lifted now depend on cpu_mxcsr_harness (add_dependencies), so the documented scalar-only build produces the harness DLL the check loads. Verified the dependency form with a minimal CMake project on Linux; the Windows build and the scalar check itself were not run here. 0dc3c4b7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121231261 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7121231261). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:34:56Z. --- AI-assisted follow-up: cpu_float_original_lifted and cpu_float_swapped_lifted now depend on cpu_mxcsr_harness (add_dependencies), so the documented scalar-only build produces the harness DLL the check loads. Verified the dependency form with a minimal CMake project on Linux; the Windows build and the scalar check itself were not run here. 0dc3c4b7.
tedin7 commented 2026-11-24 06:50:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:06:05Z.


@codex review

AI-assisted: the inline findings are fixed and answered in their threads; please re-read the current head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121706749 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7121706749). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:06:05Z. --- @codex review AI-assisted: the inline findings are fixed and answered in their threads; please re-read the current head.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:11:32Z.


Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 0dc3c4b7c4

ℹ️ 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:comment:7121791654 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7121791654). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T04:11:32Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. You're on a roll. **Reviewed commit:** `0dc3c4b7c4` <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>
tedin7 commented 2026-11-24 06:50:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:50:16Z.


AI-assisted fix for a failure reported by a Windows Server 2025 node on 0dc3c4b7: cpu_aot_scalar_float failed in check_mxcsr with root_ss(0x807fffff) under MXCSR 0x1fc0, the translation returning 0xffc00000 and the processor 0x80000000.

  • Cause: with DAZ the processor reads a negative denormal as -0 and SQRTSS returns -0; the Windows C runtime tests the sign of the bits and returns the default NaN. std::sqrt on Linux compiles to the instruction, so the Linux run could not show it.
  • Fix (52c67518): SQRTSS and SQRTSD now use _mm_sqrt_ss and _mm_sqrt_sd (<emmintrin.h>), fed from the run-time (volatile) operand as before, so the constant-root rounding fix still holds (root_const_ss under round-up still gives 0x3fb504f4).
  • Test: the MXCSR check adds the FTZ-only words, fixed results for denormal operands under DAZ and FTZ (SQRT of a negative denormal is -0, of a positive one +0, MIN and MAX of denormals flush to a signed zero), and a wrong rule that tests the sign before DAZ. MIN and MAX already used the processor compare and flush the result under DAZ; the new fixed results cover negative denormals for both.
  • Run on Linux: clang-19 at -O0, -O2 and -O3: 39,407 MXCSR calls match the processor, 27 patched-instruction and 12 signature rejections pass. Negative control: the previous translation linked with a sqrt/sqrtf that tests the sign of the bits fails at -O0 on root_ss(0x807fffff) with 0xffc00000 instead of 0x80000000; at -O2 and -O3 that stand-in did not reproduce the failure, so the control is shown at -O0 only.
  • Not run: any Windows run, MSVC or ML64 build, or the real Windows C runtime; the fix is checked only against the processor on Linux.

@codex review

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122383226 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7122383226). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:50:16Z. --- AI-assisted fix for a failure reported by a Windows Server 2025 node on 0dc3c4b7: `cpu_aot_scalar_float` failed in `check_mxcsr` with `root_ss(0x807fffff)` under MXCSR `0x1fc0`, the translation returning `0xffc00000` and the processor `0x80000000`. - Cause: with DAZ the processor reads a negative denormal as `-0` and `SQRTSS` returns `-0`; the Windows C runtime tests the sign of the bits and returns the default NaN. `std::sqrt` on Linux compiles to the instruction, so the Linux run could not show it. - Fix (52c67518): `SQRTSS` and `SQRTSD` now use `_mm_sqrt_ss` and `_mm_sqrt_sd` (`<emmintrin.h>`), fed from the run-time (volatile) operand as before, so the constant-root rounding fix still holds (`root_const_ss` under round-up still gives `0x3fb504f4`). - Test: the MXCSR check adds the FTZ-only words, fixed results for denormal operands under DAZ and FTZ (SQRT of a negative denormal is `-0`, of a positive one `+0`, MIN and MAX of denormals flush to a signed zero), and a wrong rule that tests the sign before DAZ. MIN and MAX already used the processor compare and flush the result under DAZ; the new fixed results cover negative denormals for both. - Run on Linux: clang-19 at -O0, -O2 and -O3: 39,407 MXCSR calls match the processor, 27 patched-instruction and 12 signature rejections pass. Negative control: the previous translation linked with a `sqrt`/`sqrtf` that tests the sign of the bits fails at -O0 on `root_ss(0x807fffff)` with `0xffc00000` instead of `0x80000000`; at -O2 and -O3 that stand-in did not reproduce the failure, so the control is shown at -O0 only. - Not run: any Windows run, MSVC or ML64 build, or the real Windows C runtime; the fix is checked only against the processor on Linux. @codex review
chatgpt-codex-connector[bot commented 2026-11-24 06:50:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:55:11Z.


Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 52c67518ed

ℹ️ 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:comment:7122456946 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7122456946). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T04:55:11Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. :rocket: **Reviewed commit:** `52c67518ed` <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>
chatgpt-codex-connector[bot commented 2026-11-24 06:50:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:02:27Z.


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-24T04:55:12.198714Z 52c6751 Manual request
ℹ️ 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:7120714377 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7120714377). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:02:27Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"52c67518ed50a4d3662933a896404dd132e8dcb1","has_any_findings":false,"has_unresolved_findings":false,"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-24T04:55:12.198714Z">2026-11-24T04:55:12.198714Z</relative-time> | `52c6751` | Manual request | <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>
tedin7 commented 2026-11-24 06:50:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:03:12Z.


Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + ML64) at commit 52c67518:

  • Debug (--preset dev):
    • Build: cmake --preset dev && cmake --build out/build/dev -j 6 --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness
    • Test: ctest --test-dir out/build/dev -R "^cpu_aot_scalar_float$" --output-on-failure -> 1/1 passed (2.26s, total 2.29s)
  • Release /O2 (--preset release):
    • Build: cmake --preset release && cmake --build out/build/release -j 6 --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness
    • Test: ctest --test-dir out/build/release -R "^cpu_aot_scalar_float$" --output-on-failure -> 1/1 passed (3.06s, total 3.09s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122579524 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#issuecomment-7122579524). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T05:03:12Z. --- Re-verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + ML64) at commit `52c67518`: - **Debug (`--preset dev`)**: - Build: `cmake --preset dev && cmake --build out/build/dev -j 6 --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness` - Test: `ctest --test-dir out/build/dev -R "^cpu_aot_scalar_float$" --output-on-failure` -> **1/1 passed** (`2.26s`, total `2.29s`) - **Release `/O2` (`--preset release`)**: - Build: `cmake --preset release && cmake --build out/build/release -j 6 --target cpu_float_original cpu_float_original_lifted cpu_float_swapped cpu_float_swapped_lifted cpu_mxcsr_harness` - Test: `ctest --test-dir out/build/release -R "^cpu_aot_scalar_float$" --output-on-failure` -> **1/1 passed** (`3.06s`, total `3.09s`)
chatgpt-codex-connector[bot commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:10:53Z.

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

@@ -366,6 +386,22 @@ def lift(pe, name, result, slots):
     const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y;
     return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r);
 }
+// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative
+// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is
+// kept out of those cases because its NaN sign and its errno handling are not the processor's.
+template <class Float, class Bits> static Bits root(Bits b) {
+    const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2);
+    const Float y = cast<Float>(b);
+    if (y != y) return b | quiet;
+    if (y < 0) return static_cast<Bits>(~(quiet - 1));
+    return cast<Bits>(static_cast<Float>(std::sqrt(y)));
+}
+// MINSS, MAXSS, MINSD and MAXSD return the destination only when the comparison is true. Equal values
+// (so zeros of either sign) and any NaN, which compares false, give the source operand unchanged.
+template <class Float, class Bits> static Bits extreme(Bits a, Bits b, char op) {
+    const Float x = cast<Float>(a), y = cast<Float>(b);
+    return (op == '<' ? x < y : x > y) ? a : b;

P2 Badge Normalize selected MIN/MAX operands when host DAZ is set

When the host thread has MXCSR.DAZ enabled, native scalar MIN/MAX flush a selected denormal operand to signed zero. The floating-point comparison here honors DAZ, but returning the original integer a or b bypasses that normalization. For example, with MXCSR 0x1fc0, native MINSS(+0, 0x00000001) returns 0x00000000, while this helper returns 0x00000001 (reproduced with Clang 17 on x86-64 Linux at -O0, -O2, and -O3). This affects all four new MIN/MAX forms without any guest MXCSR write, contrary to the documented host-MXCSR behavior. Normalize the selected operand according to DAZ or use an instruction-level implementation, and cover this in the differential test.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675045955 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675045955). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:10:53Z. **Code review location:** `tools/cpu_sse_aot.py`; line 403 ~~~~diff @@ -366,6 +386,22 @@ def lift(pe, name, result, slots): const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y; return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r); } +// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative +// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is +// kept out of those cases because its NaN sign and its errno handling are not the processor's. +template <class Float, class Bits> static Bits root(Bits b) { + const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2); + const Float y = cast<Float>(b); + if (y != y) return b | quiet; + if (y < 0) return static_cast<Bits>(~(quiet - 1)); + return cast<Bits>(static_cast<Float>(std::sqrt(y))); +} +// MINSS, MAXSS, MINSD and MAXSD return the destination only when the comparison is true. Equal values +// (so zeros of either sign) and any NaN, which compares false, give the source operand unchanged. +template <class Float, class Bits> static Bits extreme(Bits a, Bits b, char op) { + const Float x = cast<Float>(a), y = cast<Float>(b); + return (op == '<' ? x < y : x > y) ? a : b; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Normalize selected MIN/MAX operands when host DAZ is set** When the host thread has MXCSR.DAZ enabled, native scalar MIN/MAX flush a selected denormal operand to signed zero. The floating-point comparison here honors DAZ, but returning the original integer `a` or `b` bypasses that normalization. For example, with MXCSR `0x1fc0`, native `MINSS(+0, 0x00000001)` returns `0x00000000`, while this helper returns `0x00000001` (reproduced with Clang 17 on x86-64 Linux at `-O0`, `-O2`, and `-O3`). This affects all four new MIN/MAX forms without any guest MXCSR write, contrary to the documented host-MXCSR behavior. Normalize the selected operand according to DAZ or use an instruction-level implementation, and cover this in the differential test. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:10:53Z.

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

@@ -366,6 +386,22 @@ def lift(pe, name, result, slots):
     const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y;
     return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r);
 }
+// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative
+// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is
+// kept out of those cases because its NaN sign and its errno handling are not the processor's.
+template <class Float, class Bits> static Bits root(Bits b) {
+    const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2);
+    const Float y = cast<Float>(b);
+    if (y != y) return b | quiet;
+    if (y < 0) return static_cast<Bits>(~(quiet - 1));
+    return cast<Bits>(static_cast<Float>(std::sqrt(y)));

P2 Badge Preserve host rounding for constant SQRT operands

When a supported leaf constructs a constant SQRT operand, such as by converting the integer 2 to float, this ordinary std::sqrt call can be folded at compile time using default rounding instead of the host MXCSR. With the emitted helper compiled by Clang 17 on x86-64 Linux at -O2 or -O3, root<float>(0x40000000u) returns 0x3fb504f3 even with host MXCSR 0x5f80 (round toward positive infinity), whereas native SQRTSS returns 0x3fb504f4. This requires no guest MXCSR write and violates the documented host-rounding behavior. Prevent constant folding from bypassing runtime rounding, using a suitable barrier or FP-environment-aware compilation, and add a constant-source fixture.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675045985 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675045985). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:10:53Z. **Code review location:** `tools/cpu_sse_aot.py`; line 397 ~~~~diff @@ -366,6 +386,22 @@ def lift(pe, name, result, slots): const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y; return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r); } +// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative +// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is +// kept out of those cases because its NaN sign and its errno handling are not the processor's. +template <class Float, class Bits> static Bits root(Bits b) { + const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2); + const Float y = cast<Float>(b); + if (y != y) return b | quiet; + if (y < 0) return static_cast<Bits>(~(quiet - 1)); + return cast<Bits>(static_cast<Float>(std::sqrt(y))); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve host rounding for constant SQRT operands** When a supported leaf constructs a constant SQRT operand, such as by converting the integer 2 to float, this ordinary `std::sqrt` call can be folded at compile time using default rounding instead of the host MXCSR. With the emitted helper compiled by Clang 17 on x86-64 Linux at `-O2` or `-O3`, `root<float>(0x40000000u)` returns `0x3fb504f3` even with host MXCSR `0x5f80` (round toward positive infinity), whereas native `SQRTSS` returns `0x3fb504f4`. This requires no guest MXCSR write and violates the documented host-rounding behavior. Prevent constant folding from bypassing runtime rounding, using a suitable barrier or FP-environment-aware compilation, and add a constant-source fixture. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:23:59Z.

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

@@ -366,6 +386,22 @@ def lift(pe, name, result, slots):
     const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y;
     return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r);
 }
+// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative
+// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is
+// kept out of those cases because its NaN sign and its errno handling are not the processor's.
+template <class Float, class Bits> static Bits root(Bits b) {
+    const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2);
+    const Float y = cast<Float>(b);
+    if (y != y) return b | quiet;
+    if (y < 0) return static_cast<Bits>(~(quiet - 1));
+    return cast<Bits>(static_cast<Float>(std::sqrt(y)));
+}
+// MINSS, MAXSS, MINSD and MAXSD return the destination only when the comparison is true. Equal values
+// (so zeros of either sign) and any NaN, which compares false, give the source operand unchanged.
+template <class Float, class Bits> static Bits extreme(Bits a, Bits b, char op) {
+    const Float x = cast<Float>(a), y = cast<Float>(b);
+    return (op == '<' ? x < y : x > y) ? a : b;

Fixed in 2d5e7fa2.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675126085 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675126085). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:23:59Z. **Code review location:** `tools/cpu_sse_aot.py`; line 403 ~~~~diff @@ -366,6 +386,22 @@ def lift(pe, name, result, slots): const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y; return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r); } +// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative +// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is +// kept out of those cases because its NaN sign and its errno handling are not the processor's. +template <class Float, class Bits> static Bits root(Bits b) { + const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2); + const Float y = cast<Float>(b); + if (y != y) return b | quiet; + if (y < 0) return static_cast<Bits>(~(quiet - 1)); + return cast<Bits>(static_cast<Float>(std::sqrt(y))); +} +// MINSS, MAXSS, MINSD and MAXSD return the destination only when the comparison is true. Equal values +// (so zeros of either sign) and any NaN, which compares false, give the source operand unchanged. +template <class Float, class Bits> static Bits extreme(Bits a, Bits b, char op) { + const Float x = cast<Float>(a), y = cast<Float>(b); + return (op == '<' ? x < y : x > y) ? a : b; ~~~~ --- Fixed in 2d5e7fa2.
tedin7 commented 2026-11-24 06:50:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:24:01Z.

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

@@ -366,6 +386,22 @@ def lift(pe, name, result, slots):
     const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y;
     return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r);
 }
+// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative
+// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is
+// kept out of those cases because its NaN sign and its errno handling are not the processor's.
+template <class Float, class Bits> static Bits root(Bits b) {
+    const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2);
+    const Float y = cast<Float>(b);
+    if (y != y) return b | quiet;
+    if (y < 0) return static_cast<Bits>(~(quiet - 1));
+    return cast<Bits>(static_cast<Float>(std::sqrt(y)));

Fixed in 2d5e7fa2.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675126304 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675126304). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:24:01Z. **Code review location:** `tools/cpu_sse_aot.py`; line 397 ~~~~diff @@ -366,6 +386,22 @@ def lift(pe, name, result, slots): const Float r = op == '+' ? x + y : op == '-' ? x - y : op == '*' ? x * y : x / y; return r != r ? static_cast<Bits>(~(quiet - 1)) : cast<Bits>(r); } +// SQRTSS and SQRTSD with exceptions masked. A NaN operand is returned quieted with its payload, a negative +// operand other than -0 gives the default NaN, whose sign is set, and -0 gives -0. The host function is +// kept out of those cases because its NaN sign and its errno handling are not the processor's. +template <class Float, class Bits> static Bits root(Bits b) { + const Bits quiet = static_cast<Bits>(1) << (std::numeric_limits<Float>::digits - 2); + const Float y = cast<Float>(b); + if (y != y) return b | quiet; + if (y < 0) return static_cast<Bits>(~(quiet - 1)); + return cast<Bits>(static_cast<Float>(std::sqrt(y))); ~~~~ --- Fixed in 2d5e7fa2.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:30:37Z.

Code review location: CMakeLists.txt; line 1598

@@ -1587,15 +1587,15 @@ if(EXISTS "${INTAKE_PYTHON}")
     foreach(variant IN ITEMS original swapped)
         cpu_asm_fixture(cpu_float_${variant} scalar_float)
         cpu_translation(cpu_float_${variant} cpu_sse_aot
-            "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq")
+            "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq,min_ss=f:ffq,max_ss=f:ffq,min_sd=d:ddq,max_sd=d:ddq,root_ss=f:fq,root_sd=d:dq,root_const_ss=f:,root_const_sd=d:")
         add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpu_float_${variant}_lifted.cpp" APPEND
             DEPENDS tools/cpu_switch_aot.py)
     endforeach()
     target_compile_definitions(cpu_float_swapped PRIVATE SWAP_OPERANDS)
     add_test(NAME cpu_aot_scalar_float COMMAND "${INTAKE_PYTHON}" -B
         "${CMAKE_SOURCE_DIR}/tests/cpu/scalar_float_check.py"
         "$<TARGET_FILE:cpu_float_original>" "$<TARGET_FILE:cpu_float_original_lifted>"
-        "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>")
+        "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>" "$<TARGET_FILE:cpu_mxcsr_harness>")

P2 Badge Include the MXCSR harness in the scalar-only build

On a clean Windows build using the scalar experiment’s documented targets (docs/experiments.md:3408), neither cpu_float_original_lifted nor cpu_float_swapped_lifted builds cpu_mxcsr_harness. CMake’s $<TARGET_FILE:tgt> documentation states that the target “is not added as a dependency” outside add_custom_command()/add_custom_target(), so this add_test() argument does not supply that dependency. scalar_float_check.py now unconditionally loads the DLL in mxcsr_access(), so the documented build/test sequence fails with a DLL-load error unless a previous build has already produced it. Add the harness to the documented target list or make it a dependency of the scalar targets.

AGENTS.md reference: AGENTS.md:L175-L176

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675165570 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675165570). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:30:37Z. **Code review location:** `CMakeLists.txt`; line 1598 ~~~~diff @@ -1587,15 +1587,15 @@ if(EXISTS "${INTAKE_PYTHON}") foreach(variant IN ITEMS original swapped) cpu_asm_fixture(cpu_float_${variant} scalar_float) cpu_translation(cpu_float_${variant} cpu_sse_aot - "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq") + "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq,min_ss=f:ffq,max_ss=f:ffq,min_sd=d:ddq,max_sd=d:ddq,root_ss=f:fq,root_sd=d:dq,root_const_ss=f:,root_const_sd=d:") add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpu_float_${variant}_lifted.cpp" APPEND DEPENDS tools/cpu_switch_aot.py) endforeach() target_compile_definitions(cpu_float_swapped PRIVATE SWAP_OPERANDS) add_test(NAME cpu_aot_scalar_float COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/cpu/scalar_float_check.py" "$<TARGET_FILE:cpu_float_original>" "$<TARGET_FILE:cpu_float_original_lifted>" - "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>") + "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>" "$<TARGET_FILE:cpu_mxcsr_harness>") ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Include the MXCSR harness in the scalar-only build** On a clean Windows build using the scalar experiment’s documented targets (`docs/experiments.md:3408`), neither `cpu_float_original_lifted` nor `cpu_float_swapped_lifted` builds `cpu_mxcsr_harness`. CMake’s `$<TARGET_FILE:tgt>` documentation states that the target “is not added as a dependency” outside `add_custom_command()`/`add_custom_target()`, so this `add_test()` argument does not supply that dependency. `scalar_float_check.py` now unconditionally loads the DLL in `mxcsr_access()`, so the documented build/test sequence fails with a DLL-load error unless a previous build has already produced it. Add the harness to the documented target list or make it a dependency of the scalar targets. AGENTS.md reference: [AGENTS.md:L175-L176](https://github.com/R0Y00/Xbox2Windows/blob/2d5e7fa2eb38d379378d0ca0259c57b16ba7c1f9/AGENTS.md#L175-L176) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 06:50:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:34:54Z.

Code review location: CMakeLists.txt; line 1598

@@ -1587,15 +1587,15 @@ if(EXISTS "${INTAKE_PYTHON}")
     foreach(variant IN ITEMS original swapped)
         cpu_asm_fixture(cpu_float_${variant} scalar_float)
         cpu_translation(cpu_float_${variant} cpu_sse_aot
-            "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq")
+            "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq,min_ss=f:ffq,max_ss=f:ffq,min_sd=d:ddq,max_sd=d:ddq,root_ss=f:fq,root_sd=d:dq,root_const_ss=f:,root_const_sd=d:")
         add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpu_float_${variant}_lifted.cpp" APPEND
             DEPENDS tools/cpu_switch_aot.py)
     endforeach()
     target_compile_definitions(cpu_float_swapped PRIVATE SWAP_OPERANDS)
     add_test(NAME cpu_aot_scalar_float COMMAND "${INTAKE_PYTHON}" -B
         "${CMAKE_SOURCE_DIR}/tests/cpu/scalar_float_check.py"
         "$<TARGET_FILE:cpu_float_original>" "$<TARGET_FILE:cpu_float_original_lifted>"
-        "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>")
+        "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>" "$<TARGET_FILE:cpu_mxcsr_harness>")

Fixed in 0dc3c4b7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675189932 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1168#discussion_r4675189932). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:34:54Z. **Code review location:** `CMakeLists.txt`; line 1598 ~~~~diff @@ -1587,15 +1587,15 @@ if(EXISTS "${INTAKE_PYTHON}") foreach(variant IN ITEMS original swapped) cpu_asm_fixture(cpu_float_${variant} scalar_float) cpu_translation(cpu_float_${variant} cpu_sse_aot - "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq") + "blend_ss=f:ffqf,blend_sd=d:ddqd,convert=q:fdq,from_int=d:qq,classify_ss=q:ff,classify_sd=q:dq,round_trip=f:f,zero_xorps=d:d,zero_pxor=d:d,zero_xorpd=d:d,probe_ss=q:qff,neg_jcc=q:q,setcc_mix=q:qqq,cmovcc_mix=q:qqq,min_ss=f:ffq,max_ss=f:ffq,min_sd=d:ddq,max_sd=d:ddq,root_ss=f:fq,root_sd=d:dq,root_const_ss=f:,root_const_sd=d:") add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cpu_float_${variant}_lifted.cpp" APPEND DEPENDS tools/cpu_switch_aot.py) endforeach() target_compile_definitions(cpu_float_swapped PRIVATE SWAP_OPERANDS) add_test(NAME cpu_aot_scalar_float COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/cpu/scalar_float_check.py" "$<TARGET_FILE:cpu_float_original>" "$<TARGET_FILE:cpu_float_original_lifted>" - "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>") + "$<TARGET_FILE:cpu_float_swapped>" "$<TARGET_FILE:cpu_float_swapped_lifted>" "$<TARGET_FILE:cpu_mxcsr_harness>") ~~~~ --- Fixed in 0dc3c4b7.
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!1161
No description provided.