public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Updates for float128 tests
@ 2020-12-04  3:41 Michael Meissner
  2020-12-04  3:49 ` Date: Sat, 21 Nov 2020 00:33:52 -0500 Michael Meissner
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Michael Meissner @ 2020-12-04  3:41 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

These patches update the test suite patches I posted on November 21.

There are 3 patches in this series.

    1)	The first patch adds new target-support options;
    2)	The second patch updates pr70117.c; (and)
    3)	The third patch updates convert-bfp-11.c.

In the target supports patches, 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.

I modified the two tests to use the new target supports where we select IBM
128-bit at compile time.  This will allow these two tests to be tested with the
current compilers, and also continue to running these two tests when the
default long double has been changed.  I have built compilers with each of the
three long double formats being default, and all 3 compilers run these tests
(providing I use GLIBC 2.32 or later).

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

* Date: Sat, 21 Nov 2020 00:33:52 -0500
  2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
@ 2020-12-04  3:49 ` Michael Meissner
  2020-12-04  3:57 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2020-12-04  3:49 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: Add long double target-supports.

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

* [PATCH 2/3] PowerPC: require IBM long double for pr70117.
  2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
  2020-12-04  3:49 ` Date: Sat, 21 Nov 2020 00:33:52 -0500 Michael Meissner
@ 2020-12-04  3:57 ` Michael Meissner
  2020-12-14 23:26   ` Segher Boessenkool
  2020-12-04  4:03 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner
  2020-12-04  4:06 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
  3 siblings, 1 reply; 12+ messages in thread
From: Michael Meissner @ 2020-12-04  3:57 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: PR target/70117, Force long double to be IBM 128-bit.

This patch replaces the following patch:
| Date: Sat, 21 Nov 2020 00:37:10 -0500
| Subject: [PATCH 2/3] PowerPC: require IBM long double for pr70117.
| Message-ID: <20201121053710.GD17995@ibm-toto.the-meissners.org>
| https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559840.html

This patch uses the ppc_long_double_override_ibm target supports option that
was in the previous patch to make sure pr70117.c uses IBM extended double that
this test was designed for.

I have run this test on a power9 little endian server system with 3 compilers,
one configured for IBM long double, 1 configured for IEEE long double, and 1
configured for 64-bit long double.  All of the compilers used GLIBC 2.32, which
is needed to support switching the long double type, but this patch should work
with older GLIBCs as long as the compiler long double format matches GLIBC's
long double.

Can I check this change into the master branch once the previous patch is
applied?

gcc/testsuite/
2020-12-03  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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c
index 3bbd2c595e0..6efece1c7c8 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
@@ -1,5 +1,6 @@
-/* { 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_ibm } */
+/* { dg-options "-std=c99 -O2 -mlong-double-128 -mabi=ibmlongdouble -Wno-psabi" } */
 
 #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.
  2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
  2020-12-04  3:49 ` Date: Sat, 21 Nov 2020 00:33:52 -0500 Michael Meissner
  2020-12-04  3:57 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
@ 2020-12-04  4:03 ` Michael Meissner
  2020-12-04  4:06 ` [PATCH 1/3] PowerPC: Add long double target-supports Michael Meissner
  3 siblings, 0 replies; 12+ 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] 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
                   ` (2 preceding siblings ...)
  2020-12-04  4:03 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test Michael Meissner
@ 2020-12-04  4:06 ` Michael Meissner
  2020-12-14 20:50   ` Segher Boessenkool
  3 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-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

* Re: [PATCH 2/3] PowerPC: require IBM long double for pr70117.
  2020-12-04  3:57 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
@ 2020-12-14 23:26   ` Segher Boessenkool
  2020-12-17 18:18     ` Michael Meissner
  0 siblings, 1 reply; 12+ messages in thread
From: Segher Boessenkool @ 2020-12-14 23:26 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

Hi!

On Thu, Dec 03, 2020 at 10:57:56PM -0500, Michael Meissner wrote:
> --- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
> +++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> @@ -1,5 +1,6 @@
> -/* { 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_ibm } */
> +/* { dg-options "-std=c99 -O2 -mlong-double-128 -mabi=ibmlongdouble -Wno-psabi" } */


So we probably really want some add_options_for_ thing, and use that
everywhere else?


Before this patch you did not test for anything printf (or glibc at
all); why is that suddenly necessary?


Segher

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

* Re: [PATCH 2/3] PowerPC: require IBM long double for pr70117.
  2020-12-14 23:26   ` Segher Boessenkool
