diff mbox series

[1/2] PowerPC: PR 97791: Fix an issue with gnu attributes.

Message ID 20210114172717.GA5676@ibm-toto.the-meissners.org
State New
Headers show
Series PowerPC: PR 97791: Fix attribute problems | expand

Commit Message

Michael Meissner Jan. 14, 2021, 5:27 p.m. UTC
[PATCH 1/2] PowerPC: PR 97791: Fix an issue with gnu attributes.

This patch patch fixes the problem that we set the GNU attribute for long
double if a type were passed or returned that uses the same representation as
the long double type (i.e. passing explicit __float128/_Float128 when long
double is IEEE 128-bit or passing __ibm128 when long double is IBM 128-bit).

I have tested this patch by doing builds, bootstraps, and make check with 3
builds on a power9 little endian server:

    *   Build one used the default long double being IBM 128-bit;
    *   Build two set the long double default to IEEE 128-bit; (and)
    *   Build three set the long double default to 64-bit.

The compilers built fine providing I recompiled gmp, mpc, and mpfr with the
appropriate long double options.  There were a few differences in the test
suite runs that will be addressed in later patches, but over all it works well.
This patch is highly desirable to be able to build a toolchain where the
default long double is IEEE 128-bit.  Can I check this patch into the master
branch for GCC 11?

gcc/
2021-01-14  Michael Meissner  <meissner@linux.ibm.com>
            Alan Modra  <amodra@gmail.com>

	PR gcc/97791
	* config/rs6000/rs6000-call.c (init_cumulative_args): Only set
	that long double was returned if the type is actually long
	double.
	(rs6000_function_arg_advance_1): Only set that long double was
	passed if the type is actually long double.
---
 gcc/config/rs6000/rs6000-call.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 2308cc8b4a2..519313bc0d6 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -6554,12 +6554,14 @@  init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
 	  if (SCALAR_FLOAT_MODE_P (return_mode))
 	    {
 	      rs6000_passes_float = true;
+
+	      /* If GNU attributes are enabled, mark if the function returns
+		 long double.  We do not mark if the function returns a type
+		 such as __ibm128 that uses the same modes as the current long
+		 double type, only if an actual long double type was used.  */
 	      if ((HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE || TARGET_64BIT)
-		  && (FLOAT128_IBM_P (return_mode)
-		      || FLOAT128_IEEE_P (return_mode)
-		      || (return_type != NULL
-			  && (TYPE_MAIN_VARIANT (return_type)
-			      == long_double_type_node))))
+		  && return_type != NULL
+		  && TYPE_MAIN_VARIANT (return_type) == long_double_type_node)
 		rs6000_passes_long_double = true;
 
 	      /* Note if we passed or return a IEEE 128-bit type.  We changed
@@ -6994,11 +6996,14 @@  rs6000_function_arg_advance_1 (CUMULATIVE_ARGS *cum, machine_mode mode,
       if (SCALAR_FLOAT_MODE_P (mode))
 	{
 	  rs6000_passes_float = true;
+
+	  /* If GNU attributes are enabled, mark if the function passes long
+	     double.  We do not mark if the function returns a type such as
+	     __ibm128 that uses the same modes as the current long double type,
+	     only if an actual long double type was used.  */
 	  if ((HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE || TARGET_64BIT)
-	      && (FLOAT128_IBM_P (mode)
-		  || FLOAT128_IEEE_P (mode)
-		  || (type != NULL
-		      && TYPE_MAIN_VARIANT (type) == long_double_type_node)))
+	      && type != NULL
+	      && TYPE_MAIN_VARIANT (type) == long_double_type_node)
 	    rs6000_passes_long_double = true;
 
 	  /* Note if we passed or return a IEEE 128-bit type.  We changed the