aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--sysdeps/powerpc/fpu/e_hypot.c94
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile5
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c19
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c26
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c33
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c19
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c26
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c33
9 files changed, 39 insertions, 232 deletions
diff --git a/ChangeLog b/ChangeLog
index d335dd173a..0b2d80ffcc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2019-07-08 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ * sysdeps/powerpc/fpu/e_hypot.c (two60, two500, two600, two1022,
+ twoM500, twoM600, two60factor, pdnum): Remove.
+ (TEST_INFO_NAN, GET_TW0_HIGH_WORD): Remove macro.
+ (__ieee754_hypot): Replace static variables with inline definition,
+ remove ununsed branches.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+ (libm-sysdep_routines): Remove e_hypot-* objects.
+ (CFLAGS-e_hypot-power7.c, CFLAGS-e_hypotf-power7.c): Remove rule.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c: Remove
+ file.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c: Likewise.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c: Likewise.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c: Likewise.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c: Likewise.
+ * sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c: Likewise.
+
* benchtests/Makefile (bench-math): Add hypot.
* benchtests/hypot-inputs: New file.
diff --git a/sysdeps/powerpc/fpu/e_hypot.c b/sysdeps/powerpc/fpu/e_hypot.c
index 039e5be430..16cc55bed9 100644
--- a/sysdeps/powerpc/fpu/e_hypot.c
+++ b/sysdeps/powerpc/fpu/e_hypot.c
@@ -22,15 +22,6 @@
#include <math-underflow.h>
#include <stdint.h>
-static const double two60 = 1.152921504606847e+18;
-static const double two500 = 3.2733906078961419e+150;
-static const double two600 = 4.149515568880993e+180;
-static const double two1022 = 4.49423283715579e+307;
-static const double twoM500 = 3.054936363499605e-151;
-static const double twoM600 = 2.4099198651028841e-181;
-static const double two60factor = 1.5592502418239997e+290;
-static const double pdnum = 2.225073858507201e-308;
-
/* __ieee754_hypot(x,y)
*
* This a FP only version without any FP->INT conversion.
@@ -39,53 +30,18 @@ static const double pdnum = 2.225073858507201e-308;
* is needed.
*/
-#ifdef _ARCH_PWR7
-/* POWER7 isinf and isnan optimization are fast. */
-# define TEST_INF_NAN(x, y) \
- if ((isinf(x) || isinf(y)) \
- && !issignaling (x) && !issignaling (y)) \
- return INFINITY; \
- if (isnan(x) || isnan(y)) \
- return x + y;
-# else
-/* For POWER6 and below isinf/isnan triggers LHS and PLT calls are
- * costly (especially for POWER6). */
-# define GET_TW0_HIGH_WORD(d1,d2,i1,i2) \
- do { \
- ieee_double_shape_type gh_u1; \
- ieee_double_shape_type gh_u2; \
- gh_u1.value = (d1); \
- gh_u2.value = (d2); \
- (i1) = gh_u1.parts.msw & 0x7fffffff; \
- (i2) = gh_u2.parts.msw & 0x7fffffff; \
- } while (0)
-
-# define TEST_INF_NAN(x, y) \
- do { \
- uint32_t hx, hy; \
- GET_TW0_HIGH_WORD(x, y, hx, hy); \
- if (hy > hx) { \
- uint32_t ht = hx; hx = hy; hy = ht; \
- } \
- if (hx >= 0x7ff00000) { \
- if ((hx == 0x7ff00000 || hy == 0x7ff00000) \
- && !issignaling (x) && !issignaling (y)) \
- return INFINITY; \
- return x + y; \
- } \
- } while (0)
-
-#endif
-
-
double
__ieee754_hypot (double x, double y)
{
+ if ((isinf (x) || isinf (y))
+ && !issignaling (x) && !issignaling (y))
+ return INFINITY;
+ if (isnan (x) || isnan (y))
+ return x + y;
+
x = fabs (x);
y = fabs (y);
- TEST_INF_NAN (x, y);
-
if (y > x)
{
double t = x;
@@ -94,40 +50,34 @@ __ieee754_hypot (double x, double y)
}
if (y == 0.0)
return x;
+
/* if y is higher enough, y * 2^60 might overflow. The tests if
y >= 1.7976931348623157e+308/2^60 (two60factor) and uses the
appropriate check to avoid the overflow exception generation. */
- if (y > two60factor)
- {
- if ((x / y) > two60)
- return x + y;
- }
- else
- {
- if (x > (y * two60))
- return x + y;
- }
- if (x > two500)
+ if (y <= 0x1.fffffffffffffp+963 && x > (y * 0x1p+60))
+ return x + y;
+
+ if (x > 0x1p+500)
{
- x *= twoM600;
- y *= twoM600;
- return sqrt (x * x + y * y) / twoM600;
+ x *= 0x1p-600;
+ y *= 0x1p-600;
+ return sqrt (x * x + y * y) / 0x1p-600;
}
- if (y < twoM500)
+ if (y < 0x1p-500)
{
- if (y <= pdnum)
+ if (y <= 0x0.fffffffffffffp-1022)
{
- x *= two1022;
- y *= two1022;
- double ret = sqrt (x * x + y * y) / two1022;
+ x *= 0x1p+1022;
+ y *= 0x1p+1022;
+ double ret = sqrt (x * x + y * y) / 0x1p+1022;
math_check_force_underflow_nonneg (ret);
return ret;
}
else
{
- x *= two600;
- y *= two600;
- return sqrt (x * x + y * y) / two600;
+ x *= 0x1p+600;
+ y *= 0x1p+600;
+ return sqrt (x * x + y * y) / 0x1p+600;
}
}
return sqrt (x * x + y * y);
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
index 118865a1a9..534d5a7133 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
@@ -8,8 +8,7 @@ sysdep_calls := s_modf-power5+ s_modf-ppc64 \
sysdep_routines += $(sysdep_calls)
libm-sysdep_routines += s_logb-power7 s_logbf-power7 \
s_logbl-power7 s_logb-ppc64 s_logbf-ppc64 \
- s_logbl-ppc64 e_hypot-ppc64 \
- e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
+ s_logbl-ppc64 \
$(sysdep_calls:s_%=m_%)
CFLAGS-s_logbf-power7.c = -mcpu=power7
@@ -17,8 +16,6 @@ CFLAGS-s_logbl-power7.c = -mcpu=power7
CFLAGS-s_logb-power7.c = -mcpu=power7
CFLAGS-s_modf-power5+.c = -mcpu=power5+
CFLAGS-s_modff-power5+.c = -mcpu=power5+
-CFLAGS-e_hypot-power7.c = -mcpu=power7
-CFLAGS-e_hypotf-power7.c = -mcpu=power7
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
deleted file mode 100644
index 69818d8438..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ieee_hypot() POWER7 version.
- Copyright (C) 2013-2019 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 <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypot-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
deleted file mode 100644
index da1e80f0d6..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot-ppc64.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ieee_hypot() PowerPC64 version.
- Copyright (C) 2013-2019 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 <math.h>
-
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __ieee754_hypot __ieee754_hypot_ppc64
-
-#include <sysdeps/powerpc/fpu/e_hypot.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
deleted file mode 100644
index 3bd04e9517..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypot.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Multiple versions of ieee754_hypot.
- Copyright (C) 2013-2019 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 <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__ieee754_hypot) __ieee754_hypot_ppc64 attribute_hidden;
-extern __typeof (__ieee754_hypot) __ieee754_hypot_power7 attribute_hidden;
-
-libc_ifunc (__ieee754_hypot,
- (hwcap & PPC_FEATURE_ARCH_2_06)
- ? __ieee754_hypot_power7
- : __ieee754_hypot_ppc64);
-
-strong_alias (__ieee754_hypot, __hypot_finite)
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
deleted file mode 100644
index 223947a617..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-power7.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ieee_hypotf() POWER7 version.
- Copyright (C) 2013-2019 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 <sysdeps/powerpc/powerpc32/power4/fpu/multiarch/e_hypotf-power7.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
deleted file mode 100644
index 6d5d54bb79..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf-ppc64.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ieee_hypot() PowerPC64 version.
- Copyright (C) 2013-2019 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 <math.h>
-
-#undef strong_alias
-#define strong_alias(a, b)
-
-#define __ieee754_hypotf __ieee754_hypotf_ppc64
-
-#include <sysdeps/powerpc/fpu/e_hypotf.c>
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c
deleted file mode 100644
index 02c0ab497f..0000000000
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_hypotf.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Multiple versions of ieee754_hypot.
- Copyright (C) 2013-2019 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 <math.h>
-#include <math_private.h>
-#include <math_ldbl_opt.h>
-#include <shlib-compat.h>
-#include "init-arch.h"
-
-extern __typeof (__ieee754_hypotf) __ieee754_hypotf_ppc64 attribute_hidden;
-extern __typeof (__ieee754_hypotf) __ieee754_hypotf_power7 attribute_hidden;
-
-libc_ifunc (__ieee754_hypotf,
- (hwcap & PPC_FEATURE_ARCH_2_06)
- ? __ieee754_hypotf_power7
- : __ieee754_hypotf_ppc64);
-
-strong_alias (__ieee754_hypotf, __hypotf_finite)