public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work077)] Use correct names for __ibm128 if long double is IEEE 128-bit.
@ 2022-01-27 18:35 Michael Meissner
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Meissner @ 2022-01-27 18:35 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f7e25436afcb4233dda8c439698d57ed78975869

commit f7e25436afcb4233dda8c439698d57ed78975869
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Thu Jan 27 13:35:12 2022 -0500

    Use correct names for __ibm128 if long double is IEEE 128-bit.
    
    If you are on a PowerPC system where the default long double is IEEE
    128-bit, GCC will use the wrong names for some of the conversion functions
    for the __ibm128 type.
    
    What is happening is when the defult long double is IEEE 128-bit, the
    various convert, truncation, and extend functions did not specify a
    default name for the conversion.  The machine indepentent portions of the
    compiler would construct a call with an 'if' name (IFmode being the mode
    for IBM 128-bit floating point).  This patch specifies to use the
    tradiation 'tf' name for these conversion functions.
    
    2022-01-27  Michael Meissner  <meissner@the-meissners.org>
    
    gcc/
            PR target/104253
            * config/rs6000/rs6000.cc (TARGET_IEEEQUAD_DEFAULT): If the
            compiler used to build the current compiler defaults to IEEE
            128-bit long double,  make that the default for this build.

Diff:
---
 gcc/config/rs6000/rs6000.cc | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index f5c089a2a26..4fa0540c6af 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -11106,6 +11106,14 @@ init_float128_ibm (machine_mode mode)
      names.  */
   if (mode == IFmode)
     {
+      set_conv_libfunc (sext_optab, mode, SFmode, "__extendsftf2");
+      set_conv_libfunc (sext_optab, mode, DFmode, "__extenddftf2");
+      set_conv_libfunc (trunc_optab, SFmode, mode, "__trunctfsf2");
+      set_conv_libfunc (trunc_optab, DFmode, mode, "__trunctfdf2");
+
+      set_conv_libfunc (sext_optab, mode, IFmode, "__trunctftf2");
+      set_conv_libfunc (trunc_optab, IFmode, mode, "__extendtftf2");
+
       set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdtf");
       set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddtf");
       set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdtf");
@@ -11113,6 +11121,16 @@ init_float128_ibm (machine_mode mode)
       set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd");
       set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd");
 
+      set_conv_libfunc (sfix_optab, SImode, mode, "__fixtfsi");
+      set_conv_libfunc (ufix_optab, SImode, mode, "__fixunstfsi");
+      set_conv_libfunc (sfix_optab, DImode, mode, "__fixtfdi");
+      set_conv_libfunc (ufix_optab, DImode, mode, "__fixunstfdi");
+
+      set_conv_libfunc (sfloat_optab, mode, SImode, "__floatsitf");
+      set_conv_libfunc (ufloat_optab, mode, SImode, "__floatunsitf");
+      set_conv_libfunc (sfloat_optab, mode, DImode, "__floatditf");
+      set_conv_libfunc (ufloat_optab, mode, DImode, "__floatunditf");
+
       if (TARGET_POWERPC64)
 	{
 	  set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti");


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

* [gcc(refs/users/meissner/heads/work077)] Use correct names for __ibm128 if long double is IEEE 128-bit.
@ 2022-01-28 21:27 Michael Meissner
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Meissner @ 2022-01-28 21:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b62254a5c029fbca54a374f18ca00160d5209e8c

commit b62254a5c029fbca54a374f18ca00160d5209e8c
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Fri Jan 28 16:24:57 2022 -0500

    Use correct names for __ibm128 if long double is IEEE 128-bit.
    
    If you are on a PowerPC system where the default long double is IEEE
    128-bit, GCC will use the wrong names for some of the conversion functions
    for the __ibm128 type.
    
    What is happening is when the defult long double is IEEE 128-bit, the
    various convert, truncation, and extend functions did not specify a
    default name for the conversion.  The machine indepentent portions of the
    compiler would construct a call with an 'if' name (IFmode being the mode
    for IBM 128-bit floating point).  This patch specifies to use the
    tradiational 'tf' name for these conversion functions.
    
    2022-01-28  Michael Meissner  <meissner@the-meissners.org>
    
    gcc/
            PR target/104253
            * config/rs6000/rs6000.cc (init_float128_ibm): Use the TF names
            for builtin conversions between __ibm128 and DImode when long
            double uses the IEEE 128-bit format.
    
    gcc/testsuite/
            PR target/104253
            * gcc.target/powerpc/pr104253.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc                 |   6 ++
 gcc/testsuite/gcc.target/powerpc/pr104253.c | 154 ++++++++++++++++++++++++++++
 2 files changed, 160 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index f5c089a2a26..3b4c496df56 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -11113,6 +11113,12 @@ init_float128_ibm (machine_mode mode)
       set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd");
       set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd");
 
+      set_conv_libfunc (sfix_optab, DImode, mode, "__fixtfdi");
+      set_conv_libfunc (ufix_optab, DImode, mode, "__fixunstfdi");
+
+      set_conv_libfunc (sfloat_optab, mode, DImode, "__floatditf");
+      set_conv_libfunc (ufloat_optab, mode, DImode, "__floatunditf");
+
       if (TARGET_POWERPC64)
 	{
 	  set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti");
diff --git a/gcc/testsuite/gcc.target/powerpc/pr104253.c b/gcc/testsuite/gcc.target/powerpc/pr104253.c
new file mode 100644
index 00000000000..a1e73fe012c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr104253.c
@@ -0,0 +1,154 @@
+/*
+ * Require float128 support because __ibm128 currently is not enabled unless we
+ * also have __float128 support.
+ */
+
+/* { dg-do run } */
+/* { require-effective-target ppc_float128_sw } */
+/* { dg-options "-O2 -mvsx -mfloat128" } */
+
+/*
+ * PR target/104253
+ *
+ * Verify that the various conversions to and from __ibm128 work.  When the
+ *  default for long double is changed to IEEE 128-bit, originally GCC would
+ *  call the functions using an 'if' name instead of 'tf.
+ */
+
+#include <stdlib.h>
+
+extern float              ibm128_to_sf  (__ibm128) __attribute__((noinline));
+extern double             ibm128_to_df  (__ibm128) __attribute__((noinline));
+extern int                ibm128_to_si  (__ibm128) __attribute__((noinline));
+extern long long          ibm128_to_di  (__ibm128) __attribute__((noinline));
+extern unsigned int       ibm128_to_usi (__ibm128) __attribute__((noinline));
+extern unsigned long long ibm128_to_udi (__ibm128) __attribute__((noinline));
+
+extern __ibm128 sf_to_ibm128  (float)              __attribute__((noinline));
+extern __ibm128 df_to_ibm128  (double)             __attribute__((noinline));
+extern __ibm128 si_to_ibm128  (int)                __attribute__((noinline));
+extern __ibm128 di_to_ibm128  (long long)          __attribute__((noinline));
+extern __ibm128 usi_to_ibm128 (unsigned int)       __attribute__((noinline));
+extern __ibm128 udi_to_ibm128 (unsigned long long) __attribute__((noinline));
+
+float
+ibm128_to_sf  (__ibm128 x)
+{
+  return x;
+}
+
+double
+ibm128_to_df  (__ibm128 x)
+{
+  return x;
+}
+
+int
+ibm128_to_si  (__ibm128 x)
+{
+  return x;
+}
+
+long long
+ibm128_to_di  (__ibm128 x)
+{
+  return x;
+}
+
+unsigned int
+ibm128_to_usi (__ibm128 x)
+{
+  return x;
+}
+
+unsigned long long
+ibm128_to_udi (__ibm128 x)
+{
+  return x;
+}
+
+__ibm128
+sf_to_ibm128  (float x)
+{
+  return x;
+}
+
+__ibm128
+df_to_ibm128  (double x)
+{
+  return x;
+}
+
+__ibm128
+si_to_ibm128  (int x)
+{
+  return x;
+}
+
+__ibm128
+di_to_ibm128  (long long x)
+{
+  return x;
+}
+
+__ibm128
+usi_to_ibm128 (unsigned int x)
+{
+  return x;
+}
+
+__ibm128
+udi_to_ibm128 (unsigned long long x)
+{
+  return x;
+}
+
+volatile float			seven_sf	= 7.0f;
+volatile double			seven_df	= 7.0;
+volatile int			seven_si	= 7;
+volatile long long		seven_di	= 7LL;
+volatile unsigned int		seven_usi	= 7U;
+volatile unsigned long long	seven_udi	= 7ULL;
+volatile __ibm128		seven_ibm128	= 7.0;
+
+int
+main (void)
+{
+  if (seven_ibm128 != sf_to_ibm128 (seven_sf))
+    abort ();
+
+  if (seven_ibm128 != df_to_ibm128 (seven_df))
+    abort ();
+
+  if (seven_ibm128 != si_to_ibm128 (seven_si))
+    abort ();
+
+  if (seven_ibm128 != di_to_ibm128 (seven_di))
+    abort ();
+
+  if (seven_ibm128 != usi_to_ibm128 (seven_usi))
+    abort ();
+
+  if (seven_ibm128 != udi_to_ibm128 (seven_udi))
+    abort ();
+
+  if (seven_sf != ibm128_to_sf (seven_ibm128))
+    abort ();
+
+  if (seven_df != ibm128_to_df (seven_ibm128))
+    abort ();
+
+  if (seven_si != ibm128_to_si (seven_ibm128))
+    abort ();
+
+  if (seven_di != ibm128_to_di (seven_ibm128))
+    abort ();
+
+  if (seven_usi != ibm128_to_usi (seven_ibm128))
+    abort ();
+
+  if (seven_udi != ibm128_to_udi (seven_ibm128))
+    abort ();
+
+  return 0;
+}


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

* [gcc(refs/users/meissner/heads/work077)] Use correct names for __ibm128 if long double is IEEE 128-bit.
@ 2022-01-28 17:37 Michael Meissner
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Meissner @ 2022-01-28 17:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:964b43e585c69a9555f2b25066962e0c3bab3b95

commit 964b43e585c69a9555f2b25066962e0c3bab3b95
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Fri Jan 28 12:36:49 2022 -0500

    Use correct names for __ibm128 if long double is IEEE 128-bit.
    
    If you are on a PowerPC system where the default long double is IEEE
    128-bit, GCC will use the wrong names for some of the conversion functions
    for the __ibm128 type.
    
    What is happening is when the defult long double is IEEE 128-bit, the
    various convert, truncation, and extend functions did not specify a
    default name for the conversion.  The machine indepentent portions of the
    compiler would construct a call with an 'if' name (IFmode being the mode
    for IBM 128-bit floating point).  This patch specifies to use the
    tradiational 'tf' name for these conversion functions.
    
    2022-01-28  Michael Meissner  <meissner@the-meissners.org>
    
    gcc/
            PR target/104253
            * config/rs6000/rs6000.cc (TARGET_IEEEQUAD_DEFAULT): If the
            compiler used to build the current compiler defaults to IEEE
            128-bit long double,  make that the default for this build.
    
    gcc/testsuite/
            PR target/104253
            * gcc.target/powerpc/pr104253.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc                 |  18 ++++
 gcc/testsuite/gcc.target/powerpc/pr104253.c | 154 ++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index f5c089a2a26..4fa0540c6af 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -11106,6 +11106,14 @@ init_float128_ibm (machine_mode mode)
      names.  */
   if (mode == IFmode)
     {
+      set_conv_libfunc (sext_optab, mode, SFmode, "__extendsftf2");
+      set_conv_libfunc (sext_optab, mode, DFmode, "__extenddftf2");
+      set_conv_libfunc (trunc_optab, SFmode, mode, "__trunctfsf2");
+      set_conv_libfunc (trunc_optab, DFmode, mode, "__trunctfdf2");
+
+      set_conv_libfunc (sext_optab, mode, IFmode, "__trunctftf2");
+      set_conv_libfunc (trunc_optab, IFmode, mode, "__extendtftf2");
+
       set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdtf");
       set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddtf");
       set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdtf");
@@ -11113,6 +11121,16 @@ init_float128_ibm (machine_mode mode)
       set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd");
       set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd");
 
+      set_conv_libfunc (sfix_optab, SImode, mode, "__fixtfsi");
+      set_conv_libfunc (ufix_optab, SImode, mode, "__fixunstfsi");
+      set_conv_libfunc (sfix_optab, DImode, mode, "__fixtfdi");
+      set_conv_libfunc (ufix_optab, DImode, mode, "__fixunstfdi");
+
+      set_conv_libfunc (sfloat_optab, mode, SImode, "__floatsitf");
+      set_conv_libfunc (ufloat_optab, mode, SImode, "__floatunsitf");
+      set_conv_libfunc (sfloat_optab, mode, DImode, "__floatditf");
+      set_conv_libfunc (ufloat_optab, mode, DImode, "__floatunditf");
+
       if (TARGET_POWERPC64)
 	{
 	  set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti");
diff --git a/gcc/testsuite/gcc.target/powerpc/pr104253.c b/gcc/testsuite/gcc.target/powerpc/pr104253.c
new file mode 100644
index 00000000000..a1e73fe012c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr104253.c
@@ -0,0 +1,154 @@
+/*
+ * Require float128 support because __ibm128 currently is not enabled unless we
+ * also have __float128 support.
+ */
+
+/* { dg-do run } */
+/* { require-effective-target ppc_float128_sw } */
+/* { dg-options "-O2 -mvsx -mfloat128" } */
+
+/*
+ * PR target/104253
+ *
+ * Verify that the various conversions to and from __ibm128 work.  When the
+ *  default for long double is changed to IEEE 128-bit, originally GCC would
+ *  call the functions using an 'if' name instead of 'tf.
+ */
+
+#include <stdlib.h>
+
+extern float              ibm128_to_sf  (__ibm128) __attribute__((noinline));
+extern double             ibm128_to_df  (__ibm128) __attribute__((noinline));
+extern int                ibm128_to_si  (__ibm128) __attribute__((noinline));
+extern long long          ibm128_to_di  (__ibm128) __attribute__((noinline));
+extern unsigned int       ibm128_to_usi (__ibm128) __attribute__((noinline));
+extern unsigned long long ibm128_to_udi (__ibm128) __attribute__((noinline));
+
+extern __ibm128 sf_to_ibm128  (float)              __attribute__((noinline));
+extern __ibm128 df_to_ibm128  (double)             __attribute__((noinline));
+extern __ibm128 si_to_ibm128  (int)                __attribute__((noinline));
+extern __ibm128 di_to_ibm128  (long long)          __attribute__((noinline));
+extern __ibm128 usi_to_ibm128 (unsigned int)       __attribute__((noinline));
+extern __ibm128 udi_to_ibm128 (unsigned long long) __attribute__((noinline));
+
+float
+ibm128_to_sf  (__ibm128 x)
+{
+  return x;
+}
+
+double
+ibm128_to_df  (__ibm128 x)
+{
+  return x;
+}
+
+int
+ibm128_to_si  (__ibm128 x)
+{
+  return x;
+}
+
+long long
+ibm128_to_di  (__ibm128 x)
+{
+  return x;
+}
+
+unsigned int
+ibm128_to_usi (__ibm128 x)
+{
+  return x;
+}
+
+unsigned long long
+ibm128_to_udi (__ibm128 x)
+{
+  return x;
+}
+
+__ibm128
+sf_to_ibm128  (float x)
+{
+  return x;
+}
+
+__ibm128
+df_to_ibm128  (double x)
+{
+  return x;
+}
+
+__ibm128
+si_to_ibm128  (int x)
+{
+  return x;
+}
+
+__ibm128
+di_to_ibm128  (long long x)
+{
+  return x;
+}
+
+__ibm128
+usi_to_ibm128 (unsigned int x)
+{
+  return x;
+}
+
+__ibm128
+udi_to_ibm128 (unsigned long long x)
+{
+  return x;
+}
+
+volatile float			seven_sf	= 7.0f;
+volatile double			seven_df	= 7.0;
+volatile int			seven_si	= 7;
+volatile long long		seven_di	= 7LL;
+volatile unsigned int		seven_usi	= 7U;
+volatile unsigned long long	seven_udi	= 7ULL;
+volatile __ibm128		seven_ibm128	= 7.0;
+
+int
+main (void)
+{
+  if (seven_ibm128 != sf_to_ibm128 (seven_sf))
+    abort ();
+
+  if (seven_ibm128 != df_to_ibm128 (seven_df))
+    abort ();
+
+  if (seven_ibm128 != si_to_ibm128 (seven_si))
+    abort ();
+
+  if (seven_ibm128 != di_to_ibm128 (seven_di))
+    abort ();
+
+  if (seven_ibm128 != usi_to_ibm128 (seven_usi))
+    abort ();
+
+  if (seven_ibm128 != udi_to_ibm128 (seven_udi))
+    abort ();
+
+  if (seven_sf != ibm128_to_sf (seven_ibm128))
+    abort ();
+
+  if (seven_df != ibm128_to_df (seven_ibm128))
+    abort ();
+
+  if (seven_si != ibm128_to_si (seven_ibm128))
+    abort ();
+
+  if (seven_di != ibm128_to_di (seven_ibm128))
+    abort ();
+
+  if (seven_usi != ibm128_to_usi (seven_ibm128))
+    abort ();
+
+  if (seven_udi != ibm128_to_udi (seven_ibm128))
+    abort ();
+
+  return 0;
+}


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

end of thread, other threads:[~2022-01-28 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 18:35 [gcc(refs/users/meissner/heads/work077)] Use correct names for __ibm128 if long double is IEEE 128-bit Michael Meissner
2022-01-28 17:37 Michael Meissner
2022-01-28 21:27 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).