public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR target/102059 Fix inline of target specific functions
@ 2022-02-09  3:27 Michael Meissner
  2022-02-09  8:56 ` Kewen.Lin
  2022-02-11 17:53 ` Ping: " Michael Meissner
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Meissner @ 2022-02-09  3:27 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner, Will Schmidt

Reset -mpower8-fusion for power9 inlining power8 functions, PR 102059.

This patch is an attempt to make a much simpler patch to fix PR target/102059
than the previous patch.

It just fixes the issue that if a function is specifically declared as a power8
function, you can't inline in functions that are specified with power9 or
power10 options.

The issue is -mpower8-fusion is cleared when you use -mcpu=power9 or
-mcpu=power10.  When I wrote the code for controlling which function can inline
other functions, -mpower8-fusion was set for -mcpu=power9 (-mcpu=power10 was
not an option at that time).  This patch fixes this particular problem.

Perhaps -mpower8-fusion should go away in the GCC 13 time frame.  This patch
just goes in and resets the fusion bit for testing inlines.

I have built a bootstrapped little endian compiler on power9 and the tests had
no regressions.

I have built a bootstrapped big endian compiler on power8 and I tested both
32-bit and 64-bit builds, and there were no regressions.

Can I install this into the trunk and back port it into GCC 11 after a burn-in
period?

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.
---
 gcc/config/rs6000/rs6000.cc                   |  8 ++++++++
 gcc/testsuite/gcc.target/powerpc/pr102059-4.c | 20 +++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr102059-4.c

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;
+}
-- 
2.34.1


-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com

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

end of thread, other threads:[~2022-03-08 21:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09  3:27 [PATCH] PR target/102059 Fix inline of target specific functions Michael Meissner
2022-02-09  8:56 ` Kewen.Lin
2022-02-09 19:00   ` Michael Meissner
2022-02-11 17:53 ` Ping: " Michael Meissner
2022-03-08 17:28   ` Segher Boessenkool
2022-03-08 21:10     ` 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).