fix: SSE2 MINSD/MAXSD DAZ, XSAVE AVX-only MXCSR, MMX read state #1639
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1646"
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 tedin7 on 2026-11-24T15:47:17Z.
AI-assisted; commands listed were executed locally.
What
Three lifted-state defects found by comparing the lifters' C++ helpers with the instructions run natively, plus a lift-time MMX-state tracking fix:
tools/cpu_sse2_aot.py). The helper compared with C operators, so with MXCSR.DAZ set a denormal operand came back unchanged; the instruction returns a zero of the same sign. The helper now runs the instruction on run-time operands (as the scalar and packed float lifters already do).tools/cpu_xsave_aot.py). XSAVE stores MXCSR and MXCSR_MASK when RFBM selects SSE or AVX (XSAVEC: SSE only, XSAVEOPT: either). The lifted XSAVE stored them with SSE alone, so bytes 24..31 of the buffer were left as they were. The lift-time "MXCSR defined before save" check and docstring cover the form too.tools/cpu_sse_fxsave_aot.py,tools/cpu_xsave_aot.py).MOVQ m64, mmandMOVQ r64, mmclear TOP and mark all tags valid like any MMX instruction; the lifters did it for writes only, so a following FXSAVE/XSAVE reported the restored TOP, tag word and stack order (and XSTATE_BV[0] for XSAVE).cpu_xsave_aot.pyalso now marksmmx_activeon read-onlyMOVQso an unclosed MMX read beforeretis rejected, matchingcpu_sse_fxsave_aot.py.Tests
Each fix has a positive case that fails on
origin/mainand passes after, and a negative control in the checker:cpu_aot_sse2_regs: newcheck_daz_extrema(4 denormal MAXSD/MINSD cases under DAZ, native and lifted). Newread_mxcsr/write_mxcsrhelpers are linked into the fixture, assse2_packed_cvtdoes. Control: the C-comparison result differs from the expected one.cpu_aot_xsave_state: new exportsop_xrstor64_xsave64_avxandop_xrstor64_movq_read_xsave64; the reference model stores MXCSR for RFBM with SSE or AVX. Controls: output without MXCSR, and output without the MMX state change, are rejected by the comparator. Added rejection controls forvzeroupper_xsave64_avx_mxcsr_undefined,unclosed_mmx_read_gpr, andunclosed_mmx_read_mem.cpu_aot_sse_fxsave: new exportsop_fxrstor64_movq_storeandop_fxrstor64_movq_gpr. Control: output of the same sequence without the MM read is rejected.CMakeLists.txt: one line (
target_sources(... sse2_mxcsr_test.asm)) and the three export lists; no newadd_test(the existing tests were extended).Verification
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207, ML64 14.44.35230) at commit
84f0128959cf11bf567d02eb9245fc672ee91afc:--preset dev):cmake --build --preset dev --target cpu_sse2_regs_altered cpu_sse2_regs_altered_lifted cpu_sse2_regs_original cpu_sse2_regs_original_lifted cpu_sse_fxsave_altered cpu_sse_fxsave_altered_lifted cpu_sse_fxsave_canonical_lifted cpu_sse_fxsave_original cpu_sse_fxsave_original_lifted cpu_xsave_state_altered cpu_xsave_state_altered_lifted cpu_xsave_state_canonical_altered_lifted cpu_xsave_state_canonical_lifted cpu_xsave_state_compacted_altered_lifted cpu_xsave_state_compacted_lifted cpu_xsave_state_original cpu_xsave_state_original_lifted -- -j 6): PASS (4.72s)ctest --preset dev -R '^(cpu_aot_sse2_regs|cpu_aot_sse_fxsave|cpu_aot_xsave_state)$' --parallel 4 --no-tests=error --output-on-failure): 3/3 passed (0.64s:cpu_aot_sse_fxsave0.24s,cpu_aot_xsave_state0.50s,cpu_aot_sse2_regs0.56s)/O2(--preset release):cmake --build --preset release --target cpu_sse2_regs_altered cpu_sse2_regs_altered_lifted cpu_sse2_regs_original cpu_sse2_regs_original_lifted cpu_sse_fxsave_altered cpu_sse_fxsave_altered_lifted cpu_sse_fxsave_canonical_lifted cpu_sse_fxsave_original cpu_sse_fxsave_original_lifted cpu_xsave_state_altered cpu_xsave_state_altered_lifted cpu_xsave_state_canonical_altered_lifted cpu_xsave_state_canonical_lifted cpu_xsave_state_compacted_altered_lifted cpu_xsave_state_compacted_lifted cpu_xsave_state_original cpu_xsave_state_original_lifted -- -j 6): PASS (2.15s)ctest --preset release -R '^(cpu_aot_sse2_regs|cpu_aot_sse_fxsave|cpu_aot_xsave_state)$' --parallel 4 --no-tests=error --output-on-failure): 3/3 passed (0.64s:cpu_aot_sse_fxsave0.23s,cpu_aot_xsave_state0.49s,cpu_aot_sse2_regs0.55s)Local checks:
python3 tests/docs_links_check.py: PASS (16 Markdown files, 348 links)python3 tests/bidi_controls_check.py: PASS (1267 files)git diff --check origin/main...HEAD: cleanNotes
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T15:55:53Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
84f0128ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.