Skip to content

test(libc): read only the standard exception flags in the tiny asin and atan check - #1056

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/24311
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/24311

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#24311, originally opened by Jazeupoi.

Source commit: dc3734b0c5f55b8a0ebad2a9d5fa59d7e096d7db. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

guest_math fails on macOS since boykopovar#23972 added CheckTinyInverseTrigFlags:

core/libs/tests/GuestMath.cpp:4794: requirement failed

The check compares std::fetestexcept(FE_ALL_EXCEPT) with FE_INEXACT. On x86_64 macOS, FE_ALL_EXCEPT is 0x3f and includes FE_DENORMALOPERAND (0x02). An SSE operation on a subnormal input sets that flag, so for ±denorm_min the test reads 0x22 where it expects 0x20. With temporary logging, the four failing cases are asin and atan of 0x1p-1074 and -0x1p-1074: the result bits and errno are as expected, the flags are 0x22. glibc's FE_ALL_EXCEPT has no such flag, so Linux passes.

The file already defines StandardExceptions, the five C exception flags, for this. The check now uses it, as boykopovar#20503 did for two other tests. The library is unchanged, and the check still requires exactly FE_INEXACT for nonzero inputs and no flag for zeros.

Tested

Apple M4, macOS 27.0.1, Apple clang (Command Line Tools), x86_64 Release build under Rosetta 2. main 0a025bd3c6 with boykopovar#17425 and boykopovar#11049, which the macOS build needs.

Tree guest_math
main fails 3 of 3 at GuestMath.cpp:4794
this PR passes 3 of 3

Not run on Linux or Windows. The change only drops non-standard flags from the comparison, so a platform whose FE_ALL_EXCEPT is the five standard flags reads the same value as before.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

Summary by CodeRabbit

  • Tests
    • Updated inverse-trigonometric checks to verify standard floating-point exceptions while preserving result, error-code, and exception-mask assertions.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Inverse Trig Exception Flags

Layer / File(s) Summary
Standard exception mask
core/libs/tests/GuestMath.cpp
CheckTinyInverseTrigFlags compares expected flags against StandardExceptions.

Suggested reviewers: jjenkx, derkarussellbremser

Change: Other

Merge Risk: Minimal · up to dc373

This is a test-only fix that stops platform-specific denormal-operand flags on x86_64 macOS from failing the inverse-trig check. It has no production behavior impact and merge risk is minimal.

Security architecture risk: Minimal · up to dc373

GuestMath now checks only standard floating-point exception flags. It still checks the result bits and errno, and the library behavior is unchanged.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 1
  • Waived: $0.25 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

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: 3eb71fbe-e18f-4895-8ff6-df90511145cc
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and dc3734b.

Files selected for processing: 1

  • core/libs/tests/GuestMath.cpp

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants