public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] PowerPC: Fix up tests for IEEE 128-bit long double
@ 2021-01-15  3:37 Michael Meissner
  2021-01-15  3:39 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Michael Meissner @ 2021-01-15  3:37 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

In November, I submitted a patch to fix up some of the tests for when IEEE
128-bit is used as the long double format.  Segher had some suggestions.  These
patches are based on those suggestions:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559836.html

These patches add several more selections to target-supports.exp:

    *	3 selections for the current long double format;
    *	3 selections if we can change the long double format to a particular
	value.
    *	3 functions to return the options needed to switch the long double
	format for use with dg-add-options.

And there are the 2 tests (pr70117, convert-bfp-11.c) that need to be
configured run with IBM 128-bit long double because the test itself was written
knowing about the format of IBM 128-bit floating point.

I have run tests on a little endian power9 system with 3 compilers:
    *	One compiler using the default IBM 128-bit format;
    *	One compiler using the IEEE 128-bit format; (and)
    *	One compiler using 64-bit long doubles.

I have also tested compilers on a big endian power8 system with a compiler
defaulting to power8 code generation and another with the default cpu set.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] PowerPC: Add long double target-supports.
  2021-01-15  3:37 [PATCH 0/3] PowerPC: Fix up tests for IEEE 128-bit long double Michael Meissner
