cpu: lower packed SSE arithmetic in the SSE FP translator #1206

Merged
tedin7 merged 2 commits from upstream-pr/1213 into main 2026-11-24 08:18:28 +00:00
tedin7 commented 2026-11-24 03:35:23 +00:00 (Migrated from github.com)

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


Change

tools/cpu_sse_fp_aot.py now lowers the packed single-precision ADDPS, SUBPS, MULPS, DIVPS, MINPS, MAXPS and SQRTPS in bounded leaf functions (register source and 16-byte aligned m128 source). Before this change the translator refused them with unsupported instruction.

  • The generated code executes the same SSE operation at run time (xmmintrin.h). Rounding mode, DAZ and FTZ are the host's; the translator never folds a result. A guest ldmxcsr is still not lifted and exception flags are not observed (declared in the docs and the translator docstring).
  • NaN sources of ADD, SUB, MUL and DIV are resolved in software (first source operand if it is a NaN, else the second, made quiet) so a compiler that commutes an addition cannot change a payload. MINPS and MAXPS use the host instruction unchanged (second source operand for equal values, signed zeros and any NaN; DAZ follows the host). SQRTPS only reads its source.
  • Rejected as before: VEX/EVEX, packed double forms, scalar forms, rcpps, rsqrtps, unaligned or non-argument memory operands, nonvolatile or undefined registers.

Advances the legacy SSE FP translator coverage in docs/experiments.md. No overlapping open PR (searched open PRs for sse, packed, addps, sqrtps, minps and arith). It touches tools/cpu_sse_fp_aot.py and the sse_fp fixture only, not the scalar translator of #1168.

Verification

Linux x86-64 (QEMU virtual processor): fixture assembled with llvm-ml-19, linked with lld-link-19, original machine code run through a Windows-ABI caller, translation built with clang++-19 at -O0, -O2 and -O3 (-Wall -Wextra, no warnings). The unmodified tests/cpu/sse_fp_check.py entry points check_differential, check_arithmetic_modes and check_alt_encodings_and_rejections were run with a harness that only replaces the DLL binding with that caller; all three passed at every optimization level:

  • 4,432 native/lifted/reference cases over 63 exports bit for bit; the ALTER_IMM translation diverged from the original on all 35 arithmetic and compare mutation exports (fewest differing cases 27).
  • 59,392 arithmetic runs in 16 MXCSR control words (4 rounding modes x neither, DAZ, FTZ, both): native, translated code and the exact Python reference agree on 468,906 lanes; 6,230 lanes the reference leaves undecided (FTZ boundary, MIN/MAX under DAZ with a denormal result) are compared native against translated only.
  • 82 unit rejection controls, 12 alternate-encoding lift checks and 10 PE-patched rejection controls.
  • Negative control: with tools/cpu_sse_fp_aot.py from origin/main the new fixture fails at translation (unsupported instruction at RVA 0x11f9: addps xmm0,xmm1). Translator mutants built and run: add as subtract (lifted op_addps case 0), multiply as divide (op_mulps case 0), minimum as maximum and swapped MINPS operands (op_minps case 0), SQRTPS not quieting a NaN (op_sqrtps case 5), SQRTPS reading its destination (op_sqrtps case 0) all fail. Dropping the software NaN rule passes on this host (the processor already returns the same NaN), so that rule is defensive and not shown to matter here.
  • python3 -B tests/form_coverage_check.py and python3 -B tests/docs_links_check.py: pass.
  • Not run by me: the MSVC/MASM build and ctest run of cpu_aot_sse_fp on Windows (including the faulting-read control check_discarded_read, which needs structured exceptions). CI runs it.

