Repository navigation
fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does - #9862
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
The exhaustive |
…bc.prx does cbrtf returned the host cbrt, so its result depended on the host: on Windows it differs from the libc.prx that titles ship on 1,303,357,444 of the 2^32 floats. That libc.prx is msun's s_cbrtf.c, which gives the same bits as PPSA07923's, PPSA05916's and PPSA13934's copies for every argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8778a1a to
ac92cc6
Compare
|
Rebased onto current |
|
Linux run (the description lists Linux as not tested). Docker on Windows: Ubuntu 26.04, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,
No findings. AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head ac92cc6281131d8499a23c2d1f6ae47296027230. The implementation follows FreeBSD 11.4 msun's cbrtf bit-level seed, subnormal scaling and two double-precision Newton steps; special values and signed zero are covered. The production and test files are unchanged since the tested base; the only current-main change among the PR paths is the adjacent debt index.
I locally built the exact PR Math.cpp and test source and ran the isolated 21-case CheckCbrtfConsoleBits on Linux; it passed. The available full guest_math CTest uses an older source snapshot and aborts first at its strtol check, so this is not a full-suite pass. The author reports exhaustive Windows comparisons and repeated focused tests; independent Linux testing reports five passing guest_math runs and notes the 21 cases also pass with Linux main's implementation. Hosted policy checks pass; product jobs are skipped.
What
cbrtfreturned the host'scbrt, so its result depended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 1,303,357,444 of the 2^32 floats (30 %). For example, the console givescbrtf(0x3f000555)=0x3f4b32c7andcbrtf(0x7f7fffff)=0x54cb2ff5.The titles'
cbrtf(NIDGlelR9EEeck) is FreeBSD msun'ss_cbrtf.c, andcbrtfnow computes it the same way:B1/B2, and subnormals scaled by2^24first;The titles' copies set no
errno, and neither does this.cbrtfis imported by 4 of the 22 titles whose relinker registries I audited: PPSA02630, PPSA19591, PPSA25872 and PPSA27616. The core is in double precision, so the FMA-contracted copy of PPSA13934 gives the same bits too.Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,maind6e7ab4.libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. Theircbrtfand this build'scbrtf_nid_postfixgive the same bits for all 2^32 arguments, and none of them setserrno.guest_math: the newCheckCbrtfConsoleBitshas 21 cases with the console's results, each also checking thaterrnois untouched: subnormals and normals where UCRT differs, of both signs, ±0, the smallest subnormal, the largest subnormal and smallest normal, 1, ±8,FLT_MAX, the infinities and NaN payloads of both signs.guest_mathand the libc tests (8) pass in three runs out of three. Withmain'sMath.cppand this test,guest_mathaborts in aRequire.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.tools/pr_overlap.py --branchfinds no conflicting pull request, and the branch merges cleanly with my other math PRs (fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771, fix(libc): compute atanf with FreeBSD msun's algorithm, as titles' libc.prx does #9777, fix(libc): compute atan2f with FreeBSD msun's algorithm, as titles' libc.prx does #9784, fix(libc): compute expf with FreeBSD msun's algorithm, as titles' libc.prx does #9839, fix(libc): compute logf with FreeBSD msun's algorithm, as titles' libc.prx does #9841, fix(libc): compute exp2f with FreeBSD msun's algorithm, as titles' libc.prx does #9844, fix(libc): compute powf like the libc.prx that titles ship #9850, fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857).ac92cc628merged cleanly ontomainfcd455870: Ubuntu 26.04 in Docker on Windows, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,BUILD_TESTING=ON. The reviewer reportsguest_mathpassing five runs (--repeat until-fail:5). All 21 new cases also pass with main'sMath.cppon this Linux setup, so these cases demonstrate a Windows regression fix and Linux compatibility; they do not establish a Linux result change. An input that distinguishes glibc from the console remains unestablished. This is reviewer-supplied evidence for those revisions, not a local rerun or a latest-main claim.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).