@ 2021-01-15  3:39 ` Michael Meissner
  2021-01-15 18:16   ` Joseph Myers
  2021-01-15  3:40 ` [PATCH 2/3] PowerPC: PR target/70117, Force long double to be IBM 128-bit Michael Meissner
  2021-01-15  3:41 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner
  2 siblings, 1 reply; 12+ messages in thread
From: Michael Meissner @ 2021-01-15  3:39 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

[PATCH 1/3] PowerPC: Add long double target-supports.

This patch add several more selections to target-supports.exp:

    *	3 selections for the current long double format;
    *	3 selections if we can change the long double format to a particular
	value.
    *	3 functions to return the options needed to switch the long double
	format for use with dg-add-options.

I have run tests on a little endian power9 system with 3 compilers:
    *	One compiler using the default IBM 128-bit format;
    *	One compiler using the IEEE 128-bit format; (and)
    *	One compiler using 64-bit long doubles.

I have also tested compilers on a big endian power8 system with a compiler
defaulting to power8 code generation and another with the default cpu set.

Can I check this patch into the master branch?

gcc/testsuite/
2021-01-14  Michael Meissner  <meissner@linux.ibm.com>

	* lib/target-supports.exp
	(check_effective_target_ppc_long_double_ibm128): New function.
	(check_effective_target_ppc_long_double_ieee128): New function.
	(check_effective_target_ppc_long_double_64bit): New function.
	(add_options_for_ppc_long_double_override_ibm128): New function.
	(check_effective_target_ppc_long_double_override_ibm128): New
	function.
	(add_options_for_ppc_long_double_override_ieee128): New function.
	(check_effective_target_ppc_long_double_override_ieee128): New
	function.
	(add_options_for_ppc_long_double_override_64bit): New function.
	(check_effective_target_ppc_long_double_override_64bit): New
	function.
---
 gcc/testsuite/lib/target-supports.exp | 155 ++++++++++++++++++++++++++
 1 file changed, 155 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 47d4c45e9eb..2badb495adc 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2354,6 +2354,161 @@ proc check_effective_target_ppc_ieee128_ok { } {
     }]
 }
 
+# See if the target is a powerpc with the long double format that uses the IBM
+# extended double format.
+
+proc check_effective_target_ppc_long_double_ibm128 { } {
+    return [check_cached_effective_target ppc_long_double_ibm {
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+	    return 1;
+	  #else
+	    return 0;
+	  #endif
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that uses the IEEE
+# 128-bit format.
+
+proc check_effective_target_ppc_long_double_ieee128 { } {
+    return [check_cached_effective_target ppc_long_double_ieee {
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+	    return 1;
+	  #else
+	    return 0;
+	  #endif
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that is 64-bit.
+
+proc check_effective_target_ppc_long_double_64bit { } {
+    return [check_cached_effective_target ppc_long_double_64bit {
+	int main()
+	{
+	  #ifndef _ARCH_PPC
+	    return 1;
+	  #else
+	    return sizeof (long double) != 8;
+	  #endif
+	}
+    }]
+}
+
+# Like check_effective_target_ppc_long_double_ibm128, but check if we can
+# explicitly override the long double format to use the IBM 128-bit extended
+# double format, and GLIBC supports doing this override by switching the
+# sprintf to handle long double.
+
+proc add_options_for_ppc_long_double_override_ibm128 { flags } {
+    if { [istarget powerpc*-*-*] } {
+	return "$flags -mlong-double-128 -Wno-psabi -mabi=ibmlongdouble"
+    }
+    return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_ibm128 { } {
+    return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {
+	#include <string.h>
+	#include <stdio.h>
+	volatile __ibm128 a = (__ibm128) 3.0;
+	volatile long double one = 1.0L;
+	volatile long double two = 2.0L;
+	volatile long double b;
+	char buffer[20];
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+	    return 1;
+	  #else
+	    b = one + two;
+	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+	      return 1;
+	    sprintf (buffer, "%lg", b);
+	    return strcmp (buffer, "3") != 0;
+	  #endif
+	}
+    } [add_options_for_ppc_long_double_override_ibm128 ""]]
+}
+
+# Like check_effective_target_ppc_long_double_ieee, but check if we can
+# explicitly override the long double format to use the IEEE 128-bit format,
+# and GLIBC supports doing this override by switching the sprintf to handle
+# long double.
+
+proc add_options_for_ppc_long_double_override_ieee128 { flags } {
+    if { [istarget powerpc*-*-*] } {
+	return "$flags -mlong-double-128 -Wno-psabi -mabi=ieeelongdouble"
+    }
+    return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_ieee128 { } {
+    return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {
+	#include <string.h>
+	#include <stdio.h>
+	volatile _Float128 a = 3.0f128;
+	volatile long double one = 1.0L;
+	volatile long double two = 2.0L;
+	volatile long double b;
+	char buffer[20];
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+	    return 1;
+	  #else
+	    b = one + two;
+	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+	      return 1;
+	    sprintf (buffer, "%lg", b);
+	    return strcmp (buffer, "3") != 0;
+	  #endif
+	}
+    }  [add_options_for_ppc_long_double_override_ieee128 ""]]
+}
+
+# Like check_effective_target_ppc_long_double_64bit, but override the long
+# double format to be 64-bit explicitly.
+
+proc add_options_for_ppc_long_double_override_64bit { flags } {
+    if { [istarget powerpc*-*-*] } {
+	return "$flags -mlong-double-64"
+    }
+    return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_64bit { } {
+    return [check_runtime_nocache ppc_long_double_ovveride_64bit {
+	#include <string.h>
+	#include <stdio.h>
+	volatile double a = 3.0;
+	volatile long double one = 1.0L;
+	volatile long double two = 2.0L;
+	volatile long double b;
+	char buffer[20];
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || defined(__LONG_DOUBLE_128__)
+	    return 1;
+	  #else
+	    if (sizeof (long double) != sizeof (double))
+	      return 1;
+	    b = one + two;
+	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+	      return 1;
+	    sprintf (buffer, "%lg", b);
+	    return strcmp (buffer, "3") != 0;
+	  #endif
+	}
+    }  [add_options_for_ppc_long_double_override_64bit ""]]
+}
+
 # Return 1 if the target supports executing VSX instructions, 0
 # otherwise.  Cache the result.
 
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/3] PowerPC: PR target/70117, Force long double to be IBM 128-bit.
  2021-01-15  3:37 [PATCH 0/3] PowerPC: Fix up tests for IEEE 128-bit long double Michael Meissner
  2021-01-15  3:39 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
@ 2021-01-15  3:40 ` Michael Meissner
  2021-01-15  3:41 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner
  2 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2021-01-15  3:40 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