Evidence and follow-up

  • New fixture code is original MASM in tests/cpu/sse_fp.asm (29 exports plus the native-only harness op_call_with_mxcsr, which sets the control word for one call and restores it). The reference tests/cpu/sse_fp_ref.py is exact rational arithmetic with no host floating-point and none of the translator.
  • No new store forms: outputs use the existing movaps stores, and every call checks 32-byte guards around all three buffers and that unwritten output bytes keep their fill value. A runtime-unaligned base is outside the leaf contract (16-byte aligned argument pointers), as for cmpps.
  • Not covered: unmasked exceptions and exception flags, the packed double and scalar arithmetic forms, rcpps and rsqrtps. Whether the processor returns original bits or a flushed zero for MIN/MAX under DAZ, and whether FTZ judges tininess before or after rounding, are left unconstrained in the reference rather than assumed.
  • 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:6574026256 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:35:23Z. --- ## Change `tools/cpu_sse_fp_aot.py` now lowers the packed single-precision `ADDPS`, `SUBPS`, `MULPS`, `DIVPS`, `MINPS`, `MAXPS` and `SQRTPS` in bounded leaf functions (register source and 16-byte aligned `m128` source). Before this change the translator refused them with `unsupported instruction`. - The generated code executes the same SSE operation at run time (`xmmintrin.h`). Rounding mode, DAZ and FTZ are the host's; the translator never folds a result. A guest `ldmxcsr` is still not lifted and exception flags are not observed (declared in the docs and the translator docstring). - NaN sources of ADD, SUB, MUL and DIV are resolved in software (first source operand if it is a NaN, else the second, made quiet) so a compiler that commutes an addition cannot change a payload. `MINPS` and `MAXPS` use the host instruction unchanged (second source operand for equal values, signed zeros and any NaN; DAZ follows the host). `SQRTPS` only reads its source. - Rejected as before: VEX/EVEX, packed double forms, scalar forms, `rcpps`, `rsqrtps`, unaligned or non-argument memory operands, nonvolatile or undefined registers. Advances the legacy SSE FP translator coverage in `docs/experiments.md`. No overlapping open PR (searched open PRs for sse, packed, addps, sqrtps, minps and arith). It touches `tools/cpu_sse_fp_aot.py` and the `sse_fp` fixture only, not the scalar translator of #1168. ## Verification Linux x86-64 (QEMU virtual processor): fixture assembled with `llvm-ml-19`, linked with `lld-link-19`, original machine code run through a Windows-ABI caller, translation built with `clang++-19` at -O0, -O2 and -O3 (`-Wall -Wextra`, no warnings). The unmodified `tests/cpu/sse_fp_check.py` entry points `check_differential`, `check_arithmetic_modes` and `check_alt_encodings_and_rejections` were run with a harness that only replaces the DLL binding with that caller; all three passed at every optimization level: - 4,432 native/lifted/reference cases over 63 exports bit for bit; the ALTER_IMM translation diverged from the original on all 35 arithmetic and compare mutation exports (fewest differing cases 27). - 59,392 arithmetic runs in 16 MXCSR control words (4 rounding modes x neither, DAZ, FTZ, both): native, translated code and the exact Python reference agree on 468,906 lanes; 6,230 lanes the reference leaves undecided (FTZ boundary, MIN/MAX under DAZ with a denormal result) are compared native against translated only. - 82 unit rejection controls, 12 alternate-encoding lift checks and 10 PE-patched rejection controls. - Negative control: with `tools/cpu_sse_fp_aot.py` from `origin/main` the new fixture fails at translation (`unsupported instruction at RVA 0x11f9: addps xmm0,xmm1`). Translator mutants built and run: add as subtract (`lifted op_addps case 0`), multiply as divide (`op_mulps case 0`), minimum as maximum and swapped MINPS operands (`op_minps case 0`), SQRTPS not quieting a NaN (`op_sqrtps case 5`), SQRTPS reading its destination (`op_sqrtps case 0`) all fail. Dropping the software NaN rule passes on this host (the processor already returns the same NaN), so that rule is defensive and not shown to matter here. - `python3 -B tests/form_coverage_check.py` and `python3 -B tests/docs_links_check.py`: pass. - Not run by me: the MSVC/MASM build and `ctest` run of `cpu_aot_sse_fp` on Windows (including the faulting-read control `check_discarded_read`, which needs structured exceptions). CI runs it. ## Evidence and follow-up - New fixture code is original MASM in `tests/cpu/sse_fp.asm` (29 exports plus the native-only harness `op_call_with_mxcsr`, which sets the control word for one call and restores it). The reference `tests/cpu/sse_fp_ref.py` is exact rational arithmetic with no host floating-point and none of the translator. - No new store forms: outputs use the existing `movaps` stores, and every call checks 32-byte guards around all three buffers and that unwritten output bytes keep their fill value. A runtime-unaligned base is outside the leaf contract (16-byte aligned argument pointers), as for `cmpps`. - Not covered: unmasked exceptions and exception flags, the packed double and scalar arithmetic forms, `rcpps` and `rsqrtps`. Whether the processor returns original bits or a flushed zero for MIN/MAX under DAZ, and whether FTZ judges tininess before or after rounding, are left unconstrained in the reference rather than assumed. - 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.
