Skip to content

fix(libc): preserve expf rounding and exception behavior - #10113

Open
JJenkx wants to merge 28 commits into
boykopovar:mainfrom
JJenkx:windows/libc-expf-msun
Open

JJenkx wants to merge 28 commits into
boykopovar:mainfrom
JJenkx:windows/libc-expf-msun

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What

expf now preserves the scalar bundled-libc algorithm's results and floating-point side effects across caller rounding modes. It uses the existing msun-derived reduction and polynomial, with the native range branches, evaluation order and fixed binary32 constants.

  • Overflow calls _Feraise(8) and returns positive infinity. The explicit underflow branch calls _Feraise(16) before the final multiplication; the general subnormal path leaves errno unchanged.
  • The native argument-1 literal returns without adding inexact. Small arguments retain the huge + x inexact trigger.
  • Arithmetic follows the native 1 + (x - ratio) order. Exact hexadecimal float constants avoid runtime double-to-float conversion under directed rounding.
  • MathExpf.cpp retains the existing Sun/msun licence and attribution, with source-scoped -frounding-math and -ffp-contract=off.

The log1pf prerequisite from #10007 and its authored history remain intentionally retained. This updates the existing PR; no duplicate expf implementation PR is created.

Tested

Current-head Linux validation (2026-11-27): f876efc0ef1c529370c6304149e3adb8443e27f4 merges main f73d791b3df4dcaa773297a93f5ae2c062ee95a3 and retains main's scalar and fused logf paths alongside this PR's dedicated MathExpf.cpp. All six targeted Linux x86-64 Release CTests passed with zero skips. The guest_expf_environment suite passed all 1,128 checks, and the dedicated source retained -frounding-math -ffp-contract=off. Exact-head Linux report.

Historical CMake maintenance (2026-11-26): head 996aaa42e5f8c7d72bf09031e317b2c9e7228bcf merges main 79e4f35199fa93b44e4689f391f603dec5b702cb. The maintenance commit changes only CMake placement: the expf source/flag blocks avoid the gamma insertion points, and guest_expf_environment moves into an independent test fragment with its original BUILD_TESTING guard. MathExpf.cpp and GuestExpfEnvironment.cpp remain byte-identical to public head 86fc4fc9c2f0.

A fresh Linux x86-64 / GCC 16.2.1 / Release Ninja build of raw libc/kernel and four focused executables passes. guest_expf_environment, guest_math, guest_math_elementary and guest_floating_point pass, 4/4, zero skips. The CTest backtrace confirms registration from the new fragment; Ninja retains -frounding-math and -ffp-contract=off; actual raw-provider loading and unchanged input hashes are verified. Conventions, debt-fold and whitespace checks pass. Full Git pair merges with #10226 (ca8a86166e6f), #24306 (0fbd95fdc9d6) and #24360 (53137577143a) are clean; the gamma pairs conflicted in CMake before this maintenance. These are merge checks, not new gamma runtime tests.

Maintenance patch, build/test helpers, compiler flags, registration/loader receipts, logs and JUnit — anonymous download and all 20 payload hashes verified; SHA-256 8bd6922de236eda39482f5021367095aca6bfebed52f2d09464650455e5c2ce8. This maintenance validation did not rerun the full patched SDK, Windows, original-module differential, console, title/GPU or performance checks. Earlier mathematical validation remains pinned to the revisions below.

Earlier refresh: merged upstream 786bc3afa1c874f98ec2990eb58179a99eeb425c as 86fc4fc9c2f04da5210c6cf23a69aa2f4eed05ce. The CMake conflict keeps both this PR's guest_expf_environment registration and main's guest_lgamma_poles registration, including their separate Windows environment blocks. The production MathExpf.cpp, golden fixture and debt fragment are byte-identical to the corrected prior head 61549d86.

At that earlier pin on Linux 7.3.5-arch1-1, the complete patched/raw SDK and relinker build pass. All five focused CPU groups pass: guest_math, guest_math_exact, guest_dinkumware_internals, guest_floating_point, guest_expf_environment. Source, configuration and submodules were restored. Current-main patch, build provenance, frozen SDK hashes and verbose test logs, SHA-256 811511ebd9c391badddb43bf75489f38728e09bbf92f8ebe24bf11134a634ee8; downloaded again and verified all 19 payload hashes plus the manifest. Hosted CI was pending when that refreshed-pin report was written. The Windows owner also reports the earlier public head 86fc4fc9c2f0 merged onto main 87b7ef3891 as c553316ef1: guest_expf_environment, guest_lgamma_poles and guest_math all pass in each of three runs on Windows 11 Enterprise 22621 / WinLibs GCC 15.2 UCRT Release. This is a three-group Windows check, not a claim that the whole Windows suite ran. Owner report.

