fix(libc): preserve tanh saturation flags and directed rounding #10506
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10506"
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-24T05:45:19Z.
What
The saturation branch introduced by #10316 evaluates
1 - tinywith a volatile operand.tanh(22)therefore raisesFE_INEXACT; under downward or toward-zero rounding its result is the representable value below 1. The suppliedlibc.prxin FAR: Changing Tides (PPSA03766) returns exact signed 1 with no new exception flags for finite magnitudes of at least 22.Return exact signed 1 from that branch. Add a regression covering positive/negative saturation, four rounding modes, all DAZ/FTZ combinations, and clean or pre-existing sticky flags. Record the remaining unsaturated discrepancies in debt.
This follows #10316 and its #10306 dependency; the new topic is one commit on their existing implementations. Base main is
6c52b649e7; a merge-tree check against current maina5a2c946a3is clean. The overlap report lists shared math/test/debt anchors; the declared parent PRs supply the required implementations.Tested
Current-main refresh — 2026-11-04. Head
9bed91fb373a0d29d27af064547ded5ec28b5207merges main9ab6a281ea61c9e62a7eb07eb4cef8f19ede1c5cwhile retaining the prior public head as an ancestor. Main’s newer code, regression fixtures and debt entries are preserved alongside this topic.Linux x86-64, GCC16.2.1, Ninja Release: actual libc, libkernel and libSceAmpr CMake owners rebuilt coherently.
guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs (9 passes, zero skips). The same groups pass three times on pinned main. Public-header audit and conventions pass. Original licence-notice trailing whitespace is retained where present. The scoped recipe reuses frozen ZArchive/zstd providers; this is not a whole-project build. No new Windows, bundled-SDK, physical-console, title/GPU or FPS measurement is claimed; earlier reports retain their original pins.Exact source/parent proofs, per-branch patches/input manifests, build and CTest logs/JUnit, library/executable hashes and scoped CMake recipe, SHA-256
97a2377bc996be1690e8853e1ea090a98b5ed808bcc37a15a5cdada5c2e00845(download verified). AI-assisted: yes (Codex).Current-main integration — 2026-11-03. Head
e1d96ebdf91075b1783f614f65ce5b4fded0bb1cincludes main4f41f4c375f5abb487dbd184fbc150f31994d762and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic.Linux x86-64 Release, GCC 16.2.1, Ninja, BUILD_TESTING=ON: rebuilt actual libc and math executables.
guest_math,guest_math_exact, andguest_dinkumware_internalseach pass 3/3 (9 passes, zero skips);public_headersand conventions pass. The same three groups pass 3/3 plus headers on pinned main. All 34 recursive dependency trees and 31,551 tracked blobs verify with zero errors; the update=none QuickJS test262 corpus is excluded from these library inputs. Whitespace check passes.Source/parent/gitlink proofs, exact library/test hashes, raw logs/JUnit, and head-leased push receipts: qualification archive, SHA-256
e6a50522bc28e30871fdc2c12a88d2537515914239e8166f6237f48895126a06(download verified). Older platform/reference reports retain their original pins; no new Windows/macOS, SDK-module, console, title/GPU or performance claim. AI-assisted: yes (Codex).Earlier dated qualifications below retain their recorded source/platform pins.
Current-main integration (2026-11-02):
7028b1757c9e42d2e943e931d07ae5a5ee592795includes maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8and retains the existing public commits. Conflicts preserve main’s math implementations, regression checks and debt entries alongside this topic. Linux x86-64 Release, GCC 16.2.1: rebuilt libc and the three math executables;guest_math,guest_math_exactandguest_dinkumware_internalseach pass three times (9 passes, zero skips), andpublic_headerspasses. The same baseline groups pass on main; conventions and whitespace pass. Source and dependency blobs, executable/library hashes, raw logs and JUnit are retained. This refresh adds no new console, Windows, title, GPU or numerical-reference measurement. Qualification evidence, SHA-25622866bd2a060ba69cd4387d471605afe20ed644e3257174b2d1488635f8c9b52(download verified).Current-main conflict refresh, 2026-10-27 UTC: exact head
54d349183697fe9e09f9a8e41eb77f81ca1590fcon tested main74acfad65b3f0fd4eab653f3a3989d298fba1157. Resolved overlapping test/debt context while preserving this branch's authored production/test edits and main's nextafter environment implementation and coverage. Existing prerequisite commits remain in their original series order.Linux focused rebuild of
libcand selected test executables passesguest_mathandguest_math_exact, each three times: 6 passes, zero skips. Conventions and whitespace checks pass. Final fetched maincb45ae2ddf6e113a4619e8fed91fe7b9333c5c0fmerges cleanly; its later change is an unrelated Windows crash-test pattern, and the executed qualification remains pinned to the stated base. No new Windows, console, GPU, title, full-suite or negative-control run is claimed. Earlier reference/Windows evidence keeps its original pins.Exact pins, branch patches, preservation proofs, build/test logs, JUnit and lease-push receipts for this refresh batch. SHA-256:
e33f98cc467f038af662cc5fa491c3acc1806bb47171cf77b748f0d4d052c1f2; downloaded copy verified.Current Linux refresh:
9c79f0a14c5e28fc6bc5c3a68d5ed2eb24a6ed3bis refreshed onto maina5a780eaaa7f187fe8f5c7f2ef244f6a6dab2762, with prerequisite authorship retained and no merge commits. The original production and regression function bodies are preserved, along with main's log1p implementation, regression calls and current public declarations.Fresh Linux x86-64 Release:
guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass3/3 before and after the production-only main-Math negative control. The negative aborts as expected while exact-math/Dinkumware controls pass. Restored libc is byte-identical and sources clean. Conventions, whitespace and merge-tree checks pass.Exact-head logs, negative/restoration results and preservation proof (SHA-256
f107a42be1dabc4ef72ffddcc6274d35e65ebd40146c811214558b28d4952a90). No fresh original-module matrix, Windows/macOS/title/console or performance measurement is claimed by this refresh. Earlier reports below retain their measured source pins.Previous qualification (historical source pins)
Current Linux refresh: head
489726b9f600a42daf6e7f493d18f9dd867b5774, directly on #10316 ata5b452fa493d91a14fbb3e708f618171a9b3dcb4(itself one commit on main50a4f824fc3ee23177d8e1effbe306e50150187f). The merged #10306 commit is no longer duplicated in this stack. Production added/removed lines are byte-identical to the previous reviewed head. Fresh independent libc/math build; guest_math and guest_dinkumware_internals each pass three consecutive runs. With only Math.cpp reverted to the direct parent's production code and the new fixture retained, guest_math aborts; restoration returns both groups to passing and reproduces the original libc library hash. Conventions/whitespace pass.Read-only merge-tree against fetched main
dc15ed65375228a0f69c41d7770c4c118adb38f2is clean; the checks above are on the explicitly stated tested base, not a build of that merge tree. Windows remains user-paused and has not been rerun on this head.Exact-head Linux build, JUnit, negative/restoration controls and rebase proof, SHA-256
1087c9bf4d5bd4e0a9c5e54b5d18e710c1e576d7de607f0adc30d41d23af67a2.Historical previous-head evidence (not rerun on the current head):
Linux x86-64, Ryzen 9 7950X, GCC 16.2.1, Release. Final head
12826b49859a22e3896b7ff6670152ea94d22397.guest_mathandguest_dinkumware_internalseach pass three consecutive runs at the final head. The new saturation test makes 480 calls per run.720c7318597f28501ea3c644ac744333120d85ddretains the original production code.guest_mathaborts at the named saturation check (tanh(22)has unexpected inexact);guest_dinkumware_internalspasses.tanhcode is byte-identical in the original unwrapped module and its converted guest function. Both module hashes remain unchanged. Original module binaries are excluded from the evidence archive.Source patch, numeric comparison logs, fixture, build/test logs, negative-control result and overlap report. SHA256
496fc2f59831bb8ff5e71c3c9f288ea3fcbc8b4dac7e8c1baea56d333c583279.Not tested: Windows, macOS, a physical console or unmasked floating-point exceptions. This is library correctness evidence; no title bring-up or FPS gain is established.
Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at6a8a2372a3c3932e23dce46dd388cfe9b06aa87a(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.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.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)cbee22480462; present in audited main3fea2a937ba)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:06:41Z.
Review: APPROVED
Reviewed exact head
12826b49859a22e3896b7ff6670152ea94d22397against the pinned FreeBSD 11.4s_tanh.c/s_expm1.calgorithms and the surrounding errno/floating-point handling. The saturation branch returns the signed exact unit value without an arithmetic operation, and the regression exercises both signs, four rounding modes, DAZ/FTZ combinations, sticky flags, infinities and maximum finite inputs. The author reports 64,512-call CPU differential comparisons and red/green test evidence; I did not reproduce that fixture locally. Hosted conventions, intake, eligibility, labels, report, register-context, relinker, write-watch and ASan checks pass. Full product Linux/Windows jobs were skipped by workflow selection, and no console run is claimed.