Repository navigation
fix(libc): compute hypotl with FreeBSD msun's ld80 code as the bundled libc.prx does - #11634
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
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.
|
bc4b229 to
2850689
Compare
|
@MarcZX10 As in my reply on #11632: the binary's
The precision guest threads start with is #11849. |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
2850689 to
bf6406e
Compare
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, 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 AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
MarcZX10
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
A runtime differential of this head against the Setup:
Results:
Only finite arguments in those ranges were covered: no NaNs, infinities, subnormals or extreme exponents. AI-assisted: yes (Claude Code). |
bf6406e to
f6e7494
Compare
|
@MarcZX10 Reproduced: at f6e7494,
#11849 now declares |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
@MarcZX10 #11632 has merged, so this PR is now only the |
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release,
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
# Conflicts: # docs/dev/debt/libc.md
|
@MarcZX10 Head 360e13e merges current |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release,
AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
Linux check of head
|
| 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.
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
left a comment
There was a problem hiding this comment.
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
Math.cppat reviewed headGuestMath.cppat reviewed headfix-libc-hypotl-msun-ld80.mdat reviewed head
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.
|
@c1b3r-p3d1a About your Linux check:
On Windows the test does catch the change:
Which three tests did the counter-check run, and was @MarcZX10 About your review of 6e37e8fcd4:
The Windows runs above are on 6e37e8f, where @oneandonlydean a4630de (your merge of |
What
hypotlreturned the host'shypotlafter 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)is0x8e0412b11140db2f:4021on the console and…2eon the host.The evidence is the
libc.prxbundled with PPSA21564, buildJ03093718, the library's own code. Itshypotl(0x48b90, no calls) is FreeBSD msun'se_hypotl.cfor ld80. This PR ports it operation for operation:ahas the larger exponent field, then take|a|and|b|.a + bwhen the exponent fields differ by more than 71.w = |x + 0| - |y + 0|; this raisesFE_INVALIDfor ∞ - ∞, as the binary does. Returnaorbif either is an infinity, otherwisew.0x5ff3, rebias both by −0x2058.0x200bwith a normal exponent, rebias both by +0x2058.breturnsa.bwith a zero exponent field gives the default NaN withFE_INVALID, as below.a(or2a) andbby clearing the low 32 bits of the mantissa (ClearLowMantissaWord), then takefsqrtof the same exact-product expression.2^k, built from its bits.The subnormal case follows the binary. When the argument with the smaller exponent field (
yon a tie) is nonzero with a zero exponent field and the other is below 2^-16311, the binary returns the default NaN0xc000000000000000:ffffand raisesFE_INVALID, and so does this port.0x7fff:4000000000000000(at 0x159dc0), a pseudo-NaN.a,bandw: after checkingb's mantissa it never reads the arguments again and has now > btest. It runs thew <= barithmetic on the pseudo-NaN, and each operation is invalid or propagates the default NaN.t1 + t1, the first of those operations (fadd st(0), st(0)at 0x48d99). Multiplying the arguments by it instead would leavew * (-w)on two default NaNs of opposite sign, for which the x87 returns the positive one whatever the operand order, so the result would be0xc000000000000000:7fff.hypotl(3 * 2^-16445, 4 * 2^-16445)is that NaN here too, at every precision, andhypotl(3 * 2^-16445, -0)is still3 * 2^-16445.The binary has no control-word instruction (msun's
ENTERIchanges the precision only on i386), so it runs at the caller's x87 precision, and so does this port, ascbrtldoes in #11632. The precision a guest thread starts with is #11849.The debt fragment
docs/dev/debt/changes/fix-libc-hypotl-msun-ld80.mdadds an entry forhypotlthat records that other SDK builds and the systemlibSceLibcInternalare not compared, and describes the subnormal case. The host-computed list dropshypotl. 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 ofMath.cpp, after #11632's, behind aDerived 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, sogit diff --checkpasses.Tested
Head 6e37e8f is two commits on a4630de (oneandonlydean's merge of
main023c6ea). a4630de had left two copies of the host-computed list line indocs/dev/debt/libc.md, and the debt files are no longer edited directly (Fragments). 0fc7b59 mergesmaindcf3d15 without a conflict and setslibc.mdtomain's; 6e37e8f addsdocs/dev/debt/changes/fix-libc-hypotl-msun-ld80.md, which changes that line and adds thehypotlentry. With the fragment applied,tools/debt_fold.py --show libcgivesmain's line withouthypotland its C11 F.10.4.3 note, and thehypotlentry under Functional. (debt_fold.py --checkstops ondocs-nkwebkit-drop-readded-count-lines.md, which fails onmainitself, so I ran it on a copy without that file.) The PR's diff ofMath.cppandGuestMath.cppagainstmainis line for line the same as at 360e13e.BUILD_TESTING=ON, Ninja:guest_math,guest_math_elementaryandguest_math_exactpass 3 runs each.Math.cppreverted tomain's and the tests kept,guest_mathaborts in 3 of 3 runs atGuest hypotl failed for 8000000000000000:0001, 8000000000000000:0001 with control word 037f; restored, it passes 3 of 3 again.tools/select_tests.pyselects 5828 of 5967 tests for the three changed files, on this head and onmaindcf3d15. The 129 tests that fail, are skipped or do not run on this head do the same onmain;mainalso failsagc_driver_cached_image_multisample_guard. Not covered: Windows Defender quarantined 34 freshly linked AGC executables on both sides (33 tests andagc_shader_replay.exe, flagged asTrojan:Win64/ShellCode.MKA!MTB), so their tests did not run or failed, andagc_driver_upload_cache_read_only_flush_testsdoes 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
main813f46c (which has #11632) into the previous head c9e16f1, without a conflict. c9e16f1 merged #11632's head b2a99b1, which brings inmaina4eca2a, into 307aaca, with one conflict indocs/dev/debt/libc.md:mainhas #11849's shorterasinlentry directly below thehypotlentry, so the resolution keptmain'sasinland this PR'shypotl. 307aaca merged #11632's head 5ab9b29, which brings inmaine0caf13, 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.Native comparison. I used the harness from fix(libc): compute acosl with FreeBSD msun's ld80 code as the bundled libc.prx does #11260, with that
libc.prx's segments mapped into a Linux process, and ran the binary'shypotlnext to this head's at 64, 53 and 24 bits under each rounding mode: 10,000,000 random pairs over every exponent (subnormals, ±∞, NaNs and non-canonical encodings included) and 10,000,000 pairs with exponent fields at most 80 apart, 240,000,000 calls in all. The results, NaN bits included,errnoand the exception flags match on every pair, and the control word is unchanged after every call.Negative control. With msun's 2^16382 factor put back,
guest_mathfails onhypotl(3 * 2^-16445, 4 * 2^-16445)and the same sweep reports result and flag differences on the subnormal path, for exampleFE_INVALIDon the console andFE_INEXACT | FE_UNDERFLOWthere.guest_mathandguest_math_exactpass 3 runs each.guest_mathgainsCheckHypotlConsoleBits, 24 known-answer pairs from that binary, each run at control word0x037fand at0x027f(53 bits) with the binary's result for that precision:hypotl(max, max)overflowing to ∞;0x8e0412b11140e000:4021at 53 bits;FE_INVALIDfor two subnormals, two larger subnormals of opposite sign, an unnormal with a subnormal, +0 with a subnormal, and a gap of 71 in the exponent field; the subnormal itself for a subnormal with −0.Each check requires the binary's result and x87 exception flags, no SSE flag, the same control word afterwards, and
errnounchanged. The existinghypotl(3, -4)andhypotl(NaN, -∞)checks still pass.Hosted run. On GitHub's
ubuntu-latestrunner (x86_64, GCC 13.3.0, Release), the earlier head 7e9165c plus only a fork-only workflow commit (04a0367) passesguest_math3 runs (run).Whole suite. Not rerun on this head, which changes only the subnormal branch and its checks; all 2536 tests passed on the earlier head 2850689.
Conventions.
python3 tools/check_conventions.py --base upstream/mainpasses with 0 errors on 6e37e8f, with this title and description. Its one warning is the length of the host-computed list entry the fragment changes, 1419 characters.Overlap. On 6e37e8f,
python3 tools/pr_overlap.py --branch fix/libc-hypotl-msun-ld80reports no pull request that shares lines or exports. It could not compare feat(libc): implement the nextafter and nexttoward families #6295, fix(libc): match lgamma's signgam for -0 and its errno at poles as measured on a PS5 #7544 and fix(libc): lgamma stores 1 in signgam for -0 #17026, which conflict withmainand shareMath.cppandGuestMath.cpp; none of their diffs mentionshypotl.cbrtlentry,JoinExtendedand theasinlentry aremain's.log1pl,acoshl,asinhl,atanhlandjnf,ynf.debt_fold.pyrefuses two fragments that change one entry, so whichever lands second has to rework its fragment against the line the first one leaves. This PR was opened and approved first, so I have not added a dependency.Stacking. fix(libc): compute cbrtl with FreeBSD msun's ld80 code as the bundled libc.prx does #11632 has merged, so this PR is now only the
hypotlcommit; it addedJoinExtendedand the test helperCallAtControlWord, which are onmain.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)