https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/148670
>From 30f3a33cea2cfcbe61663102d47dcc74ff43ccb3 Mon Sep 17 00:00:00 2001 From: bassiounix <muhammad.m.bassio...@gmail.com> Date: Mon, 14 Jul 2025 19:50:42 +0300 Subject: [PATCH 1/2] [libc][math] fix-exp --- libc/src/__support/FPUtil/PolyEval.h | 8 ++++---- libc/src/__support/FPUtil/multiply_add.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libc/src/__support/FPUtil/PolyEval.h b/libc/src/__support/FPUtil/PolyEval.h index 41104620ed61d..105b3f2698897 100644 --- a/libc/src/__support/FPUtil/PolyEval.h +++ b/libc/src/__support/FPUtil/PolyEval.h @@ -25,19 +25,19 @@ namespace LIBC_NAMESPACE_DECL { namespace fputil { template <typename T> -LIBC_INLINE cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> +LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> polyeval(const T &, const T &a0) { return a0; } template <typename T> -LIBC_INLINE cpp::enable_if_t<(sizeof(T) <= sizeof(void *)), T> polyeval(T, - T a0) { +LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) <= sizeof(void *)), T> +polyeval(T, T a0) { return a0; } template <typename T, typename... Ts> -LIBC_INLINE cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> +LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> polyeval(const T &x, const T &a0, const Ts &...a) { return multiply_add(x, polyeval(x, a...), a0); } diff --git a/libc/src/__support/FPUtil/multiply_add.h b/libc/src/__support/FPUtil/multiply_add.h index 8260702e2c9f4..5f759f86227cb 100644 --- a/libc/src/__support/FPUtil/multiply_add.h +++ b/libc/src/__support/FPUtil/multiply_add.h @@ -23,13 +23,13 @@ namespace fputil { // which uses FMA instructions to speed up if available. template <typename T> -LIBC_INLINE cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> +LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) > sizeof(void *)), T> multiply_add(const T &x, const T &y, const T &z) { return x * y + z; } template <typename T> -LIBC_INLINE cpp::enable_if_t<(sizeof(T) <= sizeof(void *)), T> +LIBC_INLINE static constexpr cpp::enable_if_t<(sizeof(T) <= sizeof(void *)), T> multiply_add(T x, T y, T z) { return x * y + z; } @@ -47,7 +47,7 @@ namespace LIBC_NAMESPACE_DECL { namespace fputil { #ifdef LIBC_TARGET_CPU_HAS_FMA_FLOAT -LIBC_INLINE float multiply_add(float x, float y, float z) { +LIBC_INLINE static constexpr float multiply_add(float x, float y, float z) { #if __has_builtin(__builtin_elementwise_fma) return __builtin_elementwise_fma(x, y, z); #else @@ -57,7 +57,7 @@ LIBC_INLINE float multiply_add(float x, float y, float z) { #endif // LIBC_TARGET_CPU_HAS_FMA_FLOAT #ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE -LIBC_INLINE double multiply_add(double x, double y, double z) { +LIBC_INLINE static constexpr double multiply_add(double x, double y, double z) { #if __has_builtin(__builtin_elementwise_fma) return __builtin_elementwise_fma(x, y, z); #else >From c7311382041e08bbd2fe53d64bc809cde6831f10 Mon Sep 17 00:00:00 2001 From: bassiounix <muhammad.m.bassio...@gmail.com> Date: Mon, 14 Jul 2025 20:23:08 +0300 Subject: [PATCH 2/2] make builtins constexpr --- clang/lib/CodeGen/CGBuiltin.cpp | 4 ++-- clang/lib/CodeGen/CGBuiltin.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 5f2eb76e7bacb..506654d01f64e 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -602,7 +602,7 @@ Value *emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, // Emit an intrinsic that has 2 operands of the same type as its result. // Depending on mode, this may be a constrained floating-point intrinsic. -static Value *emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, +static constexpr Value *emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID) { llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); @@ -640,7 +640,7 @@ emitBinaryExpMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, const CallExpr *E, // Emit an intrinsic that has 3 operands of the same type as its result. // Depending on mode, this may be a constrained floating-point intrinsic. -static Value *emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, +static constexpr Value *emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID) { llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); diff --git a/clang/lib/CodeGen/CGBuiltin.h b/clang/lib/CodeGen/CGBuiltin.h index 667bce845f5c0..aafc78ce77dff 100644 --- a/clang/lib/CodeGen/CGBuiltin.h +++ b/clang/lib/CodeGen/CGBuiltin.h @@ -60,7 +60,7 @@ enum class clang::CodeGen::CodeGenFunction::MSVCIntrin { // matching the argument type. It is assumed that only the first argument is // overloaded. template <unsigned N> -llvm::Value *emitBuiltinWithOneOverloadedType(clang::CodeGen::CodeGenFunction &CGF, +static constexpr llvm::Value *emitBuiltinWithOneOverloadedType(clang::CodeGen::CodeGenFunction &CGF, const clang::CallExpr *E, unsigned IntrinsicID, llvm::StringRef Name = "") { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits