[libc-commits] [libc] [libc][math] Implement an integer-only version of double precision sin and cos with 1 ULP errors. (PR #184752)
Muhammad Bassiouni via libc-commits
libc-commits at lists.llvm.org
Mon Mar 9 19:38:48 PDT 2026
================
@@ -48,6 +48,34 @@ polyeval(T x, T a0, Ts... a) {
return multiply_add(x, polyeval(x, a...), a0);
}
+// Evaluating alternating polynomials using subtraction directly.
+// altpolyeval(x, a_0, a_1, ..., a_n) = a_0 - x * a_1 + x^2 * a_2 - ... +
+// + (-1)^n x_n * a_n.
+template <typename T>
+LIBC_INLINE cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T>
+altpolyeval(const T &, const T &a0) {
+ return a0;
+}
+
+template <typename T>
+LIBC_INLINE cpp::enable_if_t<(sizeof(T) <= sizeof(void *)), T>
+altpolyeval(T, T a0) {
+ return a0;
+}
+
+// TODO: Make use of FMA instructions when using these for floating points.
+template <typename T, typename... Ts>
+LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T>
----------------
bassiounix wrote:
what is the reason for this to be static?
didn't we have a problem with static before on baremetal?
is this going to be used in `libmvec` thus it's static?
https://github.com/llvm/llvm-project/pull/184752
More information about the libc-commits
mailing list