From: Michael Meissner Date: Fri, 1 Sep 2017 22:10:57 +0000 (+0000) Subject: re PR libquadmath/81848 (Add PowerPC support to libquadmath) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c949f0a1ce9cfa8c48e62628493140d60e65ea7;p=gcc.git re PR libquadmath/81848 (Add PowerPC support to libquadmath) 2017-09-01 Michael Meissner PR libquadmath/81848 * configure.ac (powerpc*-linux*): Use attribute mode KC to create complex __float128 on PowerPC instead of attribute mode TC. * quadmath.h (__complex128): Likewise. * configure: Regenerate. * math/cbrtq.c (CBRT2): Use __float128 not long double. (CBRT4): Likewise. (CBRT2I): Likewise. (CBRT4I): Likewise. * math/j0q.c (U0): Likewise. * math/sqrtq.c (sqrtq): Don't depend on implicit conversion between __float128, instead explicitly convert the __float128 value to long double because the PowerPC does not allow __float128 and long double in the same expression. From-SVN: r251613 --- diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog index bc37c3f66ba..c897d33a2bc 100644 --- a/libquadmath/ChangeLog +++ b/libquadmath/ChangeLog @@ -1,3 +1,20 @@ +2017-09-01 Michael Meissner + + PR libquadmath/81848 + * configure.ac (powerpc*-linux*): Use attribute mode KC to create + complex __float128 on PowerPC instead of attribute mode TC. + * quadmath.h (__complex128): Likewise. + * configure: Regenerate. + * math/cbrtq.c (CBRT2): Use __float128 not long double. + (CBRT4): Likewise. + (CBRT2I): Likewise. + (CBRT4I): Likewise. + * math/j0q.c (U0): Likewise. + * math/sqrtq.c (sqrtq): Don't depend on implicit conversion + between __float128, instead explicitly convert the __float128 + value to long double because the PowerPC does not allow __float128 + and long double in the same expression. + 2017-07-19 Gerald Pfeifer * math/powq.c (powq): Use uint32_t instead of u_int32_t. diff --git a/libquadmath/configure b/libquadmath/configure index d2f13bf7751..b1dc7f38537 100755 --- a/libquadmath/configure +++ b/libquadmath/configure @@ -12516,7 +12516,11 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif __float128 foo (__float128 x) { @@ -12563,7 +12567,11 @@ fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif __float128 foo (__float128 x) { diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac index 41fbe1259ee..4226524caf8 100644 --- a/libquadmath/configure.ac +++ b/libquadmath/configure.ac @@ -210,7 +210,11 @@ AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun]) AC_CACHE_CHECK([whether __float128 is supported], [libquad_cv_have_float128], [GCC_TRY_COMPILE_OR_LINK([ + #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) typedef _Complex float __attribute__((mode(TC))) __complex128; + #else + typedef _Complex float __attribute__((mode(KC))) __complex128; + #endif __float128 foo (__float128 x) { diff --git a/libquadmath/math/cbrtq.c b/libquadmath/math/cbrtq.c index 2567d4d5bd3..a7a36f953cd 100644 --- a/libquadmath/math/cbrtq.c +++ b/libquadmath/math/cbrtq.c @@ -56,10 +56,10 @@ Adapted for glibc October, 2001. #include "quadmath-imp.h" -static const long double CBRT2 = 1.259921049894873164767210607278228350570251Q; -static const long double CBRT4 = 1.587401051968199474751705639272308260391493Q; -static const long double CBRT2I = 0.7937005259840997373758528196361541301957467Q; -static const long double CBRT4I = 0.6299605249474365823836053036391141752851257Q; +static const __float128 CBRT2 = 1.259921049894873164767210607278228350570251Q; +static const __float128 CBRT4 = 1.587401051968199474751705639272308260391493Q; +static const __float128 CBRT2I = 0.7937005259840997373758528196361541301957467Q; +static const __float128 CBRT4I = 0.6299605249474365823836053036391141752851257Q; __float128 diff --git a/libquadmath/math/j0q.c b/libquadmath/math/j0q.c index c6e482b1c51..2dc93d5292f 100644 --- a/libquadmath/math/j0q.c +++ b/libquadmath/math/j0q.c @@ -816,7 +816,7 @@ static __float128 Y0_2D[NY0_2D + 1] = { /* 1.000000000000000000000000000000000000000E0 */ }; -static const long double U0 = -7.3804295108687225274343927948483016310862e-02Q; +static const __float128 U0 = -7.3804295108687225274343927948483016310862e-02Q; /* Bessel function of the second kind, order zero. */ diff --git a/libquadmath/math/sqrtq.c b/libquadmath/math/sqrtq.c index f63c0d1f6d2..56ea5d3243c 100644 --- a/libquadmath/math/sqrtq.c +++ b/libquadmath/math/sqrtq.c @@ -32,14 +32,17 @@ sqrtq (const __float128 x) } #ifdef HAVE_SQRTL - if (x <= LDBL_MAX && x >= LDBL_MIN) { - /* Use long double result as starting point. */ - y = sqrtl ((long double) x); - - /* One Newton iteration. */ - y -= 0.5q * (y - x / y); - return y; + long double xl = (long double) x; + if (xl <= LDBL_MAX && xl >= LDBL_MIN) + { + /* Use long double result as starting point. */ + y = (__float128) sqrtl (xl); + + /* One Newton iteration. */ + y -= 0.5q * (y - x / y); + return y; + } } #endif diff --git a/libquadmath/quadmath.h b/libquadmath/quadmath.h index 1555304c7f9..95487b7d6ef 100644 --- a/libquadmath/quadmath.h +++ b/libquadmath/quadmath.h @@ -29,7 +29,11 @@ extern "C" { /* Define the complex type corresponding to __float128 ("_Complex __float128" is not allowed) */ +#if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__) typedef _Complex float __attribute__((mode(TC))) __complex128; +#else +typedef _Complex float __attribute__((mode(KC))) __complex128; +#endif #ifdef __cplusplus # define __quadmath_throw throw ()