From efeb2bd1ab49215325040aa53396a2c19dfd1402 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 1 Apr 2022 10:19:57 -0300 Subject: math: Add math-use-builtins-fabs (BZ#29027) Both float, double, and _Float128 are assumed to be supported (float and double already only uses builtins). Only long double is parametrized due GCC bug 29253 which prevents its usage on powerpc. It allows to remove i686, ia64, x86_64, powerpc, and sparc arch specific implementation. On ia64 it also fixes the sNAN handling: math/test-float64x-fabs math/test-ldouble-fabs Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, powerpc64-linux-gnu, sparc64-linux-gnu, and ia64-linux-gnu. --- sysdeps/powerpc/fpu/math-use-builtins-fabs.h | 8 +++++ sysdeps/powerpc/powerpc32/fpu/s_fabsl.S | 52 ---------------------------- sysdeps/powerpc/powerpc64/fpu/s_fabsl.S | 34 ------------------ 3 files changed, 8 insertions(+), 86 deletions(-) create mode 100644 sysdeps/powerpc/fpu/math-use-builtins-fabs.h delete mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fabsl.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fabsl.S (limited to 'sysdeps/powerpc') diff --git a/sysdeps/powerpc/fpu/math-use-builtins-fabs.h b/sysdeps/powerpc/fpu/math-use-builtins-fabs.h new file mode 100644 index 0000000000..8976d0b956 --- /dev/null +++ b/sysdeps/powerpc/fpu/math-use-builtins-fabs.h @@ -0,0 +1,8 @@ +/* Generic implementations already assume builtin support for + float, double, and _Float128 . */ + +/* We can't enable it for long double due GCC Bugzilla Bug 29253 + "expand_abs wrong default code for floating point" where it can + cause spurious "invalid" exceptions from comparisons with NaN in + the code sequence generated. */ +#define USE_FABSL_BUILTIN 0 diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S b/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S deleted file mode 100644 index 8bdcdc8cfb..0000000000 --- a/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S +++ /dev/null @@ -1,52 +0,0 @@ -/* Copy a sign bit between floating-point values. - IBM extended format long double version. - Copyright (C) 2004-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY(__fabsl) -/* long double [f1,f2] fabs (long double [f1,f2] x); - fabs(x,y) returns a value with the magnitude of x and - with the sign bit of y. */ -#ifdef _ARCH_PPCGR - /* fsel available. */ - fmr fp0,fp1 -#else - /* Use integer operations to test sign of high part to avoid - exceptions on sNaNs. */ - stwu r1,-16(r1) - cfi_adjust_cfa_offset (16) - stfd fp1,8(r1) -#endif - fabs fp1,fp1 -#ifdef _ARCH_PPCGR - fneg fp3,fp2 - fsel fp2,fp0,fp2,fp3 -#else - lwz r3,8+HIWORD(r1) - cmpwi cr6,r3,0 - addi r1,r1,16 - cfi_adjust_cfa_offset (-16) - bgelr cr6 - fneg fp2,fp2 -#endif - blr -END (__fabsl) - -long_double_symbol (libm, __fabsl, fabsl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S b/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S deleted file mode 100644 index ec796a1cd3..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S +++ /dev/null @@ -1,34 +0,0 @@ -/* Copy a sign bit between floating-point values. - IBM extended format long double version. - Copyright (C) 2004-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY_TOCLESS (__fabsl) -/* long double [f1,f2] fabs (long double [f1,f2] x); - fabs(x,y) returns a value with the magnitude of x and - with the sign bit of y. */ - fmr fp0,fp1 - fabs fp1,fp1 - fneg fp3,fp2 - fsel fp2,fp0,fp2,fp3 - blr -END (__fabsl) - -long_double_symbol (libm, __fabsl, fabsl) -- cgit 1.4.1