[libc-commits] [libc] [libc][math][c23] Improve performance of fadd using double arithmetic (PR #112055)

via libc-commits libc-commits at lists.llvm.org
Fri Oct 11 15:18:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Job Henandez Lara (Jobhdez)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/112055.diff


2 Files Affected:

- (modified) libc/test/src/math/performance_testing/CMakeLists.txt (+12) 
- (added) libc/test/src/math/performance_testing/fadd_perf.cpp (+22) 


``````````diff
diff --git a/libc/test/src/math/performance_testing/CMakeLists.txt b/libc/test/src/math/performance_testing/CMakeLists.txt
index 60c074a248f72a..f1399663a6cf34 100644
--- a/libc/test/src/math/performance_testing/CMakeLists.txt
+++ b/libc/test/src/math/performance_testing/CMakeLists.txt
@@ -475,6 +475,18 @@ add_perf_binary(
     libc.src.math.fminimum_numf16
   COMPILE_OPTIONS
     -fno-builtin
+    )
+
+add_perf_binary(
+  fadd_perf
+  SRCS
+    fadd_perf.cpp
+  DEPENDS
+    .binary_op_single_output_diff
+    libc.src.math.fadd
+    libc.src.__support.FPUtil.fp_bits
+  COMPILE_OPTIONS
+    -fno-builtin
 )
 
 add_perf_binary(
diff --git a/libc/test/src/math/performance_testing/fadd_perf.cpp b/libc/test/src/math/performance_testing/fadd_perf.cpp
new file mode 100644
index 00000000000000..b903595d26c829
--- /dev/null
+++ b/libc/test/src/math/performance_testing/fadd_perf.cpp
@@ -0,0 +1,22 @@
+//===-- Performance test for the fadd function ----------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "BinaryOpSingleOutputPerf.h"
+#include "src/math/fadd.h"
+
+static constexpr size_t DOUBLE_ROUNDS = 40;
+
+float fadd_placeholder_binary(double x, double y) {
+  return static_cast<float>(x + y);
+}
+
+int main() {
+  BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, double, myFunc, fadd_placeholder_binary, DOUBLE_ROUNDS, "fadd_perf.log")
+    return 0;
+}
+    

``````````

</details>


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


More information about the libc-commits mailing list