>From 84ae44abc7a79b9c2e6d9f18a30516d3e8f65b1f Mon Sep 17 00:00:00 2001
From: Michael Meissner <meiss...@linux.ibm.com>
Date: Wed, 13 Jan 2021 21:45:20 -0500
Subject: [PATCH 2/2] PowerPC: PR 97791: Do not set gnu attributes on moves

This patch eliminates the code in rs6000_emit_move to set the long double
attribute.  This eliminates the false positives that occur when a type uses a
mode that is the same mode as the long double type.  However, to catch the
cases where long double is used without being passed or returned, we would need
to implement a GIMPLE pass that looked for explicit long double usage.

This patch also changes the the 3 tests that tested this move support to be
'XFAIL' until we flag long double usage correctly.

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  <meiss...@linux.ibm.com>

        PR gcc/97791
        * config/rs6000/rs6000.c (rs6000_emit_move): Delete code that sets
        whether long double was passed based on the modes used in moves.

gcc/testsuite/
2021-01-14  Michael Meissner  <meiss...@linux.ibm.com>

        PR target/97791
        * gcc.target/powerpc/gnuattr1.c: Mark as XFAIL.
        * gcc.target/powerpc/gnuattr2.c: Mark as XFAIL.
        * gcc.target/powerpc/gnuattr3.c: Mark as XFAIL.
---
 gcc/config/rs6000/rs6000.c                  | 17 -----------------
 gcc/testsuite/gcc.target/powerpc/gnuattr1.c |  9 +++++++--
 gcc/testsuite/gcc.target/powerpc/gnuattr2.c |  9 +++++++--
 gcc/testsuite/gcc.target/powerpc/gnuattr3.c |  9 +++++++--
 4 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 47a56912e27..6f48dd6566d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -10077,23 +10077,6 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode 
mode)
       && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
     gcc_unreachable ();
 
-#ifdef HAVE_AS_GNU_ATTRIBUTE
-  /* If we use a long double type, set the flags in .gnu_attribute that say
-     what the long double type is.  This is to allow the linker's warning
-     message for the wrong long double to be useful, even if the function does
-     not do a call (for example, doing a 128-bit add on power9 if the long
-     double type is IEEE 128-bit.  Do not set this if __ibm128 or __floa128 are
-     used if they aren't the default long dobule type.  */
-  if (rs6000_gnu_attr && (HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE || TARGET_64BIT))
-    {
-      if (TARGET_LONG_DOUBLE_128 && (mode == TFmode || mode == TCmode))
-       rs6000_passes_float = rs6000_passes_long_double = true;
-
-      else if (!TARGET_LONG_DOUBLE_128 && (mode == DFmode || mode == DCmode))
-       rs6000_passes_float = rs6000_passes_long_double = true;
-    }
-#endif
-
   /* See if we need to special case SImode/SFmode SUBREG moves.  */
   if ((mode == SImode || mode == SFmode) && SUBREG_P (source)
       && rs6000_emit_move_si_sf_subreg (dest, source, mode))
diff --git a/gcc/testsuite/gcc.target/powerpc/gnuattr1.c 
b/gcc/testsuite/gcc.target/powerpc/gnuattr1.c
index cf46777849a..9c7680aabae 100644
--- a/gcc/testsuite/gcc.target/powerpc/gnuattr1.c
+++ b/gcc/testsuite/gcc.target/powerpc/gnuattr1.c
@@ -1,11 +1,16 @@
 /* { dg-do compile { target { powerpc*-linux-* } } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O2 -mvsx -mlong-double-64" } */
-/* { dg-final { scan-assembler "gnu_attribute 4, 9" } } */
+/* { dg-final { scan-assembler "gnu_attribute 4, 9" {xfail *-*-*} } } */
 
 /* Check that if we can do the long double operation without doing an emulator
    call, such as with 64-bit long double support, that we still set the
-   appropriate .gnu_attribute.  */
+   appropriate .gnu_attribute.
+
+   However, the code that did this in rs6000_emit_move has been removed because
+   it could not differentiate between long double and another type that uses
+   the same mode.  This test is marked as xfail until a gimple pass is added to
+   track the use of long double types.  */
 
 long double a;
 
diff --git a/gcc/testsuite/gcc.target/powerpc/gnuattr2.c 
b/gcc/testsuite/gcc.target/powerpc/gnuattr2.c
index 32a4ba255a8..4ca60d63261 100644
--- a/gcc/testsuite/gcc.target/powerpc/gnuattr2.c
+++ b/gcc/testsuite/gcc.target/powerpc/gnuattr2.c
@@ -1,13 +1,18 @@
 /* { dg-do compile { target { powerpc*-linux-* && lp64 } } } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-options "-O2 -mpower9-vector -mabi=ieeelongdouble -Wno-psabi" } */
-/* { dg-final { scan-assembler "gnu_attribute 4, 13" } } */
+/* { dg-final { scan-assembler "gnu_attribute 4, 13" {xfail *-*-*} } } */
 
 /* Check that if we can do the long double operation without doing an emulator
    call, such as with IEEE 128-bit hardware support on power9, that we still
    set the appropriate .gnu_attribute.  The && lp64 is needed, because we can't
    enable the IEEE 128-bit hardware instructions on ISA 3.0 (power9) in 32-bit,
-   because we don't have a TImode available.  */
+   because we don't have a TImode available.
+
+   However, the code that did this in rs6000_emit_move has been removed because
+   it could not differentiate between long double and another type that uses
+   the same mode.  This test is marked as xfail until a gimple pass is added to
+   track the use of long double types.  */
 
 long double a;
 
diff --git a/gcc/testsuite/gcc.target/powerpc/gnuattr3.c 
b/gcc/testsuite/gcc.target/powerpc/gnuattr3.c
index bd5a64fe330..7eb3ebc3c43 100644
--- a/gcc/testsuite/gcc.target/powerpc/gnuattr3.c
+++ b/gcc/testsuite/gcc.target/powerpc/gnuattr3.c
@@ -1,11 +1,16 @@
 /* { dg-do compile { target { powerpc*-linux-* } } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O2 -mvsx -mabi=ibmlongdouble -Wno-psabi" } */
-/* { dg-final { scan-assembler "gnu_attribute 4, 5" } } */
+/* { dg-final { scan-assembler "gnu_attribute 4, 5" {xfail *-*-*} } } */
 
 /* Check that if we can do the long double operation without doing an emulator
    call, such as with copysign, that we still set the appropriate
-   .gnu_attribute.  */
+   .gnu_attribute.
+
+   However, the code that did this in rs6000_emit_move has been removed because
+   it could not differentiate between long double and another type that uses
+   the same mode.  This test is marked as xfail until a gimple pass is added to
+   track the use of long double types.  */
 
 long double a, b, c;
 
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797

Reply via email to