cpu: lower AVX broadcast, permute, shuffle, blend, dot, round, and vzeroall instructions #384

Merged
Vonsek merged 4 commits from upstream-pr/390 into main 2026-11-23 17:27:36 +00:00
Vonsek commented 2026-11-22 00:07:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-22T00:07:12Z.


Change

  • Lower 26 VEX 128-bit and 256-bit AVX broadcast, lane extract/insert, permute, shuffle, unpack, blend, dot-product, round, and vzeroall instructions in tools/ffx_version_query.py:
    • Broadcasts and 128-bit lane ops: vbroadcastss, vbroadcastsd, vbroadcastf128, vextractf128, vinsertf128, vperm2f128
    • Permutes, shuffles, unpacks, and duplicates: vpermilps, vpermilpd, vshufps, vshufpd, vunpcklps, vunpckhps, vunpcklpd, vunpckhpd, vmovddup, vmovsldup, vmovshdup
    • Blends, dot products, rounding, and state clear: vblendps, vblendpd, vblendvps, vblendvpd, vdpps, vdppd, vroundps, vroundpd, vzeroall
  • Restrict lowering to EncodingKind.VEX (rejecting EVEX and MXCSR rounding mode imm8 & 4 != 0) and zero upper YMM bytes for 128-bit XMM destinations.
  • Probe CPUID leaf 1 ECX bits 27 (OSXSAVE) and 28 (AVX) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with SKIP_RETURN_CODE 77 on hosts without AVX).
  • Add source-built MASM differential fixture tests/cpu/avx_shuffle_blend.{asm,def,py}, CMake target cpu_avx_shuffle_blend_lifted, CTest cpu_aot_avx_shuffle_blend, coverage mapping in tools/form_coverage.py, and documentation in docs/experiments.md.

Verification

  • Confirmed pre-fix failure on cmake --build --preset dev --target cpu_avx_shuffle_blend_lifted:
    ValueError: unsupported query operation at 0x1000: vbroadcastss ymm0,dword ptr [rcx]
  • Built and tested on Windows 11 x64 (VS 2022 Build Tools):
    • cmake --build --preset dev --target cpu_avx_shuffle_blend_lifted succeeded with 0 warnings
    • ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_shuffle_blend|cpu_aot_bmi1)$" -V: 2/2 passed (26 AVX broadcast/permute/shuffle/blend/dot/round/zeroall cases matched native and translated DLLs + MXCSR-mode vroundps rejection control)
    • .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: form coverage checks passed

Evidence and follow-up

  • Covers 26 AVX-grouped mnemonics in docs/coverage/x64_zen2.tsv using source-built fixtures, gated by a runtime CPUID/XCR0 check.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536142129 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-22T00:07:12Z. --- ## Change - Lower 26 VEX 128-bit and 256-bit AVX broadcast, lane extract/insert, permute, shuffle, unpack, blend, dot-product, round, and `vzeroall` instructions in `tools/ffx_version_query.py`: - Broadcasts and 128-bit lane ops: `vbroadcastss`, `vbroadcastsd`, `vbroadcastf128`, `vextractf128`, `vinsertf128`, `vperm2f128` - Permutes, shuffles, unpacks, and duplicates: `vpermilps`, `vpermilpd`, `vshufps`, `vshufpd`, `vunpcklps`, `vunpckhps`, `vunpcklpd`, `vunpckhpd`, `vmovddup`, `vmovsldup`, `vmovshdup` - Blends, dot products, rounding, and state clear: `vblendps`, `vblendpd`, `vblendvps`, `vblendvpd`, `vdpps`, `vdppd`, `vroundps`, `vroundpd`, `vzeroall` - Restrict lowering to `EncodingKind.VEX` (rejecting EVEX and MXCSR rounding mode imm8 & 4 != 0) and zero upper YMM bytes for 128-bit XMM destinations. - Probe CPUID leaf 1 ECX bits 27 (`OSXSAVE`) and 28 (`AVX`) plus XCR0 XMM/YMM state before invoking the native fixture (exiting 77 with `SKIP_RETURN_CODE 77` on hosts without AVX). - Add source-built MASM differential fixture `tests/cpu/avx_shuffle_blend.{asm,def,py}`, CMake target `cpu_avx_shuffle_blend_lifted`, CTest `cpu_aot_avx_shuffle_blend`, coverage mapping in `tools/form_coverage.py`, and documentation in `docs/experiments.md`. ## Verification - Confirmed pre-fix failure on `cmake --build --preset dev --target cpu_avx_shuffle_blend_lifted`: `ValueError: unsupported query operation at 0x1000: vbroadcastss ymm0,dword ptr [rcx]` - Built and tested on Windows 11 x64 (VS 2022 Build Tools): - `cmake --build --preset dev --target cpu_avx_shuffle_blend_lifted` succeeded with 0 warnings - `ctest --preset dev --no-tests=error -R "^(cpu_aot_avx_shuffle_blend|cpu_aot_bmi1)$" -V`: 2/2 passed (`26 AVX broadcast/permute/shuffle/blend/dot/round/zeroall cases matched native and translated DLLs` + MXCSR-mode `vroundps` rejection control) - `.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py`: `form coverage checks passed` ## Evidence and follow-up - Covers 26 `AVX`-grouped mnemonics in `docs/coverage/x64_zen2.tsv` using source-built fixtures, gated by a runtime CPUID/XCR0 check.
upstream-sync closed this pull request 2026-11-24 06:42:47 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:42:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-22T00:20:10Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0881a1512

ℹ️ 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:6009144292 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#pullrequestreview-6009144292). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:20:10Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `a0881a1512` <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:48:14 +00:00 (Migrated from github.com)

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


Codex Review Summary: ✅ Completed

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

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

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

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

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7071372757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#issuecomment-7071372757). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:11:01Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a0881a1512acb65a6b915fc00bd6613f354a2fbe","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-22T00:20:13.905996Z">2026-11-22T00:20:13.905996Z</relative-time> | `a0881a1` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
legacy-code-archaeologist commented 2026-11-24 06:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T19:26:04Z.


Verified afc5773 on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, dev preset. ctest --preset dev --no-tests=error -R "^cpu_" -j 4 passes 81 of 81 on this branch's base.

Two notes:

  • tests/cpu/avx_shuffle_blend.py exercises vdpps_op/vdppd_op only with finite inputs; there are no NaN or infinity lanes. In #602 a DPPS case with several NaN products failed on this Intel host because the reference model encodes one vendor's NaN choice, and the translation runs the host's own dot-product instruction. The same case does not arise here yet, but a multi-NaN dot product would need the same vendor-tolerant check.
  • The branch no longer merges cleanly with main at ff7f68a (git merge-tree).

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7084398376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#issuecomment-7084398376). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T19:26:04Z. --- Verified `afc5773` on an Intel Core i7-6820HQ (Skylake), Windows 11 26100.9168, MSVC/ML64 19.52.37029, `dev` preset. `ctest --preset dev --no-tests=error -R "^cpu_" -j 4` passes 81 of 81 on this branch's base. Two notes: - `tests/cpu/avx_shuffle_blend.py` exercises `vdpps_op/vdppd_op` only with finite inputs; there are no NaN or infinity lanes. In #602 a DPPS case with several NaN products failed on this Intel host because the reference model encodes one vendor's NaN choice, and the translation runs the host's own dot-product instruction. The same case does not arise here yet, but a multi-NaN dot product would need the same vendor-tolerant check. - The branch no longer merges cleanly with `main` at `ff7f68a` (`git merge-tree`). AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 06:49:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:59:54Z.


