[libc-commits] [libc] [llvm] [libc][math] Refactor sincos implementation to header only (PR #177522)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Fri Jan 23 13:48:28 PST 2026


================
@@ -0,0 +1,232 @@
+//===-- Implementation header for sincos ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SINCOS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SINCOS_H
+
+#include "hdr/errno_macros.h"
+#include "range_reduction_double_common.h"
+#include "sincos_eval.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/double_double.h"
+#include "src/__support/FPUtil/dyadic_float.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/rounding_mode.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
+
+#ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
+#include "src/__support/math/range_reduction_double_fma.h"
+#else
+#include "src/__support/math/range_reduction_double_nofma.h"
+#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+using DoubleDouble = fputil::DoubleDouble;
+using Float128 = typename fputil::DyadicFloat<128>;
+
+LIBC_INLINE static constexpr void sincos(double x, double *sin_x,
+                                         double *cos_x) {
+  using namespace math::range_reduction_double_internal;
+  using FPBits = typename fputil::FPBits<double>;
+  FPBits xbits(x);
+
----------------
bassiounix wrote:

```suggestion
namespace LIBC_NAMESPACE_DECL {

namespace math {

LIBC_INLINE static constexpr void sincos(double x, double *sin_x,
                                         double *cos_x) {
  using DoubleDouble = fputil::DoubleDouble;
  using Float128 = typename fputil::DyadicFloat<128>;
  using namespace math::range_reduction_double_internal;
  using FPBits = typename fputil::FPBits<double>;
  FPBits xbits(x);

```

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


More information about the libc-commits mailing list