cpu: lower FNINIT and FINIT in the checked x87 entry #897
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/904"
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 denn0x on 2026-11-23T16:37:13Z.
Refs #406
Adds
fninitandfinitto the checked x87 entry. The fixed profile still rejects both.Behavior
fninitloads control word0x037F, clears C0 to C3 and empties every register, so the depth after it is 0.finitdecodes aswaitandfninit. Every exception is masked, so none is pending andwaitdoes nothing.fninit, all zero, until the next x87 instruction. C1 is included, as afterfprem(#893).0x037Fhas 64-bit precision. A function that runsfninitmust restore0x027Fbefore it returns, otherwise it leaves with status 3, as forfldcw. It also counts as loading the control word for the call and edge rule, so a function withfninitand a call is rejected.fninithas emptied the stack is a stack underflow and is rejected.Measurements
Commit
7217bf5on1f6c38a. The full suite and identity check ran on the same change atd2dc298, before a rebase over #404, which does not touch the x87 files. AMD Ryzen 7 7700 (AMD64 Family 25 Model 97 Stepping 2), Windows 11 build 26300, MSVC x64,devpreset.cpu_aot_x87_fldcwgains two exports and two controls:cw_fninitrunsfcom, so C0, C2 and C3 are set, thenfninitunder a loaded word,fnstsw ax,fnstcw, and a quotient under0x037F.cw_finitrunsfinitat depth 8, then returns without a restore, which gives status 3.*result.fninitthe native and translated C0 to C3 are 0 andfnstcwstores0x037F.fninitword(fninitkeeps the control word), with 1680, andfninitsw(fninitkeeps C0 to C3), with 850. The other ten still mismatch.fninitin the fixed profile,fninitwith a call, and a store afterfninit. Translated, new:fninitwith a value on the stack, then a restore.Wider checks on the same commit:
ctest --preset dev --no-tests=error -R '^cpu_'at7217bf5: 162/162 pass.dxr_opacity_hardware,gpu_alias_lookup_writes_hardwareandpixel_aot_comparisons_hardware), from code this change does not touch.cpu_*.cppversusmain: 311 byte-identical and 3 more after removing theaot_source_sha256line. The 11cpu_x87_fldcw_*sources only gain lines, for the two new exports. The remaining 2 are the build-path-dependentcpu_exe_image_selectorandcpu_image_data_lifted.form_coverage_check,docs_links_checkandbidi_controls_checkpass.docs/experiments.mdupdates the checked-entry paragraph and thecpu_aot_x87_fldcwresults. The earlier Intel Core Ultra 7 358H result is kept and labelled as covering the 15 exports from before this change.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T16:57:02Z.
Independent Windows x64 review of
7217bf5on Intel Family 6 Model 183 Stepping 1: cpu_aot_x87_fldcw passed in Debug and Release. Both new controls fired in each run (1,680 control-word and 850 condition-code mismatches), and the post-FNINIT stack underflow and fixed-entry refusals were observed. Precision-control 01 was recorded separately as a native observation.