[Bug 295089] [libm] implementation of rsqrt, rsqrtf, and rsqrtl.
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 295089] [libm] implementation of rsqrt, rsqrtf, and rsqrtl."
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 10 May 2026 16:38:21 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295089
--- Comment #2 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:
URL:
https://cgit.FreeBSD.org/src/commit/?id=3085fc9d97bd83785ba3ba43e0378d7d67987d1f
commit 3085fc9d97bd83785ba3ba43e0378d7d67987d1f
Author: Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2026-05-08 14:06:08 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-05-10 16:36:33 +0000
[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
lib/msun/Makefile | 6 +-
lib/msun/Symbol.map | 3 +
lib/msun/man/sqrt.3 | 53 ++++++++++-
lib/msun/src/math.h | 3 +
lib/msun/src/math_private.h | 83 +++++++++++++++++
lib/msun/src/s_rsqrt.c (new) | 153 +++++++++++++++++++++++++++++++
lib/msun/src/s_rsqrtf.c (new) | 155 ++++++++++++++++++++++++++++++++
lib/msun/src/s_rsqrtl.c (new) | 203 ++++++++++++++++++++++++++++++++++++++++++
8 files changed, 654 insertions(+), 5 deletions(-)
--
You are receiving this mail because:
You are the assignee for the bug.