[libc-commits] [libc] [libc][mathvec] Vectorise exp2f and exp10f (PR #211365)
via libc-commits
libc-commits at lists.llvm.org
Fri Jul 31 08:22:53 PDT 2026
================
@@ -208,9 +209,21 @@ LIBC_INLINE constexpr static simd<T, N> abs(simd<T, N> x) {
return __builtin_elementwise_abs(x);
}
template <typename T, size_t N>
-LIBC_INLINE constexpr static simd<T, N> fma(simd<T, N> x, simd<T, N> y,
- simd<T, N> z) {
- return __builtin_elementwise_fma(x, y, z);
+LIBC_INLINE constexpr static simd<T, N> multiply_add(simd<T, N> x, simd<T, N> y,
+ simd<T, N> z) {
+#if __has_builtin(__builtin_elementwise_fma)
+#ifdef LIBC_TARGET_CPU_HAS_FMA_FLOAT
+ if constexpr (cpp::is_same_v<T, float>)
+ return __builtin_elementwise_fma(x, y, z);
+#endif // LIBC_TARGET_CPU_HAS_FMA_FLOAT
+
+#ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
+ if constexpr (cpp::is_same_v<T, double>)
+ return __builtin_elementwise_fma(x, y, z);
+#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
+#endif // __has_builtin(__builtin_elementwise_fma)
+
+ return x * y + z;
----------------
lntue wrote:
nit: can you create temporary for `x*y` to make sure compilers won't fuse them?
https://github.com/llvm/llvm-project/pull/211365
More information about the libc-commits
mailing list