chatgpt-codex-connector[bot commented 2026-11-24 06:46:58 +00:00 (Migrated from github.com)

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

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e03a299c6c

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

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033475358 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#pullrequestreview-6033475358). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:03:45Z. **Review:** COMMENTED --- _No description provided._
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:03:48Z.


AI-assisted update: the native MXCSR driver now lives in its own native-only source (tests/cpu/sse_fp_harness.asm), so translated-form coverage for cpu_aot_sse_fp counts 16 mnemonics (13 SSE forms) again. form_coverage_check.py has a new check that fails if the driver is counted. Fixed in 9b54fdd7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121671662 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#issuecomment-7121671662). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:03:48Z. --- AI-assisted update: the native MXCSR driver now lives in its own native-only source (tests/cpu/sse_fp_harness.asm), so translated-form coverage for cpu_aot_sse_fp counts 16 mnemonics (13 SSE forms) again. form_coverage_check.py has a new check that fails if the driver is counted. Fixed in 9b54fdd7.
tedin7 commented 2026-11-24 06:50:18 +00:00 (Migrated from github.com)

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


@codex review

AI-assisted: the native-driver coverage finding is fixed in 9b54fdd7 and answered in its thread; please re-read the current head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7121822251 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#issuecomment-7121822251). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:13:30Z. --- @codex review AI-assisted: the native-driver coverage finding is fixed in 9b54fdd7 and answered in its thread; 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:19:59Z.


Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 9b54fdd78f

ℹ️ 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:7121921071 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#issuecomment-7121921071). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T04:19:59Z. --- <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. Can't wait for the next one! **Reviewed commit:** `9b54fdd78f` <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:18 +00:00 (Migrated from github.com)

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


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:20:00.748979Z 9b54fdd 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:7121432125 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#issuecomment-7121432125). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:47:56Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"9b54fdd78f0b2723a462cb036e07759a7269a38e","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:20:00.748979Z">2026-11-24T04:20:00.748979Z</relative-time> | `9b54fdd` | 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:22 +00:00 (Migrated from github.com)

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


Windows Server 2025 verification (9b54fdd7) — PASS (Debug + Release /O2)

  • Environment: Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, D3D12 WARP
  • Debug (--preset dev) (9.41s build+test):
    • cmake --build --preset dev -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harness
    • ctest --test-dir out\build\dev -R "^cpu_aot_sse_fp$" --output-on-failure -> 1/1 passed (0 skipped, 8.14s)
  • Release /O2 (--preset release) (10.65s configure+build+test):
    • cmake --preset release && cmake --build --preset release -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harness
    • ctest --test-dir out\build\release -R "^cpu_aot_sse_fp$" --output-on-failure -> 1/1 passed (0 skipped, 8.06s)
  • Additional check: python -B tests\form_coverage_check.py -> passed
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122464579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#issuecomment-7122464579). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:55:40Z. --- Windows Server 2025 verification (`9b54fdd7`) — **PASS (Debug + Release `/O2`)** - **Environment**: Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, D3D12 WARP - **Debug (`--preset dev`)** (9.41s build+test): - `cmake --build --preset dev -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harness` - `ctest --test-dir out\build\dev -R "^cpu_aot_sse_fp$" --output-on-failure` -> **1/1 passed** (0 skipped, 8.14s) - **Release `/O2` (`--preset release`)** (10.65s configure+build+test): - `cmake --preset release && cmake --build --preset release -j 6 --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered_lifted cpu_sse_fp_harness` - `ctest --test-dir out\build\release -R "^cpu_aot_sse_fp$" --output-on-failure` -> **1/1 passed** (0 skipped, 8.06s) - **Additional check**: `python -B tests\form_coverage_check.py` -> **passed**
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:55:26Z.

Code review location: tests/cpu/sse_fp.asm; line 734

@@ -341,4 +342,403 @@ op_pipeline PROC FRAME
     ret
 op_pipeline ENDP
 
+; --- Packed float arithmetic: reg, aligned m128, m128 at +16 and self sources ---
+; ALTER_IMM swaps each register-form operation (add/sub, mul/div, min/max; sqrt becomes
+; add), moves each memory source by 16 bytes and replaces each self source by xmm1, so
+; every lowering has a build that must differ on known words.
+
+op_addps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    subps xmm0, xmm1
+ELSE
+    addps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps ENDP
+
+op_addps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    addps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_mem ENDP
+
+op_addps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm0, XMMWORD PTR [rdx]
+ELSE
+    addps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_mem_disp ENDP
+
+op_addps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    addps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_self ENDP
+
+op_subps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    subps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps ENDP
+
+op_subps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    subps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    subps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_mem ENDP
+
+op_subps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    subps xmm0, XMMWORD PTR [rdx]
+ELSE
+    subps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_mem_disp ENDP
+
+op_subps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    subps xmm0, xmm1
+ELSE
+    subps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_self ENDP
+
+op_mulps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    divps xmm0, xmm1
+ELSE
+    mulps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps ENDP
+
+op_mulps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_mem ENDP
+
+op_mulps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    mulps xmm0, XMMWORD PTR [rdx]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_mem_disp ENDP
+
+op_mulps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    mulps xmm0, xmm1
+ELSE
+    mulps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_self ENDP
+
+op_divps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    mulps xmm0, xmm1
+ELSE
+    divps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps ENDP
+
+op_divps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    divps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_mem ENDP
+
+op_divps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx]
+ELSE
+    divps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_mem_disp ENDP
+
+op_divps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    divps xmm0, xmm1
+ELSE
+    divps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_self ENDP
+
+op_minps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    maxps xmm0, xmm1
+ELSE
+    minps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps ENDP
+
+op_minps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    minps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    minps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_mem ENDP
+
+op_minps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    minps xmm0, XMMWORD PTR [rdx]
+ELSE
+    minps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_mem_disp ENDP
+
+op_minps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    minps xmm0, xmm1
+ELSE
+    minps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_self ENDP
+
+op_maxps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    minps xmm0, xmm1
+ELSE
+    maxps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps ENDP
+
+op_maxps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    maxps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    maxps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_mem ENDP
+
+op_maxps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    maxps xmm0, XMMWORD PTR [rdx]
+ELSE
+    maxps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_mem_disp ENDP
+
+op_maxps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    maxps xmm0, xmm1
+ELSE
+    maxps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_self ENDP
+
+op_sqrtps PROC FRAME
+    .endprolog
+    movaps xmm1, XMMWORD PTR [rdx]
+    movaps xmm2, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm2, xmm1
+ELSE
+    sqrtps xmm2, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm2
+    ret
+op_sqrtps ENDP
+
+op_sqrtps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    sqrtps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    sqrtps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_mem ENDP
+
+op_sqrtps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    sqrtps xmm0, XMMWORD PTR [rdx]
+ELSE
+    sqrtps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_mem_disp ENDP
+
+op_sqrtps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    sqrtps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_self ENDP
+
+; Chained arithmetic: every operation feeds the next through registers, with a memory
+; source at +16 and a destination reused across instructions.
+op_arith_pipeline PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+    addps xmm0, xmm1
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    subps xmm0, xmm1
+    movaps xmm2, XMMWORD PTR [rcx+16]
+    divps xmm2, xmm0
+    minps xmm2, xmm1
+    maxps xmm0, xmm2
+    sqrtps xmm3, xmm0
+    movaps XMMWORD PTR [r8], xmm3
+    movaps XMMWORD PTR [r8+16], xmm2
+    ret
+op_arith_pipeline ENDP
+
+; Test harness, not translated: runs fn(a, b, out) with MXCSR set to the fifth argument and
+; restores the caller's MXCSR before returning, so the host control word never leaks into the
+; checker. RCX = fn, RDX = a, R8 = b, R9 = out, [stack] = MXCSR value.
+op_call_with_mxcsr PROC FRAME
+    sub rsp, 56
+    .allocstack 56
+    .endprolog
+    mov r10, rcx
+    stmxcsr DWORD PTR [rsp+36]
+    mov eax, DWORD PTR [rsp+96]
+    mov DWORD PTR [rsp+40], eax
+    ldmxcsr DWORD PTR [rsp+40]