Updated the branch to adb3101 and preserved the existing XMM shuffle paths and #404 packed integer regression. The new YMM paths now run through the correct width dispatch. The XMM memory VMOVDDUP reads only the decoded eight bytes, verified at a no-access page boundary. VDPPS uses the host lane operation and passes the cancellation case that distinguishes a left-to-right sum. The multiple-NaN check accepts a NaN in selected lanes and still compares the other lanes bit for bit. The original AVX fixture and the existing SSE3/4, AVX packed FP and AVX integer shift/pack checks passed 4/4 in both Debug and Release. Fresh CI will run on the updated head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7107994508 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#issuecomment-7107994508). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T16:59:54Z. --- Updated the branch to adb3101 and preserved the existing XMM shuffle paths and #404 packed integer regression. The new YMM paths now run through the correct width dispatch. The XMM memory VMOVDDUP reads only the decoded eight bytes, verified at a no-access page boundary. VDPPS uses the host lane operation and passes the cancellation case that distinguishes a left-to-right sum. The multiple-NaN check accepts a NaN in selected lanes and still compares the other lanes bit for bit. The original AVX fixture and the existing SSE3/4, AVX packed FP and AVX integer shift/pack checks passed 4/4 in both Debug and Release. Fresh CI will run on the updated head.
R0Y00 commented 2026-11-24 06:49:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T17:08:46Z.


d9320ba adds a Win64-native wrapper that saves and restores XMM6–XMM15 around the raw VZEROALL fixture. A separate native call now checks that an XMM6 sentinel survives. It also adds exact signaling-NaN readbacks for VROUNDPS and VROUNDPD with the invalid exception masked. This verifies the packed round intrinsics, in addition to the eight-byte VMOVDDUP guard-page and VDPPS cancellation checks from the earlier update. All four focused tests passed in Debug and Release.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7108217602 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#issuecomment-7108217602). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T17:08:46Z. --- d9320ba adds a Win64-native wrapper that saves and restores XMM6–XMM15 around the raw VZEROALL fixture. A separate native call now checks that an XMM6 sentinel survives. It also adds exact signaling-NaN readbacks for VROUNDPS and VROUNDPD with the invalid exception masked. This verifies the packed round intrinsics, in addition to the eight-byte VMOVDDUP guard-page and VDPPS cancellation checks from the earlier update. All four focused tests passed in Debug and Release.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-22T00:20:11Z.

Code review location: tools/ffx_version_query.py; line 369

@@ -210,6 +230,145 @@ def write(expr):
             stmt = (f"{{ auto input = {src}; {dst} = {{}}; for (size_t n=0; n<16; n+=4) {{ "
                     f"auto v = load<uint32_t>(reinterpret_cast<word>(input.data()+n)) {operation}; "
                     f"memcpy({dst}.data()+n, &v, 4); }} }}")
