[libc-commits] [libc] [libc][math] Improve fmul performance by using double-double arithmetic. (PR #107517)

via libc-commits libc-commits at lists.llvm.org
Sat Sep 14 11:04:34 PDT 2024


================
@@ -5,16 +5,119 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-
 #include "src/math/fmul.h"
+#include "hdr/errno_macros.h"
+#include "hdr/fenv_macros.h"
+#include "src/__support/FPUtil/double_double.h"
 #include "src/__support/FPUtil/generic/mul.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
+#include <iostream>
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float, fmul, (double x, double y)) {
+
+#ifndef LIBC_TARGET_CPU_HAS_FMA
----------------
lntue wrote:

Add comment explaining that without FMA instructions, `fputil::exact_mult` is not correctly rounded for all rounding modes, so we fall back to the generic `fmul` implementation.

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


More information about the libc-commits mailing list