feat(libc): compute sinl, cosl and tanl with FreeBSD msun's ld80 algorithm #18513
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18513"
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 boykopovar/AnyPS5. Originally posted by AlfaRojo on 2026-11-11T19:33:15Z.
What
sinl,coslandtanlreturned the host'sstd::sin,std::cosandstd::tan. They now follow FreeBSD msun release/11.4.0:s_sinl.c,s_cosl.c,s_tanl.cwith the ld80k_sinl.c,k_cosl.c,k_tanl.cande_rem_pio2l.h. The reduction reuses the libcKernelRemPio2(__kernel_rem_pio2); its pi/2 table was cut to the 66 entries a double needs, so it is now the full 690 entries of msun'sipio2, needed for long double arguments up to the largest finite value. The table moves tocore/libs/prx/libc/include/general/RemPio2Table.hpp, which libc and libSceLibcInternal'sRemPio2.cppboth include instead of each keeping a copy. The debt entry indocs/dev/debt/libc.mdmoves the three functions out of the host-math line and records that the console result anderrnoare unverified.Tested
Windows 11 Pro 10.0.26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release, based on main
65351c2931.guest_math3/3 runs pass, as doguest_math_elementaryandguest_math_exact. The new check pins ±0 and subnormal arguments, ±infinity (NaN,FE_INVALID,errnountouched), NaN, and 60 inputs (including 1e10, 1e300, 1e4000 and near multiples of pi/2 up to 2^5000) to the bit; every pinned result is within 0.53 ulp of an mpmath 24000-bit reference.k_rem_pio2.c,k_sinl.c,k_cosl.c,k_tanl.c,s_sinl.c,s_cosl.c,s_tanl.c, amd64 constants): 120 million results (40 million arguments, all three functions) over random arguments of every exponent, around pi/4 and the 2^25 pi/2 boundary, and near multiples of pi/2, 0 mismatches. Before the table was extended the harness found 78 mismatches in 3000, all for arguments above 2^1024.Math.cppfrom main the new check fails (GuestMath.cpp:3276); with the change it passes.tools/check_conventions.py --base upstream/mainpasses;tools/check_test_registration.pypasses.tools/pr_overlap.py): #11262 (atanl) and #11266 (exp2l) edit the sameMath.cpplines and #18110, #18481 the same debt line, so those will need a trivial rebase. #18122 listssinl,coslandtanlonly as_nid_disambig1forwards to the existing_nid_no_patchentry points, not an implementation. The comparisons the tool could not complete (PRs conflicting with main: 6295, 7544, 11109 touchMath.cpp; the others onlydocs/dev/debt/libc.md) were checked forsinl/cosl/tanl/rem_pio2lby search with no hit.0adfbb8749(merged with upstream/main, which now has #18525 and #19328):guest_math,guest_math_elementaryandguest_math_exactpass in 3/3 runs;check_conventions.py --base upstream/mainpasses.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)