cpu: lower legacy SSE2 packed double bitwise logic (ANDPD, ANDNPD, ORPD, XORPD) in cpu_sse_fp_aot #2340
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2348"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T13:10:54Z.
Change
Lower legacy SSE2 packed double bitwise logic instructions (
ANDPD,ANDNPD,ORPD,XORPD) intools/cpu_sse_fp_aot.pyand add a dedicated source-built differential,/O2, mutation, and rejection test suite (tests/cpu/sse_fp_pd_logic.{asm,def},tests/cpu/sse_fp_pd_logic_check.py, registered ascpu_aot_sse_fp_pd_logicinCMakeLists.txt):Code.ANDPD_XMM_XMMM128,Code.ANDNPD_XMM_XMMM128,Code.ORPD_XMM_XMMM128, andCode.XORPD_XMM_XMMM128toBITWISE_LOGIC_FUNCTIONS, reusing the 128-bit lane-exact bitwise helpers (op_andps,op_andnps,op_orps,op_xorps) forXMM0..XMM5and 16-byte-aligned[rcx|rdx|r8 + disp]m128operands.XORPD xmmN, xmmNso undefinedXMM0..XMM5self-zeroing lowers toop_zero_vec().tests/cpu/sse_fp_check.pyandtests/cpu/sse_fp_pd_check.pyto replace the newly supportedandpd/xorpdentries with still-rejected legacy SSE2 forms (cvtdq2pd,unpckhpd).Verification
Verified on commit
c606907f(rebased ontoupstream/main7bc59951):cmake --build --preset dev --target cpu_sse_fp_original cpu_sse_fp_original_lifted cpu_sse_fp_altered cpu_sse_fp_altered_lifted cpu_sse_fp_logic_original cpu_sse_fp_logic_original_lifted cpu_sse_fp_logic_altered cpu_sse_fp_logic_altered_lifted cpu_sse_fp_pd_original cpu_sse_fp_pd_original_lifted cpu_sse_fp_pd_altered cpu_sse_fp_pd_altered_lifted cpu_sse_fp_pd_logic_original cpu_sse_fp_pd_logic_original_lifted cpu_sse_fp_pd_logic_altered cpu_sse_fp_pd_logic_altered_lifted cpu_sse_fp_harness-> succeeded (exit 0)ctest --preset dev -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure -V->100% tests passed, 0 tests failed out of 4(cpu_aot_sse_fp,cpu_aot_sse_fp_logic,cpu_aot_sse_fp_pd,cpu_aot_sse_fp_pd_logic)cmake --build --preset release --target ...-> succeeded (exit 0)ctest --preset release -R "^cpu_aot_sse_fp" -E "cpu_native_archive_" --output-on-failure -V->100% tests passed, 0 tests failed out of 4(22.52 sec;cpu_aot_sse_fp_pd_logic:5 alt + 5 VEX/EVEX + 27 IR + 3 raw + 9 PE-patched + CLI,1060 lifted + 1060 /O2 cases across 20 exports,ALTER_IMM diverged on {'op_andpd': 53, 'op_andnpd': 53, 'op_andnpd_mem': 53, 'op_orpd': 53, 'op_xorpd': 52, 'op_pd_logic_pipeline': 50})out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit 0)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py->Self-test passed. Checked 19 Markdown files and 453 links.(exit 0)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1641 tracked source, script and build/CI files: no bidirectional controls.(exit 0)No capability skips (baseline SSE2).
Evidence and follow-up
tests/cpu/sse_fp_pd_logic.asm(; coverage: source cpu_aot_sse_fp_pd_logic) is a clean-room synthetic MASM fixture covering all 4 instructions across register, aligned[rdx], aligned[rdx+16], self-operand, self-zeroingxorpdfeeding logic and double FP arithmetic, a chained pipeline, and a discarded alignedm128read (verified to fault on NULLrdxunder both Debug and/O2).ALTER_IMMdivergence on 6 exports,andnpd(~dst) & srcasymmetry, 1-bit output mutation detection, VEX/EVEX (VANDPD,VANDNPD,VORPD,VXORPD, EVEXVANDPD), unalignedm128displacements (+1,+8,-4), nonvolatileXMM6..15, undefined non-self operands, non-r8stores, segment/LOCK/REP/XOP prefixes, PE-patched DLLs, and CLI non-traceback rejection.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:16:14Z.
Review: COMMENTED
Review of head
c606907fa034c271946e02ff6a749b8e29be3217(PR is 4 commits behindorigin/main, MERGEABLE, title neutral, no clean-room concerns seen).Verdict: no P1, no P2.
Commands executed locally (Linux worktree):
git diff --stat origin/main...HEAD: 7 files, +834/-6git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: self-test passed, 19 files / 453 linkspython3 tests/bidi_controls_check.py: self-test passed, 1641 files, no bidi controlsgh pr checks 2348: Linux Python checks, Windows build+test and gfx1013 fixtures pass; /O2 job skippedCorrectness (read against the diff):
tools/cpu_sse_fp_aot.py:80-83: ANDPD/ANDNPD/ORPD/XORPD map to the existing 128-bit lane-exact helpers. These ops are pure bitwise, so reusing the PS helpers is semantically exact.op_andnpsis(~dst) & src, which matches ANDNPD (dst complemented).tools/cpu_sse_fp_aot.py:~473: the self-zero idiom now coversxorpd xmmN, xmmN, same rules asxorps(undefined XMM0..XMM5 allowed)._bit_opcomputesandnas(~d) & s, consistent with the ISA.sse_fp_check.pyandsse_fp_pd_check.pycorrectly replace the now-supportedandpd/xorpdwith still-rejectedcvtdq2pd/unpckhpd. Thepe_patcheslist is updated to match.cpu_aot_sse_fp_*entries.Not done / limits:
cpu_aot_sse_fp_pd_logicsuite needs the Windows PE fixtures plusiced_x86/pefile, which are not available in this Linux worktree. I could not run it locally and I did not run a local mutation of the lifter. The PR's own suite includes an output-bit-flip mutation control and an ALTER_IMM variant, and the Windows CI job passed. Win2025 was not queued because the change is CPU AOT only (no gfx2hlsl or shader code).Nits (non-blocking):
AI-assisted; commands listed were executed locally.