1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Remove SPARC sqrt wrappers (bug 21973).

This 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 8847f03770
Author: David S. Miller <davem@davemloft.net>
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.

	[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.
This commit is contained in:
Joseph Myers
2017-08-21 17:46:34 +00:00
parent 813378e9fe
commit 831bbd5527
13 changed files with 19 additions and 430 deletions

View File

@ -1,5 +1,23 @@
2017-08-21 Joseph Myers <joseph@codesourcery.com>
[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.
* math/math.h [__USE_MISC] (_LIB_VERSION_TYPE): Remove.
[__USE_MISC] (_LIB_VERSION): Likewise.
[__USE_MISC] (struct exception): Likewise.

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -1,12 +0,0 @@
#include <sparc-ifunc.h>
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"

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -1,12 +0,0 @@
#include <sparc-ifunc.h>
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"

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math-svid-compat.h>
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)

View File

@ -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