The original differential and trap measurements below remain historical evidence at their named pins.

Arch Linux x86-64, GCC 16.2.1, Release. Main 7fa48cd1c6cda62b4ebe86575085199a33e08c1d; old public #10113 ea1052637d616b6ec43ed9fd0ec4ed90f971f2a6; corrected head 61549d86c2a61edbd005d9b441748b3d9bd906aa. Comparisons use frozen private merges of the public branches onto that main. The old-PR composition and the corrected head's pre-fix parent have identical source trees.

Full SDK libs, relinker and four existing CPU groups built and passed on main, main plus old #10113, and main plus #21714. The correction also passes the new guest_expf_environment test: 1,128 result/flag/errno/control checks, including a pending divide-by-zero flag. All five groups pass. The exact same new executable fails against both main and old #10113 raw test libraries, then passes with the correction; loader paths are verified and loader failures are excluded.

Actual patched SDK versus the original converted PPSA21564 libc export (ab860676108827e0983eefbde3a711b5ce8e20f0b24b492498b6e04cb23c6130): 6,906 inputs × three x87 precisions × four rounding modes × four DAZ/FTZ states × two pending states = 662,976 comparisons per bank. Both function owners are checked by device/inode, reference outcomes are identical across providers, and banks/modules/probe hashes remain unchanged.

Provider Result differences Raw exception-flag differences Errno differences
Main 121,704 924 3,840
Main + old #10113 83,364 2,124 0
Main + #21714 121,704 12,912 15,576
Corrected #10113 0 0 0

Caller control differences: zero for every bank. The SDK's __error aliases host errno on this Linux machine, so the two logged errno columns are one channel, not independent measurements.

A separate Linux child-process comparison enables exception traps in both x87 and SSE: 144 reference/SDK pairs, checking first-trap signal, flags, errno, result and controls. Old #10113 has 96 mismatches; the correction has zero. Original-module dependencies, including _Feraise, still come from each SDK, so this does not independently establish console/helper conformance.

Complete evidence, source patches and reproducers — SHA-256 eb013afbaf76b1a234a17402ee3c0afc5befd14cf1543813613bdcbe88903bf1, 166 payloads; downloaded and every payload verified. Original binaries, original assembly, game assets, SDK binaries and caches are excluded.

Conventions pass; the merge-tree check against current main is clean. The official overlap scan and pinned manual comparisons are included. #10226 is the dependent erff/erfcf child; #21714 is a tested alternative, not a dependency; #19434 forwards a separate library surface; #24322 splits source files. The gamma PRs share independent additive CMake registrations. All fifteen fail-closed primary patches match previously reviewed pins, and the two additional shared test hunks concern nextafter/nexttoward and double lgamma only.

These are sampled Linux CPU measurements, not a new exhaustive all-float result. Prior Windows/macOS reports on the old public head remain historical. The separate Windows owner report above covers three focused groups on the refreshed head composed with its named main; it does not reproduce the original-module differential or trap comparisons. No new macOS qualification is available. FMA-contracted title variants can retain different last bits, as documented in debt. No console execution, game unblock, GPU, loading-time or FPS improvement is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(libc): follow msun for log1pf #10007
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved expf results across normal and very small inputs, including overflow, underflow, and subnormal cases.
    • Improved expf behavior across rounding modes and floating-point exception conditions.
    • Improved log1pf results for finite inputs within its valid range, while retaining handling for values outside that range.
  • Documentation
    • Added notes on updated math behavior and reported comparison results, including coverage and areas that have not yet been verified.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 19434 expf

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.