+        elif op == M.VZEROALL and i.encoding == EncodingKind.VEX:
+            stmt = " ".join(f"{v} = {{}};" for v in wide.values()) if has_wide else ";"
+        elif op in avx_shuffle_ops and op != M.VZEROALL and i.encoding == EncodingKind.VEX and has_wide:
+            if op == M.VEXTRACTF128:
+                src = wide[i.op1_register]
+                lane = (i.immediate(2) & 1) * 16
+                if i.op0_kind == K.REGISTER and i.op0_register in wide_xmm:
+                    dst = wide_xmm[i.op0_register]
+                    stmt = f"{{ auto s = {src}; {dst} = {{}}; memcpy({dst}.data(), s.data()+{lane}, 16); }}"
+                elif i.op0_kind == K.MEMORY:
+                    stmt = f"memcpy(reinterpret_cast<void*>({address()}), {src}.data()+{lane}, 16);"
+                else:
+                    raise ValueError(f"unsupported VEXTRACTF128 dest at {i.ip:#x}: {i}")
+            elif op == M.VINSERTF128:
+                dst, src1 = wide[i.op0_register], wide[i.op1_register]
+                lane = (i.immediate(3) & 1) * 16
+                if i.op2_kind == K.REGISTER and i.op2_register in wide_xmm:
+                    s2 = f"uint8_t s2[16]; memcpy(s2, {wide_xmm[i.op2_register]}.data(), 16);"
+                elif i.op2_kind == K.MEMORY:
+                    s2 = f"uint8_t s2[16]; memcpy(s2, reinterpret_cast<const void*>({address()}), 16);"
+                else:
+                    raise ValueError(f"unsupported VINSERTF128 src2 at {i.ip:#x}: {i}")
+                stmt = f"{{ auto t = {src1}; {s2} memcpy(t.data()+{lane}, s2, 16); {dst} = t; }}"
+            elif op in (M.VBROADCASTSS, M.VBROADCASTSD, M.VBROADCASTF128):
+                dst = wide_any[i.op0_register]
+                nbytes = 32 if i.op0_register in wide else 16
+                elem = {M.VBROADCASTSS: 4, M.VBROADCASTSD: 8, M.VBROADCASTF128: 16}[op]
+                zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else ""
+                if i.op1_kind == K.MEMORY:
+                    s_init = f"uint8_t e[{elem}]; memcpy(e, reinterpret_cast<const void*>({address()}), {elem});"
+                elif i.op1_kind == K.REGISTER and i.op1_register in wide_xmm:
+                    s_init = f"uint8_t e[{elem}]; memcpy(e, {wide_xmm[i.op1_register]}.data(), {elem});"
+                else:
+                    raise ValueError(f"unsupported broadcast source at {i.ip:#x}: {i}")
+                stmt = f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={elem}) memcpy({dst}.data()+n, e, {elem});{zero_hi} }}"
+            elif op == M.VPERM2F128:
+                dst, src1 = wide[i.op0_register], wide[i.op1_register]
+                imm = i.immediate(3)
+                s2 = (f"auto s2 = {wide[i.op2_register]};" if i.op2_kind == K.REGISTER
+                      else f"auto s2 = load<std::array<uint8_t,32>>({address()});")
+                def p2_lane(sel, out_off):
+                    if sel & 8:
+                        return f"memset({dst}.data()+{out_off}, 0, 16);"
+                    src_name = "s1" if (sel & 2) == 0 else "s2"
+                    src_off = 16 if (sel & 1) else 0
+                    return f"memcpy({dst}.data()+{out_off}, {src_name}.data()+{src_off}, 16);"
+                stmt = f"{{ auto s1 = {src1}; {s2} {p2_lane(imm & 0xf, 0)} {p2_lane((imm >> 4) & 0xf, 16)} }}"
+            elif op in (M.VMOVDDUP, M.VMOVSLDUP, M.VMOVSHDUP, M.VROUNDPS, M.VROUNDPD) or (op in (M.VPERMILPS, M.VPERMILPD) and i.op2_kind == K.IMMEDIATE8):
+                dst = wide_any[i.op0_register]
+                nbytes = 32 if i.op0_register in wide else 16
+                zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else ""
+                s_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op1_register]};" if i.op1_kind == K.REGISTER
+                          else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});")
+                if op == M.VMOVDDUP:
+                    stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"memcpy({dst}.data()+l, rhs.data()+l, 8); memcpy({dst}.data()+l+8, rhs.data()+l, 8); }}{zero_hi} }}")
+                elif op == M.VMOVSLDUP:
+                    stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=8) {{ "
+                            f"memcpy({dst}.data()+l, rhs.data()+l, 4); memcpy({dst}.data()+l+4, rhs.data()+l, 4); }}{zero_hi} }}")
+                elif op == M.VMOVSHDUP:
+                    stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=8) {{ "
+                            f"memcpy({dst}.data()+l, rhs.data()+l+4, 4); memcpy({dst}.data()+l+4, rhs.data()+l+4, 4); }}{zero_hi} }}")
+                elif op == M.VPERMILPS:
+                    imm = i.immediate(2)
+                    copies = " ".join(f"memcpy({dst}.data()+l+{4*k}, rhs.data()+l+{4*((imm >> (2*k)) & 3)}, 4);" for k in range(4))
+                    stmt = f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=16) {{ {copies} }}{zero_hi} }}"
+                elif op == M.VPERMILPD:
+                    imm = i.immediate(2)
+                    stmt = (f"{{ {s_init} for (size_t g=0; g<{nbytes // 16}; ++g) {{ "
+                            f"const unsigned s0 = ({imm}u >> (2u * g)) & 1u, s1 = ({imm}u >> (2u * g + 1u)) & 1u; "
+                            f"memcpy({dst}.data()+16*g, rhs.data()+16*g+8*s0, 8); "
+                            f"memcpy({dst}.data()+16*g+8, rhs.data()+16*g+8*s1, 8); }}{zero_hi} }}")
+                else:  # VROUNDPS, VROUNDPD
+                    imm = i.immediate(2)
+                    if imm & 4:
+                        raise ValueError(f"unsupported MXCSR rounding mode in {op} at {i.ip:#x}: {i}")
+                    mode = imm & 3
+                    ftype, lane_size = ("float", 4) if op == M.VROUNDPS else ("double", 8)
+                    stmt = (f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={lane_size}) {{ "
+                            f"{ftype} b; memcpy(&b, rhs.data()+n, {lane_size}); "
+                            f"const {ftype} v = round_x86(b, {mode}u); memcpy({dst}.data()+n, &v, {lane_size}); }}{zero_hi} }}")
+            else:
+                dst, src1 = wide_any[i.op0_register], wide_any[i.op1_register]
+                nbytes = 32 if i.op0_register in wide else 16
+                zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else ""
+                s2_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op2_register]};" if i.op2_kind == K.REGISTER
+                           else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});")
+                if op == M.VPERMILPS:
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"for (size_t k=0; k<4; ++k) {{ uint32_t c; memcpy(&c, rhs.data()+l+4*k, 4); "
+                            f"memcpy({dst}.data()+l+4*k, lhs.data()+l+4*(c & 3u), 4); }} }}{zero_hi} }}")
+                elif op == M.VPERMILPD:
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"for (size_t k=0; k<2; ++k) {{ uint64_t c; memcpy(&c, rhs.data()+l+8*k, 8); "
+                            f"memcpy({dst}.data()+l+8*k, lhs.data()+l+8*((c >> 1) & 1u), 8); }} }}{zero_hi} }}")
+                elif op == M.VSHUFPS:
+                    imm = i.immediate(3)
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"memcpy({dst}.data()+l+0, lhs.data()+l+{4*(imm & 3)}, 4); "
+                            f"memcpy({dst}.data()+l+4, lhs.data()+l+{4*((imm >> 2) & 3)}, 4); "
+                            f"memcpy({dst}.data()+l+8, rhs.data()+l+{4*((imm >> 4) & 3)}, 4); "
+                            f"memcpy({dst}.data()+l+12, rhs.data()+l+{4*((imm >> 6) & 3)}, 4); }}{zero_hi} }}")
+                elif op == M.VSHUFPD:
+                    imm = i.immediate(3)
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t g=0; g<{nbytes // 16}; ++g) {{ "
+                            f"const unsigned s0 = ({imm}u >> (2u * g)) & 1u, s1 = ({imm}u >> (2u * g + 1u)) & 1u; "
+                            f"memcpy({dst}.data()+16*g, lhs.data()+16*g+8*s0, 8); "
+                            f"memcpy({dst}.data()+16*g+8, rhs.data()+16*g+8*s1, 8); }}{zero_hi} }}")
+                elif op in (M.VUNPCKLPS, M.VUNPCKHPS, M.VUNPCKLPD, M.VUNPCKHPD):
+                    lane_size = 4 if op in (M.VUNPCKLPS, M.VUNPCKHPS) else 8
+                    base = 0 if op in (M.VUNPCKLPS, M.VUNPCKLPD) else 8
+                    pairs = 8 // lane_size
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"for (size_t k=0; k<{pairs}; ++k) {{ "
+                            f"memcpy({dst}.data()+l+2*k*{lane_size}, lhs.data()+l+{base}+k*{lane_size}, {lane_size}); "
+                            f"memcpy({dst}.data()+l+(2*k+1)*{lane_size}, rhs.data()+l+{base}+k*{lane_size}, {lane_size}); }} }}{zero_hi} }}")
+                elif op in (M.VBLENDPS, M.VBLENDPD):
+                    imm = i.immediate(3)
+                    lane_size = 4 if op == M.VBLENDPS else 8
+                    lanes = nbytes // lane_size
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t k=0; k<{lanes}; ++k) {{ "
+                            f"const auto& p = (({imm}u >> k) & 1u) ? rhs : lhs; "
+                            f"memcpy({dst}.data()+k*{lane_size}, p.data()+k*{lane_size}, {lane_size}); }}{zero_hi} }}")
+                elif op in (M.VBLENDVPS, M.VBLENDVPD):
+                    mask_reg = wide_any[i.op3_register]
+                    lane_size = 4 if op == M.VBLENDVPS else 8
+                    lanes = nbytes // lane_size
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} auto m = {mask_reg}; for (size_t k=0; k<{lanes}; ++k) {{ "
+                            f"const auto& p = (m[(k + 1) * {lane_size} - 1] & 0x80u) ? rhs : lhs; "
+                            f"memcpy({dst}.data()+k*{lane_size}, p.data()+k*{lane_size}, {lane_size}); }}{zero_hi} }}")
+                else:  # VDPPS, VDPPD
+                    imm = i.immediate(3)
+                    ftype, lane_size, lanes = ("float", 4, 4) if op == M.VDPPS else ("double", 8, 2)
+                    stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ "
+                            f"{ftype} a[{lanes}], b[{lanes}], s = {ftype}(0); "
+                            f"memcpy(a, lhs.data()+l, 16); memcpy(b, rhs.data()+l, 16); "
+                            f"for (size_t k=0; k<{lanes}; ++k) {{ if (({imm}u >> (4u + k)) & 1u) s += a[k] * b[k]; }} "

P2 Badge Preserve the pairwise reduction order of VDPPS

For cancellation-sensitive inputs, this sequential accumulation produces different results from the instruction. With the fixture's existing 0xd5 immediate, source lanes [1e20f, 0, -1e20f, 3] dotted with [1, 1, 1, 1] produce 0 natively but 3 in the emitted code, reproduced with a source-built AVX probe under default MXCSR. VDPPS reduces the masked products as (p0 + p1) + (p2 + p3), with intermediate rounding, rather than accumulating left to right. Emit that reduction tree and add a cancellation-sensitive differential case.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4655735367 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#discussion_r4655735367). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:20:11Z. **Code review location:** `tools/ffx_version_query.py`; line 369 ~~~~diff @@ -210,6 +230,145 @@ def write(expr): stmt = (f"{{ auto input = {src}; {dst} = {{}}; for (size_t n=0; n<16; n+=4) {{ " f"auto v = load<uint32_t>(reinterpret_cast<word>(input.data()+n)) {operation}; " f"memcpy({dst}.data()+n, &v, 4); }} }}") + elif op == M.VZEROALL and i.encoding == EncodingKind.VEX: + stmt = " ".join(f"{v} = {{}};" for v in wide.values()) if has_wide else ";" + elif op in avx_shuffle_ops and op != M.VZEROALL and i.encoding == EncodingKind.VEX and has_wide: + if op == M.VEXTRACTF128: + src = wide[i.op1_register] + lane = (i.immediate(2) & 1) * 16 + if i.op0_kind == K.REGISTER and i.op0_register in wide_xmm: + dst = wide_xmm[i.op0_register] + stmt = f"{{ auto s = {src}; {dst} = {{}}; memcpy({dst}.data(), s.data()+{lane}, 16); }}" + elif i.op0_kind == K.MEMORY: + stmt = f"memcpy(reinterpret_cast<void*>({address()}), {src}.data()+{lane}, 16);" + else: + raise ValueError(f"unsupported VEXTRACTF128 dest at {i.ip:#x}: {i}") + elif op == M.VINSERTF128: + dst, src1 = wide[i.op0_register], wide[i.op1_register] + lane = (i.immediate(3) & 1) * 16 + if i.op2_kind == K.REGISTER and i.op2_register in wide_xmm: + s2 = f"uint8_t s2[16]; memcpy(s2, {wide_xmm[i.op2_register]}.data(), 16);" + elif i.op2_kind == K.MEMORY: + s2 = f"uint8_t s2[16]; memcpy(s2, reinterpret_cast<const void*>({address()}), 16);" + else: + raise ValueError(f"unsupported VINSERTF128 src2 at {i.ip:#x}: {i}") + stmt = f"{{ auto t = {src1}; {s2} memcpy(t.data()+{lane}, s2, 16); {dst} = t; }}" + elif op in (M.VBROADCASTSS, M.VBROADCASTSD, M.VBROADCASTF128): + dst = wide_any[i.op0_register] + nbytes = 32 if i.op0_register in wide else 16 + elem = {M.VBROADCASTSS: 4, M.VBROADCASTSD: 8, M.VBROADCASTF128: 16}[op] + zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else "" + if i.op1_kind == K.MEMORY: + s_init = f"uint8_t e[{elem}]; memcpy(e, reinterpret_cast<const void*>({address()}), {elem});" + elif i.op1_kind == K.REGISTER and i.op1_register in wide_xmm: + s_init = f"uint8_t e[{elem}]; memcpy(e, {wide_xmm[i.op1_register]}.data(), {elem});" + else: + raise ValueError(f"unsupported broadcast source at {i.ip:#x}: {i}") + stmt = f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={elem}) memcpy({dst}.data()+n, e, {elem});{zero_hi} }}" + elif op == M.VPERM2F128: + dst, src1 = wide[i.op0_register], wide[i.op1_register] + imm = i.immediate(3) + s2 = (f"auto s2 = {wide[i.op2_register]};" if i.op2_kind == K.REGISTER + else f"auto s2 = load<std::array<uint8_t,32>>({address()});") + def p2_lane(sel, out_off): + if sel & 8: + return f"memset({dst}.data()+{out_off}, 0, 16);" + src_name = "s1" if (sel & 2) == 0 else "s2" + src_off = 16 if (sel & 1) else 0 + return f"memcpy({dst}.data()+{out_off}, {src_name}.data()+{src_off}, 16);" + stmt = f"{{ auto s1 = {src1}; {s2} {p2_lane(imm & 0xf, 0)} {p2_lane((imm >> 4) & 0xf, 16)} }}" + elif op in (M.VMOVDDUP, M.VMOVSLDUP, M.VMOVSHDUP, M.VROUNDPS, M.VROUNDPD) or (op in (M.VPERMILPS, M.VPERMILPD) and i.op2_kind == K.IMMEDIATE8): + dst = wide_any[i.op0_register] + nbytes = 32 if i.op0_register in wide else 16 + zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else "" + s_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op1_register]};" if i.op1_kind == K.REGISTER + else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});") + if op == M.VMOVDDUP: + stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"memcpy({dst}.data()+l, rhs.data()+l, 8); memcpy({dst}.data()+l+8, rhs.data()+l, 8); }}{zero_hi} }}") + elif op == M.VMOVSLDUP: + stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=8) {{ " + f"memcpy({dst}.data()+l, rhs.data()+l, 4); memcpy({dst}.data()+l+4, rhs.data()+l, 4); }}{zero_hi} }}") + elif op == M.VMOVSHDUP: + stmt = (f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=8) {{ " + f"memcpy({dst}.data()+l, rhs.data()+l+4, 4); memcpy({dst}.data()+l+4, rhs.data()+l+4, 4); }}{zero_hi} }}") + elif op == M.VPERMILPS: + imm = i.immediate(2) + copies = " ".join(f"memcpy({dst}.data()+l+{4*k}, rhs.data()+l+{4*((imm >> (2*k)) & 3)}, 4);" for k in range(4)) + stmt = f"{{ {s_init} for (size_t l=0; l<{nbytes}; l+=16) {{ {copies} }}{zero_hi} }}" + elif op == M.VPERMILPD: + imm = i.immediate(2) + stmt = (f"{{ {s_init} for (size_t g=0; g<{nbytes // 16}; ++g) {{ " + f"const unsigned s0 = ({imm}u >> (2u * g)) & 1u, s1 = ({imm}u >> (2u * g + 1u)) & 1u; " + f"memcpy({dst}.data()+16*g, rhs.data()+16*g+8*s0, 8); " + f"memcpy({dst}.data()+16*g+8, rhs.data()+16*g+8*s1, 8); }}{zero_hi} }}") + else: # VROUNDPS, VROUNDPD + imm = i.immediate(2) + if imm & 4: + raise ValueError(f"unsupported MXCSR rounding mode in {op} at {i.ip:#x}: {i}") + mode = imm & 3 + ftype, lane_size = ("float", 4) if op == M.VROUNDPS else ("double", 8) + stmt = (f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={lane_size}) {{ " + f"{ftype} b; memcpy(&b, rhs.data()+n, {lane_size}); " + f"const {ftype} v = round_x86(b, {mode}u); memcpy({dst}.data()+n, &v, {lane_size}); }}{zero_hi} }}") + else: + dst, src1 = wide_any[i.op0_register], wide_any[i.op1_register] + nbytes = 32 if i.op0_register in wide else 16 + zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else "" + s2_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op2_register]};" if i.op2_kind == K.REGISTER + else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});") + if op == M.VPERMILPS: + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"for (size_t k=0; k<4; ++k) {{ uint32_t c; memcpy(&c, rhs.data()+l+4*k, 4); " + f"memcpy({dst}.data()+l+4*k, lhs.data()+l+4*(c & 3u), 4); }} }}{zero_hi} }}") + elif op == M.VPERMILPD: + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"for (size_t k=0; k<2; ++k) {{ uint64_t c; memcpy(&c, rhs.data()+l+8*k, 8); " + f"memcpy({dst}.data()+l+8*k, lhs.data()+l+8*((c >> 1) & 1u), 8); }} }}{zero_hi} }}") + elif op == M.VSHUFPS: + imm = i.immediate(3) + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"memcpy({dst}.data()+l+0, lhs.data()+l+{4*(imm & 3)}, 4); " + f"memcpy({dst}.data()+l+4, lhs.data()+l+{4*((imm >> 2) & 3)}, 4); " + f"memcpy({dst}.data()+l+8, rhs.data()+l+{4*((imm >> 4) & 3)}, 4); " + f"memcpy({dst}.data()+l+12, rhs.data()+l+{4*((imm >> 6) & 3)}, 4); }}{zero_hi} }}") + elif op == M.VSHUFPD: + imm = i.immediate(3) + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t g=0; g<{nbytes // 16}; ++g) {{ " + f"const unsigned s0 = ({imm}u >> (2u * g)) & 1u, s1 = ({imm}u >> (2u * g + 1u)) & 1u; " + f"memcpy({dst}.data()+16*g, lhs.data()+16*g+8*s0, 8); " + f"memcpy({dst}.data()+16*g+8, rhs.data()+16*g+8*s1, 8); }}{zero_hi} }}") + elif op in (M.VUNPCKLPS, M.VUNPCKHPS, M.VUNPCKLPD, M.VUNPCKHPD): + lane_size = 4 if op in (M.VUNPCKLPS, M.VUNPCKHPS) else 8 + base = 0 if op in (M.VUNPCKLPS, M.VUNPCKLPD) else 8 + pairs = 8 // lane_size + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"for (size_t k=0; k<{pairs}; ++k) {{ " + f"memcpy({dst}.data()+l+2*k*{lane_size}, lhs.data()+l+{base}+k*{lane_size}, {lane_size}); " + f"memcpy({dst}.data()+l+(2*k+1)*{lane_size}, rhs.data()+l+{base}+k*{lane_size}, {lane_size}); }} }}{zero_hi} }}") + elif op in (M.VBLENDPS, M.VBLENDPD): + imm = i.immediate(3) + lane_size = 4 if op == M.VBLENDPS else 8 + lanes = nbytes // lane_size + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t k=0; k<{lanes}; ++k) {{ " + f"const auto& p = (({imm}u >> k) & 1u) ? rhs : lhs; " + f"memcpy({dst}.data()+k*{lane_size}, p.data()+k*{lane_size}, {lane_size}); }}{zero_hi} }}") + elif op in (M.VBLENDVPS, M.VBLENDVPD): + mask_reg = wide_any[i.op3_register] + lane_size = 4 if op == M.VBLENDVPS else 8 + lanes = nbytes // lane_size + stmt = (f"{{ auto lhs = {src1}; {s2_init} auto m = {mask_reg}; for (size_t k=0; k<{lanes}; ++k) {{ " + f"const auto& p = (m[(k + 1) * {lane_size} - 1] & 0x80u) ? rhs : lhs; " + f"memcpy({dst}.data()+k*{lane_size}, p.data()+k*{lane_size}, {lane_size}); }}{zero_hi} }}") + else: # VDPPS, VDPPD + imm = i.immediate(3) + ftype, lane_size, lanes = ("float", 4, 4) if op == M.VDPPS else ("double", 8, 2) + stmt = (f"{{ auto lhs = {src1}; {s2_init} for (size_t l=0; l<{nbytes}; l+=16) {{ " + f"{ftype} a[{lanes}], b[{lanes}], s = {ftype}(0); " + f"memcpy(a, lhs.data()+l, 16); memcpy(b, rhs.data()+l, 16); " + f"for (size_t k=0; k<{lanes}; ++k) {{ if (({imm}u >> (4u + k)) & 1u) s += a[k] * b[k]; }} " ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve the pairwise reduction order of VDPPS** For cancellation-sensitive inputs, this sequential accumulation produces different results from the instruction. With the fixture's existing `0xd5` immediate, source lanes `[1e20f, 0, -1e20f, 3]` dotted with `[1, 1, 1, 1]` produce `0` natively but `3` in the emitted code, reproduced with a source-built AVX probe under default MXCSR. VDPPS reduces the masked products as `(p0 + p1) + (p2 + p3)`, with intermediate rounding, rather than accumulating left to right. Emit that reduction tree and add a cancellation-sensitive differential case. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 06:50:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-22T00:20:11Z.

Code review location: tools/ffx_version_query.py; line 285

@@ -210,6 +230,145 @@ def write(expr):
             stmt = (f"{{ auto input = {src}; {dst} = {{}}; for (size_t n=0; n<16; n+=4) {{ "
                     f"auto v = load<uint32_t>(reinterpret_cast<word>(input.data()+n)) {operation}; "
                     f"memcpy({dst}.data()+n, &v, 4); }} }}")
+        elif op == M.VZEROALL and i.encoding == EncodingKind.VEX:
+            stmt = " ".join(f"{v} = {{}};" for v in wide.values()) if has_wide else ";"
+        elif op in avx_shuffle_ops and op != M.VZEROALL and i.encoding == EncodingKind.VEX and has_wide:
+            if op == M.VEXTRACTF128:
+                src = wide[i.op1_register]
+                lane = (i.immediate(2) & 1) * 16
+                if i.op0_kind == K.REGISTER and i.op0_register in wide_xmm:
+                    dst = wide_xmm[i.op0_register]
+                    stmt = f"{{ auto s = {src}; {dst} = {{}}; memcpy({dst}.data(), s.data()+{lane}, 16); }}"
+                elif i.op0_kind == K.MEMORY:
+                    stmt = f"memcpy(reinterpret_cast<void*>({address()}), {src}.data()+{lane}, 16);"
+                else:
+                    raise ValueError(f"unsupported VEXTRACTF128 dest at {i.ip:#x}: {i}")
+            elif op == M.VINSERTF128:
+                dst, src1 = wide[i.op0_register], wide[i.op1_register]
+                lane = (i.immediate(3) & 1) * 16
+                if i.op2_kind == K.REGISTER and i.op2_register in wide_xmm:
+                    s2 = f"uint8_t s2[16]; memcpy(s2, {wide_xmm[i.op2_register]}.data(), 16);"
+                elif i.op2_kind == K.MEMORY:
+                    s2 = f"uint8_t s2[16]; memcpy(s2, reinterpret_cast<const void*>({address()}), 16);"
+                else:
+                    raise ValueError(f"unsupported VINSERTF128 src2 at {i.ip:#x}: {i}")
+                stmt = f"{{ auto t = {src1}; {s2} memcpy(t.data()+{lane}, s2, 16); {dst} = t; }}"
+            elif op in (M.VBROADCASTSS, M.VBROADCASTSD, M.VBROADCASTF128):
+                dst = wide_any[i.op0_register]
+                nbytes = 32 if i.op0_register in wide else 16
+                elem = {M.VBROADCASTSS: 4, M.VBROADCASTSD: 8, M.VBROADCASTF128: 16}[op]
+                zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else ""
+                if i.op1_kind == K.MEMORY:
+                    s_init = f"uint8_t e[{elem}]; memcpy(e, reinterpret_cast<const void*>({address()}), {elem});"
+                elif i.op1_kind == K.REGISTER and i.op1_register in wide_xmm:
+                    s_init = f"uint8_t e[{elem}]; memcpy(e, {wide_xmm[i.op1_register]}.data(), {elem});"
+                else:
+                    raise ValueError(f"unsupported broadcast source at {i.ip:#x}: {i}")
+                stmt = f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={elem}) memcpy({dst}.data()+n, e, {elem});{zero_hi} }}"
+            elif op == M.VPERM2F128:
+                dst, src1 = wide[i.op0_register], wide[i.op1_register]
+                imm = i.immediate(3)
+                s2 = (f"auto s2 = {wide[i.op2_register]};" if i.op2_kind == K.REGISTER
+                      else f"auto s2 = load<std::array<uint8_t,32>>({address()});")
+                def p2_lane(sel, out_off):
+                    if sel & 8:
+                        return f"memset({dst}.data()+{out_off}, 0, 16);"
+                    src_name = "s1" if (sel & 2) == 0 else "s2"
+                    src_off = 16 if (sel & 1) else 0
+                    return f"memcpy({dst}.data()+{out_off}, {src_name}.data()+{src_off}, 16);"
+                stmt = f"{{ auto s1 = {src1}; {s2} {p2_lane(imm & 0xf, 0)} {p2_lane((imm >> 4) & 0xf, 16)} }}"
+            elif op in (M.VMOVDDUP, M.VMOVSLDUP, M.VMOVSHDUP, M.VROUNDPS, M.VROUNDPD) or (op in (M.VPERMILPS, M.VPERMILPD) and i.op2_kind == K.IMMEDIATE8):
+                dst = wide_any[i.op0_register]
+                nbytes = 32 if i.op0_register in wide else 16
+                zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else ""
+                s_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op1_register]};" if i.op1_kind == K.REGISTER
+                          else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});")

