From aa33a2d866c0f3f2f9b3cb26f8ff2074bcd169b4 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Fri, 6 May 2022 11:39:13 -0500 Subject: [PATCH] rs6000: Ignore fusion option flags for inlining test [PR102059] The -mpower8-fusion option does not modify which instructions we can generate, so ignore it when deciding whether we can inline callee into caller. 2022-05-06 Michael Meissner gcc/ PR target/102059 * config/rs6000/rs6000.c (rs6000_can_inline_p): Ignore -mpower8-fusion option for inlining purposes. gcc/testsuite/ PR target/102059 * gcc.target/powerpc/pr102059-4.c: New test. (cherry picked from commit 2fb654f77d5292864ef57040f7bc01d7a975f6d9) --- gcc/config/rs6000/rs6000.c | 4 ++++ gcc/testsuite/gcc.target/powerpc/pr102059-4.c | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr102059-4.c diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index e95d877f8667..4ea0e73594d2 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24477,6 +24477,10 @@ rs6000_can_inline_p (tree caller, tree callee) else caller_isa = rs6000_isa_flags; + /* Ignore the -mpower8-fusion option for inlining purposes. */ + callee_isa &= ~OPTION_MASK_P8_FUSION; + explicit_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 000000000000..5fe66f8af4bf --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr102059-4.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ +/* { dg-require-effective-target power10_ok } */ + +/* Verify that power10 can explicity include functions compiled for power8. + The issue was -mcpu=power8 enables -mpower8-fusion, but -mcpu=power9 or + -mcpu=power10 do not set power8-fusion by default. Thus when doing this + compilation, they would get an error that the inline function failed in its + inlining due to having incompatible options. */ + +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.47.2