Pull request Shared files not compared
PR 7715 core/libs/prx/libc/CMakeLists.txt
PR 8965 core/libs/prx/libc/CMakeLists.txt
PR 12682 core/libs/prx/libc/CMakeLists.txt
PR 12688 core/libs/prx/libc/CMakeLists.txt
PR 12700 core/libs/prx/libc/CMakeLists.txt
PR 12717 core/libs/prx/libc/CMakeLists.txt
PR 12849 core/libs/prx/libc/CMakeLists.txt
PR 12965 core/libs/prx/libc/CMakeLists.txt
PR 23395 core/libs/prx/libc/CMakeLists.txt
PR 26796 core/libs/prx/libc/CMakeLists.txt
PR 27540 core/libs/prx/libc/CMakeLists.txt
PR 27568 core/libs/prx/libc/CMakeLists.txt
PR 27569 core/libs/prx/libc/CMakeLists.txt
PR 27646 core/libs/prx/libc/CMakeLists.txt
PR 27815 core/libs/prx/libc/CMakeLists.txt
PR 27823 core/libs/prx/libc/CMakeLists.txt
PR 28071 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/src/Math.cpp
PR 28808 core/libs/prx/libc/CMakeLists.txt

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed exact head 1977b6b. The msun port and test additions look carefully scoped; the exhaustive comparisons against three shipped libc.prx copies are strong evidence, including the documented FMA-contracted exception. The current-main sync check is a clean merge (1 ahead/25 behind), and exact-head git diff --check plus tools/check_conventions.py --base upstream/main pass.

I found one merge blocker required by the repository overlap rule: combining this exact head with open #10007 produces a content conflict in core/libs/tests/GuestMath.cpp (git merge-tree --write-tree reports conflict). The changes are separate functions, but both insert at the same test location. Please agree with #10007’s author which lands first, record the resulting Depends on: #N on the checklist line, and rebase/resolve the second branch. Then rerun guest_math on the resolved head. I attempted a local full-build configure for the focused test, but it stops because SDL2 development files are unavailable here; I did not run a local runtime test. Hosted policy/conventions/intake checks and relinker/register-context/write-watch matrices pass; full Linux/Windows jobs are skipped by path policy.

@JJenkx
JJenkx force-pushed the windows/libc-expf-msun branch from 1977b6b to 5534968 Compare October 23, 2026 10:25
@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks, done. Since #10007 is the older PR, it lands first:

  • this PR is now its one expf commit on top of fix(libc): follow msun for log1pf #10007's head 89b9820fee (55349685bd, pushed);
  • the GuestMath.cpp conflict is resolved by keeping both test functions, CheckLog1pf then CheckExpfConsoleBits, with each call in main unchanged;
  • the checklist now says Depends on: #10007.

On 55349685bd, guest_math passes in 3 of 3 runs on Windows (MinGW-w64 GCC 15.2 UCRT r7, Release), and tools/check_conventions.py passes. The stacked head also merges cleanly with current main (513ca7e558). If #10007 changes before it lands, I'll restack on its new head.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for resolving #10007 first. I verified this exact head is stacked on 89b9820fee, the pairwise merge with #10007 is clean, the checklist now names Depends on: #10007, and the reported guest_math 3/3 rerun covers the resolved stack. The exact-head diff check passes; conventions reports 0 errors (with an existing/updated debt-length warning on the 1,265-character expf entry). The published exhaustive expf comparisons remain strong evidence for the implementation.

The remaining declared dependencies are still open: #9771, #9841 and #9844. Pairwise merges of this head with them still conflict (respectively in the debt file, GuestMath.cpp, and Math.cpp). The branch is also 3 commits ahead/238 behind current main, with docs/dev/debt/libc.md changed on both sides. Since your checklist already says to rebase after those three land, please do that, resolve the shared hunks, then rerun guest_math and conventions on the final integrated head before approval. The current clean merge with main does not include those dependent PRs.

@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed 30036a752d, a docs-only commit that puts the expf debt entry's gap first and brings it to 687 characters. The conventions debt-length warning is gone. Exact-head conventions and git diff --check pass.

Agreed on the rest: once #9771, #9841 and #9844 land, I'll rebase this onto that main, resolve the shared hunks in docs/dev/debt/libc.md, GuestMath.cpp and Math.cpp, and rerun guest_math and conventions on the final integrated head before asking for another look.

@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Linux run at this PR's exact head 38afab9894 (38afab989453c28e5caef9e9dc936a47f6a8470d), not merged onto anything else; its base on main is 4997726a5f.

Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release, BUILD_TESTING=ON.

  • guest_math: passed in each of 3 runs, exit code 0 each time, with no failed, skipped or not-run tests.

This is the focused test only; no title, console or floating-point exception flags were checked.

