cpu: accept FFREEP ST(0) on a nonempty stack in the x87 profile #1354
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1361"
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 legacy-code-archaeologist on 2026-11-24T09:15:01Z.
Refs #1338
What
The x87 profile (
tools/x87_lower.py) now accepts FFREEP ST(0) on a nonempty stack. This follows the narrowed scope in #1338.Evidence
cpu_aot_x87_examinegains the exportffreep_top:ffreep st(0)at depths 3, 2 and 1.fnstsw ax,and ah, 38h, then stores AH.The check fails in each of these cases:
ffreep: FFREEP also overwrites the deepest register with the one above it. 33/850 mismatches; the input 1.0 hides it.fftop: the first FFREEP leaves TOP at 5. 34/850.ffreepon an empty stack;ffreep, and a reader of C1 after it;ffreep st(2);ffree st(0)andffree st(1);fincstpandfdecstp.Windows 11 Pro 26100.9168, Intel i7-6820HQ, MSVC 19.52, commit
b274877bon623e2112:Result:
releasepreset gives the same result.Other runs:
ctest --preset dev -E '_hardware$': 582/582.ctest --preset dev -R '^cpu_' -E '_hardware$': 225/225.-R '^cpu_aot_x87_': 21/21.tools/form_coverage.py --gaps x64_zen2no longer listsffreep.ffreestays listed.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:30:28Z.
Review: COMMENTED
Technical peer review at commit
b274877beba687e589d134e7225a4c25c99ccf88(LGTM, no blocking findings):Code audit:
tools/x87_lower.py: addsM.FFREEPtoX87_OPS;_effect()acceptsR.ST0on a nonempty stack (depth > 0, returningdepth - 1) and rejects non-ST0operands (unsupported x87 operand) and empty stacks (x87 stack underflow);_statement()emits a no-op comment since the pop is the depth change, while C0–C3 remain undefined afterwards.tests/cpu/x87_examine.{asm,def,py},CMakeLists.txt,docs/experiments.md: addsffreep_top(verifying physical TOP 5, 6, 7, 0 viafnstsw axand preserved values below across 34 encodings), two new negative controls (ffreepandfftopmutated DLLs), and 8 new rejection cases (ffreepon empty stack, C0/C1 readers afterffreep,ffreep st(2),ffree st(0),ffree st(1),fincstp,fdecstp).Checks:
docs_links_check.py(16 Markdown files, 301 links),bidi_controls_check.py(1145 files),py_compileontools/x87_lower.pyandtests/cpu/x87_examine.py, andx87_examine.check_rejections()(accepted 1, rejected 14 sequences) all passed;git diff --checkclean.--preset dev):cpu_aot_x87_examine(0.51s) — 1/1 passed (0.58s)./O2(--preset release):cpu_aot_x87_examine(0.51s) — 1/1 passed (0.58s).