[gcc(refs/vendors/ibm/heads/gcc-11-branch)] rs6000: Reset -mpower8-fusion for power9 inlining power8 functions [PR102059]
Peter Bergner
bergner@gcc.gnu.org
Fri Feb 18 21:10:31 GMT 2022
https://gcc.gnu.org/g:64575dfb22aecd7c239b2b5c63f4e1721cfaf987
commit 64575dfb22aecd7c239b2b5c63f4e1721cfaf987
Author: Michael Meissner <meissner@gcc.gnu.org>
Date: Fri Feb 18 15:01:53 2022 -0600
rs6000: Reset -mpower8-fusion for power9 inlining power8 functions [PR102059]
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. Since -mpower8-fusion does not change which instructions
we can generate, the solution here is to ignore that flag when determing
whether we can inline a function or not.
2022-02-18 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.
(Backport of a submitted trunk patch that isn't upstream yet.)
Diff:
---
gcc/config/rs6000/rs6000.c | 8 ++++++++
gcc/testsuite/gcc.target/powerpc/pr102059-4.c | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index ae13c3ab825..b646224c68b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -25056,6 +25056,14 @@ rs6000_can_inline_p (tree caller, tree callee)
else
caller_isa = rs6000_isa_flags;
+ /* 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.
a vsx function may inline an altivec function, but a no-vsx function
must not inline a vsx function. However, for those options that the
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