From patchwork Fri Aug 18 17:13:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 22223 Received: (qmail 67847 invoked by alias); 18 Aug 2017 17:13:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 66755 invoked by uid 89); 18 Aug 2017 17:13:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=1377, unnecessarily, Remark X-HELO: relay1.mentorg.com Date: Fri, 18 Aug 2017 17:13:09 +0000 From: Joseph Myers To: CC: Subject: Remove SPARC sqrt wrappers (bug 21973) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) This patch, relative to a tree with applied (but with no essential dependence on that patch), removes the SPARC-specific wrappers for sqrt and sqrtf. These wrappers, by adding architecture-specific uses of _LIB_VERSION and __kernel_standard, unnecessarily complicate cleanups of libm error handling. They also do not serve a useful optimization purpose. GCC knows about sqrt as a built-in function, and can generate direct calls to a hardware square root instruction, either on its own, in the -fno-math-errno case, or together with an inline check for the argument being negative and a call to the out-of-line sqrt function for error handling only in that case (and has been able to do so for a long time). Thus in practice the wrapper will only be called only in the case of negative arguments, which is not a case it is useful to optimize for. The removal of the wrappers also uncovers, and fixes, an old bug. 32-bit SPARC libm used (checked with glibc 2.8 binaries) to have a sqrtl compat symbol, version GLIBC_2.0, for old binaries when sqrtl was an alias of sqrt (I don't have pre-glibc-2.4 binaries for SPARC to hand to check for the sqrtl symbol in those). This disappeared, probably with: commit 8847f0377003fbfe9cbe951ce9f8717d74f26247 Author: David S. Miller Date: Tue Feb 28 22:37:58 2012 -0800 Add sparc optimized sqrt{,f}. Removing the wrappers brings back the generic ldbl-opt logic for creating such compat symbols, and so restores the compat symbol that should be there. This could of course also be fixed in the wrappers - but as noted above, the wrappers are optimizing a case it's not useful to optimize, so the bug of the missing compat symbol serves to illustrate the risks involved with the extra complexity of architecture-specific function versions where not needed. Tested with build-many-glibcs.py. (Remark: it would be reasonable to add e_sqrt.c for sparc64, and e_sqrtf.c for sparc32 and sparc64, so that the software sqrt/sqrtf implementations don't get built into libm, but that's more a matter of code size reduction than of improving speed for any likely use case.) 2017-08-18 Joseph Myers [BZ #21973] * sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Remove file. * sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S : Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise. * sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Add GLIBC_2.0 sqrtl symbol. diff --git a/sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S b/sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S deleted file mode 100644 index cca7654..0000000 --- a/sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S +++ /dev/null @@ -1,54 +0,0 @@ -/* sqrt function. sparc32 version. - Copyright (C) 2012-2017 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 (__sqrt) - clr %g1 - std %g0, [%sp + 72] - std %o0, [%sp + 80] - ldd [%sp + 72], %f8 - ldd [%sp + 80], %f0 - fcmpd %f0, %f8 - fbl 1f - nop -8: retl - fsqrtd %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o2 - mov %o1, %o3 - mov 26, %o4 - mov %o7, %g1 - call __kernel_standard - mov %g1, %o7 -END (__sqrt) - -weak_alias (__sqrt, sqrt) diff --git a/sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S b/sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S deleted file mode 100644 index 34f6113..0000000 --- a/sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S +++ /dev/null @@ -1,52 +0,0 @@ -/* sqrtf function. sparc32 version. - Copyright (C) 2012-2017 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 (__sqrtf) - st %g0, [%sp + 68] - st %o0, [%sp + 72] - ld [%sp + 68], %f8 - ld [%sp + 72], %f0 - fcmps %f0, %f8 - fbl 1f - nop -8: retl - fsqrts %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o1 - mov 126, %o2 - mov %o7, %g1 - call __kernel_standard_f - mov %g1, %o7 -END (__sqrtf) - -weak_alias (__sqrtf, sqrtf) diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile index 322e300..2a2d374 100644 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile +++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile @@ -3,7 +3,6 @@ ifeq ($(have-as-vis3),yes) libm-sysdep_routines += m_copysignf-vis3 m_copysign-vis3 s_fabs-vis3 \ s_fabsf-vis3 s_llrintf-vis3 s_llrint-vis3 \ s_rintf-vis3 s_rint-vis3 \ - w_sqrt_compat-vis3 w_sqrtf_compat-vis3 \ s_fmaf-vis3 s_fma-vis3 s_nearbyint-vis3 \ s_nearbyintf-vis3 s_fdimf-vis3 s_fdim-vis3 sysdep_routines += s_copysignf-vis3 s_copysign-vis3 diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S deleted file mode 100644 index a3a642f..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S +++ /dev/null @@ -1,50 +0,0 @@ -/* sqrt function. sparc32 v9 vis3 version. - Copyright (C) 2012-2017 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 (__sqrt_vis3) - movwtos %o0, %f0 - fzero %f8 - movwtos %o1, %f1 - fcmpd %f0, %f8 - fbl 1f - nop -8: retl - fsqrtd %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o2 - mov %o1, %o3 - mov 26, %o4 - mov %o7, %g1 - call __kernel_standard - mov %g1, %o7 -END (__sqrt_vis3) diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat.S deleted file mode 100644 index 1ccac19..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat.S +++ /dev/null @@ -1,12 +0,0 @@ -#include - -SPARC_ASM_VIS3_IFUNC(sqrt) - -weak_alias (__sqrt, sqrt) - -# undef weak_alias -# define weak_alias(a, b) - -#define __sqrt __sqrt_generic - -#include "../w_sqrt_compat.S" diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S deleted file mode 100644 index 8cd1607..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S +++ /dev/null @@ -1,48 +0,0 @@ -/* sqrtf function. sparc32 v9 vis3 version. - Copyright (C) 2012-2017 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 (__sqrtf_vis3) - movwtos %o0, %f0 - fzeros %f8 - fcmps %f0, %f8 - fbl 1f - nop -8: retl - fsqrts %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o1 - mov 126, %o2 - mov %o7, %g1 - call __kernel_standard_f - mov %g1, %o7 -END (__sqrtf_vis3) diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat.S deleted file mode 100644 index f0e759a..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat.S +++ /dev/null @@ -1,12 +0,0 @@ -#include - -SPARC_ASM_VIS3_IFUNC(sqrtf) - -weak_alias (__sqrtf, sqrtf) - -# undef weak_alias -# define weak_alias(a, b) - -#define __sqrtf __sqrtf_generic - -#include "../w_sqrtf_compat.S" diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S b/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S deleted file mode 100644 index f3003da..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S +++ /dev/null @@ -1,52 +0,0 @@ -/* sqrt function. sparc32 v9 version. - Copyright (C) 2012-2017 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 (__sqrt) - std %o0, [%sp + 80] - fzero %f8 - ldd [%sp + 80], %f0 - fcmpd %f0, %f8 - fbl 1f - nop -8: retl - fsqrtd %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o2 - mov %o1, %o3 - mov 26, %o4 - mov %o7, %g1 - call __kernel_standard - mov %g1, %o7 -END (__sqrt) - -weak_alias (__sqrt, sqrt) diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S b/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S deleted file mode 100644 index 7a102de..0000000 --- a/sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S +++ /dev/null @@ -1,51 +0,0 @@ -/* sqrtf function. sparc32 v9 version. - Copyright (C) 2012-2017 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 (__sqrtf) - st %o0, [%sp + 72] - fzeros %f8 - ld [%sp + 72], %f0 - fcmps %f0, %f8 - fbl 1f - nop -8: retl - fsqrts %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ld [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be 8b - mov %o0, %o1 - mov 126, %o2 - mov %o7, %g1 - call __kernel_standard_f - mov %g1, %o7 -END (__sqrtf) - -weak_alias (__sqrtf, sqrtf) diff --git a/sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S b/sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S deleted file mode 100644 index 937e150..0000000 --- a/sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S +++ /dev/null @@ -1,49 +0,0 @@ -/* sqrt function. sparc64 version. - Copyright (C) 2012-2017 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 (__sqrt) - fzero %f8 - fcmpd %fcc2, %f0, %f8 - fbl,pn %fcc2, 1f - nop -8: retl - fsqrtd %f0, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ldx [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be,pt %icc, 8b - fmovd %f0, %f2 - mov 26, %o2 - mov %o7, %g1 - call __kernel_standard - mov %g1, %o7 -END (__sqrt) - -weak_alias (__sqrt, sqrt) diff --git a/sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S b/sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S deleted file mode 100644 index 875ed3b..0000000 --- a/sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S +++ /dev/null @@ -1,49 +0,0 @@ -/* sqrtf function. sparc64 version. - Copyright (C) 2012-2017 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 (__sqrtf) - fzeros %f8 - fcmps %fcc2, %f1, %f8 - fbl,pn %fcc2, 1f - nop -8: retl - fsqrts %f1, %f0 -1: -#ifdef SHARED - SETUP_PIC_REG_LEAF(o5, g1) - sethi %gdop_hix22(_LIB_VERSION), %g1 - xor %g1, %gdop_lox10(_LIB_VERSION), %g1 - ldx [%o5 + %g1], %g1, %gdop(_LIB_VERSION) -#else - sethi %hi(_LIB_VERSION), %g1 - or %g1, %lo(_LIB_VERSION), %g1 -#endif - ld [%g1], %g1 - cmp %g1, -1 - be,pt %icc, 8b - fmovs %f1, %f3 - mov 126, %o2 - mov %o7, %g1 - call __kernel_standard_f - mov %g1, %o7 -END (__sqrtf) - -weak_alias (__sqrtf, sqrtf) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist index f73af6f..61042ba 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist @@ -137,6 +137,7 @@ GLIBC_2.0 sinhl F GLIBC_2.0 sinl F GLIBC_2.0 sqrt F GLIBC_2.0 sqrtf F +GLIBC_2.0 sqrtl F GLIBC_2.0 tan F GLIBC_2.0 tanf F GLIBC_2.0 tanh F