From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id E6796385828E; Fri, 17 Feb 2023 19:39:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6796385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676662787; bh=rHpAIl1FSJf+oMF/uUee+MiEAVef3zJ6IFJUuC6UyHk=; h=From:To:Subject:Date:From; b=F8fup4kwC8JYUe8bKzvHdcWEt8ndeZnN2wIBuK35/KlwZyrbkjQzvpEYXWXjSefLY doQzWTt/yYDYrSmoeZaPxNyoN/QXL2b/v3gC512OXfey6/+VLuk8RBgaKcgtZBSDCT XBQI08ZsfkII3SuvKJ2dq4aCSAbA+uEn7E+S7Umw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] ARC:fpu: add extra capability check before use of sqrt and fma builtins X-Act-Checkin: glibc X-Git-Author: Pavel Kozlov X-Git-Refname: refs/heads/master X-Git-Oldrev: 87abcf9a6e34d64f556b0b9d3ccd2689b2c2e0b6 X-Git-Newrev: dab63442791e334d592ce91827ffa9d14ca92ea9 Message-Id: <20230217193947.E6796385828E@sourceware.org> Date: Fri, 17 Feb 2023 19:39:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dab63442791e334d592ce91827ffa9d14ca92ea9 commit dab63442791e334d592ce91827ffa9d14ca92ea9 Author: Pavel Kozlov Date: Tue Jan 17 16:12:23 2023 +0400 ARC:fpu: add extra capability check before use of sqrt and fma builtins Add extra check for compiler definitions to ensure that compiler provides sqrt and fma hw fpu instructions else use software implementation. As divide/sqrt and FMA hw support from CPU side is optional, the compiler can be configured by options to generate hw FPU instructions, but without use of FDDIV, FDSQRT, FSDIV, FSSQRT, FDMADD and FSMADD instructions. In this case __builtin_sqrt and __builtin_sqrtf provided by compiler can't be used inside the glibc code, as these builtins are used in implementations of sqrt() and sqrtf() functions but at the same time these builtins unfold to sqrt() and sqrtf(). So it is possible to receive code like that: 0001c4b4 <__ieee754_sqrtf>: 1c4b4: 0001 0000 b 0 ;1c4b4 <__ieee754_sqrtf> The same is also true for __builtin_fma and __builtin_fmaf. Reviewed-by: Adhemerval Zanella Diff: --- sysdeps/arc/fpu/math-use-builtins-fma.h | 14 ++++++++++++-- sysdeps/arc/fpu/math-use-builtins-sqrt.h | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sysdeps/arc/fpu/math-use-builtins-fma.h b/sysdeps/arc/fpu/math-use-builtins-fma.h index eede75aa41..2acd8113ce 100644 --- a/sysdeps/arc/fpu/math-use-builtins-fma.h +++ b/sysdeps/arc/fpu/math-use-builtins-fma.h @@ -1,4 +1,14 @@ -#define USE_FMA_BUILTIN 1 -#define USE_FMAF_BUILTIN 1 +#if defined __ARC_FPU_DP_FMA__ +# define USE_FMA_BUILTIN 1 +#else +# define USE_FMA_BUILTIN 0 +#endif + +#if defined __ARC_FPU_SP_FMA__ +# define USE_FMAF_BUILTIN 1 +#else +# define USE_FMAF_BUILTIN 0 +#endif + #define USE_FMAL_BUILTIN 0 #define USE_FMAF128_BUILTIN 0 diff --git a/sysdeps/arc/fpu/math-use-builtins-sqrt.h b/sysdeps/arc/fpu/math-use-builtins-sqrt.h index e94c915ba6..a449bc6092 100644 --- a/sysdeps/arc/fpu/math-use-builtins-sqrt.h +++ b/sysdeps/arc/fpu/math-use-builtins-sqrt.h @@ -1,4 +1,14 @@ -#define USE_SQRT_BUILTIN 1 -#define USE_SQRTF_BUILTIN 1 +#if defined __ARC_FPU_DP_DIV__ +# define USE_SQRT_BUILTIN 1 +#else +# define USE_SQRT_BUILTIN 0 +#endif + +#if defined __ARC_FPU_SP_DIV__ +# define USE_SQRTF_BUILTIN 1 +#else +# define USE_SQRTF_BUILTIN 0 +#endif + #define USE_SQRTL_BUILTIN 0 #define USE_SQRTF128_BUILTIN 0