P2 Badge Limit XMM VMOVDDUP memory loads to eight bytes

For vmovddup xmm0, qword ptr [rcx], the architectural memory operand is only eight bytes, but nbytes is 16 because it describes the destination width. This initializer consequently reads eight bytes beyond the operand. When the source occupies the last eight readable bytes before a protected page, the native instruction succeeds while the emitted code faults in an unoptimized build; this was reproduced with a guarded-page probe. Derive the read size from the memory operand or special-case the 128-bit VMOVDDUP form instead of using the output width.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4655735374 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#discussion_r4655735374). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:20:11Z. **Code review location:** `tools/ffx_version_query.py`; line 285 ~~~~diff @@ -210,6 +230,145 @@ def write(expr): stmt = (f"{{ auto input = {src}; {dst} = {{}}; for (size_t n=0; n<16; n+=4) {{ " f"auto v = load<uint32_t>(reinterpret_cast<word>(input.data()+n)) {operation}; " f"memcpy({dst}.data()+n, &v, 4); }} }}") + elif op == M.VZEROALL and i.encoding == EncodingKind.VEX: + stmt = " ".join(f"{v} = {{}};" for v in wide.values()) if has_wide else ";" + elif op in avx_shuffle_ops and op != M.VZEROALL and i.encoding == EncodingKind.VEX and has_wide: + if op == M.VEXTRACTF128: + src = wide[i.op1_register] + lane = (i.immediate(2) & 1) * 16 + if i.op0_kind == K.REGISTER and i.op0_register in wide_xmm: + dst = wide_xmm[i.op0_register] + stmt = f"{{ auto s = {src}; {dst} = {{}}; memcpy({dst}.data(), s.data()+{lane}, 16); }}" + elif i.op0_kind == K.MEMORY: + stmt = f"memcpy(reinterpret_cast<void*>({address()}), {src}.data()+{lane}, 16);" + else: + raise ValueError(f"unsupported VEXTRACTF128 dest at {i.ip:#x}: {i}") + elif op == M.VINSERTF128: + dst, src1 = wide[i.op0_register], wide[i.op1_register] + lane = (i.immediate(3) & 1) * 16 + if i.op2_kind == K.REGISTER and i.op2_register in wide_xmm: + s2 = f"uint8_t s2[16]; memcpy(s2, {wide_xmm[i.op2_register]}.data(), 16);" + elif i.op2_kind == K.MEMORY: + s2 = f"uint8_t s2[16]; memcpy(s2, reinterpret_cast<const void*>({address()}), 16);" + else: + raise ValueError(f"unsupported VINSERTF128 src2 at {i.ip:#x}: {i}") + stmt = f"{{ auto t = {src1}; {s2} memcpy(t.data()+{lane}, s2, 16); {dst} = t; }}" + elif op in (M.VBROADCASTSS, M.VBROADCASTSD, M.VBROADCASTF128): + dst = wide_any[i.op0_register] + nbytes = 32 if i.op0_register in wide else 16 + elem = {M.VBROADCASTSS: 4, M.VBROADCASTSD: 8, M.VBROADCASTF128: 16}[op] + zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else "" + if i.op1_kind == K.MEMORY: + s_init = f"uint8_t e[{elem}]; memcpy(e, reinterpret_cast<const void*>({address()}), {elem});" + elif i.op1_kind == K.REGISTER and i.op1_register in wide_xmm: + s_init = f"uint8_t e[{elem}]; memcpy(e, {wide_xmm[i.op1_register]}.data(), {elem});" + else: + raise ValueError(f"unsupported broadcast source at {i.ip:#x}: {i}") + stmt = f"{{ {s_init} for (size_t n=0; n<{nbytes}; n+={elem}) memcpy({dst}.data()+n, e, {elem});{zero_hi} }}" + elif op == M.VPERM2F128: + dst, src1 = wide[i.op0_register], wide[i.op1_register] + imm = i.immediate(3) + s2 = (f"auto s2 = {wide[i.op2_register]};" if i.op2_kind == K.REGISTER + else f"auto s2 = load<std::array<uint8_t,32>>({address()});") + def p2_lane(sel, out_off): + if sel & 8: + return f"memset({dst}.data()+{out_off}, 0, 16);" + src_name = "s1" if (sel & 2) == 0 else "s2" + src_off = 16 if (sel & 1) else 0 + return f"memcpy({dst}.data()+{out_off}, {src_name}.data()+{src_off}, 16);" + stmt = f"{{ auto s1 = {src1}; {s2} {p2_lane(imm & 0xf, 0)} {p2_lane((imm >> 4) & 0xf, 16)} }}" + elif op in (M.VMOVDDUP, M.VMOVSLDUP, M.VMOVSHDUP, M.VROUNDPS, M.VROUNDPD) or (op in (M.VPERMILPS, M.VPERMILPD) and i.op2_kind == K.IMMEDIATE8): + dst = wide_any[i.op0_register] + nbytes = 32 if i.op0_register in wide else 16 + zero_hi = f" memset({dst}.data()+16, 0, 16);" if nbytes == 16 else "" + s_init = (f"std::array<uint8_t,32> rhs = {wide_any[i.op1_register]};" if i.op1_kind == K.REGISTER + else f"std::array<uint8_t,32> rhs{{}}; memcpy(rhs.data(), reinterpret_cast<const void*>({address()}), {nbytes});") ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Limit XMM VMOVDDUP memory loads to eight bytes** For `vmovddup xmm0, qword ptr [rcx]`, the architectural memory operand is only eight bytes, but `nbytes` is 16 because it describes the destination width. This initializer consequently reads eight bytes beyond the operand. When the source occupies the last eight readable bytes before a protected page, the native instruction succeeds while the emitted code faults in an unoptimized build; this was reproduced with a guarded-page probe. Derive the read size from the memory operand or special-case the 128-bit VMOVDDUP form instead of using the output width. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 06:50:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-22T00:20:11Z.

