[gcc(refs/users/meissner/heads/work078)] Reset -mpower8-fusion for inline test, PR 102059.

Michael Meissner meissner@gcc.gnu.org
Tue Feb 8 21:43:38 GMT 2022


https://gcc.gnu.org/g:4015918720331c0379564313ab8461b559737e96

commit 4015918720331c0379564313ab8461b559737e96
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Tue Feb 8 16:43:15 2022 -0500

    Reset -mpower8-fusion for inline test, PR 102059.
    
    2022-02-08   Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            PR target/102059
            * config/rs6000/rs6000.cc (rs6000_can_inline_p): Don't test for
            power8-fusion if the caller was power9 or power10.
    
    gcc/testsuite/
            PR target/102059
            * gcc.target/powerpc/pr102059-4.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc                   |  8 ++++++++
 gcc/testsuite/gcc.target/powerpc/pr102059-4.c | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index eaba9a2d698..e2d94421ae9 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -25278,6 +25278,14 @@ rs6000_can_inline_p (tree caller, tree callee)
 	      callee_isa &= ~OPTION_MASK_HTM;
 	      explicit_isa &= ~OPTION_MASK_HTM;
 	    }
+
+	  /* Power9 and power10 do not set power8-fusion.  If the callee was
+	     explicitly compiled for power8, and the caller was power9 or
+	     power10, ignore the power8-fusion bits if it was set by
+	     default.  */
+	  if ((caller_isa & OPTION_MASK_P8_FUSION) == 0
+	      && (explicit_isa & OPTION_MASK_P8_FUSION) == 0)
+	    callee_isa &= ~OPTION_MASK_P8_FUSION;
 	}
 
       /* The callee's options must be a subset of the caller's options, i.e.
diff --git a/gcc/testsuite/gcc.target/powerpc/pr102059-4.c b/gcc/testsuite/gcc.target/powerpc/pr102059-4.c
new file mode 100644
index 00000000000..627c6f820c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr102059-4.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -Wno-attributes" } */
+
+/* Verify that power10 can explicity include functions compiled for power8.
+   The issue is -mcpu=power8 enables -mpower8-fusion, but -mcpu=power9 or
+   -mcpu=power10 do not set power8-fusion by default.  */
+
+static inline int __attribute__ ((always_inline,target("cpu=power8")))
+foo (int *b)
+{
+  *b += 10;
+  return *b;
+}
+
+int
+bar (int *a)
+{
+  *a = foo (a);
+  return 0;
+}


More information about the Gcc-cvs mailing list