[PATCH 2/3] PowerPC: PR target/70117, Force long double to be IBM 128-bit.

This patch fixes the pr70117 test to use IBM 128-bit long double.

I have run tests on a little endian power9 system with 3 compilers:
    *	One compiler using the default IBM 128-bit format;
    *	One compiler using the IEEE 128-bit format; (and)
    *	One compiler using 64-bit long doubles.

I have also tested compilers on a big endian power8 system with a compiler
defaulting to power8 code generation and another with the default cpu set.

Can I check this patch into the master branch?

gcc/testsuite/
2021-01-14  Michael Meissner  <meissner@linux.ibm.com>

	PR target/70117
	* gcc.target/powerpc/pr70117.c: Force the long double type to use
	the IBM 128-bit format.
---
 gcc/testsuite/gcc.target/powerpc/pr70117.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c
index 3bbd2c595e0..8a5fad1dee0 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
@@ -1,5 +1,7 @@
-/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } } */
-/* { dg-options "-std=c99 -mlong-double-128 -O2" } */
+/* { dg-do run } */
+/* { dg-require-effective-target ppc_long_double_override_ibm128 } */
+/* { dg-options "-std=c99 -O2" } */
+/* { dg-add-options ppc_long_double_override_ibm128 } */
 
 #include <float.h>
 
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/3] PowerPC: Force IBM long double for conversion test.
  2021-01-15  3:37 [PATCH 0/3] PowerPC: Fix up tests for IEEE 128-bit long double Michael Meissner
  2021-01-15  3:39 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
  2021-01-15  3:40 ` [PATCH 2/3] PowerPC: PR target/70117, Force long double to be IBM 128-bit Michael Meissner
@ 2021-01-15  3:41 ` Michael Meissner
  2 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2021-01-15  3:41 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

[PATCH 3/3] PowerPC: Force IBM long double for conversion test.

The test c-c++-common/dfp/convert-bfp-11.c explicit expects long double to use
the IBM 128-bit extended double format.  In particular, some of the tests
expect an infinity to be created if decimal values that are converted that are
too large for IBM extended double.  However, the numbers do fit in the range
for IEEE 128-bit format, since it has a larger exponent than the IBM 128-bit
format.  The test fails because an infinity is not generated.

This patch explicitly sets the long double type to IBM extended double.

I have run tests on a little endian power9 system with 3 compilers:
    *	One compiler using the default IBM 128-bit format;
    *	One compiler using the IEEE 128-bit format; (and)
    *	One compiler using 64-bit long doubles.

I have also tested compilers on a big endian power8 system with a compiler
defaulting to power8 code generation and another with the default cpu set.

Can I check this patch into the master branch?

gcc/testsuite/
2021-01-14  Michael Meissner  <meissner@linux.ibm.com>

	* c-c++-common/dfp/convert-bfp-11.c: Force using IBM 128-bit long
	double.  Remove check for 64-bit long double.
---
 .../c-c++-common/dfp/convert-bfp-11.c          | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c
index 95c433d2c24..35da07d1fa4 100644
--- a/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c
+++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c
@@ -1,9 +1,14 @@
-/* { dg-skip-if "" { ! "powerpc*-*-linux*" } } */
+/* { dg-require-effective-target dfp } */
+/* { dg-require-effective-target ppc_long_double_override_ibm128 } */
+/* { dg-add-options ppc_long_double_override_ibm128 } */
 
-/* Test decimal float conversions to and from IBM 128-bit long double. 
-   Checks are skipped at runtime if long double is not 128 bits.
-   Don't force 128-bit long doubles because runtime support depends
-   on glibc.  */
+/* We force the long double type to be IBM 128-bit because the CONVERT_TO_PINF
+   tests will fail if we use IEEE 128-bit floating point.  This is due to IEEE
+   128-bit having a larger exponent range than IBM 128-bit extended double.  So
+   tests that would generate an infinity with IBM 128-bit will generate a
+   normal number with IEEE 128-bit.  */
+
+/* Test decimal float conversions to and from IBM 128-bit long double.   */
 
 #include "convert.h"
 
