Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc][math][c23] Add expm1f16 C23 math function #102387

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

overmighty
Copy link
Member

Part of #95250.

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 7, 2024

@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)

Changes

Part of #95250.


Patch is 23.05 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/102387.diff

13 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/docs/math/index.rst (+1-1)
  • (modified) libc/spec/stdc.td (+1)
  • (modified) libc/src/math/CMakeLists.txt (+1)
  • (added) libc/src/math/expm1f16.h (+21)
  • (modified) libc/src/math/generic/CMakeLists.txt (+25-3)
  • (modified) libc/src/math/generic/expf16.cpp (+4-57)
  • (added) libc/src/math/generic/expm1f16.cpp (+139)
  • (modified) libc/src/math/generic/expxf16.h (+65)
  • (modified) libc/test/src/math/CMakeLists.txt (+21-10)
  • (added) libc/test/src/math/expm1f16_test.cpp (+40)
  • (modified) libc/test/src/math/smoke/CMakeLists.txt (+17-4)
  • (added) libc/test/src/math/smoke/expm1f16_test.cpp (+65)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 39d90bf06a0cf..332a90c84fbdc 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -584,6 +584,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
     libc.src.math.exp10f16
     libc.src.math.exp2f16
     libc.src.math.expf16
+    libc.src.math.expm1f16
     libc.src.math.f16add
     libc.src.math.f16addf
     libc.src.math.f16addl
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index ce83571e2b381..642776ddf4991 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -294,7 +294,7 @@ Higher Math Functions
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
 | exp2m1    | |check|          |                 |                        |                      |                        | 7.12.6.5               | F.10.3.5                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| expm1     | |check|          | |check|         |                        |                      |                        | 7.12.6.6               | F.10.3.6                   |