P2 Badge Exclude the native driver from translated-form coverage

When cpu_aot_sse_fp passes, tools/form_coverage.py::measure counts every mnemonic in this coverage: source file, including this explicitly native-only driver. Consequently, a report with only that test passing credits ldmxcsr, stmxcsr, call, and the integer glue as translated even though cpu_sse_fp_exports excludes the driver. I reproduced 22 credited forms instead of 16, including 15 SSE forms instead of 13, so the MXCSR forms appear covered even when their actual translation fixture fails or is absent. Move the driver into an excluded native harness source, as done for mxcsr_harness.asm, or record only instructions actually lifted.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675315203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#discussion_r4675315203). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T03:55:26Z. **Code review location:** `tests/cpu/sse_fp.asm`; line 734 ~~~~diff @@ -341,4 +342,403 @@ op_pipeline PROC FRAME ret op_pipeline ENDP +; --- Packed float arithmetic: reg, aligned m128, m128 at +16 and self sources --- +; ALTER_IMM swaps each register-form operation (add/sub, mul/div, min/max; sqrt becomes +; add), moves each memory source by 16 bytes and replaces each self source by xmm1, so +; every lowering has a build that must differ on known words. + +op_addps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + subps xmm0, xmm1 +ELSE + addps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps ENDP + +op_addps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm0, XMMWORD PTR [rdx+16] +ELSE + addps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_mem ENDP + +op_addps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm0, XMMWORD PTR [rdx] +ELSE + addps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_mem_disp ENDP + +op_addps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + addps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_self ENDP + +op_subps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + subps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps ENDP + +op_subps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + subps xmm0, XMMWORD PTR [rdx+16] +ELSE + subps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_mem ENDP + +op_subps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + subps xmm0, XMMWORD PTR [rdx] +ELSE + subps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_mem_disp ENDP + +op_subps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + subps xmm0, xmm1 +ELSE + subps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_self ENDP + +op_mulps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + divps xmm0, xmm1 +ELSE + mulps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps ENDP + +op_mulps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + mulps xmm0, XMMWORD PTR [rdx+16] +ELSE + mulps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_mem ENDP + +op_mulps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + mulps xmm0, XMMWORD PTR [rdx] +ELSE + mulps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_mem_disp ENDP + +op_mulps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + mulps xmm0, xmm1 +ELSE + mulps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_self ENDP + +op_divps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + mulps xmm0, xmm1 +ELSE + divps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps ENDP + +op_divps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx+16] +ELSE + divps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_mem ENDP + +op_divps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx] +ELSE + divps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_mem_disp ENDP + +op_divps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + divps xmm0, xmm1 +ELSE + divps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_self ENDP + +op_minps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + maxps xmm0, xmm1 +ELSE + minps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps ENDP + +op_minps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + minps xmm0, XMMWORD PTR [rdx+16] +ELSE + minps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_mem ENDP + +op_minps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + minps xmm0, XMMWORD PTR [rdx] +ELSE + minps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_mem_disp ENDP + +op_minps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + minps xmm0, xmm1 +ELSE + minps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_self ENDP + +op_maxps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + minps xmm0, xmm1 +ELSE + maxps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps ENDP + +op_maxps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + maxps xmm0, XMMWORD PTR [rdx+16] +ELSE + maxps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_mem ENDP + +op_maxps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + maxps xmm0, XMMWORD PTR [rdx] +ELSE + maxps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_mem_disp ENDP + +op_maxps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + maxps xmm0, xmm1 +ELSE + maxps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_self ENDP + +op_sqrtps PROC FRAME + .endprolog + movaps xmm1, XMMWORD PTR [rdx] + movaps xmm2, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm2, xmm1 +ELSE + sqrtps xmm2, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm2 + ret +op_sqrtps ENDP + +op_sqrtps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + sqrtps xmm0, XMMWORD PTR [rdx+16] +ELSE + sqrtps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_mem ENDP + +op_sqrtps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + sqrtps xmm0, XMMWORD PTR [rdx] +ELSE + sqrtps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_mem_disp ENDP + +op_sqrtps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + sqrtps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_self ENDP + +; Chained arithmetic: every operation feeds the next through registers, with a memory +; source at +16 and a destination reused across instructions. +op_arith_pipeline PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] + addps xmm0, xmm1 +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx+16] +ELSE + mulps xmm0, XMMWORD PTR [rdx+16] +ENDIF + subps xmm0, xmm1 + movaps xmm2, XMMWORD PTR [rcx+16] + divps xmm2, xmm0 + minps xmm2, xmm1 + maxps xmm0, xmm2 + sqrtps xmm3, xmm0 + movaps XMMWORD PTR [r8], xmm3 + movaps XMMWORD PTR [r8+16], xmm2 + ret +op_arith_pipeline ENDP + +; Test harness, not translated: runs fn(a, b, out) with MXCSR set to the fifth argument and +; restores the caller's MXCSR before returning, so the host control word never leaks into the +; checker. RCX = fn, RDX = a, R8 = b, R9 = out, [stack] = MXCSR value. +op_call_with_mxcsr PROC FRAME + sub rsp, 56 + .allocstack 56 + .endprolog + mov r10, rcx + stmxcsr DWORD PTR [rsp+36] + mov eax, DWORD PTR [rsp+96] + mov DWORD PTR [rsp+40], eax + ldmxcsr DWORD PTR [rsp+40] ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Exclude the native driver from translated-form coverage** When `cpu_aot_sse_fp` passes, `tools/form_coverage.py::measure` counts every mnemonic in this `coverage: source` file, including this explicitly native-only driver. Consequently, a report with only that test passing credits `ldmxcsr`, `stmxcsr`, `call`, and the integer glue as translated even though `cpu_sse_fp_exports` excludes the driver. I reproduced 22 credited forms instead of 16, including 15 SSE forms instead of 13, so the MXCSR forms appear covered even when their actual translation fixture fails or is absent. Move the driver into an excluded native harness source, as done for `mxcsr_harness.asm`, or record only instructions actually lifted. 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-24T04:03:45Z.

