Skip to content

fix(libc): compute hypotl with FreeBSD msun's ld80 code as the bundled libc.prx does - #11634

Merged
oneandonlydean merged 12 commits into
boykopovar:mainfrom
AlexFigas:fix/libc-hypotl-msun-ld80
Nov 17, 2026
Merged

oneandonlydean merged 12 commits into
boykopovar:mainfrom
AlexFigas:fix/libc-hypotl-msun-ld80

Conversation

@AlexFigas

@AlexFigas AlexFigas commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

hypotl returned the host's hypotl after an infinity check. On 20,000,000 random pairs with nearby exponents, glibc's result differs from the console's on 539,841 of them, and its NaN bits on 729,412. For example, hypotl(0x8e0412b10b328599:4021, 0xa5e56711d52bca5e:c00f) is 0x8e0412b11140db2f:4021 on the console and …2e on the host.

The evidence is the libc.prx bundled with PPSA21564, build J03093718, the library's own code. Its hypotl (0x48b90, no calls) is FreeBSD msun's e_hypotl.c for ld80. This PR ports it operation for operation:

  • Order. Swap so that a has the larger exponent field, then take |a| and |b|.
  • Far apart. Return a + b when the exponent fields differ by more than 71.
  • ∞ and NaN. At an all-ones exponent, compute w = |x + 0| - |y + 0|; this raises FE_INVALID for ∞ - ∞, as the binary does. Return a or b if either is an infinity, otherwise w.
  • Huge. Above exponent field 0x5ff3, rebias both by −0x2058.
  • Tiny.
    • Below 0x200b with a normal exponent, rebias both by +0x2058.
    • A zero b returns a.
    • A nonzero b with a zero exponent field gives the default NaN with FE_INVALID, as below.
  • Middle. Split a (or 2a) and b by clearing the low 32 bits of the mantissa (ClearLowMantissaWord), then take fsqrt of the same exact-product expression.
  • Scale back. Multiply by 2^k, built from its bits.

The subnormal case follows the binary. When the argument with the smaller exponent field (y on a tie) is nonzero with a zero exponent field and the other is below 2^-16311, the binary returns the default NaN 0xc000000000000000:ffff and raises FE_INVALID, and so does this port.

  • In place of msun's 2^16382 scale factor, the binary loads 0x7fff:4000000000000000 (at 0x159dc0), a pseudo-NaN.
  • Its tiny path (0x48d6e to 0x48e24) uses that constant for a, b and w: after checking b's mantissa it never reads the arguments again and has no w > b test. It runs the w <= b arithmetic on the pseudo-NaN, and each operation is invalid or propagates the default NaN.
  • The port builds the same pseudo-NaN at run time and returns t1 + t1, the first of those operations (fadd st(0), st(0) at 0x48d99). Multiplying the arguments by it instead would leave w * (-w) on two default NaNs of opposite sign, for which the x87 returns the positive one whatever the operand order, so the result would be 0xc000000000000000:7fff.
  • So hypotl(3 * 2^-16445, 4 * 2^-16445) is that NaN here too, at every precision, and hypotl(3 * 2^-16445, -0) is still 3 * 2^-16445.