@ 2020-12-17 18:18     ` Michael Meissner
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2020-12-17 18:18 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

On Mon, Dec 14, 2020 at 05:26:03PM -0600, Segher Boessenkool wrote:
> Hi!
> 
> On Thu, Dec 03, 2020 at 10:57:56PM -0500, Michael Meissner wrote:
> > --- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> > @@ -1,5 +1,6 @@
> > -/* { 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_ibm } */
> > +/* { dg-options "-std=c99 -O2 -mlong-double-128 -mabi=ibmlongdouble -Wno-psabi" } */
> 
> 
> So we probably really want some add_options_for_ thing, and use that
> everywhere else?
> 
> 
> Before this patch you did not test for anything printf (or glibc at
> all); why is that suddenly necessary?

It works fine on systems where long double is IBM extended double (hence the
exclusions for darwin, aix, which do not have 128-bit long double).  It does
not work on systems where long double is either 64-bit or uses the IEEE 128-bit
representation.

For example, if I build a compiler where long double is 64-bit (i.e. PR 97543),
this test will fail.

In a previous version of the patch you said that it was a problem in that the
test was not run on systems where we have flipped the long double default.  So
I added the options to try and force it to run with IBM 128-bit long double.

-- 
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 2/3] PowerPC: require IBM long double for pr70117.
  2020-11-21  5:37 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
  2020-11-21 15:46   ` David Edelsohn
@ 2020-11-23 20:55   ` Segher Boessenkool
  1 sibling, 0 replies; 12+ messages in thread
From: Segher Boessenkool @ 2020-11-23 20:55 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, David Edelsohn, Bill Schmidt,
	Peter Bergner

Hi!

On Sat, Nov 21, 2020 at 12:37:10AM -0500, Michael Meissner wrote:
> Since the test is explicitly checking for IBM extended double, do not try to
> run it when long double is IEEE 128-bit.

Before your change, it would explicitly use __ibm128 if that is not the
same as long double.

You need a better explanation / justification for the patch.

What goes wrong without the patch?  Is that to be expected?  Etc.

You get less coverage than before after this patch (it will now only run
on systems that have double-double as long double).


Segher

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

* Re: [PATCH 2/3] PowerPC: require IBM long double for pr70117.
  2020-11-21 15:46   ` David Edelsohn
@ 2020-11-22  6:31     ` Michael Meissner
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Meissner @ 2020-11-22  6:31 UTC (permalink / raw)
  To: David Edelsohn
  Cc: Michael Meissner, GCC Patches, Segher Boessenkool, Bill Schmidt,
	Peter Bergner

On Sat, Nov 21, 2020 at 10:46:45AM -0500, David Edelsohn wrote:
> On Sat, Nov 21, 2020 at 12:37 AM Michael Meissner
> <meissner@linux.ibm.com> wrote:
> >
> > PowerPC: require IBM long double for pr70117.
> >
> > Since the test is explicitly checking for IBM extended double, do not try to
> > run it when long double is IEEE 128-bit.
> >
> > I have tested this patch and the first patch in the series on a little endian
> > power9 system with 3 compilers that have the 3 different long double types
> > configured.  I verified that this test is listed as unsupported if long double
> > is not IBM 128-bit, and it passes if long double is IBM 128-bit.
> >
> > Can I check this patch into the master branch?  After an appropriate soak-in
> > time, can I back port this patch to the previous open GCC trees?
> >
> > gcc/testsuite/
> > 2020-11-21  Michael Meissner  <meissner@linux.ibm.com>
> >
> >         PR target/70117
> >         * gcc.target/powerpc/pr70117.c: Only run the test if long double
> >         uses the IBM extended double format.
> > ---
> >  gcc/testsuite/gcc.target/powerpc/pr70117.c | 22 ++++------------------
> >  1 file changed, 4 insertions(+), 18 deletions(-)
> >
> > diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> > index 3bbd2c595e0..2077d15afd4 100644
> > --- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> > @@ -1,26 +1,12 @@
> > -/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } } */
> > -/* { dg-options "-std=c99 -mlong-double-128 -O2" } */
> > +/* { dg-require-effective-target ppc_long_double_ibm } */
> > +/* { dg-options "-std=c99 -O2" } */
> 
> Mike,
> 
> You still need a
> 
> /* { dg-do run } */
> 
> line.  But without any target specified.
> 
> Segher may have other comments.
> 
> Thanks, David

Thanks.

-- 
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 2/3] PowerPC: require IBM long double for pr70117.
  2020-11-21  5:37 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
@ 2020-11-21 15:46   ` David Edelsohn
  2020-11-22  6:31     ` Michael Meissner
  2020-11-23 20:55   ` Segher Boessenkool
  1 sibling, 1 reply; 12+ messages in thread
From: David Edelsohn @ 2020-11-21 15:46 UTC (permalink / raw)
  To: Michael Meissner, GCC Patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

