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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread

* [PATCH 3/3] PowerPC: Force IBM long double for conversion test.
  2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
@ 2020-12-04  4:03 ` Michael Meissner
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Meissner @ 2020-12-04  4:03 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: Force IBM long double for conversion test.

This patch replaces the following patch:
| Date: Sat, 21 Nov 2020 00:39:53 -0500
| Subject: [PATCH 3/3] PowerPC: Require IBM long double for conversion test.
| Message-ID: <20201121053953.GE17995@ibm-toto.the-meissners.org>
| https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559841.html

The test c-c++-common/dfp/convert-bfp-11.c explicitly 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 uses the target support option that says we can change the long
double type.  If the long double type uses the IBM format, you can use older
GLIBCs.  If you are using IEEE long doubles, this test will only run if GLIBC
is 2.32 or newer that supports switching the long double format.

I have checked this patch with 3 compilers built on a little endian power9
system, 1 compiler with IBM default long double, 1 compiler with IEEE default
long double, and 1 compiler with 64-bit long double.  This test passes with all
3 compilers.

Can I check this patch into the master branch?

gcc/testsuite/
2020-12-03  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..d19d6aa9220 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_ibm } */
+/* { dg-options "-O2 -mlong-double-128 -mabi=ibmlongdouble -Wno-psabi" } */
 
-/* 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] 7+ messages in thread

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

Thread overview: 7+ 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:03 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner

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