cpu: add dedicated cpu_x87_exp_log_aot lifter for F2XM1, FYL2X, and FYL2XP1 #2415
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2423"
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-25T16:18:29Z.
Change
Add a dedicated standalone x87 exponential/logarithmic AOT lifter (
tools/cpu_x87_exp_log_aot.py) forF2XM1,FYL2X, andFYL2XP1, with a source-built MASM differential fixture (tests/cpu/x87_exp_log_aot.{asm,def}), verification suite (tests/cpu/x87_exp_log_aot_check.py), and CTest registration (cpu_aot_x87_exp_loginCMakeLists.txt). Disjoint from PR #1663 (tools/x87_lower.py,tools/x87_soft.h, andtests/cpu/x87_*.pyare untouched).BigF128-bit integer arithmetic): lifts straight-line leaf functions (void lifted_<name>(word rcx, word rdx, word r8)) with zero hostfloat/double/long double,<cmath>, or SSE instructions, avoiding MSVC 64-bitlong doubletruncation and guaranteeing complete host MXCSR (DAZ/FTZ) isolation without clobbering MXCSR.F2XM1:2^ST(0) - 1on the Intel SDM domain[-1, +1]; exact on+-0(F2XM1(-0.0) == -0.0),+1,-1;<= 1 ULPvs arbitrary-precision 80-digitDecimalreference (observed max0 ULP) and<= 1 ULPvs native x87 (observed max1 ULP).FYL2X:ST(1) * log2(ST(0))with stack pop forx > 0plus SDM special cases (#Z (ZE)onx == +-0with finite nonzeroy,#IA (IE)on negativex,(+-0, +-0),(+inf, +-0),(1, +-inf)).FYL2XP1:ST(1) * log2(ST(0) + 1)with stack pop on the Intel SDM domain[-(1 - sqrt(2)/2), +(1 - sqrt(2)/2)](plus lifted-only spec checks forx == -1#Z (ZE)andx < -1#IA (IE), where hardware behavior outside the SDM domain is undefined).[rcx|rdx|r8]:fld m32/m64/m80,fld1,fldz,fst m32/m64,fstp m32/m64/m80/st(0),fnstsw ax(+mov word ptr [r8], ax),fldcw m16,fnstcw m16,fninit, and terminalret.RN/RD/RU/RZ), FCW precision control (PC 24/53/64, preserved acrossfldcw/fnstcwand not truncating transcendental results per Intel SDM Vol. 1 8.1.5.2), sNaN quieting +#IA (IE), unnormals -> indefinite +#IA,#DE/#OE/#UE/#PEstatus flags, and stack depth/pop semantics.FSIN/FCOS/FSINCOS/FPTAN/FPATAN, stack overflow/underflow, non-empty x87 stack atret, XMM/YMM/ZMM/VEX/EVEX, prefixes (includingWAIT/9B), non-flat/displaced/indexed/non-arg memory, stores outside[r8], undefinedaxreads, branches, missingret, and trailing instructions afterret.Verification
Verified on commit
65489770(based onupstream/main7092683a) in bothdev(Debug) andrelease(/O2) presets (baseline x87, 0 skips):cmake --build --preset dev --target cpu_x87_exp_log_aot_original cpu_x87_exp_log_aot_original_lifted cpu_x87_exp_log_aot_altered cpu_x87_exp_log_aot_altered_lifted-> exit 0.ctest --preset dev -R "^cpu_aot_x87_exp_log$" -E "cpu_native_archive_" --output-on-failure -V->1/1 Passed (0.32s):6 x87 exp/log sequences accepted; 37 rejection controls passed; 847 differential/FCW/status/special cases matched (max ULP vs Decimal ref=0, vs native x87=1); 36 MXCSR DAZ/FTZ isolation checks passed; 6 mutant controls + 5 altered-build controls caught.cmake --build --preset release --target cpu_x87_exp_log_aot_original cpu_x87_exp_log_aot_original_lifted cpu_x87_exp_log_aot_altered cpu_x87_exp_log_aot_altered_lifted-> exit 0.ctest --preset release -R "^cpu_aot_x87_exp_log$" -E "cpu_native_archive_" --output-on-failure -V->1/1 Passed (0.33s): identical6/37/847 (max ULP ref=0, nat=1)/36/6+5results.FORM_COVERAGE_RECORD(bothdevandrelease): 14 recorded forms (f2xm1,fld,fld1,fldcw,fldz,fninit,fnstcw,fnstsw,fst,fstp,fyl2x,fyl2xp1,mov,ret).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 464 links.(exit 0).out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 1727 tracked source, script and build/CI files: no bidirectional controls.(exit 0).tools/cpu_x87_exp_log_aot.py: 8/8 mutations killed across translator guards (FSINtrig rejection, non-empty stack atret, store-outside-r8, displaced memory) and rebuilt C++ semantics (F2XM1(-0.0)sign,FYL2X#Z,FYL2XP1#Z, FCW rounding control).Evidence and follow-up
All fixtures (
tests/cpu/x87_exp_log_aot.asm,.def,_check.py) are source-built under the repository MIT license with; coverage: record cpu_aot_x87_exp_logandALTER_X87_EXP_LOGaltered-build controls; no external binaries or game files are used. Contributors can build and run the test withctest --preset dev -R "^cpu_aot_x87_exp_log$" -V(or--preset release).Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:22:03Z.
Review: COMMENTED
Review of head
6bbf4a62(comment only, no approval).Checked:
x87_lower.py,x87_soft.hortests/cpu/x87_*.py. No other open or merged PR covers F2XM1/FYL2X/FYL2XP1 (searched all states).cpu_aot_x87_exp_logcompares the lifted code with native x87 and with a Decimal reference, and also covers MXCSR isolation, FCW rounding, status-word flags and built-in mutants (check_mutants). That guards the new behavior with real values, not string checks.cpu_aot_x87_trigpattern (original and altered variants, exports list).Commands run locally:
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passpython3 -m py_compileon the lifter and the check: passgh pr update-branch(head moved to6bbf4a62; the PR's own diff is unchanged), CI green on the new headcpu_aot_x87_exp_logpassed in both (receipt in the next comment)Not done: the in-test mutants only run on Windows, so I did not mutate the lifter on Linux.
No blocking findings.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:22:04Z.
Win2025 WARP receipt for head
6bbf4a62after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
6bbf4a6222b3c6d99825c748b2ee2dfc9c34c171:--preset dev):cmake --build --preset dev --target cpu_x87_exp_log_aot_altered cpu_x87_exp_log_aot_altered_lifted cpu_x87_exp_log_aot_original cpu_x87_exp_log_aot_original_lifted -- -j 2):4.11s(configure2.00s)ctest --preset dev -R 'cpu_aot_x87_exp_log' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.59s:cpu_aot_x87_exp_log0.44s)/O2(--preset release):cmake --build --preset release --target cpu_x87_exp_log_aot_altered cpu_x87_exp_log_aot_altered_lifted cpu_x87_exp_log_aot_original cpu_x87_exp_log_aot_original_lifted -- -j 2):1.59s(configure2.66s)ctest --preset release -R 'cpu_aot_x87_exp_log' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.44s:cpu_aot_x87_exp_log0.34s)sccache: 0/4 hits; wall19.4sAI-assisted; commands listed were executed locally.