Code review location: tests/cpu/avx_shuffle_blend.asm; line 244

@@ -0,0 +1,249 @@
+; Source-owned differential fixture for 26 AVX broadcast, extract/insert, permute, shuffle, blend, dot, round, and zeroall instructions.
+.code
+
+vbroadcastss_op PROC FRAME
+    .endprolog
+    vbroadcastss ymm0, dword ptr [rcx]
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vbroadcastss_op ENDP
+
+vbroadcastsd_op PROC FRAME
+    .endprolog
+    vbroadcastsd ymm0, qword ptr [rcx]
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vbroadcastsd_op ENDP
+
+vbroadcastf128_op PROC FRAME
+    .endprolog
+    vbroadcastf128 ymm0, xmmword ptr [rcx]
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vbroadcastf128_op ENDP
+
+vextractf128_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vextractf128 xmm0, ymm1, 1
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vextractf128_op ENDP
+
+vinsertf128_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vinsertf128 ymm0, ymm1, xmmword ptr [rdx], 1
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vinsertf128_op ENDP
+
+vperm2f128_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vperm2f128 ymm0, ymm1, ymm2, 31h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vperm2f128_op ENDP
+
+vpermilps_imm_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vpermilps ymm0, ymm1, 0B1h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vpermilps_imm_op ENDP
+
+vpermilpd_imm_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vpermilpd ymm0, ymm1, 09h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vpermilpd_imm_op ENDP
+
+vshufps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vshufps ymm0, ymm1, ymm2, 0D2h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vshufps_op ENDP
+
+vshufpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vshufpd ymm0, ymm1, ymm2, 05h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vshufpd_op ENDP
+
+vunpcklps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vunpcklps ymm0, ymm1, ymm2
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vunpcklps_op ENDP
+
+vunpckhps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vunpckhps ymm0, ymm1, ymm2
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vunpckhps_op ENDP
+
+vunpcklpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vunpcklpd ymm0, ymm1, ymm2
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vunpcklpd_op ENDP
+
+vunpckhpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vunpckhpd ymm0, ymm1, ymm2
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vunpckhpd_op ENDP
+
+vmovddup_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovddup ymm0, ymm1
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vmovddup_op ENDP
+
+vmovsldup_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovsldup ymm0, ymm1
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vmovsldup_op ENDP
+
+vmovshdup_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovshdup ymm0, ymm1
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vmovshdup_op ENDP
+
+vblendps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vblendps ymm0, ymm1, ymm2, 0A5h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vblendps_op ENDP
+
+vblendpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vblendpd ymm0, ymm1, ymm2, 0Ah
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vblendpd_op ENDP
+
+vblendvps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vmovups ymm3, ymmword ptr [r9]
+    vblendvps ymm0, ymm1, ymm2, ymm3
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vblendvps_op ENDP
+
+vblendvpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vmovups ymm3, ymmword ptr [r9]
+    vblendvpd ymm0, ymm1, ymm2, ymm3
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vblendvpd_op ENDP
+
+vdpps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vdpps ymm0, ymm1, ymm2, 0D5h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vdpps_op ENDP
+
+vdppd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vmovups ymm2, ymmword ptr [rdx]
+    vdppd xmm0, xmm1, xmm2, 031h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vdppd_op ENDP
+
+vroundps_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vroundps ymm0, ymm1, 08h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vroundps_op ENDP
+
+vroundpd_op PROC FRAME
+    .endprolog
+    vmovups ymm1, ymmword ptr [rcx]
+    vroundpd ymm0, ymm1, 09h
+    vmovups ymmword ptr [r8], ymm0
+    vzeroupper
+    ret
+vroundpd_op ENDP
+
+vzeroall_op PROC FRAME
+    .endprolog
+    vmovups ymm0, ymmword ptr [rcx]
+    vzeroall