+| expm1     | |check|          | |check|         |                        | |check|              |                        | 7.12.6.6               | F.10.3.6                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
 | fma       | |check|          | |check|         |                        |                      |                        | 7.12.13.1              | F.10.10.1                  |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index d24d43526fe5c..76555439a2dc8 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -594,6 +594,7 @@ def StdC : StandardSpec<"stdc"> {
 
           FunctionSpec<"expm1", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"expm1f", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
+          GuardedFunctionSpec<"expm1f16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
 
           FunctionSpec<"exp10", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
           FunctionSpec<"exp10f", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index a3c9b5473c290..9ccc3f1a347f2 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -120,6 +120,7 @@ add_math_entrypoint_object(exp10f16)
 
 add_math_entrypoint_object(expm1)
 add_math_entrypoint_object(expm1f)
+add_math_entrypoint_object(expm1f16)
 
 add_math_entrypoint_object(f16add)
 add_math_entrypoint_object(f16addf)
diff --git a/libc/src/math/expm1f16.h b/libc/src/math/expm1f16.h
new file mode 100644
index 0000000000000..644e6cddd7666
--- /dev/null
+++ b/libc/src/math/expm1f16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for expm1f16 ----------------------*- 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_MATH_EXPM1F16_H
+#define LLVM_LIBC_SRC_MATH_EXPM1F16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float16 expm1f16(float16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_EXPM1F16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 77f7f4fef007b..469df67951ab3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1322,14 +1322,12 @@ add_entrypoint_object(
   HDRS
     ../expf16.h
   DEPENDS
+    .expxf16
     libc.hdr.errno_macros
     libc.hdr.fenv_macros
-    libc.src.__support.CPP.array
     libc.src.__support.FPUtil.except_value_utils
     libc.src.__support.FPUtil.fenv_impl
     libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.FPUtil.multiply_add
-    libc.src.__support.FPUtil.nearest_integer
     libc.src.__support.FPUtil.polyeval
     libc.src.__support.FPUtil.rounding_mode
     libc.src.__support.macros.optimization
@@ -1571,6 +1569,27 @@ add_entrypoint_object(
     -O3
 )
 
+add_entrypoint_object(
+  expm1f16
+  SRCS
+    expm1f16.cpp
+  HDRS
+    ../expm1f16.h
+  DEPENDS
+    .expxf16
+    libc.hdr.errno_macros
+    libc.hdr.fenv_macros
+    libc.src.__support.FPUtil.except_value_utils
+    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.polyeval
+    libc.src.__support.FPUtil.rounding_mode
+    libc.src.__support.macros.optimization
+  COMPILE_OPTIONS
+    -O3
+)
+
 add_entrypoint_object(
   powf
   SRCS
@@ -4878,4 +4897,7 @@ add_header_library(
     expxf16.h
   DEPENDS
     libc.src.__support.CPP.array
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.nearest_integer
+    libc.src.__support.FPUtil.polyeval
 )
diff --git a/libc/src/math/generic/expf16.cpp b/libc/src/math/generic/expf16.cpp
index b198c559dfedb..7ffdbd5191008 100644
--- a/libc/src/math/generic/expf16.cpp
+++ b/libc/src/math/generic/expf16.cpp
@@ -7,15 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/expf16.h"
+#include "expxf16.h"
 #include "hdr/errno_macros.h"
 #include "hdr/fenv_macros.h"
-#include "src/__support/CPP/array.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/except_value_utils.h"
-#include "src/__support/FPUtil/multiply_add.h"
-#include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/FPUtil/rounding_mode.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
@@ -41,28 +39,6 @@ static constexpr fputil::ExceptValues<float16, 3> EXPF16_EXCEPTS_HI = {{
     {0xa954U, 0x3bacU, 1U, 0U, 0U},
 }};
 
-// Generated by Sollya with the following commands:
-//   > display = hexadecimal;
-//   > for i from -18 to 12 do print(round(exp(i), SG, RN));
-static constexpr cpp::array<float, 31> EXP_HI = {
-    0x1.05a628p-26f, 0x1.639e32p-25f, 0x1.e355bcp-24f, 0x1.4875cap-22f,
-    0x1.be6c7p-21f,  0x1.2f6054p-19f, 0x1.9c54c4p-18f, 0x1.183542p-16f,
-    0x1.7cd79cp-15f, 0x1.02cf22p-13f, 0x1.5fc21p-12f,  0x1.de16bap-11f,
-    0x1.44e52p-9f,   0x1.b993fep-8f,  0x1.2c155cp-6f,  0x1.97db0cp-5f,
-    0x1.152aaap-3f,  0x1.78b564p-2f,  0x1p+0f,         0x1.5bf0a8p+1f,
-    0x1.d8e64cp+2f,  0x1.415e5cp+4f,  0x1.b4c902p+5f,  0x1.28d38ap+7f,
-    0x1.936dc6p+8f,  0x1.122886p+10f, 0x1.749ea8p+11f, 0x1.fa7158p+12f,
-    0x1.5829dcp+14f, 0x1.d3c448p+15f, 0x1.3de166p+17f,
-};
-
-// Generated by Sollya with the following commands:
-//   > display = hexadecimal;
-//   > for i from 0 to 7 do print(round(exp(i * 2^-3), SG, RN));
-static constexpr cpp::array<float, 8> EXP_MID = {
-    0x1p+0f,        0x1.221604p+0f, 0x1.48b5e4p+0f, 0x1.747a52p+0f,
-    0x1.a61298p+0f, 0x1.de455ep+0f, 0x1.0ef9dcp+1f, 0x1.330e58p+1f,
-};
-
 LLVM_LIBC_FUNCTION(float16, expf16, (float16 x)) {
   using FPBits = fputil::FPBits<float16>;
   FPBits x_bits(x);
@@ -135,38 +111,9 @@ LLVM_LIBC_FUNCTION(float16, expf16, (float16 x)) {
   if (auto r = EXPF16_EXCEPTS_HI.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
     return r.value();
 
-  // For -18 < x < 12, to compute exp(x), we perform the following range
-  // reduction: find hi, mid, lo, such that:
-  //   x = hi + mid + lo, in which
-  //     hi is an integer,
-  //     mid * 2^3 is an integer,
-  //     -2^(-4) <= lo < 2^(-4).
-  // In particular,
-  //   hi + mid = round(x * 2^3) * 2^(-3).
-  // Then,
-  //   exp(x) = exp(hi + mid + lo) = exp(hi) * exp(mid) * exp(lo).
-  // We store exp(hi) and exp(mid) in the lookup tables EXP_HI and EXP_MID
-  // respectively.  exp(lo) is computed using a degree-3 minimax polynomial
-  // generated by Sollya.
-
-  float xf = x;
-  float kf = fputil::nearest_integer(xf * 0x1.0p+3f);
-  int x_hi_mid = static_cast<int>(kf);
-  int x_hi = x_hi_mid >> 3;
-  int x_mid = x_hi_mid & 0x7;
-  // lo = x - (hi + mid) = round(x * 2^3) * (-2^(-3)) + x
-  float lo = fputil::multiply_add(kf, -0x1.0p-3f, xf);
-
-  float exp_hi = EXP_HI[x_hi + 18];
-  float exp_mid = EXP_MID[x_mid];
-  // Degree-3 minimax polynomial generated by Sollya with the following
-  // commands:
-  //   > display = hexadecimal;
-  //   > P = fpminimax(expm1(x)/x, 2, [|SG...|], [-2^-4, 2^-4]);
-  //   > 1 + x * P;
-  float exp_lo =
-      fputil::polyeval(lo, 0x1p+0f, 0x1p+0f, 0x1.001p-1f, 0x1.555ddep-3f);
-  return static_cast<float16>(exp_hi * exp_mid * exp_lo);
+  // exp(x) = exp(hi + mid) * exp(lo)
+  auto [exp_hi_mid, exp_lo] = exp_range_reduction(x);
+  return static_cast<float16>(exp_hi_mid * exp_lo);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/expm1f16.cpp b/libc/src/math/generic/expm1f16.cpp
new file mode 100644
index 0000000000000..f13f6850db524
--- /dev/null
+++ b/libc/src/math/generic/expm1f16.cpp
@@ -0,0 +1,139 @@
+//===-- Half-precision e^x - 1 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 "src/math/expm1f16.h"
+#include "expxf16.h"
+#include "hdr/errno_macros.h"
+#include "hdr/fenv_macros.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/PolyEval.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"
+
+namespace LIBC_NAMESPACE_DECL {
+
+static constexpr fputil::ExceptValues<float16, 1> EXPM1F16_EXCEPTS_LO = {{
+    // (input, RZ output, RU offset, RD offset, RN offset)
+    // x = 0x1.564p-5, expm1f16(x) = 0x1.5d4p-5 (RZ)
+    {0x2959U, 0x2975U, 1U, 0U, 1U},
+}};
+
+#ifdef LIBC_TARGET_CPU_HAS_FMA
+static constexpr size_t N_EXPM1F16_EXCEPTS_HI = 2;
+#else
+static constexpr size_t N_EXPM1F16_EXCEPTS_HI = 3;
+#endif
+
+static constexpr fputil::ExceptValues<float16, N_EXPM1F16_EXCEPTS_HI>
+    EXPM1F16_EXCEPTS_HI = {{
+        // (input, RZ output, RU offset, RD offset, RN offset)
+        // x = 0x1.c34p+0, expm1f16(x) = 0x1.34cp+2 (RZ)
+        {0x3f0dU, 0x44d3U, 1U, 0U, 1U},
+        // x = -0x1.e28p-3, expm1f16(x) = -0x1.adcp-3 (RZ)
+        {0xb38aU, 0xb2b7U, 0U, 1U, 1U},
+#ifndef LIBC_TARGET_CPU_HAS_FMA
+        // x = 0x1.a08p-3, exp10m1f(x) = 0x1.cdcp-3 (RZ)
+        {0x3282U, 0x3337U, 1U, 0U, 0U},
+#endif
+    }};
+
+LLVM_LIBC_FUNCTION(float16, expm1f16, (float16 x)) {
+  using FPBits = fputil::FPBits<float16>;
+  FPBits x_bits(x);
+
+  uint16_t x_u = x_bits.uintval();
+  uint16_t x_abs = x_u & 0x7fffU;
+
+  // When |x| <= 2^(-3), or |x| >= -11 * log(2), or x is NaN.
+  if (LIBC_UNLIKELY(x_abs <= 0x3000U || x_abs >= 0x47a0U)) {
+    // expm1(NaN) = NaN
+    if (x_bits.is_nan()) {
+      if (x_bits.is_signaling_nan()) {
+        fputil::raise_except_if_required(FE_INVALID);
+        return FPBits::quiet_nan().get_val();
+      }
+
+      return x;
+    }
+
+    // expm1(+/-0) = +/-0
+    if (x_abs == 0)
+      return x;
+
+    // When x >= 12.
+    if (x_bits.is_pos() && x_abs >= 0x4a00U) {
+      // expm1(+inf) = +inf
+      if (x_bits.is_inf())
+        return FPBits::inf().get_val();
+
+      switch (fputil::quick_get_round()) {
+      case FE_TONEAREST:
+      case FE_UPWARD:
+        fputil::set_errno_if_required(ERANGE);
+        fputil::raise_except_if_required(FE_OVERFLOW);
+        return FPBits::inf().get_val();
+      default:
+        return FPBits::max_normal().get_val();
+      }
+    }
+
+    // When x <= -11 * log(2).
+    if (x_u >= 0xc7a0U) {
+      // expm1(-inf) = -1
+      if (x_bits.is_inf())
+        return FPBits::one(Sign::NEG).get_val();
+
+      fputil::set_errno_if_required(ERANGE);
+      fputil::raise_except_if_required(FE_INEXACT);
+
+      switch (fputil::quick_get_round()) {
+      case FE_UPWARD:
+      case FE_TOWARDZERO:
+        return static_cast<float16>(-0x1.ffcp-1);
+      case FE_TONEAREST:
+        if (x_u > 0xc828U)
+          return FPBits::one(Sign::NEG).get_val();
+        return static_cast<float16>(-0x1.ffcp-1);
+      default:
+        return FPBits::one(Sign::NEG).get_val();
+      }
+    }
+
+    // When 0 < |x| <= 2^(-3).
+    if (x_abs <= 0x3000U && !x_bits.is_zero()) {
+      if (auto r = EXPM1F16_EXCEPTS_LO.lookup(x_u);
+          LIBC_UNLIKELY(r.has_value()))
+        return r.value();
+
+      float xf = x;
+      // Degree-5 minimax polynomial generated by Sollya with the following
+      // commands:
+      //   > display = hexadecimal;
+      //   > P = fpminimax(expm1(x)/x, 4, [|SG...|], [-2^-3, 2^-3]);
+      //   > x * P;
+      return static_cast<float16>(
+          xf * fputil::polyeval(xf, 0x1p+0f, 0x1.fffff8p-2f, 0x1.555556p-3f,
+                                0x1.55905ep-5f, 0x1.1124c2p-7f));
+    }
+  }
+
+  if (auto r = EXPM1F16_EXCEPTS_HI.lookup(x_u); LIBC_UNLIKELY(r.has_value()))
+    return r.value();
+
+  // exp(x) = exp(hi + mid) * exp(lo)
+  auto [exp_hi_mid, exp_lo] = exp_range_reduction(x);
+  // expm1(x) = exp(hi + mid) * exp(lo) - 1
+  return static_cast<float16>(fputil::multiply_add(exp_hi_mid, exp_lo, -1.0f));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/expxf16.h b/libc/src/math/generic/expxf16.h
index c33aca337b98d..53815e0e27553 100644
--- a/libc/src/math/generic/expxf16.h
+++ b/libc/src/math/generic/expxf16.h
@@ -10,11 +10,76 @@
 #define LLVM_LIBC_SRC_MATH_GENERIC_EXPXF16_H
 
 #include "src/__support/CPP/array.h"
+#include "src/__support/FPUtil/PolyEval.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/macros/config.h"
 #include <stdint.h>
 
 namespace LIBC_NAMESPACE_DECL {
 
+// Generated by Sollya with the following commands:
+//   > display = hexadecimal;
+//   > for i from -18 to 12 do print(round(exp(i), SG, RN));
+static constexpr cpp::array<float, 31> EXP_HI = {
+    0x1.05a628p-26f, 0x1.639e32p-25f, 0x1.e355bcp-24f, 0x1.4875cap-22f,
+    0x1.be6c7p-21f,  0x1.2f6054p-19f, 0x1.9c54c4p-18f, 0x1.183542p-16f,
+    0x1.7cd79cp-15f, 0x1.02cf22p-13f, 0x1.5fc21p-12f,  0x1.de16bap-11f,
+    0x1.44e52p-9f,   0x1.b993fep-8f,  0x1.2c155cp-6f,  0x1.97db0cp-5f,
+    0x1.152aaap-3f,  0x1.78b564p-2f,  0x1p+0f,         0x1.5bf0a8p+1f,
+    0x1.d8e64cp+2f,  0x1.415e5cp+4f,  0x1.b4c902p+5f,  0x1.28d38ap+7f,
+    0x1.936dc6p+8f,  0x1.122886p+10f, 0x1.749ea8p+11f, 0x1.fa7158p+12f,
+    0x1.5829dcp+14f, 0x1.d3c448p+15f, 0x1.3de166p+17f,
+};
+
+// Generated by Sollya with the following commands:
+//   > display = hexadecimal;
+//   > for i from 0 to 7 do print(round(exp(i * 2^-3), SG, RN));
+static constexpr cpp::array<float, 8> EXP_MID = {
+    0x1p+0f,        0x1.221604p+0f, 0x1.48b5e4p+0f, 0x1.747a52p+0f,
+    0x1.a61298p+0f, 0x1.de455ep+0f, 0x1.0ef9dcp+1f, 0x1.330e58p+1f,
+};
+
+struct ExpRangeReduction {
+  float exp_hi_mid;
+  float exp_lo;
+};
+
+ExpRangeReduction exp_range_reduction(float16 x) {
+  // For -18 < x < 12, to compute exp(x), we perform the following range
+  // reduction: find hi, mid, lo, such that:
+  //   x = hi + mid + lo, in which
+  //     hi is an integer,
+  //     mid * 2^3 is an integer,
+  //     -2^(-4) <= lo < 2^(-4).
+  // In particular,
+  //   hi + mid = round(x * 2^3) * 2^(-3).
+  // Then,
+  //   exp(x) = exp(hi + mid + lo) = exp(hi) * exp(mid) * exp(lo).
+  // We store exp(hi) and exp(mid) in the lookup tables EXP_HI and EXP_MID
+  // respectively.  exp(lo) is computed using a degree-3 minimax polynomial
+  // generated by Sollya.
+
+  float xf = x;
+  float kf = fputil::nearest_integer(xf * 0x1.0p+3f);
+  int x_hi_mid = static_cast<int>(kf);
+  int x_hi = x_hi_mid >> 3;
+  int x_mid = x_hi_mid & 0x7;
+  // lo = x - (hi + mid) = round(x * 2^3) * (-2^(-3)) + x
+  float lo = fputil::multiply_add(kf, -0x1.0p-3f, xf);
+
+  float exp_hi = EXP_HI[x_hi + 18];
+  float exp_mid = EXP_MID[x_mid];
+  // Degree-3 minimax polynomial generated by Sollya with the following
+  // commands:
+  //   > display = hexadecimal;
+  //   > P = fpminimax(expm1(x)/x, 2, [|SG...|], [-2^-4, 2^-4]);
+  //   > 1 + x * P;
+  float exp_lo =
+      fputil::polyeval(lo, 0x1p+0f, 0x1p+0f, 0x1.001p-1f, 0x1.555ddep-3f);
+  return {exp_hi * exp_mid, exp_lo};
+}
+
 // Generated by Sollya with the following commands:
 //   > display = hexadecimal;
 //   > for i from 0 to 7 do printsingle(round(2^(i * 2^-3), SG, RN));
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index d209c9a38499b..b6b6953a68871 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1663,6 +1663,19 @@ add_fp_unittest(
     libc.src.__support.FPUtil.fp_bits
 )
 
+add_fp_unittest(
+  expm1_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    expm1_test.cpp
+  DEPENDS
+    libc.src.errno.errno
+    libc.src.math.expm1
+    libc.src.__support.FPUtil.fp_bits
+)
+
 add_fp_unittest(
   expm1f_test
   NEED_MPFR
@@ -1677,16 +1690,14 @@ add_fp_unittest(
 )
 
 add_fp_unittest(
- expm1_test
- NEED_MPFR
- SUITE
-   libc-math-unittests
- SRCS
-   expm1_test.cpp
- DEPENDS
-   libc.src.errno.errno
-   libc.src.math.expm1
-   libc.src.__support.FPUtil.fp_bits
+  expm1f16_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    expm1f16_test.cpp
+  DEPENDS
+    libc.src.math.expm1f16
 )
 
 add_fp_unittest(
diff --git a/libc/test/src/math/expm1f16_test.cpp b/libc/test/src/math/expm1f16_test.cpp
new file mode 100644
index 0000000000000..a6a6fcf73d383
--- /dev/null
+++ b/libc/test/src/math/expm1f16_test.cpp
@@ -0,0 +1,40 @@
+//===-- Exhaustive test for expm1f16 --------------------------------------===//
+//
+// 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 "src/math/expm1f16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+
+using LlvmLibcExpm1f16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+// Range: [0, Inf];
+static constexpr uint16_t POS_START = 0x0000U;
+static constexpr uint16_t POS_STOP = 0x7c00U;
+
+// Range: [-Inf, 0];
+static constexpr uint16_t NEG_START = 0x8000U;
+static constexpr uint16_t NEG_STOP = 0xfc00U;
+
+TEST_F(LlvmLibcExpm1f16Test, PositiveRange) {
+  for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
+    float16 x = FPBits(v).get_val();
+    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
+                                   LIBC_NAMESPACE::expm1f16(x), 0.5);
+  }
+}
+
+TEST_F(LlvmLibcExpm1f16Test, NegativeRange) {
+  for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
+    float16 x = FPBits(v).get_val();
+    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x,
+                                   LIBC_NAMESPACE::expm1f16(x), 0.5);
+  }
+}
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 9aa5399aae9d3..18d8eb27aec23 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3294,6 +3294,18 @@ add_fp_unittest(...
[truncated]

@overmighty overmighty requested a review from lntue August 12, 2024 16:24
@overmighty overmighty merged commit 560ed8c into main Aug 13, 2024
8 checks passed
@overmighty overmighty deleted the users/overmighty/libc-math-expm1f16 branch August 13, 2024 14:48
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 13, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-libc-amdgpu-runtime running on omp-vega20-1 while building libc at step 5 "compile-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/3669

Here is the relevant piece of the build log for the reference:

Step 5 (compile-openmp) failure: build (failure)
...
4.090 [4/8/636] Building CXX object libc/src/stdio/printf_core/CMakeFiles/libc.src.stdio.printf_core.converter.dir/converter.cpp.o
4.190 [4/7/637] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.strtold.dir/strtold.cpp.o
4.216 [4/6/638] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.strtof.dir/strtof.cpp.o
4.233 [4/5/639] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.strtod.dir/strtod.cpp.o
4.284 [2/6/640] Linking CXX static library /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/lib/amdgcn-amd-amdhsa/libc.a
4.356 [2/5/641] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.log1p.dir/log1p.cpp.o
4.543 [2/4/642] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.log10.dir/log10.cpp.o
4.611 [2/3/643] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.log2.dir/log2.cpp.o
4.615 [2/2/644] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.log.dir/log.cpp.o
4.652 [0/3/645] Linking CXX executable libc/lib/libm.bc
FAILED: libc/lib/libm.bc 
: && /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++ --target=amdgcn-amd-amdhsa -O3 -DNDEBUG -r -nostdlib -flto -Wl,--lto-emit-llvm libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.acos.dir/acos.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.inv_trigf_utils.dir/inv_trigf_utils.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.acosf.dir/acosf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.acosh.dir/acosh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.explogxf.dir/explogxf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.common_constants.dir/common_constants.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.acoshf.dir/acoshf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.asin.dir/asin.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.asinf.dir/asinf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.asinh.dir/asinh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.asinhf.dir/asinhf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.atan.dir/atan.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.atan2.dir/atan2.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.atan2f.dir/atan2f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.atanf.dir/atanf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.atanh.dir/atanh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.atanhf.dir/atanhf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.canonicalize.dir/canonicalize.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.canonicalizef.dir/canonicalizef.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.canonicalizel.dir/canonicalizel.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrt.dir/cbrt.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrtf.dir/cbrtf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.ceil.dir/ceil.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.ceilf.dir/ceilf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ceill.dir/ceill.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.copysign.dir/copysign.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.copysignf.dir/copysignf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.copysignl.dir/copysignl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.cos.dir/cos.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.cosf.dir/cosf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.cosh.dir/cosh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.coshf.dir/coshf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.cospif.dir/cospif.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ddivl.dir/ddivl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.dfmal.dir/dfmal.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.dmull.dir/dmull.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.dsqrtl.dir/dsqrtl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.erf.dir/erf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.erff.dir/erff.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp.dir/exp.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10.dir/exp10.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10f.dir/exp10f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2.dir/exp2.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2f.dir/exp2f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2m1f.dir/exp2m1f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.expf.dir/expf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.expm1.dir/expm1.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.expm1f.dir/expm1f.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fabs.dir/fabs.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fabsf.dir/fabsf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fabsl.dir/fabsl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fadd.dir/fadd.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.faddl.dir/faddl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdim.dir/fdim.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdimf.dir/fdimf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdiml.dir/fdiml.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdiv.dir/fdiv.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdivl.dir/fdivl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ffma.dir/ffma.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ffmal.dir/ffmal.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.floor.dir/floor.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.floorf.dir/floorf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.floorl.dir/floorl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fma.dir/fma.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmaf.dir/fmaf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmax.dir/fmax.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmaxf.dir/fmaxf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum.dir/fmaximum.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximumf.dir/fmaximumf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximuml.dir/fmaximuml.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_mag.dir/fmaximum_mag.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_magf.dir/fmaximum_magf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_magl.dir/fmaximum_magl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_mag_num.dir/fmaximum_mag_num.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_mag_numf.dir/fmaximum_mag_numf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_mag_numl.dir/fmaximum_mag_numl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_num.dir/fmaximum_num.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_numf.dir/fmaximum_numf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_numl.dir/fmaximum_numl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaxl.dir/fmaxl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmin.dir/fmin.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fminf.dir/fminf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum.dir/fminimum.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimumf.dir/fminimumf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimuml.dir/fminimuml.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_mag.dir/fminimum_mag.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_magf.dir/fminimum_magf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_magl.dir/fminimum_magl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_mag_num.dir/fminimum_mag_num.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_mag_numf.dir/fminimum_mag_numf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_mag_numl.dir/fminimum_mag_numl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_num.dir/fminimum_num.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_numf.dir/fminimum_numf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_numl.dir/fminimum_numl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminl.dir/fminl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmod.dir/fmod.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.fmodf.dir/fmodf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmodl.dir/fmodl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmul.dir/fmul.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmull.dir/fmull.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.frexp.dir/frexp.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.frexpf.dir/frexpf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.frexpl.dir/frexpl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrt.dir/fsqrt.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrtl.dir/fsqrtl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsub.dir/fsub.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsubl.dir/fsubl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.getpayload.dir/getpayload.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.getpayloadf.dir/getpayloadf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.getpayloadl.dir/getpayloadl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.hypot.dir/hypot.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.hypotf.dir/hypotf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ilogb.dir/ilogb.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ilogbf.dir/ilogbf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ilogbl.dir/ilogbl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.isnan.dir/isnan.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.isnanf.dir/isnanf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.isnanl.dir/isnanl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.ldexp.dir/ldexp.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.ldexpf.dir/ldexpf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ldexpl.dir/ldexpl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.lgamma.dir/lgamma.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.lgamma_r.dir/lgamma_r.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llogb.dir/llogb.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llogbf.dir/llogbf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llogbl.dir/llogbl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llrint.dir/llrint.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llrintf.dir/llrintf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llrintl.dir/llrintl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llround.dir/llround.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llroundf.dir/llroundf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llroundl.dir/llroundl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log.dir/log.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log10.dir/log10.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log10f.dir/log10f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log1p.dir/log1p.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log1pf.dir/log1pf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log2.dir/log2.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.log2f.dir/log2f.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.logb.dir/logb.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.logbf.dir/logbf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.logbl.dir/logbl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.logf.dir/logf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lrint.dir/lrint.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lrintf.dir/lrintf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lrintl.dir/lrintl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lround.dir/lround.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lroundf.dir/lroundf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lroundl.dir/lroundl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.modf.dir/modf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.modff.dir/modff.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.modfl.dir/modfl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nan.dir/nan.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nanf.dir/nanf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nanl.dir/nanl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.nearbyint.dir/nearbyint.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.nearbyintf.dir/nearbyintf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nearbyintl.dir/nearbyintl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextafter.dir/nextafter.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextafterf.dir/nextafterf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextafterl.dir/nextafterl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextdown.dir/nextdown.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextdownf.dir/nextdownf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextdownl.dir/nextdownl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nexttoward.dir/nexttoward.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nexttowardf.dir/nexttowardf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nexttowardl.dir/nexttowardl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextup.dir/nextup.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextupf.dir/nextupf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextupl.dir/nextupl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.pow.dir/pow.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.powf.dir/powf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.powi.dir/powi.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.powif.dir/powif.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.remainder.dir/remainder.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.remainderf.dir/remainderf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remainderl.dir/remainderl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remquo.dir/remquo.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remquof.dir/remquof.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remquol.dir/remquol.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.rint.dir/rint.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.rintf.dir/rintf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.rintl.dir/rintl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.round.dir/round.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundeven.dir/roundeven.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundevenf.dir/roundevenf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundevenl.dir/roundevenl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundf.dir/roundf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.scalbln.dir/scalbln.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.scalblnf.dir/scalblnf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.scalbn.dir/scalbn.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.scalbnf.dir/scalbnf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.scalbnl.dir/scalbnl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayload.dir/setpayload.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadf.dir/setpayloadf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadl.dir/setpayloadl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsig.dir/setpayloadsig.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf.dir/setpayloadsigf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigl.dir/setpayloadsigl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sin.dir/sin.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sincos.dir/sincos.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sincosf.dir/sincosf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinf.dir/sinf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.sinh.dir/sinh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinhf.dir/sinhf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sinpif.dir/sinpif.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.sqrt.dir/sqrt.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.sqrtf.dir/sqrtf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.sqrtl.dir/sqrtl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.tan.dir/tan.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.tanf.dir/tanf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.tanh.dir/tanh.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.tanhf.dir/tanhf.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.tgamma.dir/tgamma.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.tgammaf.dir/tgammaf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalorder.dir/totalorder.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalorderf.dir/totalorderf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalordermag.dir/totalordermag.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalordermagf.dir/totalordermagf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalordermagl.dir/totalordermagl.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.trunc.dir/trunc.cpp.o libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.truncf.dir/truncf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.truncl.dir/truncl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.canonicalizef16.dir/canonicalizef16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ceilf16.dir/ceilf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.copysignf16.dir/copysignf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10f16.dir/exp10f16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2f16.dir/exp2f16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.expf16.dir/expf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16add.dir/f16add.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf.dir/f16addf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addl.dir/f16addl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16div.dir/f16div.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divf.dir/f16divf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divl.dir/f16divl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16fma.dir/f16fma.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16fmaf.dir/f16fmaf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16fmal.dir/f16fmal.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16mul.dir/f16mul.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16mulf.dir/f16mulf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16mull.dir/f16mull.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sqrt.dir/f16sqrt.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sqrtf.dir/f16sqrtf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sqrtl.dir/f16sqrtl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sub.dir/f16sub.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subf.dir/f16subf.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subl.dir/f16subl.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fabsf16.dir/fabsf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fdimf16.dir/fdimf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.floorf16.dir/floorf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaxf16.dir/fmaxf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_mag_numf16.dir/fmaximum_mag_numf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_magf16.dir/fmaximum_magf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximum_numf16.dir/fmaximum_numf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmaximumf16.dir/fmaximumf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminf16.dir/fminf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_mag_numf16.dir/fminimum_mag_numf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_magf16.dir/fminimum_magf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimum_numf16.dir/fminimum_numf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fminimumf16.dir/fminimumf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fmodf16.dir/fmodf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.frexpf16.dir/frexpf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fromfpf16.dir/fromfpf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.fromfpxf16.dir/fromfpxf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.getpayloadf16.dir/getpayloadf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ilogbf16.dir/ilogbf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ldexpf16.dir/ldexpf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llogbf16.dir/llogbf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llrintf16.dir/llrintf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.llroundf16.dir/llroundf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.logbf16.dir/logbf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lrintf16.dir/lrintf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.lroundf16.dir/lroundf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.modff16.dir/modff16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nanf16.dir/nanf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nearbyintf16.dir/nearbyintf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextafterf16.dir/nextafterf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextdownf16.dir/nextdownf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nexttowardf16.dir/nexttowardf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.nextupf16.dir/nextupf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remainderf16.dir/remainderf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.remquof16.dir/remquof16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.rintf16.dir/rintf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundevenf16.dir/roundevenf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.roundf16.dir/roundf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.scalblnf16.dir/scalblnf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.scalbnf16.dir/scalbnf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadf16.dir/setpayloadf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf16.dir/setpayloadsigf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalorderf16.dir/totalorderf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalordermagf16.dir/totalordermagf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.truncf16.dir/truncf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ufromfpf16.dir/ufromfpf16.cpp.o libc/src/math/generic/CMakeFiles/libc.src.math.generic.ufromfpxf16.dir/ufromfpxf16.cpp.o -o libc/lib/libm.bc   && :
ld.lld: error: duplicate symbol: __llvm_libc_20_0_0_git::exp_range_reduction(_Float16)
>>> defined in libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10f16.dir/exp10f16.cpp.o
>>> defined in libc/src/math/generic/CMakeFiles/libc.src.math.generic.expf16.dir/expf16.cpp.o

ld.lld: error: duplicate symbol: __llvm_libc_20_0_0_git::exp_range_reduction(_Float16)
>>> defined in libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp10f16.dir/exp10f16.cpp.o
>>> defined in libc/src/math/generic/CMakeFiles/libc.src.math.generic.exp2f16.dir/exp2f16.cpp.o
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
4.697 [0/2/646] Linking CXX static library /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/lib/amdgcn-amd-amdhsa/libm.a
6.584 [0/1/647] Linking CXX executable libc/lib/libc.bc
ninja: build stopped: subcommand failed.
FAILED: runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-build /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-build 
cd /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins && /usr/local/cmake/bin/cmake --build .
ninja: build stopped: subcommand failed.

bwendling pushed a commit to bwendling/llvm-project that referenced this pull request Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants