[libc-commits] [libc] [libc][FPUtil] Make hardware helpers usable in constant expressions (PR #242283)

via libc-commits libc-commits at lists.llvm.org
Sun Nov 15 03:20:03 PST 2026


================
@@ -89,6 +70,59 @@ LIBC_INLINE constexpr double nearest_integer(double x) {
   return x;
 }
 
+} // namespace generic
+} // namespace fputil
+} // namespace LIBC_NAMESPACE_DECL
+
+// The target specific headers below define fputil::nearest_integer using the
+// rounding instructions of the target, and dispatch to generic::nearest_integer
+// during constant evaluation.
+#if (defined(LIBC_TARGET_ARCH_IS_X86_64) &&                                    \
+     defined(LIBC_TARGET_CPU_HAS_SSE4_2)) &&                                   \
+    !defined(LIBC_USE_CONSTEXPR)
----------------
linisha15 wrote:

removed the guards from the x86_64, aarch64 and GPU branches, each already dispatches to generic::nearest_integer during constant evaluation.

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


More information about the libc-commits mailing list