P2 Badge Preserve Win64 nonvolatile XMM registers around VZEROALL

On the x64 Windows target, vzeroall clears the low 128 bits of XMM6–XMM15, which are callee-saved, but this export returns without restoring them. The native fixture is called directly through ctypes in check(), so any live caller state in those registers is lost even when the output comparison passes. A source-built register probe confirms that an XMM6 sentinel returns as zero. Save and restore the nonvolatile XMM halves, or invoke this fixture through an ABI-preserving native wrapper.

AGENTS.md reference: AGENTS.md:L37-L38

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4655735378 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#discussion_r4655735378). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:20:11Z. **Code review location:** `tests/cpu/avx_shuffle_blend.asm`; line 244 ~~~~diff @@ -0,0 +1,249 @@ +; Source-owned differential fixture for 26 AVX broadcast, extract/insert, permute, shuffle, blend, dot, round, and zeroall instructions. +.code + +vbroadcastss_op PROC FRAME + .endprolog + vbroadcastss ymm0, dword ptr [rcx] + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vbroadcastss_op ENDP + +vbroadcastsd_op PROC FRAME + .endprolog + vbroadcastsd ymm0, qword ptr [rcx] + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vbroadcastsd_op ENDP + +vbroadcastf128_op PROC FRAME + .endprolog + vbroadcastf128 ymm0, xmmword ptr [rcx] + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vbroadcastf128_op ENDP + +vextractf128_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vextractf128 xmm0, ymm1, 1 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vextractf128_op ENDP + +vinsertf128_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vinsertf128 ymm0, ymm1, xmmword ptr [rdx], 1 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vinsertf128_op ENDP + +vperm2f128_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vperm2f128 ymm0, ymm1, ymm2, 31h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vperm2f128_op ENDP + +vpermilps_imm_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vpermilps ymm0, ymm1, 0B1h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vpermilps_imm_op ENDP + +vpermilpd_imm_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vpermilpd ymm0, ymm1, 09h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vpermilpd_imm_op ENDP + +vshufps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vshufps ymm0, ymm1, ymm2, 0D2h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vshufps_op ENDP + +vshufpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vshufpd ymm0, ymm1, ymm2, 05h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vshufpd_op ENDP + +vunpcklps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vunpcklps ymm0, ymm1, ymm2 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vunpcklps_op ENDP + +vunpckhps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vunpckhps ymm0, ymm1, ymm2 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vunpckhps_op ENDP + +vunpcklpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vunpcklpd ymm0, ymm1, ymm2 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vunpcklpd_op ENDP + +vunpckhpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vunpckhpd ymm0, ymm1, ymm2 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vunpckhpd_op ENDP + +vmovddup_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovddup ymm0, ymm1 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vmovddup_op ENDP + +vmovsldup_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovsldup ymm0, ymm1 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vmovsldup_op ENDP + +vmovshdup_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovshdup ymm0, ymm1 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vmovshdup_op ENDP + +vblendps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vblendps ymm0, ymm1, ymm2, 0A5h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vblendps_op ENDP + +vblendpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vblendpd ymm0, ymm1, ymm2, 0Ah + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vblendpd_op ENDP + +vblendvps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vmovups ymm3, ymmword ptr [r9] + vblendvps ymm0, ymm1, ymm2, ymm3 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vblendvps_op ENDP + +vblendvpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vmovups ymm3, ymmword ptr [r9] + vblendvpd ymm0, ymm1, ymm2, ymm3 + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vblendvpd_op ENDP + +vdpps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vdpps ymm0, ymm1, ymm2, 0D5h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vdpps_op ENDP + +vdppd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vmovups ymm2, ymmword ptr [rdx] + vdppd xmm0, xmm1, xmm2, 031h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vdppd_op ENDP + +vroundps_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vroundps ymm0, ymm1, 08h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vroundps_op ENDP + +vroundpd_op PROC FRAME + .endprolog + vmovups ymm1, ymmword ptr [rcx] + vroundpd ymm0, ymm1, 09h + vmovups ymmword ptr [r8], ymm0 + vzeroupper + ret +vroundpd_op ENDP + +vzeroall_op PROC FRAME + .endprolog + vmovups ymm0, ymmword ptr [rcx] + vzeroall ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve Win64 nonvolatile XMM registers around VZEROALL** On the x64 Windows target, `vzeroall` clears the low 128 bits of XMM6–XMM15, which are callee-saved, but this export returns without restoring them. The native fixture is called directly through ctypes in `check()`, so any live caller state in those registers is lost even when the output comparison passes. A source-built register probe confirms that an XMM6 sentinel returns as zero. Save and restore the nonvolatile XMM halves, or invoke this fixture through an ABI-preserving native wrapper. AGENTS.md reference: [AGENTS.md:L37-L38](https://github.com/R0Y00/Xbox2Windows/blob/a0881a1512acb65a6b915fc00bd6613f354a2fbe/AGENTS.md#L37-L38) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 06:50:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-22T00:20:11Z.

