public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, 0 of 3], Fix PowerPC test suite for IEEE 128-bit long double
@ 2021-02-23 16:47 Michael Meissner
  2021-02-23 16:52 ` [PATCH 1/3] Add long double target-supports on PowerPC Michael Meissner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Meissner @ 2021-02-23 16:47 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

As I mentioned in the patch for adding _Float128 <-> Decimal conversions, there
are two test cases that fail if you configure the compiler to use IEEE 128-bit
long double or 64-bit long double.  That is because these tests are explicitly
testing that the long double is a pair of doubles (i.e. IBM 128-bit long
double).

In previous iterations of this patch, I set the target condition to run the
test only if long double uses the IBM 128-bit format.  Segher suggest that
instead I add target support tests and options to force the long double format
to IBM 128-bit long double.  I rewrote the patches to do this.

In the last time I posted this patch, Joseph Myers noticed that I misspelled
'override' in two of the functions.  I have fixed this in this patch.  Thanks.

There are 3 patches in this set:

    1)	The patch to target-supports.exp to add 3 new functions that returns
	true based on what the current long double format is.  And there are
	three functions that return true if you can set the long double type at
	compile time and the GLIBC supports this option.  The remaining 2
	patches need this patch to be installed before they can be installed.

    2)	The patch to gcc/testsuite/gcc.target/powerpc/pr70117.c that forces
	this test to use IBM 128-bit long double.

    3)	The patch to gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c that
	forces this test to use IBM 128-bit long double.

I have done bootstrap builds on a power9 little endian system with the compiler
configured for the default IBM 128-bit long double and the IEEE 128-bit long
double.  The 2 tests now pass when I add these patches.  I also have built
bootstrap compilers on a power8 big endian system, and there were no
regressions.  Can I check these patches into the master branch?

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

* [PATCH 1/3] Add long double target-supports on PowerPC.
  2021-02-23 16:47 [PATCH, 0 of 3], Fix PowerPC test suite for IEEE 128-bit long double Michael Meissner
@ 2021-02-23 16:52 ` Michael Meissner
  2021-02-23 16:55 ` [PATCH 2/3] Force long double to be IBM 128-bit on PowerPC test, PR target/70117 Michael Meissner
  2021-02-23 16:56 ` [PATCH 3/3] Force IBM long double for conversion test on PowerPC Michael Meissner
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Meissner @ 2021-02-23 16:52 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

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

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.  There
were no regressions with these patches, and the two tests in the following
patches now work if the default long double is not IBM 128-bit:

    *	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.  There were no regressions.

Can I check this patch into the master branch?

gcc/testsuite/
2021-02-23  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 af46c779214..50302973b62 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_override_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_override_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_override_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] 4+ messages in thread

* [PATCH 2/3] Force long double to be IBM 128-bit on PowerPC test, PR target/70117
  2021-02-23 16:47 [PATCH, 0 of 3], Fix PowerPC test suite for IEEE 128-bit long double Michael Meissner
  2021-02-23 16:52 ` [PATCH 1/3] Add long double target-supports on PowerPC Michael Meissner
@ 2021-02-23 16:55 ` Michael Meissner
  2021-02-23 16:56 ` [PATCH 3/3] Force IBM long double for conversion test on PowerPC Michael Meissner
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Meissner @ 2021-02-23 16:55 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

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

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.  There
were no regressions with these patches, and the two tests in the following
patches now work if the default long double is not IBM 128-bit:

    *	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.  There were no regressions.

Can I check this patch into the master branch?

gcc/testsuite/
2021-02-23  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] 4+ messages in thread

* [PATCH 3/3] Force IBM long double for conversion test on PowerPC.
  2021-02-23 16:47 [PATCH, 0 of 3], Fix PowerPC test suite for IEEE 128-bit long double Michael Meissner
  2021-02-23 16:52 ` [PATCH 1/3] Add long double target-supports on PowerPC Michael Meissner
  2021-02-23 16:55 ` [PATCH 2/3] Force long double to be IBM 128-bit on PowerPC test, PR target/70117 Michael Meissner
@ 2021-02-23 16:56 ` Michael Meissner
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Meissner @ 2021-02-23 16:56 UTC (permalink / raw)
  To: Michael Meissner, gcc-patches, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner

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

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.  There
were no regressions with these patches, and the two tests in the following
patches now work if the default long double is not IBM 128-bit:

    *	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.  There were no regressions.

Can I check this patch into the master branch?

gcc/testsuite/
2021-02-22  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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 16:47 [PATCH, 0 of 3], Fix PowerPC test suite for IEEE 128-bit long double Michael Meissner
2021-02-23 16:52 ` [PATCH 1/3] Add long double target-supports on PowerPC Michael Meissner
2021-02-23 16:55 ` [PATCH 2/3] Force long double to be IBM 128-bit on PowerPC test, PR target/70117 Michael Meissner
2021-02-23 16:56 ` [PATCH 3/3] Force IBM long double for conversion test on PowerPC 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).