feat(libc): export the std::__sce_v2 extended-precision helpers #15336
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15336"
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 Danigamer05 on 2026-11-03T00:29:38Z.
What
Depends on #14955 and #15099; their commits are the first two here. Only the third commit belongs to this PR. Once those two merge, this branch will be rebased and only that commit will remain.
Export the nineteen
std::__sce_v2Dinkumware extended-precision helpers from libc. They hold a value as a short array ofdoubleorfloatparts._ZNSt8__sce_v28_Xp_setwEPdid7-gzF0237vw0xCA760_ZNSt8__sce_v28_Xp_getwEPKdi5fmNpHo4cr00xCA6E0_ZNSt8__sce_v28_Xp_setnEPdilK9jt1tdtXvA0xCAFA0_ZNSt8__sce_v28_Xp_movxEPdiPKdQoFx93+IPMY0xCAFC0_ZNSt8__sce_v28_Xp_addhEPdidwb8ubEA1o7k0xCA8A0_ZNSt8__sce_v28_Xp_addxEPdiPKdiQgyliXfKe-A0xCAFF0_ZNSt8__sce_v28_Xp_mulhEPdid3Ve0L5VKidg0xCAD80_ZNSt8__sce_v28_Xp_mulxEPdiPKdiS0_PDE+YRqBekk0xCB0C0_ZNSt8__sce_v210_Xp_ldexpxEPdiiEdDo9k1Fw2g0xCB060_ZNSt8__sce_v29_FXp_setwEPfifp81kEPUMxGc0xCE4E0_ZNSt8__sce_v29_FXp_getwEPKfiAXVguf0qb6k0xCE460_ZNSt8__sce_v29_FXp_setnEPfilZ9nLH6PFl240xCECB0_ZNSt8__sce_v29_FXp_movxEPfiPKf6m4z5Xb6DRo0xCEDD0_ZNSt8__sce_v29_FXp_addhEPfifu5NXv54Ux8U0xCE5B0_ZNSt8__sce_v29_FXp_addxEPfiPKfi13URvVAuB7Y0xCEE00_ZNSt8__sce_v29_FXp_mulhEPfifjJgT41F2+sE0xCEA90_ZNSt8__sce_v29_FXp_mulxEPfiPKfiS0_l9zhpgjwNzE0xCEED0_ZNSt8__sce_v211_FXp_ldexpxEPfiibqAsyZ97ux80xCEE70_ZNSt8__sce_v28_FeraiseEi6qSnCJLe0JE0xCB600The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).VersionedExtendedPrecision.cppfollows that module's sequence of operations and calls:double) or 12-bit (float) parts with the versioned_Dunscale,_Dintand_Dscale. These come from #15099 and #14955, and are verified there against the same module._Xp_addhrenormalizes the parts,_Xp_mulhbuffers up to four partial products, and_Xp_setnforfloatsplits the integer at 10,000._Dtestand the versioned_Feraise. That_Feraiseonly setserrno(EDOMfor 0x5,ERANGEfor 0x18) and raises no floating-point flag._Xp_ldexpxcalls libc'sldexp, as the module does.Additions and multiplications are issued with their operands in the module's order, because x86 returns the first operand's NaN when both are NaN. Both of
_Xp_getw's final sums are computed, as the module computes both before it chooses one._Xp_mulxreads the second term of its multiplier even when it is given one term, as the module does.One known difference remains, and the debt entry records it. libc's
ldexpuses the host function. It gives the module's values anderrno, but raises other SSE and x87 flags than the module's Dinkumwareldexp, so_Xp_ldexpxinherits that difference. Fixingldexpitself is a separate change; no open PR touches it.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, main5cb015caaaaf83f8ee431414ee6a457b5b307d49. Exact tested commit:23e00f1cc011c5c8aecef06c0240e7388345e428.Built libc, libkernel, their NID-patched production libraries and the related tests. All 70 selected CTests pass, among them the new
guest_sce_v2_extended_precision, plusguest_sce_v2_binary_scaling,guest_sce_v2_float_helpers,guest_math_exact,guest_dinkumware_float_bitsandpublic_headers.The new test checks 106
doubleand 105floatcases and eleven_Feraisearguments:setwandgetwof finite, extreme, subnormal, zero, infinite and NaN values at every length up to four;setnof 64-bit integers, including both limits;addhacross the 26-bit and 12-bit part boundaries, of an infinity of either sign, and of an input recorded from the side-by-side run below;mulhof finite values, NaN, zero and the largest value, including a product of two NaNs with different payloads;addx,mulxwith its scratch area,ldexpxwith underflow and overflow, andmovx.Every expected bit pattern and
errnowas taken from the original module, not from this implementation.The original functions were loaded from the bundled module with its relocations applied. Its
__errorimport was bound to this libc and__stack_chk_guardto a local value; every other import would have stopped the run, and none was called. MXCSR was reset to0x1F80and the x87 unit reinitialized before every call.The originals then ran side by side with the patched production library on 18,000,768 calls: 500,000 per function and form for each of two seeds. The inputs were:
The whole 320-byte work area, the return value,
errno, the full MXCSR and the x87 control and status words agree for every call to 18 of the 19 exports. For_Xp_ldexpx, the parts anderrnoagree in every call, while about half the calls raise other SSE or x87 flags, fromldexpas described above.Negative control: four lines were altered one at a time:
addhpart boundary was moved by one;mulh's first product were swapped;setw's second split used one bit less;_Feraise'sERANGEmask lost one bit.The new CTest failed on each. With the four applied together, the side-by-side run flagged 11 of the 19 exports, beyond the known
_Xp_ldexpxflags. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and all 70 tests and all 18,000,768 calls passed again.Code conventions and
git diff --checkpass.tools/pr_overlap.pyread 1,712 open PRs at the tested commit. It reports overlap only with #14955 and #15099, whose commits this branch contains. It keeps exit 2 for 24 branches that already conflict with main. None of their added lines contains these exports or names. Merging each with this branch and with main usinggit merge-treegives the same conflict blocks, and no block contains a line of this change. The branch also merges cleanly with #15210.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T00:39:48Z.
Review: COMMENTED
Reviewed — no blocking findings
The new extended-precision helper implementation and its checked-in test vectors have no substantiated blocking source issue in this review; approval is withheld while required hosted checks remain queued.
What I ran
Reviewed the complete 8-file diff at head
23e00f1cc011c5c8aecef06c0240e7388345e428, based on7feb37ee3e30e10139b483fb4df689d5b5b69ab8. The no-build merge preview onto that currentmaintip was clean. Environment: Debian Linux x86_64, Python 3.11.2, Git 2.39.5; GCC 12.2.0 is installed. No local compilation was performed.Results
Precheck table and unedited check output
The precheck report’s check table:
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check 7feb37ee3e30e10139b483fb4df689d5b5b69ab8...23e00f1cc011c5c8aecef06c0240e7388345e428/usr/bin/python3 tools/check_conventions.py --base 7feb37ee3e30e10139b483fb4df689d5b5b69ab8 --head 23e00f1cc011c5c8aecef06c0240e7388345e428 --title feat(libc): export the std::__sce_v2 extended-precision helpers --body /tmp/anyps5-pr-precheck/15336-session-20261103/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base 7feb37ee3e30e10139b483fb4df689d5b5b69ab8 --head 23e00f1cc011c5c8aecef06c0240e7388345e428 --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 15336 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/15336-session-20261103/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /tmp/anyps5-pr-precheck/15336-session-20261103/head-23e00f1cc011-381e9f64/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/15336-session-20261103/head-23e00f1cc011-381e9f64 --json core/libs/prx/libc/CMakeLists.txt core/libs/prx/libc/include/Api.hpp core/libs/prx/libc/src/MathExact.cpp core/libs/prx/libc/src/VersionedExtendedPrecision.cpp core/libs/tests/GuestSceV2BinaryScaling.cpp core/libs/tests/GuestSceV2ExtendedPrecision.cpp core/libs/tests/GuestSceV2FloatHelpers.cpp docs/dev/debt/libc.mdNo changed Python test module in tools/ can be run as a no-build base-source control.The precheck command printed:
The isolated helper errors were:
Exact-head convention output:
Exact-head ABI audit output for the added exports (unrelated audit warnings are shown as printed):
Exact-head test-quality heuristic output:
Hosted-check output at final refresh:
Negative control
Not run locally. The added C++ test requires an exact-head binary, which I did not build. The PR description reports four source-mutation controls and a restored-source run; those remain author-reported evidence here.
Findings
Blocking
None found in the reviewed head.
Non-blocking
main. Keep this landing order and re-run the relevant checks after the dependencies merge and this branch is updated.Sources
Not verified
No local build, CTest, negative-control run, Linux/Windows runtime, console run or independent original-module comparison was performed. All six hosted checks were queued at final refresh. The PR’s own detailed Windows test and differential-run report is not an independent run by this reviewer.
To get this to a good state
No source change is requested from this review. Let the six hosted checks complete, preserve the declared dependency order, and update this branch after #14955 and #15099 land. I will recheck the exact new head, rerun the no-build checks and assess the reported test evidence before considering approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T00:40:42Z.
Review: COMMENTED
Re-checked — same head, corrected citations
The prior #15336 review is tied to unchanged head
23e00f1cc011c5c8aecef06c0240e7388345e428; this correction fixes two malformed CMake permalinks and clarifies the test-quality result.What I ran
Read the CMake file from the exact reviewed head using the GitHub contents API; no build or test was run for this correction.
Results
Exact command output
Findings
Blocking
No change to the prior finding: I found no substantiated blocking source issue, and approval remains withheld pending the required hosted checks.
Non-blocking
The earlier Results row's
failedlabel was imprecise for the test-quality helper: it emitted three possible-registration warnings, but manual inspection confirms those CTest targets are registered. The isolated precheck itself did fail to start its helper because that script is absent from the exact-head snapshot; this is already shown in the original review's precheck output.Sources
Not verified
No new compilation, CTest, negative control, or hosted-check run was performed for this correction.
To get this to a good state
No code change is requested based on this correction. The original review remains a COMMENTED result, not an approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T03:38:59Z.
Review: APPROVED
Reviewed — looks good
The reviewed change adds the extended precision exports and documents the known
ldexpflag difference; the inspected code and submitted validation support merging.What I ran
Reviewed head
834e0c156f5e6dcf44425073526ce629a3ab948e. I did not run commands or tests; build, CTest, and side-by-side comparison results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The implementation’s execution, tests, and comparison were not independently verified. Linux, macOS, other SDKs, games, GPU behavior, and console execution were not tested per the description. Read all five changed files listed in the manifest:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/Api.hpp,core/libs/prx/libc/src/VersionedExtendedPrecision.cpp,core/libs/tests/GuestSceV2ExtendedPrecision.cpp, anddocs/dev/debt/libc.md. The manifest marks all five included; no changed file was excluded.To get this to a good state
Nothing is required.