Code review location: tools/ffx_version_query.py; line 35

@@ -30,6 +31,15 @@
 template<class T> void store(word address, T v) {
     memcpy(reinterpret_cast<void*>(address), &v, sizeof v);
 }
+template<class T> T round_x86(T x, unsigned mode) {
+    if (!std::isfinite(x) || x == T(0)) return x;

P2 Badge Quiet signaling NaNs in the packed-rounding helper

When a source lane contains a signaling NaN and invalid exceptions are masked, VROUNDPS/VROUNDPD return a quiet NaN rather than preserving the signaling representation. This early return leaves the input bits unchanged: with the fixture's vroundps immediate 8, a source-built probe produced native bits 0x7fc00001 versus lowered bits 0x7f800001 for input 0x7f800001. Handle signaling NaNs explicitly so the helper quiets them while preserving the appropriate payload.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4655735382 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/390#discussion_r4655735382). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-22T00:20:11Z. **Code review location:** `tools/ffx_version_query.py`; line 35 ~~~~diff @@ -30,6 +31,15 @@ template<class T> void store(word address, T v) { memcpy(reinterpret_cast<void*>(address), &v, sizeof v); } +template<class T> T round_x86(T x, unsigned mode) { + if (!std::isfinite(x) || x == T(0)) return x; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Quiet signaling NaNs in the packed-rounding helper** When a source lane contains a signaling NaN and invalid exceptions are masked, VROUNDPS/VROUNDPD return a quiet NaN rather than preserving the signaling representation. This early return leaves the input bits unchanged: with the fixture's `vroundps` immediate `8`, a source-built probe produced native bits `0x7fc00001` versus lowered bits `0x7f800001` for input `0x7f800001`. Handle signaling NaNs explicitly so the helper quiets them while preserving the appropriate payload. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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!384
No description provided.