On Sat, Nov 21, 2020 at 12:37 AM Michael Meissner
<meissner@linux.ibm.com> wrote:
>
> PowerPC: require IBM long double for pr70117.
>
> Since the test is explicitly checking for IBM extended double, do not try to
> run it when long double is IEEE 128-bit.
>
> I have tested this patch and the first patch in the series on a little endian
> power9 system with 3 compilers that have the 3 different long double types
> configured.  I verified that this test is listed as unsupported if long double
> is not IBM 128-bit, and it passes if long double is IBM 128-bit.
>
> Can I check this patch into the master branch?  After an appropriate soak-in
> time, can I back port this patch to the previous open GCC trees?
>
> gcc/testsuite/
> 2020-11-21  Michael Meissner  <meissner@linux.ibm.com>
>
>         PR target/70117
>         * gcc.target/powerpc/pr70117.c: Only run the test if long double
>         uses the IBM extended double format.
> ---
>  gcc/testsuite/gcc.target/powerpc/pr70117.c | 22 ++++------------------
>  1 file changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> index 3bbd2c595e0..2077d15afd4 100644
> --- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
> +++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
> @@ -1,26 +1,12 @@
> -/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } } */
> -/* { dg-options "-std=c99 -mlong-double-128 -O2" } */
> +/* { dg-require-effective-target ppc_long_double_ibm } */
> +/* { dg-options "-std=c99 -O2" } */

Mike,

You still need a

/* { dg-do run } */

line.  But without any target specified.

Segher may have other comments.

Thanks, David

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

* [PATCH 2/3] PowerPC: require IBM long double for pr70117.
  2020-11-21  5:22 [PATH 0/3] Updated PowerPC tests for long double Michael Meissner
@ 2020-11-21  5:37 ` Michael Meissner
  2020-11-21 15:46   ` David Edelsohn
  2020-11-23 20:55   ` Segher Boessenkool
  0 siblings, 2 replies; 12+ messages in thread
From: Michael Meissner @ 2020-11-21  5:37 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

PowerPC: require IBM long double for pr70117.

Since the test is explicitly checking for IBM extended double, do not try to
run it when long double is IEEE 128-bit.

I have tested this patch and the first patch in the series on a little endian
power9 system with 3 compilers that have the 3 different long double types
configured.  I verified that this test is listed as unsupported if long double
is not IBM 128-bit, and it passes if long double is IBM 128-bit.

Can I check this patch into the master branch?  After an appropriate soak-in
time, can I back port this patch to the previous open GCC trees?

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

	PR target/70117
	* gcc.target/powerpc/pr70117.c: Only run the test if long double
	uses the IBM extended double format.
---
 gcc/testsuite/gcc.target/powerpc/pr70117.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c b/gcc/testsuite/gcc.target/powerpc/pr70117.c
index 3bbd2c595e0..2077d15afd4 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr70117.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c
@@ -1,26 +1,12 @@
-/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } } */
-/* { dg-options "-std=c99 -mlong-double-128 -O2" } */
+/* { dg-require-effective-target ppc_long_double_ibm } */
+/* { dg-options "-std=c99 -O2" } */
 
 #include <float.h>
 
-#if defined(__LONG_DOUBLE_IEEE128__)
-/* If long double is IEEE 128-bit, we need to use the __ibm128 type instead of
-   long double.  We can't use __ibm128 on systems that don't support IEEE
-   128-bit floating point, because the type is not enabled on those
-   systems.  */
-#define LDOUBLE __ibm128
-
-#elif defined(__LONG_DOUBLE_IBM128__)
-#define LDOUBLE long double
-
-#else
-#error "long double must be either IBM 128-bit or IEEE 128-bit"
-#endif
-
 union gl_long_double_union
 {
   struct { double hi; double lo; } dd;
-  LDOUBLE ld;
+  long double ld;
 };
 
 /* This is gnulib's LDBL_MAX which, being 107 bits in precision, is
@@ -36,7 +22,7 @@ volatile double dnan = 0.0/0.0;
 int
 main (void)
 {
-  LDOUBLE ld;
+  long double ld;
 
   ld = gl_LDBL_MAX.ld;
   if (__builtin_isinf (ld))
-- 
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:[~2020-12-17 18:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04  3:41 [PATCH 0/3] Updates for float128 tests Michael Meissner
2020-12-04  3:49 ` Date: Sat, 21 Nov 2020 00:33:52 -0500 Michael Meissner
2020-12-04  3:57 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
2020-12-14 23:26   ` Segher Boessenkool
2020-12-17 18:18     ` Michael Meissner
2020-12-04  4:03 ` [PATCH 3/3] PowerPC: Force IBM long double for conversion test 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
  -- strict thread matches above, loose matches on Subject: below --
2020-11-21  5:22 [PATH 0/3] Updated PowerPC tests for long double Michael Meissner
2020-11-21  5:37 ` [PATCH 2/3] PowerPC: require IBM long double for pr70117 Michael Meissner
2020-11-21 15:46   ` David Edelsohn
2020-11-22  6:31     ` Michael Meissner
2020-11-23 20:55   ` 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).