From 20ec3b41eef2a36523d01f80064da57535ff9408 Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Fri, 26 Sep 2025 15:06:00 +0000 Subject: [PATCH] Disable scalar BF16 operators on current GCC versions GCC >= 13 will insert a function call to the `__extendbfsf2` helper function for scalar conversions from `__bf16` to `float`. This is prohibitively expensive, so refrain from using scalar BF16 operators on these compiler versions. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121853 --- hwy/base.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hwy/base.h b/hwy/base.h index ae4f226d2b..9d66a38cbd 100644 --- a/hwy/base.h +++ b/hwy/base.h @@ -1746,7 +1746,11 @@ HWY_F16_CONSTEXPR inline std::partial_ordering operator<=>( #ifndef HWY_HAVE_SCALAR_BF16_OPERATORS // Recent enough compiler also has operators. aarch64 clang 18 hits internal // compiler errors on bf16 ToString, hence only enable on GCC for now. -#if HWY_HAVE_SCALAR_BF16_TYPE && (HWY_COMPILER_GCC_ACTUAL >= 1300) +// GCC >= 13 will insert a function call to the __extendbfsf2 helper function +// for scalar conversions from __bf16 to float. This is prohibitively expensive, +// so refrain from using scalar BF16 operators on these compiler versions. +// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121853 +#if HWY_HAVE_SCALAR_BF16_TYPE && (HWY_COMPILER_GCC_ACTUAL >= 1700) #define HWY_HAVE_SCALAR_BF16_OPERATORS 1 #else #define HWY_HAVE_SCALAR_BF16_OPERATORS 0