[libc-commits] [libc] [libc][math][c23] Improve rsqrtf16() function (PR #160639)
via libc-commits
libc-commits at lists.llvm.org
Thu Mar 12 21:03:00 PDT 2026
================
@@ -76,6 +76,76 @@ LIBC_INLINE static constexpr float16 rsqrtf16(float16 x) {
}
return fputil::cast<float16>(result);
+
+#else
+ float xf = fputil::cast<float>(x);
+
+ int exponent = 0;
+ float mantissa = fputil::frexp(xf, exponent);
----------------
lntue wrote:
Use `FPBits` and direct bit manipulations instead of `fputil::frexp` and `fputil::ldexp`, because those 2 functions do a lot more work (w.r.t floating-point exceptions and errnos) than just extract and normalize parts of the floating-point.
https://github.com/llvm/llvm-project/pull/160639
More information about the libc-commits
mailing list