[libc-commits] [libc] [libc][math][c23] Implemented sinpif function correctly rounded for all rounding modes. (PR #97149)

via libc-commits libc-commits at lists.llvm.org
Sat Jun 29 05:12:35 PDT 2024


================
@@ -38,6 +38,16 @@ LIBC_INLINE int64_t small_range_reduction(double x, double &y) {
   return static_cast<int64_t>(kd);
 }
 
+// Return k and y, where
+//   k = round(x * 32) and y = (x * 32) - k.
+//   => pi * x = (k + y) * pi / 32
+LIBC_INLINE int64_t small_range_reduction_mul_pi(double x, double &y) {
+  double kd = fputil::nearest_integer(x * 32);
+  y = fputil::fma<double>(x, 32.0, -kd);
----------------
lntue wrote:

Use `fputil::multiply_add` as it is still correct without FMA.

https://github.com/llvm/llvm-project/pull/97149


More information about the libc-commits mailing list