diff mbox

libquadmath/81848, allow PowerPC to enable libquadmath

Message ID 20170816030601.GA18844@ibm-tiger.the-meissners.org
State New
Headers show

Commit Message

Michael Meissner Aug. 16, 2017, 3:06 a.m. UTC
On Wed, Aug 16, 2017 at 01:46:12AM +0000, Joseph Myers wrote:
> ENOPATCH

2017-08-15  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR libquadmath/81848
	* configure.ac (powerpc*-linux*): Use attribute mode KC to create
	complex __float128 on PowerPC instead of attribute mode TC.
	* quadmth.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.

Comments

Michael Meissner Aug. 23, 2017, 5:30 p.m. UTC | #1
Ping:

2017-08-15  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR libquadmath/81848
	* configure.ac (powerpc*-linux*): Use attribute mode KC to create
	complex __float128 on PowerPC instead of attribute mode TC.
	* quadmth.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.

https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00977.html
Jakub Jelinek Aug. 29, 2017, 11:11 p.m. UTC | #2
On Tue, Aug 15, 2017 at 11:06:01PM -0400, Michael Meissner wrote:
> 2017-08-15  Michael Meissner  <meissner@linux.vnet.ibm.com>
> 
> 	PR libquadmath/81848
> 	* configure.ac (powerpc*-linux*): Use attribute mode KC to create
> 	complex __float128 on PowerPC instead of attribute mode TC.
> 	* quadmth.h (__complex128): Likewise.

quadmath.h ?

> 	* 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.

Does the Q suffix on ppc* imply __float128 like on x86_64 etc.?

> --- libquadmath/math/sqrtq.c	(revision 251097)
> +++ libquadmath/math/sqrtq.c	(working copy)
> @@ -31,15 +31,18 @@ sqrtq (const __float128 x)
>      return y;
>    }
>  
> -#ifdef HAVE_SQRTL
> -  if (x <= LDBL_MAX && x >= LDBL_MIN)
> +#if defined(HAVE_SQRTL)

Why the #ifdef -> #if defined change?  That looks unnecessary.

>    {
> -    /* Use long double result as starting point.  */
> -    y = sqrtl ((long double) x);
> +    long double xl = (long double)x;

Please add a space after (long double)

> +    if (xl <= LDBL_MAX && xl >= LDBL_MIN)
> +      {
> +	/* Use long double result as starting point.  */
> +	y = sqrtl (xl);
>  
> -    /* One Newton iteration.  */
> -    y -= 0.5q * (y - x / y);
> -    return y;
> +	/* One Newton iteration.  */
> +	y -= 0.5q * (y - x / y);
> +	return y;
> +      }
>    }
>  #endif
>  

Otherwise LGTM.

	Jakub
Michael Meissner Sept. 1, 2017, 8:18 p.m. UTC | #3
On Wed, Aug 30, 2017 at 01:11:51AM +0200, Jakub Jelinek wrote:
> On Tue, Aug 15, 2017 at 11:06:01PM -0400, Michael Meissner wrote:
> > 2017-08-15  Michael Meissner  <meissner@linux.vnet.ibm.com>
> > 
> > 	PR libquadmath/81848
> > 	* configure.ac (powerpc*-linux*): Use attribute mode KC to create
> > 	complex __float128 on PowerPC instead of attribute mode TC.
> > 	* quadmth.h (__complex128): Likewise.
> 
> quadmath.h ?

Yes, thanks.

> > 	* 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.
> 
> Does the Q suffix on ppc* imply __float128 like on x86_64 etc.?

Yes.

> > --- libquadmath/math/sqrtq.c	(revision 251097)
> > +++ libquadmath/math/sqrtq.c	(working copy)
> > @@ -31,15 +31,18 @@ sqrtq (const __float128 x)
> >      return y;
> >    }
> >  
> > -#ifdef HAVE_SQRTL
> > -  if (x <= LDBL_MAX && x >= LDBL_MIN)
> > +#if defined(HAVE_SQRTL)
> 
> Why the #ifdef -> #if defined change?  That looks unnecessary.

I'll change it back.

> >    {
> > -    /* Use long double result as starting point.  */
> > -    y = sqrtl ((long double) x);
> > +    long double xl = (long double)x;
> 
> Please add a space after (long double)

Ok.

> > +    if (xl <= LDBL_MAX && xl >= LDBL_MIN)
> > +      {
> > +	/* Use long double result as starting point.  */
> > +	y = sqrtl (xl);
> >  
> > -    /* One Newton iteration.  */
> > -    y -= 0.5q * (y - x / y);
> > -    return y;
> > +	/* One Newton iteration.  */
> > +	y -= 0.5q * (y - x / y);
> > +	return y;
> > +      }
> >    }
> >  #endif
> >  
> 
> Otherwise LGTM.

Thanks.
diff mbox

Patch

Index: libquadmath/configure.ac
===================================================================
--- libquadmath/configure.ac	(revision 251097)
+++ libquadmath/configure.ac	(working copy)
@@ -210,7 +210,11 @@  AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [
 
 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)
     {
Index: libquadmath/configure
===================================================================
--- libquadmath/configure	(revision 251097)
+++ libquadmath/configure	(working copy)
@@ -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)
     {
Index: libquadmath/quadmath.h
===================================================================
--- libquadmath/quadmath.h	(revision 251097)
+++ libquadmath/quadmath.h	(working copy)
@@ -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 ()
Index: libquadmath/math/cbrtq.c
===================================================================
--- libquadmath/math/cbrtq.c	(revision 251097)
+++ libquadmath/math/cbrtq.c	(working copy)
@@ -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
Index: libquadmath/math/j0q.c
===================================================================
--- libquadmath/math/j0q.c	(revision 251097)
+++ libquadmath/math/j0q.c	(working copy)
@@ -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.  */
 
Index: libquadmath/math/sqrtq.c
===================================================================
--- libquadmath/math/sqrtq.c	(revision 251097)
+++ libquadmath/math/sqrtq.c	(working copy)
@@ -31,15 +31,18 @@  sqrtq (const __float128 x)
     return y;
   }
 
-#ifdef HAVE_SQRTL
-  if (x <= LDBL_MAX && x >= LDBL_MIN)
+#if defined(HAVE_SQRTL)
   {
-    /* Use long double result as starting point.  */
-    y = sqrtl ((long double) x);
+    long double xl = (long double)x;
+    if (xl <= LDBL_MAX && xl >= LDBL_MIN)
+      {
+	/* Use long double result as starting point.  */
+	y = sqrtl (xl);
 
-    /* One Newton iteration.  */
-    y -= 0.5q * (y - x / y);
-    return y;
+	/* One Newton iteration.  */
+	y -= 0.5q * (y - x / y);
+	return y;
+      }
   }
 #endif