Files
src/lib
Steve Kargl 3085fc9d97 [libm] implementation of rsqrt, rsqrtf, and rsqrtl
From the PR:
The attached diff implements the inverse square root function, i.e,
rsqrt(x) = 1 / sqrt(x).  Exhaustive testing of the float version
suggests that it is correctly rounded in round-to-nearest for all
test values in the range [0x1p-127,0x1p126].
Exhaustive testing of rsqrt and rsqrtl cannot be done, but 1100M
values of x for rsqrt and 400M values for rsqrtl were tested.  All
tested values were correctly rounded.

I do not have access to LD128 (i.e., IEEE 128-bit floating point)
hardware, so the implementation of rsqrtl() is untested.

The following is a summary of changes to source code.

* lib/msun/Makefile:
  . Add s_rsqrt.c and s_rsqrtf.c to COMMON_SRCS.
  . For non-53-bit long double targets, add s_rsqrtl.c to COMMON_SRCS.
  . Add MLINKS for rsqrt.3, rsqrtf.3, and rsqrtl.3 to sqrt.3.

* lib/msun/Symbol.map:
  . Add rsqrt, rsqrtf, and rsqrtl to the Symbol map for shared libm.so.

* lib/msun/man/sqrt.3:
  . Update the sqrt.3 manual page to include information for rsqrt[fl].
  . Note, these function come from ISO C23 (and IEEE-754 2008).

* lib/msun/src/math.h:
  . Add prototypes for new functions.

* lib/msun/src/math_private.h:
  . Add _SPLIT, _FAST2SUM, _SLOW2SUM, _XADD, _MUL, and _XMUL
    macros to perform type-type arthimetic (i.e., float-float).

* src/s_rsqrt.c:
  . New file with the implementation of 'double rsqrt(double)'.
  . For 53-bit long double targets, add a weak reference for rsqrtl.

* src/s_rsqrtf.c:
  . New file with the implementation of 'float rsqrt(float)'.

* src/s_rsqrtl.c
  . New file with the implementation of 'long double rsqrt(long double)'.
    Note, the LD80 version uses bit twiddling and LD128 version is a
    straight C language implementation.  The LD128 is untested due to
    lack of hardware.

PR:	295089
MFC after:	1 week
2026-05-10 19:36:33 +03:00
..
2026-01-13 10:19:04 -05:00
2026-05-10 17:53:20 +03:00
2026-04-10 12:20:27 +02:00
2024-10-14 10:26:17 -07:00
2025-01-01 15:11:06 -06:00
2026-01-03 21:37:18 +01:00
2024-10-14 10:26:17 -07:00
2026-01-06 12:56:50 -05:00
2026-03-31 18:45:14 -07:00
2024-10-14 10:26:17 -07:00
2025-10-03 19:46:55 +02:00
2026-03-15 00:41:29 -03:00
2026-04-26 15:41:47 +02:00
2025-11-24 10:47:10 -05:00
2025-11-24 10:47:10 -05:00
2025-08-08 13:27:26 -05:00
2024-10-08 16:13:39 -03:00
2024-10-14 10:26:17 -07:00
2024-11-12 12:11:51 -05:00
2025-10-23 12:03:29 -07:00
2025-09-30 09:14:05 +01:00
2026-01-06 04:26:53 +00:00
2026-03-13 23:49:53 +00:00
2026-04-08 14:22:45 -07:00
2026-01-15 07:28:28 +01:00
2025-12-03 14:21:07 +00:00
2026-04-22 15:42:56 +02:00