The binary has no control-word instruction (msun's ENTERI changes the precision only on i386), so it runs at the caller's x87 precision, and so does this port, as cbrtl does in #11632. The precision a guest thread starts with is #11849.

The debt fragment docs/dev/debt/changes/fix-libc-hypotl-msun-ld80.md adds an entry for hypotl that records that other SDK builds and the system libSceLibcInternal are not compared, and describes the subnormal case. The host-computed list drops hypotl. Its C11 F.10.4.3 note (∞ wins over NaN) moves to that entry; the port keeps that behaviour.

Licence. e_hypotl.c's notice is copied at the top of Math.cpp, after #11632's, behind a Derived from FreeBSD lib/msun/src/e_hypotl.c (release/11.4.0) line, the form #12541 uses. The source has a trailing space after "this notice"; it is dropped here, as asked on #12541, so git diff --check passes.

Tested

Head 6e37e8f is two commits on a4630de (oneandonlydean's merge of main 023c6ea). a4630de had left two copies of the host-computed list line in docs/dev/debt/libc.md, and the debt files are no longer edited directly (Fragments). 0fc7b59 merges main dcf3d15 without a conflict and sets libc.md to main's; 6e37e8f adds docs/dev/debt/changes/fix-libc-hypotl-msun-ld80.md, which changes that line and adds the hypotl entry. With the fragment applied, tools/debt_fold.py --show libc gives main's line without hypotl and its C11 F.10.4.3 note, and the hypotl entry under Functional. (debt_fold.py --check stops on docs-nkwebkit-drop-readded-count-lines.md, which fails on main itself, so I ran it on a copy without that file.) The PR's diff of Math.cpp and GuestMath.cpp against main is line for line the same as at 360e13e.

  • Windows, this head. Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r7), Release, BUILD_TESTING=ON, Ninja:
    • guest_math, guest_math_elementary and guest_math_exact pass 3 runs each.
    • With Math.cpp reverted to main's and the tests kept, guest_math aborts in 3 of 3 runs at Guest hypotl failed for 8000000000000000:0001, 8000000000000000:0001 with control word 037f; restored, it passes 3 of 3 again.
    • tools/select_tests.py selects 5828 of 5967 tests for the three changed files, on this head and on main dcf3d15. The 129 tests that fail, are skipped or do not run on this head do the same on main; main also fails agc_driver_cached_image_multisample_guard. Not covered: Windows Defender quarantined 34 freshly linked AGC executables on both sides (33 tests and agc_shader_replay.exe, flagged as Trojan:Win64/ShellCode.MKA!MTB), so their tests did not run or failed, and agc_driver_upload_cache_read_only_flush_tests does not build on Windows (setenv, fix(tests): set the upload cache test's environment with _putenv_s on Windows #19899).

The runs below are on Ubuntu 24.04 under WSL2 (GCC 13.3, Release). Head f51e83d merges main 813f46c (which has #11632) into the previous head c9e16f1, without a conflict. c9e16f1 merged #11632's head b2a99b1, which brings in main a4eca2a, into 307aaca, with one conflict in docs/dev/debt/libc.md: main has #11849's shorter asinl entry directly below the hypotl entry, so the resolution kept main's asinl and this PR's hypotl. 307aaca merged #11632's head 5ab9b29, which brings in main e0caf13, into cfee0b7 (71ce66e and 68b7307 before it). Every run below is on f51e83d except the negative control, made on the earlier head f6e7494, and the hosted run.

Checklist

@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.

This PR depends on #11632, but the new hypotl implementation has the same unresolved x87 precision-control requirement as cbrtl: the debt entry says it needs 64-bit precision, while Windows guest threads started through _beginthreadex use 53-bit precision. The implementation neither sets nor restores the x87 control word, and the reported 100-million-pair comparison was run under WSL2, so it does not establish correctness in the guest thread's Windows floating-point environment. A known-answer test under the host's default environment also does not cover this.

Please coordinate this with #11632 and make the result match the target independently of the caller's precision mode (preserving the caller's floating-point environment), or provide evidence that guest calls execute with 64-bit precision. Add tests that run the relevant cases at both 53-bit and 64-bit precision, including the reported one-bit-difference input. I cannot approve this stacked change while its documented runtime precision requirement is unmet.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

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 6295 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
PR 7544 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
PR 17026 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 As in my reply on #11632: the binary's hypotl (0x48b90) has no control-word instruction either, so it runs at the caller's precision, and so does this port (2850689, rebased on #11632's a180cc0).

  • Against the binary, 80,000,000 pairs at each of 64, 53 and 24 bits (20,000,000 under each rounding mode) give the same result, errno and flags outside the documented subnormal case, and the control word is unchanged after every call.
  • CheckHypotlConsoleBits runs all 18 pairs at 0x037f and at 0x027f with the binary's result for each precision. That includes hypotl(0x8e0412b10b328599:4021, 0xa5e56711d52bca5e:c00f): 0x8e0412b11140db2f:4021 at 64 bits and 0x8e0412b11140e000:4021 at 53. Each check also requires the binary's x87 flags, no SSE flag, the same control word afterwards, and errno unchanged. The subnormal case is checked at both control words too.
  • The debt entry no longer states a 64-bit requirement. It says the function runs at the caller's precision, as the binary does.

The precision guest threads start with is #11849.

@oneandonlydean oneandonlydean self-assigned this Oct 27, 2026
@AlexFigas
AlexFigas requested a review from MarcZX10 October 27, 2026 10:37

@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 the exact head 2850689. The implementation handles the exponent-difference shortcut, infinities/NaNs, large values, subnormals, and compensated square accumulation in the same order described from the bundled module. Its tests cover the stacked cbrtl behavior as well as hypotl edge cases. I found no specific arithmetic defect in this pass.

Independent local check: I built and ran the exact guest_math_tests target natively on Linux; it exited 0. The hosted Windows check and Ubuntu/Windows relinker plus ASan checks pass. The two macOS relinker builds, macOS register-context jobs, and Intel write-watch job remain queued; the full Linux product job is skipped by path policy. Since this PR depends on #11632, I am leaving a comment review until the remaining platform checks finish and the dependency is integrated.

@maskym

maskym commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Windows result for head bf6406e74d, merged into main 75f3702aed (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. long double is the 80-bit x87 type on this toolchain, as on the console.

The tree also carried the open libc PRs #11270, #11283, #11632, all merged cleanly, so the run is a joint one; the test of this PR is guest_math. ctest --test-dir build -R "^(guest_math|guest_math_exact|guest_dinkumware_internals)$": 3/3 passed, guest_math in 0.05 s. An earlier head of this PR passed the same test on main 1089f2bbfd together with #11260, #11262, #11266, #11278 and #10929. Build clean. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@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 the current head bf6406e. The hypotl path covers the exponent-gap shortcut, special values, large and tiny scaling, and compensated square accumulation. I did not find a new arithmetic defect in this pass. The documented bundled-binary subnormal discrepancy is explicit and has a focused test for the chosen msun behavior.

Local check: I applied the Math.cpp, GuestMath.cpp, and libc debt changes from #11632 and #11634 to a clean #11213-based checkout, built guest_math_tests in Release, and ran guest_math three times; all three passed. The combined tree includes #11213's unrelated exception changes, so this verifies the focused math sources and tests, not a literal build of this exact commit.

The hosted Windows, Ubuntu/macOS relinker, Ubuntu register-context, Windows, and ASan checks pass. The macOS x86_64 relinker, Intel Debug register-context, and Intel write-watch checks are still queued, and the Linux product job is skipped by path policy. This PR declares its dependency on #11632. I am leaving a comment review until that dependency is resolved and the queued platform checks finish.

@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 the current head bf6406e. The ld80 hypotl path and the noncanonical/precision tests are otherwise well supported. The focused local guest_math run passed three times, and the hosted checks are now green.

I found one compatibility blocker in the explicitly documented subnormal case. For hypotl(3 * 2^-16445, 4 * 2^-16445), the bundled PPSA21564 libc.prx returns the default NaN and raises FE_INVALID, while this implementation returns msun's finite 5 * 2^-16445; the new test asserts the latter. The PR attributes the binary result to a probable compiler miscompile, but the other SDK builds and system libSceLibcInternal have not been compared. Since this change is presented as reproducing the console libc behavior, the single observed target binary is currently the only direct runtime evidence for this case.

Please either reproduce that measured behavior for the supported target, or provide evidence from the system library/another supported SDK showing that the msun result is the behavior AnyPS5 should emulate, and update the claim and regression coverage accordingly. I cannot approve a known behavior difference based only on an unverified miscompile explanation. The #11632 dependency and its separate debt-file ordering issue also remain unresolved.

@JJenkx

JJenkx commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

A runtime differential of this head against the libc.prx that titles ship.

Setup:

  • A scratch loader runs the decrypted libc.prx of PPSA07923 and PPSA05916 natively on Windows 11 and calls their hypotl by NID. Neither copy is an FMA build.
  • It compares them with hypotl from the libc.prx DLL built from this PR's exact head bf6406e74d (WinLibs GCC 15.2.0 UCRT r7, Release). guest_math passes on that build.
  • There are 100,000 argument pairs per title, x in ±10^6 and y in ±10^3. Each call compares the full 80-bit result.

Results:

  • Current main differs from the titles on 10,568 of them.
  • This PR differs on none, on both titles.

Only finite arguments in those ranges were covered: no NaNs, infinities, subnormals or extreme exponents.

AI-assisted: yes (Claude Code).

@AlexFigas
AlexFigas force-pushed the fix/libc-hypotl-msun-ld80 branch from bf6406e to f6e7494 Compare October 27, 2026 17:31
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Reproduced: at f6e7494, hypotl(3 * 2^-16445, 4 * 2^-16445) returns the default NaN 0xc000000000000000:ffff and raises FE_INVALID, as J03093718 does.

  • The binary's tiny path (0x48d6e to 0x48e24) loads the pseudo-NaN 0x7fff:4000000000000000. After checking b's mantissa, it uses that constant for a, b and w and never reads the arguments again, and every later operation is invalid or propagates the default NaN.
  • The port builds the same pseudo-NaN at run time and returns t1 + t1, the first of those operations (0x48d99). Multiplying the arguments by it, as the source reads, gives the positive NaN instead.
  • CheckHypotlConsoleBits now asserts the binary's NaN and FE_INVALID at 0x037f and 0x027f for six subnormal-path pairs, your case included, and the unchanged result for a subnormal with −0. With msun's 2^16382 put back, it fails.
  • Against the binary, 240,000,000 calls match in result, NaN bits, errno and flags, with the control word unchanged. They cover 64, 53 and 24 bits under each rounding mode, random and nearby pairs, and the subnormal path is no longer excluded.
  • The debt entry now leads with what is not compared: other SDK versions and the system libSceLibcInternal.

#11849 now declares Depends on: #10253, #11632, #11634 and rebases after them.

@AlexFigas
AlexFigas requested a review from MarcZX10 October 27, 2026 18:07

@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 rechecked the updated head f6e7494db8ebb9b7e1d71f8d03aedc8c578b1328 and its delta from the previously reviewed head. The tiny-subnormal case now follows the observed PPSA21564 libc.prx result (0xc000000000000000:ffff, FE_INVALID), with regression vectors for the measured subnormal paths; the prior known-result discrepancy is addressed in code and debt text. git diff --check passes and the PR merges cleanly into the current main preview. The PR reports extensive current-head binary comparison and guest_math evidence, which I have not independently rerun on this updated head. Six macOS checks remain queued, and the declared dependency #11632 is still open, so I am leaving this as a comment review rather than approval.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 #11632 has merged, so this PR is now only the hypotl commit. Head f51e83d merges current main 813f46c into the approved branch, without a conflict (main had changed Math.cpp, GuestMath.cpp and the debt file since the base). On this head guest_math, guest_math_elementary and guest_math_exact pass 3 runs each, and all 24 console-differential sweeps of hypotl (10,000,000 pairs each, random and nearby exponents, 64, 53 and 24 bits under each rounding mode) show no difference in result, NaN bits, errno, flags or control word. git diff --check and check_conventions.py pass with 0 errors (the one length warning is the host-computed entry, 1439 characters on main, 1324 here). Depends on is now none. oberonlift's #15802 stack (opened later) rewrites hypotl too and conflicts with this head; noted in the description.

@maskym

maskym commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Retested head f51e83dd53 on Windows (the head moved since my earlier run), merged alone into main f439f7f3a0.

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

guest_math, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 11, 2026
# Conflicts:
#	docs/dev/debt/libc.md
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Head 360e13e merges current main a221a74 into the approved branch. The one conflict was the host-computed list line in docs/dev/debt/libc.md, where main moved j0f, j1f, y0f and y1f out and changed tgammaf; the resolution keeps main's line without hypotl and its C11 F.10.4.3 note. The PR's diff of Math.cpp and GuestMath.cpp against main is line for line the same as at f51e83d. On this head, on Windows 11 with WinLibs GCC 15.2.0 r7 (Release, BUILD_TESTING=ON), guest_math, guest_math_elementary and guest_math_exact pass 3 runs each; check_conventions.py has 0 errors and git diff --check is clean. pr_overlap.py now reports only #18694 and #18792 (opened after this PR) on the same debt line; noted in the description.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 13, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 14, 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

The hypotl port, regression cases, and technical debt entry were reviewed at the pinned head; no blocking defect was identified in the inspected changes.

What I ran

No commands or tests were run. The author reports Windows guest_math, guest_math_elementary, and guest_math_exact runs on this head; these were not independently run here.

Results

Check Result Note
Source and diff review passed Three changed files read
Tests in this review not run Author-reported results only

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full test suite and all author-reported runs were not independently verified. The changed files listed as reviewed in the manifest were all read: core/libs/prx/libc/src/Math.cpp, core/libs/tests/GuestMath.cpp, and docs/dev/debt/libc.md. No files were listed as excluded in the supplied manifest; files.json was unavailable through the reader, so exclusions beyond that manifest are not verified.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@maskym

maskym commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Retested head a4630de6b0 on Windows (the head moved since my earlier run), merged alone into main 3e1b183e43.

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. main itself fails to compile one test on Windows at this commit (UploadCacheReadOnlyFlush.cpp:177, setenv; #19899 fixes it), so the tree was built with ninja -k 0. This PR adds no other build failure.

guest_math, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@c1b3r-p3d1a

c1b3r-p3d1a commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Linux check of head a4630de6b0, merged onto main ff36fea157.

This PR changes 1 source file, 1 test file, 1 doc or tool file. Code it modifies: hypotl_nid_postfix. Tests it changes: GuestMath.cpp.

Result: needs attention

  • the tests that cover the changed code still pass when the change is reverted, so they do not detect it
Linux
Setup Ubuntu 24.04.4 LTS (WSL2), GCC 13
Build clean
Passed 3879 of 4112
Failed 88
Not run (executable missing or test disabled) 146
Failures caused by this PR 0
Counter-check 0 of 3 tests fail without the change
Conventions pass
Time 15 min
Tests that ran Linux
agc_driver_* 958 of 1154
guest_json_* 204 of 204
guest_libressl_* 87 of 87
guest_kernel_* 87 of 87
guest_freetype_* 83 of 85
guest_webrtc_* 70 of 70
guest_libressl3_* 68 of 68
guest_np_* 67 of 67
769 other group(s) 2254 of 2290
88 failed test(s) that also fail on main (not caused by this PR)

agc_collect_coverage_invalidation, agc_driver_bc_block_copy, agc_driver_coherent_atomic_loads_enabled, agc_driver_depth_compare_copy, agc_driver_frame_replay, agc_driver_frame_replay_allocation_ranges, agc_driver_frame_replay_busy_queue, agc_driver_frame_replay_cold_pipelines, agc_driver_frame_replay_concurrent, agc_driver_frame_replay_fence_reuse, agc_driver_frame_replay_late_clear, agc_driver_frame_replay_once, agc_driver_frame_replay_partly_covered, agc_driver_frame_replay_pending_result, agc_driver_frame_replay_rewind, agc_driver_frame_replay_rewind_compute, agc_driver_frame_replay_rewind_copy, agc_driver_frame_replay_rewind_fill, agc_driver_frame_replay_rewind_release, agc_driver_frame_replay_rewind_split, agc_driver_frame_replay_rewind_store, agc_driver_frame_replay_shader, agc_driver_frame_replay_shader_host, agc_driver_frame_replay_shader_prologue_code, agc_driver_frame_replay_shader_prologue_header, agc_driver_frame_replay_shader_prologue_readonly, agc_driver_frame_replay_store_between_walks, agc_driver_frame_replay_wait_label, agc_driver_global_atomic_csub, agc_driver_image_srgb_sample_copy, agc_driver_image_srgb_sample_copy_forced, agc_driver_image_table_vouch_queued_draws, agc_driver_lookup_log_fits_build, agc_driver_msaa_dcc_clear_2, agc_driver_msaa_dcc_clear_4, agc_driver_msaa_dcc_clear_8, agc_driver_msaa_dcc_compared_import_2, agc_driver_msaa_dcc_compared_import_4, agc_driver_msaa_dcc_compared_import_8, agc_driver_msaa_dcc_srgb_clear_2, agc_driver_msaa_dcc_srgb_clear_4, agc_driver_msaa_dcc_srgb_clear_8, agc_driver_native_color_initial_uniform_refusals, agc_driver_native_depth_aliased_depth_depth_only, agc_driver_native_depth_aliased_depth_no_stencil, agc_driver_native_depth_aliased_depth_stencil, agc_driver_native_depth_aliased_stencil, agc_driver_native_depth_bda_clear, agc_driver_native_depth_buffer_clear, agc_driver_native_depth_clear_refusals, agc_driver_native_depth_clears, agc_driver_native_depth_covered_owner, agc_driver_native_depth_driver_path, agc_driver_native_depth_driver_queued_fill, agc_driver_native_depth_expand_gate, agc_driver_native_depth_htile_plane_alias, agc_driver_native_depth_initial_owner, agc_driver_native_depth_overwritten_planes, agc_driver_native_depth_pending_units, agc_driver_native_depth_publication, agc_driver_native_depth_publication_without_htile, agc_driver_native_depth_retirement, agc_driver_native_depth_separate_stencil, agc_driver_native_depth_single_sample_view, agc_driver_native_depth_smaller_extent, agc_driver_native_depth_stencil, agc_driver_native_depth_stencil_view, agc_driver_native_depth_stored_repeat_fill, agc_driver_native_depth_uniform_plane_alias, agc_driver_native_depth_uniform_planes, agc_driver_native_multisample_depth, agc_driver_recorder, agc_driver_resource_cache_collect_refusals, agc_driver_resource_cache_collect_refusals_index, agc_driver_resource_cache_lookup_changed, agc_driver_resource_cache_pending_fail_count, agc_driver_resource_cache_pending_fail_count_index, agc_driver_resource_cache_replaced_texture, agc_driver_sample_multisample_target, agc_driver_sampled_cache_budget, agc_driver_sampled_cache_budget_without_storage_image_multisample, agc_driver_sampled_clear_keys, agc_driver_staged_clear_sampled_read, agc_driver_staged_clear_sampled_read_draw_pipeline, agc_driver_staged_clear_sampled_read_plan_verify, agc_storage_idle_writeback_race, agc_storage_kept_unit_settle, guest_freetype_ot_patched

146 test(s) not run

agc_collect_mapping_history_map, agc_collect_mapping_history_ring, agc_collect_mapping_history_shared, agc_collect_mapping_history_uncached, agc_driver_alpha_to_coverage_sample_mask_export, agc_driver_bda_reads_shadowed_results, agc_driver_bda_reads_shadowed_results_per_build, agc_driver_bitfield_mask, agc_driver_cached_image_multisample_guard, agc_driver_conservative_rasterization, agc_driver_dcc_keys_partial_rewrite_keeps_store, agc_driver_dcc_keys_rewrite_after_epoch_proof, agc_driver_dcc_keys_rewrite_after_memo, agc_driver_dcc_keys_rewrite_after_refresh_proof, agc_driver_dcc_keys_rewrite_to_register_clear, agc_driver_dcc_keys_write_beside_keys_keeps_store, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_guest_layers, agc_driver_dithered_alpha_to_coverage, agc_driver_dpp16_inactive_source, agc_driver_dpp16_operands, agc_driver_dpp16_row_share_xmask, agc_driver_dpp8, agc_driver_ds_append_consume, agc_driver_ds_permute, agc_driver_ds_swizzle, agc_driver_float16_native, agc_driver_float16_unused_nan_payloads, agc_driver_gcn_compare_exec_writes, agc_driver_gds_append_consume, agc_driver_global_store_addtid, agc_driver_idle_store_over_unmap, agc_driver_image_sample_lod_clamp, agc_driver_image_table_vouched_lookups, agc_driver_large_tracked_snapshot, agc_driver_layered_volume_mesh, agc_driver_lds_addtid, agc_driver_lds_mask_waterfall, agc_driver_lds_subword_store_branch, agc_driver_lds_tree_reduction, agc_driver_linear_target_direct_write_completion, agc_driver_linear_target_import_creation, agc_driver_look_back_scan, agc_driver_mesh, agc_driver_mesh_barycentric_emulation, agc_driver_mesh_draw_relocation, agc_driver_mesh_index_cache, agc_driver_mesh_provoking_layer, agc_driver_mesh_provoking_vertex, agc_driver_multisample_centered_lines, agc_driver_native_fmask_2, agc_driver_native_fmask_8, agc_driver_ngg_vertex_wave_info, agc_driver_ngg_vertex_wave_reduction, agc_driver_optimize_on_fiber, agc_driver_packed_float16_native, agc_driver_partially_committed_array, agc_driver_partially_committed_array_samples, agc_driver_partially_committed_volume, agc_driver_partially_committed_volume_bc, agc_driver_partially_committed_volume_bc_samples, agc_driver_partially_committed_volume_compare, agc_driver_partially_committed_volume_empty, agc_driver_partially_committed_volume_empty_samples, agc_driver_partially_committed_volume_linear, agc_driver_partially_committed_volume_linear_samples, agc_driver_partially_committed_volume_mips, agc_driver_partially_committed_volume_mips_samples, agc_driver_partially_committed_volume_page_samples, agc_driver_partially_committed_volume_samples, agc_driver_partially_committed_volume_thick, agc_driver_partially_committed_volume_thick_samples, agc_driver_partially_committed_volume_whole, agc_driver_partially_committed_volume_whole_samples, agc_driver_partially_resident_pending_stores, agc_driver_partially_resident_snapshot, agc_driver_permlane16, agc_driver_pipeline_optimized_readback_color32, agc_driver_pipeline_optimized_readback_color32_fast, agc_driver_pipeline_optimized_readback_color64, agc_driver_pipeline_optimized_readback_color64_fast, agc_driver_pipeline_statistics_report, agc_driver_pixel_helper_lanes, agc_driver_pixel_lds, agc_driver_pixel_lds_lane_slots, agc_driver_pixel_lds_limit, agc_driver_pixel_quad_perm_helpers, agc_driver_pixel_valid_mask, agc_driver_read_first_lane, agc_driver_read_lane, agc_driver_recorded_draw_staging, agc_driver_relative_dpp, agc_driver_relative_indexing_known_bits, agc_driver_repeated_fill_elision, agc_driver_resident_heap_mirror, agc_driver_sample_order_grid_reference, agc_driver_sample_order_recipe_depth_locations, agc_driver_scalar_bit_count, agc_driver_scattered_runs, agc_driver_spanned_ballot_sequence, agc_driver_sparse_dma_buf_import, agc_driver_subvector_loop, agc_driver_table_index_validation, agc_driver_tessellation_geometry, agc_driver_texture_sparse_levels, agc_driver_two_sample_alpha_to_coverage_sample_mask_export, agc_driver_two_sample_dithered_alpha_to_coverage, agc_driver_unit_shadow, agc_driver_unit_shadow_budget, agc_driver_vertex_clip_cull_distances, agc_driver_wave32_subgroup, agc_driver_wave_shared_vgprs, agc_driver_wave_uniform, agc_driver_write_lane, agc_host_import_sparse, agc_idle_publish_dmabuf_wait, agc_idle_publish_wait, agc_import_settle_initial_dcc, agc_map_gate_disjoint, agc_map_gate_fast_path, agc_map_gate_pending, agc_map_gate_publication, agc_map_gate_retry, agc_map_gate_stress, agc_pipeline_cache_file, agc_repeated_neighbour_stores, agc_shadowed_key_stores, agc_shared_write_partial_collect, agc_small_tiled_shadow_label, agc_snapshot_read_into_staging, agc_storage_clear_hand_over, agc_storage_pending_after_unwatch, agc_storage_pending_key_refresh, agc_storage_rewritten_blocks, agc_storage_rewritten_stale_units, agc_storage_written_buffer_order, agc_unit_shadow, agc_unit_shadow_completion_store, agc_unwatch_hook_lock_order, agc_write_tracking, agc_write_tracking_generation_wrap, agc_write_tracking_mark_order, guest_freetype_geometry_watched, guest_net_raw_protocol

Only tests that depend on the files this PR changes were run. A test counts against the PR only if it passes on main. Numbers come from ctest; the text is generated by a script.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 15, 2026
The debt files are no longer edited directly. The fragment drops hypotl from the host-library entry and adds its own entry under Functional, as the earlier direct edit did. The merge of main by a4630de had left two copies of the host-library entry; libc.md is now main's.

@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 inspected implementation follows the described hypotl paths, but I did not run checks on this exact head, so a formal approval is not justified.

What I ran

Head: 6e37e8fcd42dd4ca5812439639da6ac117a84249. I used repo_read.py to inspect the prepared description, commits, manifest, diff, and targeted source ranges. No build or tests were run by me.

Results

Check Result Note
Source review passed Three changed files inspected
Build and tests not run Author reports checks on earlier or other heads
Negative control not run No local execution available

Negative control

Not run by me. The description reports a negative control on an earlier head; I did not verify it.

Findings

Blocking

None identified in the inspected changes.

Non-blocking

No code change requested. The implementation and focused tests appear consistent with the stated goal in the ranges reviewed.

Sources

Not verified

I did not run the build, test suite, or negative control. The reported test results are author-provided; most are for earlier heads, and the description does not establish that they ran on this exact head. I reviewed the changed implementation and helper ranges, the new test function and call site, and the debt entry; I did not read every line of the two large C++ files. No changed files were excluded from the prepared diff.

To get this to a good state

Nothing is required. Optional: run the focused tests on this exact head before merging.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@c1b3r-p3d1a About your Linux check:

  • the tests that cover the changed code still pass when the change is reverted, so they do not detect it

On Windows the test does catch the change: guest_math fails when Math.cpp is reverted. I have not repeated your Linux tree check.

  • Windows. On the new head 6e37e8f (Windows 11, WinLibs GCC 15.2.0 r7, Release), with Math.cpp reverted to main dcf3d15's and the tests kept, guest_math aborts in 3 of 3 runs: Guest hypotl failed for 8000000000000000:0001, 8000000000000000:0001 with control word 037f. With the change restored it passes 3 of 3.
  • Linux. I did not build the tree there. On Ubuntu 24.04 under WSL2 (GCC 13.3.0, glibc 2.39), I compiled main's hypotl (the infinity check, then std::hypot) on its own and ran it on the 24 pairs of CheckHypotlConsoleBits at control words 0x037f and 0x027f. 18 of the 48 results differ from the expected bits or x87 flags. The first is the ninth pair, hypotl(0xcce56ce05f6cdac4:bfdd, 0xdc86e8ada6c48b60:bff3) at 0x037f: 0xdc86e8ada6ca7e5d:3ff3, expected …7e5c. So with the change reverted, guest_math should abort on Linux too.

Which three tests did the counter-check run, and was guest_math_tests rebuilt after the revert?

@MarcZX10 About your review of 6e37e8fcd4:

Optional: run the focused tests on this exact head before merging.

The Windows runs above are on 6e37e8f, where guest_math, guest_math_elementary and guest_math_exact also pass 3 runs each; the reverted Math.cpp is the negative control on this head. The description's Tested section has them, with the tools/select_tests.py comparison against main dcf3d15.

@oneandonlydean a4630de (your merge of main) had left two copies of the host-computed list line in docs/dev/debt/libc.md. The debt files are no longer edited directly (Fragments), so 0fc7b59 merges main dcf3d15 with libc.md set to main's, and 6e37e8f puts the same changes in docs/dev/debt/changes/fix-libc-hypotl-msun-ld80.md. The diff of Math.cpp and GuestMath.cpp against main is the same as at the approved 360e13e.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 16, 2026
@oneandonlydean
oneandonlydean merged commit 9848b2e into boykopovar:main Nov 17, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants