fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does #10222
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10222"
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 JJenkx on 2026-10-23T14:28:17Z.
What
expm1freturned the host'sexpm1, so its last bit and itserrnodepended on the host. On Windows (UCRT) the bits differ from thelibc.prxthat titles ship on 155,520,115 of the 2^32 floats, for example0x3eb17218, where the console gives0x3ed413cdand UCRT0x3ed413ce, and0xbf400ddd, where the console gives0xbf071989and UCRT0xbf071988.The titles'
expm1f(NID3EgxfDRefdw) is FreeBSD msun'ss_expm1f.c. #9867 already carries a full port of it astanhf's privateTanhfExpm1. This PR renames that functionExpm1fand exports it asexpm1f, so both functions share one copy of the algorithm.errno: msun sets none. The titles' copy setsERANGEexactly when a finite argument overflows to infinity: the 1,020,169,704 finite arguments from0x42b17218up. That includes0x42b17218itself, which takes msun's general path rather than itsx > o_thresholdbranch. Large negative arguments, which take msun'stiny - onebranch and return -1, the infinities and NaN leaveerrnoalone. The exportedexpm1fsetsERANGEin that case only.tanhfcallsExpm1fdirectly, and its arguments never reach that range.Tested
Current Linux refresh (2026-10-25): head
057bca52441f84ec539e382428892d3dc3982d1c, a linear two-topic stack on main366dd4e6b704b048e05eee65e0edead78352811a. It restacks the #9867 prerequisite's original topic commit before this PR'sexpm1ftopic. The ready public #9867 branch was not changed by this refresh; its previously merged-main prefix is not copied into this linear stack. Depends on remains #9867.The reviewed
Expm1f,expm1f_nid_postfix,tanhf_nid_postfix,CheckExpm1fConsoleBitsandCheckTanhfConsoleBitsbodies are byte-identical to previous public #10222 head3d8ff6b82ad249bba58a1b55a0d23a23ac228932; both regression calls occur once. The only rebase conflict was additive debt-file content, resolved by preserving main's child-process registry entry and both port entries.Fresh Linux x86-64 Release libc/test build:
guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass three runs (12 passes). Replacing only productionMath.cppwith the exact restacked #9867 parent makesguest_mathabort as expected; the other three groups pass 9/9. Restoring the candidate gives 12 further passes and a byte-identical rawlibc.prx. Conventions, whitespace and merge-tree checks pass.Exact-head refresh logs, parent control and preservation proof (SHA-256
2c91e823f1738ab080043004562a4a26bb9acabcd105b11e7a7777eb4fae3a88). Earlier combined and Windows/exhaustive/module evidence below stays pinned to its original revisions; no new Windows, original-module, exhaustive, physical-console, exception-matrix, game/GPU or performance result is claimed.Earlier combined Linux qualification (historical): That report used exact head
3d8ff6b82ad249bba58a1b55a0d23a23ac228932; that evidence update did not change the branch. Its earlier individual qualification stays pinned to that head. The new combined qualification below places this exact branch together with the refreshed expf/erff branches on main after the #10314 merge.The combined source retains this PR's exact
Expm1f,expm1f_nid_postfix,tanhf_nid_postfixbodies and regression calls, plus current main's newly mergedlog1pimplementation. No new individual-head run is claimed for this unchanged branch.Requested combined qualification: private merge
73e28f82193f608b3099be52d2eb5af6a31b7285has exact refreshed #10226 head6871263bf330ef858be42013737e02cb2b021addand unchanged #10222 head3d8ff6b82ad249bba58a1b55a0d23a23ac228932as parents. It includes refreshed #10113, #9867 and the attributed #10007 prerequisite. All five ports, helpers, regression functions/calls and debt entries are retained, together with main's log1p. All four focused groups pass3/3; conventions and whitespace pass. The merge commit is private test integration only.Landing order: #10007 before #10113, with open #9771's previously declared earlier position retained; #9867 before #10222; both #10113 and #10222 before #10226. #9771 is not included in this combined run. #10226's insertion conflict is resolved by keeping both distinct ports and it will refresh after prerequisites land. The current combined qualification supersedes the earlier ce4b6685/18b148ba previews for these refreshed heads.
Fresh exact-head and combined logs, controls and preservation proofs (SHA-256
acf5aaa75e68171a861939c1fcdfada7a9a2bf6ca13b789e3a6b514597e2aeda).Historical measurements: previous Windows/module and integration reports below retain their measured revisions. No new Windows, title/module, exhaustive reference matrix, console, floating-point-exception or performance claim is added.
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON.Exhaustive comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirexpm1fwith this port for all 2^32 arguments, checking result bits and whethererrnois set.errnoeverywhere.errnoeverywhere. The bits differ by 1 ulp on 197,464 arguments, because that copy is an FMA-contracted build, as withexpf(#10113) andtanhf(#9867).std::expm1thatmainuses differs from PPSA07923 on 155,520,115 arguments.guest_math: the newCheckExpm1fConsoleBitshas 34 cases with the console's results anderrno:FLT_MAXand the infinities;tiny - oneedge on both sides,-FLT_MAX;guest_mathpasses in three runs out of three on the exact head.Negative control: with
Math.cppfrom #9867's head and this test,guest_mathaborts in aRequire.Historical head:
33a697c559, this PR's one commit on top of #9867's refreshed head82668d5961, both on currentmain4997726a5f.guest_mathpasses in three runs out of three on this exact head.python tools/check_conventions.py --base 82668d5961andgit diff --checkpass.Landing order with #10226: this PR lands first. The two PRs each replace one of two adjacent host wrappers in
Math.cpp(expm1fhere,erffthere), so their merge has a one-hunk textual conflict whose resolution keeps both ports. A preview merge of both refreshed heads with that resolution (18b148ba55) passesguest_maththree times out of three. #10226 recordsDepends on: #10222.Not tested: Linux and macOS (the result no longer depends on the host's
expm1), a console, the floating-point exception flags.Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 atde5fd246210fbef0ecfdae38cb776d7708f0bf95(Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON).libc,guest_math_testsandguest_math_exact_testsrebuilt from this exact source.guest_mathandguest_math_exacteach passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass.The earlier review cleanup is preserved:
TanhfExpm1is absent,tanhfshares the singleExpm1fimplementation, and the debt entry describes the exported port.Exact source pins, preservation proofs, dependency checks, build logs and JUnit, SHA-256
1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed.Qualification update — 2026-10-30, repeat 2
Integrated pinned main
e471817c68d4e1b1e44b0ce369ed88bafe4ae8edat74fceb9201aa7e636bd0a59dcb0e7e1ab023ffbb, retaining original topic commits as ancestors. Actual parent ancestry: #9867a06ed844e352d33f89f6ed015da3203745330acd. The full current-main logb/logbf debt entry is retained; inherited unused TanhfExpm1 is absent where shared Expm1f supersedes it.Actual Linux libc/focused binaries rebuilt from this final head;
guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs (9 runtime passes), plus public_headers. Conventions against current origin/main and whitespace pass. Pinned main passed all seven runtime groups plus the header audit three times (24 runs). Full source/function/test/debt/header and 31 recursive dependency / 17,742 tracked-blob proofs are attached. Later main1c6b316cf762has 17 off-topic commits, no relevant libc/numeric/qsort/gitlink changes, and all 9 merge previews are clean; those preview trees were not executed.Focused Linux CPU scope only: prior Windows/SDK/reference reports keep original pins. No fresh Windows, console, SDK-module, title/GPU or speed measurement is claimed by this report. AI-assisted: yes. Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math9-maine471-linux-20261030-repeat2.tar.gz (SHA256 5da4ce1732b45bb3fc566c31078c8c9ae8bf0c403654dfc60d15ee28490e20bf).
AI-assisted: yes (Codex).
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).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T14:45:14Z.
Review: CHANGES_REQUESTED
Re-review of exact head
a2b86c6f364ffb1c0c5c0796198fd9fe5faef5d2. The #9867 dependency has an exact-head approval, and this PR reports exhaustive Windows comparison plus focused exact-head tests.#10226 is now also open from your account and adds the separate
erff/erfcfport. A pairwise merge preview of the exact #10222 and #10226 heads conflicts inMath.cpp. Please record a keep-both landing order between them (andDepends onon the later one), then rerun the focused math tests on the combined head. Current main also changedMath.cpp,GuestMath.cpp, and the libc debt file since this stack's merge base; refresh the stack before the final combined run.This is an integration request only; the
expm1fanderff/erfcfexports are distinct, and I am not asking for either PR to be closed.