Code review location: tests/cpu/sse_fp.asm; line 734

@@ -341,4 +342,403 @@ op_pipeline PROC FRAME
     ret
 op_pipeline ENDP
 
+; --- Packed float arithmetic: reg, aligned m128, m128 at +16 and self sources ---
+; ALTER_IMM swaps each register-form operation (add/sub, mul/div, min/max; sqrt becomes
+; add), moves each memory source by 16 bytes and replaces each self source by xmm1, so
+; every lowering has a build that must differ on known words.
+
+op_addps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    subps xmm0, xmm1
+ELSE
+    addps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps ENDP
+
+op_addps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    addps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_mem ENDP
+
+op_addps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm0, XMMWORD PTR [rdx]
+ELSE
+    addps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_mem_disp ENDP
+
+op_addps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    addps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_addps_self ENDP
+
+op_subps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    subps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps ENDP
+
+op_subps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    subps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    subps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_mem ENDP
+
+op_subps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    subps xmm0, XMMWORD PTR [rdx]
+ELSE
+    subps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_mem_disp ENDP
+
+op_subps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    subps xmm0, xmm1
+ELSE
+    subps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_subps_self ENDP
+
+op_mulps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    divps xmm0, xmm1
+ELSE
+    mulps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps ENDP
+
+op_mulps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_mem ENDP
+
+op_mulps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    mulps xmm0, XMMWORD PTR [rdx]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_mem_disp ENDP
+
+op_mulps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    mulps xmm0, xmm1
+ELSE
+    mulps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_mulps_self ENDP
+
+op_divps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    mulps xmm0, xmm1
+ELSE
+    divps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps ENDP
+
+op_divps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    divps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_mem ENDP
+
+op_divps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx]
+ELSE
+    divps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_mem_disp ENDP
+
+op_divps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    divps xmm0, xmm1
+ELSE
+    divps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_divps_self ENDP
+
+op_minps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    maxps xmm0, xmm1
+ELSE
+    minps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps ENDP
+
+op_minps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    minps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    minps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_mem ENDP
+
+op_minps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    minps xmm0, XMMWORD PTR [rdx]
+ELSE
+    minps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_mem_disp ENDP
+
+op_minps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    minps xmm0, xmm1
+ELSE
+    minps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_minps_self ENDP
+
+op_maxps PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    minps xmm0, xmm1
+ELSE
+    maxps xmm0, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps ENDP
+
+op_maxps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    maxps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    maxps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_mem ENDP
+
+op_maxps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    maxps xmm0, XMMWORD PTR [rdx]
+ELSE
+    maxps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_mem_disp ENDP
+
+op_maxps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    maxps xmm0, xmm1
+ELSE
+    maxps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_maxps_self ENDP
+
+op_sqrtps PROC FRAME
+    .endprolog
+    movaps xmm1, XMMWORD PTR [rdx]
+    movaps xmm2, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    addps xmm2, xmm1
+ELSE
+    sqrtps xmm2, xmm1
+ENDIF
+    movaps XMMWORD PTR [r8], xmm2
+    ret
+op_sqrtps ENDP
+
+op_sqrtps_mem PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    sqrtps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    sqrtps xmm0, XMMWORD PTR [rdx]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_mem ENDP
+
+op_sqrtps_mem_disp PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+IFDEF ALTER_IMM
+    sqrtps xmm0, XMMWORD PTR [rdx]
+ELSE
+    sqrtps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_mem_disp ENDP
+
+op_sqrtps_self PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+IFDEF ALTER_IMM
+    addps xmm0, xmm1
+ELSE
+    sqrtps xmm0, xmm0
+ENDIF
+    movaps XMMWORD PTR [r8], xmm0
+    ret
+op_sqrtps_self ENDP
+
+; Chained arithmetic: every operation feeds the next through registers, with a memory
+; source at +16 and a destination reused across instructions.
+op_arith_pipeline PROC FRAME
+    .endprolog
+    movaps xmm0, XMMWORD PTR [rcx]
+    movaps xmm1, XMMWORD PTR [rdx]
+    addps xmm0, xmm1
+IFDEF ALTER_IMM
+    divps xmm0, XMMWORD PTR [rdx+16]
+ELSE
+    mulps xmm0, XMMWORD PTR [rdx+16]
+ENDIF
+    subps xmm0, xmm1
+    movaps xmm2, XMMWORD PTR [rcx+16]
+    divps xmm2, xmm0
+    minps xmm2, xmm1
+    maxps xmm0, xmm2
+    sqrtps xmm3, xmm0
+    movaps XMMWORD PTR [r8], xmm3
+    movaps XMMWORD PTR [r8+16], xmm2
+    ret
+op_arith_pipeline ENDP
+
+; Test harness, not translated: runs fn(a, b, out) with MXCSR set to the fifth argument and
+; restores the caller's MXCSR before returning, so the host control word never leaks into the
+; checker. RCX = fn, RDX = a, R8 = b, R9 = out, [stack] = MXCSR value.
+op_call_with_mxcsr PROC FRAME
+    sub rsp, 56
+    .allocstack 56
+    .endprolog
+    mov r10, rcx
+    stmxcsr DWORD PTR [rsp+36]
+    mov eax, DWORD PTR [rsp+96]
+    mov DWORD PTR [rsp+40], eax
+    ldmxcsr DWORD PTR [rsp+40]

