Repository navigation
fix(libc): compute expm1 with FreeBSD msun's algorithm, as titles' libc.prx does - #10306
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release,
This is the focused test only; no title, console or floating-point exception flags were checked. AI-assisted: yes (Claude Code). |
…bc.prx does expm1 returned the host's expm1, whose last bit differs from the titles' copy on Windows on 35,152,346 of 320 million random arguments. The titles' copy is FreeBSD msun's s_expm1.c, and it sets ERANGE only when a finite argument overflows to infinity. expm1 now computes that algorithm and sets ERANGE there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92e60da to
99abd26
Compare
|
Follow-up #10510 corrects finite positive overflow across rounding modes: exact positive infinity and ERANGE, with overflow/inexact in both x87 and SSE. The bundled PPSA03766 module and old-production/candidate comparison covers 41,856 calls per arm; all 9,216 overflow rows now match, with zero changes elsewhere. The 492 existing nonoverflow result-bit differences remain documented. Same-test negative control fails at the new overflow regression; the candidate passes both Linux math suites 3/3. #10510 depends on this PR; no Windows, physical-console or game-performance claim. |
What
expm1returned the host'sexpm1, so its last bit and itserrnodepended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 35,152,346 of 320 million random arguments. For example,expm1(0x3fc78b9e474afed8)(about 0.184) is0x3fc9d99e60806b35in the bundledlibc.prxand0x3fc9d99e60806b36here.The titles' copy (NID
gqKfOiJaCOo) is FreeBSD msun'ss_expm1.c.expm1now computes it as a staticExpm1:|x| >= 56 ln2filter, with the large-negativetiny - 1return;k = ±1and general argument reductions with theccorrection;Q1–Q5rational;kcase of the reconstruction, includingk == 1024and the subnormal scaling.hugeis read at run time, as msun'svolatileread does. This is the double-precision counterpart of theexpm1fin #10222.errno: msun sets none. The titles' copy setsERANGEexactly when a finite argument overflows to infinity, which is the same rule as itsexpm1f. Large negative arguments return -1 withouterrno, and so do NaN and the infinities. The exportedexpm1setsERANGEin that case only.Tested
Current Linux refresh:
99abd2604d53b7588b6386de012527c60ad6dcc7on main6c52b649e7b1592f28db0cb8fe9ac604f0a242e7. Fresh isolated libc/math build passed;guest_mathandguest_dinkumware_internalseach passed three consecutive runs. Diff and conventions checks pass; Math.cpp and GuestMath.cpp topic changes remain unchanged after rebase. Linux logs and rebase checks.The Windows module comparisons and negative control below are historical evidence from original head
92e60da1cc495f62a17a81000fb5778dec79df44; Windows was not rerun on the refreshed commit. Results described as console results mean the supplied titles' bundled libraries executed on the Windows host, not measurements on a physical console.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main1e1c355.Comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirexpm1with this PR's code, checking result bits (NaN payloads included) anderrno, on:Results:
errnoon all of them.errno. The bits differ on 43,433 random arguments, because that copy is an FMA-contracted build.guest_math: the newCheckExpm1ConsoleBitshas 30 cases with the bundled library's results anderrno:±DBL_MAX, the infinities and NaN payloads of both signs;main's existingexpm1checks still pass.guest_mathandguest_dinkumware_internalspass in three runs out of three on the exact head.Negative control: with
main'sMath.cppand these tests,guest_mathaborts in aRequire, whileguest_dinkumware_internalsstill passes.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Overlap and order: Refreshed as one standalone expm1 topic on main
6c52b649e7b1592f28db0cb8fe9ac604f0a242e7. The prior fix(libc): compute cbrt with FreeBSD msun's algorithm, as titles' libc.prx does #10283 dependency described series order, not a required implementation. Nearby math ports share text/test/debt anchors. fix(libc): compute tanh with FreeBSD msun's algorithm, as titles' libc.prx does #10316 still requires this PR's internal Expm1 helper.Not tested: macOS, a physical console, floating-point exception flags, and
expm1l. The original module comparison and negative control were Windows-only; the new Linux build and regression checks are scoped separately above.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)sinhfentry didAI-assisted (Claude Code).