AI-assisted: yes (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
JJenkx pushed a commit to JJenkx/AnyPS5 that referenced this pull request Oct 24, 2026
Additive conflicts with main's newer libc math changes: the debt list keeps
both sides' entries (per entry), the GuestMath.cpp test functions and calls
from both sides are kept, and Math.cpp keeps both sides' independent changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx

JJenkx commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main 1e20650e84 into this branch as cdb0de8541 (was 38afab9894), a merge commit rather than a rebase. Done on Linux while the Windows session is paused.

  • The conflicts were additive, next to main's newer libc math changes. Math.cpp also conflicted next to main's new msun expm1: the result keeps this branch's log1pf and main's expm1, each defined once.
  • The docs/dev/debt/libc.md entry list keeps both sides' entries, checked per entry: this PR's entries keep their exact text, and so do main's.
  • GuestMath.cpp keeps both sides' test functions and calls.
  • New head, Linux only: guest_math and guest_math_exact pass (Arch Linux, kernel 7.2.9, GCC 16.2.1, glibc 2.44, Release, BUILD_TESTING=ON). tools/check_conventions.py --base origin/main reports no errors.
  • Earlier Windows and comparison evidence in this thread stays pinned to the heads it was measured on.

AI-assisted: yes (Claude Code)

@JJenkx

JJenkx commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed as 8f6de6c536b5165389d7f88e63d04c50bbcb48ee on main da6c581a02db, with topic commits and declared prerequisites only; no public merge commits. Reviewed production and regression bodies are unchanged. Depends on: #10007, #9771.

Fresh individual Linux qualification passes four groups 3/3 before and after an expected immediate-parent Math negative failure; controls pass and restoration is byte-identical. The requested combined exact #10222/#10226 integration is now tested as private merge ce4b6685e50a: all five ports and tests are kept, and all four groups pass 3/3. The description records the landing order and links the full receipts. #10007's carried commits retain MarcZX10 authorship. Pending #9771 ordering for #10113 remains declared; that separate code is not part of this combined run.

Earlier Windows/module reports stay historical; no fresh title/module or Windows run is claimed. AI-assisted: yes.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 86fc4fc9c2f04da5210c6cf23a69aa2f4eed05ce. I did not run build or test commands; the build and test results below are author-reported. I read all six changed files listed in the manifest and the prepared description, commit list, manifest, and diff through repo_read.py. No files were excluded by the manifest.

Results

Check Result Note
Source and test review passed Six changed files read
Linux build and focused groups not run Reported passed by author
Windows focused groups not run Reported passed by author
Hosted CI not run Pending per description
Console behavior not run Not claimed or verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not independently reproduce the reported Linux or Windows builds and focused tests, the pinned differential/trap measurements, or hosted CI. Console execution and helper conformance remain unverified, as the change description and debt note state.

To get this to a good state

Nothing is required.

@JJenkx

JJenkx commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Published CMake-only maintenance at 996aaa42e5f8c7d72bf09031e317b2c9e7228bcf, after merging main 79e4f35199fa. The implementation and environment fixture retain their exact public 86fc4fc9 bytes. The new guarded test fragment preserves the original registration, timeout and Windows environment block; source and compiler-property positions avoid the pending gamma insertions.

A fresh raw libc/kernel build and four CPU CTests pass, zero skips. Actual provider loading, stable hashes, source compiler flags and registration from the new fragment are verified. Conventions, debt-fold and whitespace checks pass.

Full pair merges with #10226, #24306 and #24360 now succeed. The same-base gamma pairs demonstrably conflict in CMake before this change and merge cleanly after it. This removes the expf/gamma CMake conflicts found in the earlier private stack; it does not claim every possible multi-PR combination or the remaining parent/child gamma debt-note conflict is resolved.

Verified maintenance evidence — 20 payloads, archive SHA-256 8bd6922de236eda39482f5021367095aca6bfebed52f2d09464650455e5c2ce8, anonymous download and all payload hashes checked. Full SDK, Windows, original-module and performance evidence in the description retains its historical pins; no repetition of those runs is claimed. The prior review was on an earlier head.

AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing in the inspected changes blocks merging; the focused checks reported for this head pass, with broader platform and console checks still unverified.

What I ran

  • No commands or tests were run in this review environment.
  • Reviewed head 996aaa42e5f8c7d72bf09031e317b2c9e7228bcf. The description reports a Linux x86-64/GCC 16.2.1 Release Ninja build and four focused tests passing at this head; those are author-reported results, not runs performed here.

Results

Check Result Note
Source and integration review passed Inspected all changed files
Focused build and tests not run Reported passing by the author
Broader platform and console checks not run Not covered by this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read core/libs/prx/libc/CMakeLists.txt, core/libs/prx/libc/src/Math.cpp, core/libs/prx/libc/src/MathExpf.cpp, core/libs/prx/libc/tests/cmake/guest_expf_environment.cmake, core/libs/tests/GuestExpfEnvironment.cpp, core/libs/tests/GuestMath.cpp, and docs/dev/debt/changes/refresh-expf-log1pf-msun-20261117.md. All seven changed files listed in the manifest were included and read. I did not run the build or tests, or verify Windows, macOS, console, or title behavior. The review folder’s description.md, commits.md, manifest.json, and diff.patch were read; no files were excluded by the prepared manifest.

To get this to a good state

Nothing is required.

@JJenkx

JJenkx commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main at f73d791b3df4 into this branch and resolved the Math.cpp conflict. The merge keeps main's scalar and fused log implementation and the branch's dedicated MathExpf.cpp implementation. GitHub now reports the PR as mergeable at f876efc0ef1c.

On Linux, all six targeted CTests passed. The guest_expf_environment suite passed 1,128 result, flag, errno, rounding, precision and pending-exception checks. guest_math, guest_math_exact, guest_math_elementary, guest_dinkumware_internals and guest_floating_point also passed. The compile database confirms -frounding-math -ffp-contract=off for MathExpf.cpp.

AI-assisted: yes

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: libc math functions

Layer / File(s) Summary
Math implementations and build integration
core/libs/prx/libc/src/Math.cpp, core/libs/prx/libc/src/MathExpf.cpp, core/libs/prx/libc/CMakeLists.txt, docs/dev/debt/changes/refresh-expf-log1pf-msun-20261117.md
Math.cpp uses Log1pfMsun for finite inputs greater than -1 and removes its previous expf_nid_postfix wrapper. The libc target builds the new expf_nid_postfix implementation with rounding-related compile options. The change notes cover log1pf, expf, and atanhf.
Function result and error tests
core/libs/tests/GuestMath.cpp
GuestMath adds approximate and bit-exact log1pf checks, plus expf result-bit and errno checks. The main test runner calls these checks.
Floating-point environment regression tests
core/libs/tests/GuestExpfEnvironment.cpp, core/libs/prx/libc/tests/cmake/guest_expf_environment.cmake
The registered environment test runs expf cases across rounding modes, x87 precision settings, and pending-exception settings. It checks result bits, flags, error values, and CPU state.

Possibly related issues

  • boykopovar/AnyPS5#9707 — The issue reports expf result differences against the console libc. This PR replaces the implementation, but the provided context does not establish that it closes all reported differences.
  • boykopovar/AnyPS5#23411 — The issue compares expf result bits, flags, and errno. This PR changes that behavior and adds tests for those outputs.

Possibly related PRs

  • boykopovar/AnyPS5#10226 — The PR ports erff and erfcf implementations that call expf; it names this PR as a dependency.

Suggested reviewers: marczx10, privacyonion, xiiyaz

Change: Bug fix

Merge Risk: Low · up to 9a339

This change replaces the libc expf implementation with a ported algorithm, and the author reports passing tests. Console behavior and performance have not been measured on the current head, so owners should watch for differences in expf results after merge.

Security architecture risk: Minimal · up to 9a339

The changes affect results and floating-point status for callers of two existing math functions. The reviewed paths did not show expanded access, new privileges, or effects beyond the calling thread.

Security review details

Security Blast Radius

  • inferred — For the inspected paths, guest-controlled inputs affect the returned float and the executing thread's floating-point state and errno. Neither new implementation takes a guest pointer or uses the scalar input to select a destination outside the thread.

Trust Boundaries and Controls

  • observed — The new expf range branches pass fixed overflow and underflow masks to the existing helper. The caller's float determines which branch runs, not which status bits the helper may write.

Resilience and Maintainability Implications

  • observed — The expf environment test checks result bits, sticky flags, errno, and preservation of floating-point control settings with exceptions masked. It does not exercise interruption at the helper's x87 wait.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65234660-d258-482f-aea5-8d43501d43a8
Commits

Reviewing files that changed from the base of the PR and between 244f4b5 and 9a33984.

Files selected for processing: 1

  • core/libs/prx/libc/src/Math.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The exact head reviewed is f876efc0ef1c529370c6304149e3adb8443e27f4; the changed production implementation and its CMake registration appear consistent with the stated goal, and no concrete blocking defect was found in the code inspected.

What I ran

No build or tests were run in this review. I read the prepared description, commit list, manifest, diff, the full MathExpf.cpp, its CMake source and compile-option registrations, and the test CMake fragment. The changed test source, Math.cpp, and other changed hunks were not read in full.

Results

Check Result Note
Diff and selected source review passed Production expf path inspected
Tests not run Author-reported validation only
Full changed-file review not run Several changed files not read

Findings

Blocking

None in the code inspected.

Non-blocking

None.

Not verified

I did not read core/libs/tests/GuestExpfEnvironment.cpp, the changed portions of core/libs/prx/libc/src/Math.cpp or core/libs/tests/GuestMath.cpp, or docs/dev/debt/changes/refresh-expf-log1pf-msun-20261117.md. I also did not run build or tests, or independently verify the validation reports in the PR description. These changed files were included in the review manifest; the listed production and test files were included in the prepared review bundle. I did not inspect files.json.

To get this to a good state

Nothing is required.

@JJenkx

JJenkx commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main 6f6f6c8e6b into this branch to refresh it and its CI (new head 244f4b5b65, no force-push). The branch was 1286 commits behind. The merge was clean, and the PR's diff against main is unchanged: Math.cpp, MathExpf.cpp, the libc CMake entry, the two tests and the debt note.

The failing checks on the previous run were unrelated to this change:

  • The Windows relinker job failed only frame_capture_minimize_replay, the replay-lifecycle Python test.
  • The windows job failed without a test failure in its log.

At the new head on Windows 11 with MinGW-w64 GCC 15.2 UCRT r7, Release:

  • guest_expf_environment, guest_math, guest_math_elementary and guest_math_exact pass 3/3 runs.
  • tools/check_conventions.py --base origin/main passes.

AI-assisted: yes.

JJenkx added a commit to JJenkx/AnyPS5 that referenced this pull request Nov 29, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 244f4b5b65b972f7c16eb2a34a7ff2feff304bee from the prepared diff and pinned repository reader. No build or tests were run in this review.

Results

Check Result Note
Diff and source review passed Seven changed files read
Build and tests not run Relied on author-reported validation

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports Linux tests and differential checks at earlier named revisions; those results were not reproduced here. Windows, console, and full patched SDK behavior at this exact head were not verified. The full text of all seven changed files was available and read; no changed files were excluded by the manifest.

To get this to a good state

Nothing is required.

main's boykopovar#21714 set expf's ERANGE in the Math.cpp expf this branch replaces.
The branch's msun expf in MathExpf.cpp keeps the console's errno (overflow
and the underflows the console reports; guest_math pins those bits), so the
Math.cpp definition stays removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJenkx

JJenkx commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main (93d64f2d1e) as 9a339843cf, since the PR had become conflicting.

The one conflict was libc/src/Math.cpp: #21714 changed the std::exp-based expf_nid_postfix there to set ERANGE itself. This PR replaces that definition with the msun port in MathExpf.cpp, so the Math.cpp copy stays removed.

The port already gives the console's errno for expf, which CheckExpfConsoleBits in guest_math pins: ERANGE on overflow and on the underflows the console reports, untouched otherwise (for example 0xc2cff1b5 → 0 with no error).

I checked this rather than assume it. Wrapping the port with #21714's rule (ERANGE whenever a finite input gives an infinite or zero result) makes guest_math and guest_expf_environment fail. Without it, they pass.

Tested at 9a339843cf on Windows 11, MinGW-w64 GCC 15.2, Release: the 5 math-related CTests (including guest_math and guest_expf_environment) pass, and tools/check_conventions.py passes.

AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The changed expf implementation and its regression coverage support the stated rounding and exception behavior at 9a339843cfb400226067217d2c7058846705bde0.

What I ran

Inspected the prepared diff and changed source context at the pinned head; no executable checks were run.

Inspected description.md, commits.md, manifest.json, diff.patch, files.json, and the changed-file contents in files/.
Read targeted source ranges with repo_read.py at the pinned head.

The description reports Linux test results from earlier heads; those are author-reported and were not reproduced for this review.

Results

Check Result Note
Source review passed All seven changed files reviewed; none excluded
Tests in this review not run No build or test execution
Author-reported validation not run Reports describe earlier heads

Negative control

Not run; no tests were executed in this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

No tests were run at this head. Windows, macOS, console behavior, and title-specific behavior were not verified. The Linux, Windows, and differential results in the PR description are author-reported results for earlier revisions.

To get this to a good state

Nothing is required.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built the focused checks against the existing Linux runtime. GuestExpfEnvironment and GuestMath passed.

AI-assisted: yes.

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libc review queue Next in the maintainer review queue: checks pass, no open change request, no conflict

Projects

None yet

Development

Successfully merging this pull request may close these issues.