[Bug 295089] [libm] implementation of rsqrt, rsqrtf, and rsqrtl.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 May 2026 22:36:22 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295089
Bug ID: 295089
Summary: [libm] implementation of rsqrt, rsqrtf, and rsqrtl.
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: kargl@FreeBSD.org
Created attachment 270500
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=270500&action=edit
Patch with libm changes
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] except for 127 values.
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.
--
You are receiving this mail because:
You are the assignee for the bug.