@@ -36,9 +41,6 @@ CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32)
 int
 main ()
 {
-  if (sizeof (long double) != 16)
-    return 0;
-
   convert_101 ();
   convert_102 ();
 
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2021-01-15  3:39 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
@ 2021-01-15 18:16   ` Joseph Myers
  2021-02-23 16:48     ` Michael Meissner
  0 siblings, 1 reply; 12+ messages in thread
From: Joseph Myers @ 2021-01-15 18:16 UTC (permalink / raw)
  To: Michael Meissner
  Cc: gcc-patches, Segher Boessenkool, David Edelsohn, Bill Schmidt,
	Peter Bergner

On Thu, 14 Jan 2021, Michael Meissner via Gcc-patches wrote:

> +    return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {

> +    return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {

> +    return [check_runtime_nocache ppc_long_double_ovveride_64bit {

All these places have the typo "ovveride".

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2021-01-15 18:16   ` Joseph Myers
@ 2021-02-23 16:48     ` Michael Meissner
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2021-02-23 16:48 UTC (permalink / raw)
  To: Joseph Myers
  Cc: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

On Fri, Jan 15, 2021 at 06:16:43PM +0000, Joseph Myers wrote:
> On Thu, 14 Jan 2021, Michael Meissner via Gcc-patches wrote:
> 
> > +    return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {
> 
> > +    return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {
> 
> > +    return [check_runtime_nocache ppc_long_double_ovveride_64bit {
> 
> All these places have the typo "ovveride".

Thanks.  I have fixed these in the next version of the patch.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-12-04  4:06 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
@ 2020-12-14 20:50   ` Segher Boessenkool
  0 siblings, 0 replies; 12+ messages in thread
From: Segher Boessenkool @ 2020-12-14 20:50 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

On Thu, Dec 03, 2020 at 11:06:12PM -0500, Michael Meissner wrote:
> +proc check_effective_target_ppc_long_double_ibm { } {
> +    return [check_cached_effective_target ppc_long_double_ibm {
> +	int main()
> +	{
> +	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
> +	    return 1;
> +	  #else
> +	    return 0;
> +	  #endif
> +	}
> +    }]
> +}

OK.

> +proc check_effective_target_ppc_long_double_ieee { } {
> +    return [check_cached_effective_target ppc_long_double_ieee {
> +	int main()
> +	{
> +	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
> +	    return 1;
> +	  #else
> +	    return 0;
> +	  #endif
> +	}
> +    }]
> +}

OK.

These names could be without "_ppc", if the functions were defined more
generically.  It's not clear that will be useful right now though.

> +# Like check_effective_target_ppc_long_double_ibm, but check if we can
> +# explicitly override the long double format to use the IBM 128-bit extended
> +# double format, and GLIBC supports doing this override by switching the
> +# sprintf to handle long double.

This comment needs work.

> +proc check_effective_target_ppc_long_double_override_ibm { } {
> +    set options "-mlong-double-128 -mabi=ibmlongdouble -Wno-psabi"
> +    check_runtime_nocache ppc_long_double_ovveride_ibm {

It is spelled "override".

> +	#include <string.h>
> +	#include <stdio.h>
> +	volatile __ibm128 a = (__ibm128) 3.0;
> +	volatile long double one = 1.0L;
> +	volatile long double two = 2.0L;
> +	volatile long double b;
> +	char buffer[20];
> +	int main()
> +	{
> +	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
> +	    return 1;
> +	  #else
> +	    b = one + two;
> +	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)

The pointer casts are unnecessary, and can be harmful.

You should use  sizeof(b)  , and check that  sizeof(a) == sizeof(b)  .

> +	      return 1;
> +	    sprintf (buffer, "%lg", b);
> +	    return strcmp (buffer, "3") != 0;
> +	  #endif
> +	}
> +    } $options
> +}

The name of this should say it is something to do with libc, or even
glibc in fact ("lg" is not portable), and with text output.

> +# Like check_effective_target_ppc_long_double_ieee, but check if we can
> +# explicitly override the long double format to use the IEEE 128-bit format,
> +# and GLIBC supports doing this override by switching the sprintf to handle
> +# long double.
> +
> +proc check_effective_target_ppc_long_double_override_ieee { } {
> +    set options "-mlong-double-128 -mabi=ieeelongdouble -Wno-psabi"
> +    check_runtime_nocache ppc_long_double_ovveride_ieee {
> +	#include <string.h>
> +	#include <stdio.h>
> +	volatile _Float128 a = 3.0f128;
> +	volatile long double one = 1.0L;
> +	volatile long double two = 2.0L;
> +	volatile long double b;
> +	char buffer[20];
> +	int main()
> +	{
> +	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
> +	    return 1;
> +	  #else
> +	    b = one + two;
> +	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
> +	      return 1;
> +	    sprintf (buffer, "%lg", b);
> +	    return strcmp (buffer, "3") != 0;
> +	  #endif
> +	}
> +    } $options
> +}

Ditto.

> +# See if the target is a powerpc with the long double format that is 128-bits.
> +
> +proc check_effective_target_ppc_long_double_128bit { } {
> +    return [check_cached_effective_target ppc_long_double_128bit {
> +	int main()
> +	{
> +	  #ifndef _ARCH_PPC
> +	    return 1;
> +	  #else
> +	    return sizeof (long double) != 16;
> +	    #endif
> +	}
> +    }]
> +}

In this case checking for PowerPC seems a really bad design: this is
obviously exactly the same on any architecture.

> +proc check_effective_target_ppc_long_double_64bit { } {
> +    return [check_cached_effective_target ppc_long_double_64bit {
> +	int main()
> +	{
> +	  #ifndef _ARCH_PPC
> +	    return 1;
> +	  #else
> +	    return sizeof (long double) != 8;
> +	  #endif
> +	}
> +    }]
> +}

Ditto.


Segher

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
@ 2020-12-04  4:06 ` Michael Meissner
  2020-12-14 20:50   ` Segher Boessenkool
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Meissner @ 2020-12-04  4:06 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: Add long double target-supports.

I messed up posting this patch, using the wrong subject line.  This patch is
what I meant to post.

This patch replaces the patch submitted on November 21st:
| Date: Sat, 21 Nov 2020 00:33:52 -0500
| Subject: [PATCH 1/3] PowerPC: Add long double target-supports.
| Message-ID: <20201121053352.GC17995@ibm-toto.the-meissners.org>
| https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559839.html

I expanded the target supports to include more options to select targets with
an appropriate long double format.  There are four options to check whether the
current long double is:

    1)  128-bit using the IBM extended double format;
    2)  128-bit using the IEEE format;
    3)  Long double is 128-bits (i.e. either IBM or IEEE); (and)
    4)  Long double is 64-bits.

I also added two new target supports:

    1)  If you can switch the long double to IBM extended double via compiler
        options and the GLIBC supports this change.  If you are using an
        existing GLIBC with IBM long double, this should work since you aren't
        switching the long double format.

    2)  And likewise if you can switch the long double to IEEE 128-bit.

This patch and the following 2 other patches were tested together on a power9
little endian server system.  I built 4 compilers:

    1)  Compiler without modifications;
    2)  Compiler using my other patches configured for IBM long double;
    3)  Compiler using my other patches configured for IEEE long double; (and)
    4)  Compiler using my other patches configure for 64-bit double.

While I used the other patches to test the 64-bit and IEEE long double, these 3
patches should work for the default builds with IBM 128-bit, and they will
continue to work once all of the long double support patches are in.  The two
tests that are patched in the next two patches, now work in all environments.
Can I apply these patches to the master branch?

gcc/testsuite/
2020-12-03  Michael Meissner  <meissner@linux.ibm.com>

	* lib/target-supports.exp
	(check_effective_target_ppc_long_double_ibm): New function.
	(check_effective_target_ppc_long_double_ieee): New function.
	(check_effective_target_ppc_long_double_override_ibm): New function.
	(check_effective_target_ppc_long_double_override_ieee): New function.
	(check_effective_target_ppc_long_double_128bit): New function.
	(check_effective_target_ppc_long_double_64bit): New function.
---
 gcc/testsuite/lib/target-supports.exp | 122 ++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index ff6bc5f4b92..01b82843bf5 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2348,6 +2348,128 @@ proc check_effective_target_ppc_ieee128_ok { } {
     }]
 }
 
+# See if the target is a powerpc with the long double format that uses the IBM
+# extended double format.
+
+proc check_effective_target_ppc_long_double_ibm { } {
+    return [check_cached_effective_target ppc_long_double_ibm {
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+	    return 1;
+	  #else
+	    return 0;
+	  #endif
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that uses the IEEE
+# 128-bit format.
+
+proc check_effective_target_ppc_long_double_ieee { } {
+    return [check_cached_effective_target ppc_long_double_ieee {
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+	    return 1;
+	  #else
+	    return 0;
+	  #endif
+	}
+    }]
+}
+
+# Like check_effective_target_ppc_long_double_ibm, but check if we can
+# explicitly override the long double format to use the IBM 128-bit extended
+# double format, and GLIBC supports doing this override by switching the
+# sprintf to handle long double.
+
+proc check_effective_target_ppc_long_double_override_ibm { } {
+    set options "-mlong-double-128 -mabi=ibmlongdouble -Wno-psabi"
+    check_runtime_nocache ppc_long_double_ovveride_ibm {
+	#include <string.h>
+	#include <stdio.h>
+	volatile __ibm128 a = (__ibm128) 3.0;
+	volatile long double one = 1.0L;
+	volatile long double two = 2.0L;
+	volatile long double b;
+	char buffer[20];
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+	    return 1;
+	  #else
+	    b = one + two;
+	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+	      return 1;
+	    sprintf (buffer, "%lg", b);
+	    return strcmp (buffer, "3") != 0;
+	  #endif
+	}
+    } $options
+}
+
+# Like check_effective_target_ppc_long_double_ieee, but check if we can
+# explicitly override the long double format to use the IEEE 128-bit format,
+# and GLIBC supports doing this override by switching the sprintf to handle
+# long double.
+
+proc check_effective_target_ppc_long_double_override_ieee { } {
+    set options "-mlong-double-128 -mabi=ieeelongdouble -Wno-psabi"
+    check_runtime_nocache ppc_long_double_ovveride_ieee {
+	#include <string.h>
+	#include <stdio.h>
+	volatile _Float128 a = 3.0f128;
+	volatile long double one = 1.0L;
+	volatile long double two = 2.0L;
+	volatile long double b;
+	char buffer[20];
+	int main()
+	{
+	  #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+	    return 1;
+	  #else
+	    b = one + two;
+	    if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+	      return 1;
+	    sprintf (buffer, "%lg", b);
+	    return strcmp (buffer, "3") != 0;
+	  #endif
+	}
+    } $options
+}
+
+# See if the target is a powerpc with the long double format that is 128-bits.
+
+proc check_effective_target_ppc_long_double_128bit { } {
+    return [check_cached_effective_target ppc_long_double_128bit {
+	int main()
+	{
+	  #ifndef _ARCH_PPC
+	    return 1;
+	  #else
+	    return sizeof (long double) != 16;
+	    #endif
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that is 64-bit.
+
+proc check_effective_target_ppc_long_double_64bit { } {
+    return [check_cached_effective_target ppc_long_double_64bit {
+	int main()
+	{
+	  #ifndef _ARCH_PPC
+	    return 1;
+	  #else
+	    return sizeof (long double) != 8;
+	  #endif
+	}
+    }]
+}
+
 # Return 1 if the target supports executing VSX instructions, 0
 # otherwise.  Cache the result.
 
-- 
2.22.0

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-11-24 21:44     ` Michael Meissner
@ 2020-11-24 23:49       ` Segher Boessenkool
  0 siblings, 0 replies; 12+ messages in thread
From: Segher Boessenkool @ 2020-11-24 23:49 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

On Tue, Nov 24, 2020 at 04:44:19PM -0500, Michael Meissner wrote:
> On Mon, Nov 23, 2020 at 02:28:57PM -0600, Segher Boessenkool wrote:
> > On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> > > +# See if the target is a powerpc with the long double format that uses the IBM
> > > +# extended double format.
> > 
> > "Return 1 if the target is PowerPC, and long double is IBM extended double."
> > 
> > > @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
> > >  	  "power10_hw"     { set selected [check_power10_hw_available] }
> > >  	  "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
> > >  	  "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> > > +	  "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> > > +	  "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> > > +	  "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
> > >  	  "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
> > >  	  "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] }
> > >  	  "ppc_mma_hw"     { set selected [check_ppc_mma_hw_available] }
> > 
> > Why this?  It just defines aliases to the exact same name?
> 
> If you remove those lines you get the failure from the default case:
> 
> 	  default          { error "unknown effective target keyword `$arg'" }

So name the functions check_effective_target_ppc_long_double_ibm etc.?
Then it is all handled by the generic code, and yes you can use these
same names in the testcases.


Segher

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-11-23 20:28   ` Segher Boessenkool
@ 2020-11-24 21:44     ` Michael Meissner
  2020-11-24 23:49       ` Segher Boessenkool
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Meissner @ 2020-11-24 21:44 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

On Mon, Nov 23, 2020 at 02:28:57PM -0600, Segher Boessenkool wrote:
> Hi!
> 
> On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> > +# See if the target is a powerpc with the long double format that uses the IBM
> > +# extended double format.
> 
> "Return 1 if the target is PowerPC, and long double is IBM extended double."
> 
> > @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
> >  	  "power10_hw"     { set selected [check_power10_hw_available] }
> >  	  "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
> >  	  "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> > +	  "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> > +	  "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> > +	  "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
> >  	  "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
> >  	  "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] }
> >  	  "ppc_mma_hw"     { set selected [check_ppc_mma_hw_available] }
> 
> Why this?  It just defines aliases to the exact same name?

If you remove those lines you get the failure from the default case:

	  default          { error "unknown effective target keyword `$arg'" }

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-11-21  5:33 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
@ 2020-11-23 20:28   ` Segher Boessenkool
  2020-11-24 21:44     ` Michael Meissner
  0 siblings, 1 reply; 12+ messages in thread
From: Segher Boessenkool @ 2020-11-23 20:28 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

Hi!

On Sat, Nov 21, 2020 at 12:33:52AM -0500, Michael Meissner wrote:
> +# See if the target is a powerpc with the long double format that uses the IBM
> +# extended double format.

"Return 1 if the target is PowerPC, and long double is IBM extended double."

> @@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
>  	  "power10_hw"     { set selected [check_power10_hw_available] }
>  	  "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
>  	  "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
> +	  "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
> +	  "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
> +	  "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
>  	  "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
>  	  "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] }
>  	  "ppc_mma_hw"     { set selected [check_ppc_mma_hw_available] }

Why this?  It just defines aliases to the exact same name?


Segher

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] PowerPC: Add long double target-supports.
  2020-11-21  5:22 [PATH 0/3] Updated PowerPC tests for long double Michael Meissner
@ 2020-11-21  5:33 ` Michael Meissner
  2020-11-23 20:28   ` Segher Boessenkool
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Meissner @ 2020-11-21  5:33 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: Add long double target-supports.

This patch adds 3 target supports to test what type of PowerPC long double is
used by the test:

   1)	Long double uses the IBM 128-bit extended double format;
   2)	Long double uses the IEEE 128-bit format; (and)
   3)	Long double uses the 64-bit format.

I have tested this patch and the following two patches in this series with
compilers with the 3 different long double types.  I verified that the two
tests being modified both are labeled as UNSUPPORTED if long double is not IBM
128-bit, and if long double is IBM 128-bit, the tests pass.

Can I check this into the master branch?  I think this patch should also be
back ported to the earlier branches.

gcc/testsuite/
2020-11-21  Michael Meissner  <meissner@linux.ibm.com>

	* lib/target-supports.exp (check_ppc_long_double_ibm): New
	function.
	(check_ppc_long_double_ieee): New function.
	(check_ppc_long_double_64bit): New function.
	(is-effective-target): Add ppc_long_double_ibm,
	ppc_long_double_ieee, and ppc_long_double_64bit.
---
 gcc/testsuite/lib/target-supports.exp | 56 +++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 22acda2a74f..adcb789d136 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2336,6 +2336,59 @@ proc check_effective_target_ppc_ieee128_ok { } {
     }]
 }
 
+# See if the target is a powerpc with the long double format that uses the IBM
+# extended double format.
+
+proc check_ppc_long_double_ibm { } {
+    return [check_cached_effective_target ppc_long_double_ibm {
+	check_runtime_nocache ppc_long_double_ibm {
+	    int main()
+	    {
+	      #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+		return 1;
+	      #else
+		return 0;
+	      #endif
+	    }
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that uses the IEEE
+# 128-bit format.
+
+proc check_ppc_long_double_ieee { } {
+    return [check_cached_effective_target ppc_long_double_ieee {
+	check_runtime_nocache ppc_long_double_ieee {
+	    int main()
+	    {
+	      #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+		return 1;
+	      #else
+		return 0;
+	      #endif
+	    }
+	}
+    }]
+}
+
+# See if the target is a powerpc with the long double format that is 64-bit.
+
+proc check_ppc_long_double_64bit { } {
+    return [check_cached_effective_target ppc_long_double_64bit {
+	check_runtime_nocache ppc_long_double_64bit {
+	    int main()
+	    {
+	      #ifndef _ARCH_PPC
+		return 1;
+	      #else
+		return sizeof (long double) != 64;
+	      #endif
+	    }
+	}
+    }]
+}
+
 # Return 1 if the target supports executing VSX instructions, 0
 # otherwise.  Cache the result.
 
@@ -7939,6 +7992,9 @@ proc is-effective-target { arg } {
 	  "power10_hw"     { set selected [check_power10_hw_available] }
 	  "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
 	  "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
+	  "ppc_long_double_ibm" { set selected [check_ppc_long_double_ibm] }
+	  "ppc_long_double_ieee" { set selected [check_ppc_long_double_ieee] }
+	  "ppc_long_double_64bit" { set selected [check_ppc_long_double_64bit] }
 	  "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
 	  "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] }
 	  "ppc_mma_hw"     { set selected [check_ppc_mma_hw_available] }
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-23 16:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15  3:37 [PATCH 0/3] PowerPC: Fix up tests for IEEE 128-bit long double Michael Meissner
2021-01-15  3:39 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
2021-01-15 18:16   ` Joseph Myers
2021-02-23 16:48     ` Michael Meissner
2021-01-15  3:40 ` [PATCH 2/3] PowerPC: PR target/70117, Force long double to be IBM 128-bit Michael Meissner
2021-01-15  3:41 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner
  -- strict thread matches above, loose matches on Subject: below --
2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
2020-12-04  4:06 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
2020-12-14 20:50   ` Segher Boessenkool
2020-11-21  5:22 [PATH 0/3] Updated PowerPC tests for long double Michael Meissner
2020-11-21  5:33 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
2020-11-23 20:28   ` Segher Boessenkool
2020-11-24 21:44     ` Michael Meissner
2020-11-24 23:49       ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).