Fixed in 9b54fdd7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4675367311 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1213#discussion_r4675367311). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:03:45Z. **Code review location:** `tests/cpu/sse_fp.asm`; line 734 ~~~~diff @@ -341,4 +342,403 @@ op_pipeline PROC FRAME ret op_pipeline ENDP +; --- Packed float arithmetic: reg, aligned m128, m128 at +16 and self sources --- +; ALTER_IMM swaps each register-form operation (add/sub, mul/div, min/max; sqrt becomes +; add), moves each memory source by 16 bytes and replaces each self source by xmm1, so +; every lowering has a build that must differ on known words. + +op_addps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + subps xmm0, xmm1 +ELSE + addps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps ENDP + +op_addps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm0, XMMWORD PTR [rdx+16] +ELSE + addps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_mem ENDP + +op_addps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm0, XMMWORD PTR [rdx] +ELSE + addps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_mem_disp ENDP + +op_addps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + addps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_addps_self ENDP + +op_subps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + subps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps ENDP + +op_subps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + subps xmm0, XMMWORD PTR [rdx+16] +ELSE + subps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_mem ENDP + +op_subps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + subps xmm0, XMMWORD PTR [rdx] +ELSE + subps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_mem_disp ENDP + +op_subps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + subps xmm0, xmm1 +ELSE + subps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_subps_self ENDP + +op_mulps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + divps xmm0, xmm1 +ELSE + mulps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps ENDP + +op_mulps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + mulps xmm0, XMMWORD PTR [rdx+16] +ELSE + mulps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_mem ENDP + +op_mulps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + mulps xmm0, XMMWORD PTR [rdx] +ELSE + mulps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_mem_disp ENDP + +op_mulps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + mulps xmm0, xmm1 +ELSE + mulps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_mulps_self ENDP + +op_divps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + mulps xmm0, xmm1 +ELSE + divps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps ENDP + +op_divps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx+16] +ELSE + divps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_mem ENDP + +op_divps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx] +ELSE + divps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_mem_disp ENDP + +op_divps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + divps xmm0, xmm1 +ELSE + divps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_divps_self ENDP + +op_minps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + maxps xmm0, xmm1 +ELSE + minps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps ENDP + +op_minps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + minps xmm0, XMMWORD PTR [rdx+16] +ELSE + minps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_mem ENDP + +op_minps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + minps xmm0, XMMWORD PTR [rdx] +ELSE + minps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_mem_disp ENDP + +op_minps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + minps xmm0, xmm1 +ELSE + minps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_minps_self ENDP + +op_maxps PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + minps xmm0, xmm1 +ELSE + maxps xmm0, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps ENDP + +op_maxps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + maxps xmm0, XMMWORD PTR [rdx+16] +ELSE + maxps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_mem ENDP + +op_maxps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + maxps xmm0, XMMWORD PTR [rdx] +ELSE + maxps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_mem_disp ENDP + +op_maxps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + maxps xmm0, xmm1 +ELSE + maxps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_maxps_self ENDP + +op_sqrtps PROC FRAME + .endprolog + movaps xmm1, XMMWORD PTR [rdx] + movaps xmm2, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + addps xmm2, xmm1 +ELSE + sqrtps xmm2, xmm1 +ENDIF + movaps XMMWORD PTR [r8], xmm2 + ret +op_sqrtps ENDP + +op_sqrtps_mem PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + sqrtps xmm0, XMMWORD PTR [rdx+16] +ELSE + sqrtps xmm0, XMMWORD PTR [rdx] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_mem ENDP + +op_sqrtps_mem_disp PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] +IFDEF ALTER_IMM + sqrtps xmm0, XMMWORD PTR [rdx] +ELSE + sqrtps xmm0, XMMWORD PTR [rdx+16] +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_mem_disp ENDP + +op_sqrtps_self PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] +IFDEF ALTER_IMM + addps xmm0, xmm1 +ELSE + sqrtps xmm0, xmm0 +ENDIF + movaps XMMWORD PTR [r8], xmm0 + ret +op_sqrtps_self ENDP + +; Chained arithmetic: every operation feeds the next through registers, with a memory +; source at +16 and a destination reused across instructions. +op_arith_pipeline PROC FRAME + .endprolog + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rdx] + addps xmm0, xmm1 +IFDEF ALTER_IMM + divps xmm0, XMMWORD PTR [rdx+16] +ELSE + mulps xmm0, XMMWORD PTR [rdx+16] +ENDIF + subps xmm0, xmm1 + movaps xmm2, XMMWORD PTR [rcx+16] + divps xmm2, xmm0 + minps xmm2, xmm1 + maxps xmm0, xmm2 + sqrtps xmm3, xmm0 + movaps XMMWORD PTR [r8], xmm3 + movaps XMMWORD PTR [r8+16], xmm2 + ret +op_arith_pipeline ENDP + +; Test harness, not translated: runs fn(a, b, out) with MXCSR set to the fifth argument and +; restores the caller's MXCSR before returning, so the host control word never leaks into the +; checker. RCX = fn, RDX = a, R8 = b, R9 = out, [stack] = MXCSR value. +op_call_with_mxcsr PROC FRAME + sub rsp, 56 + .allocstack 56 + .endprolog + mov r10, rcx + stmxcsr DWORD PTR [rsp+36] + mov eax, DWORD PTR [rsp+96] + mov DWORD PTR [rsp+40], eax + ldmxcsr DWORD PTR [rsp+40] ~~~~ --- Fixed in 9b54fdd7.
upstream-sync closed this pull request 2026-11-24 09:04:20 +00:00
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!1206
No description provided.