Hi, Now we will check optimize_function_for_speed_p (cfun) for TARGET_SAVE_TOC_INDIRECT if it's implicitly enabled. But the effect of -msave-toc-indirect is actually to save the TOC in the prologue for indirect calls rather than inline, it's also good for optimize_function_for_size? So this patch is to remove the check of optimize_function_for_speed and make it work for both optimizing for size and speed.
Bootstrapped and regtested on powerpc64-linux-gnu P8, powerpc64le-linux-gnu P{9,10} and powerpc-ibm-aix. Any thoughts? Thanks in advance! Kewen ----- gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_call_aix): Remove the check of optimize_function_for_speed_p for implicit SAVE_TOC_INDIRECT. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr108184-3.c: Adjust. --- gcc/config/rs6000/rs6000.cc | 5 +---- gcc/testsuite/gcc.target/powerpc/pr108184-3.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index f47d21980a9..870525347d5 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -25688,10 +25688,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, rtx cookie) /* Can we optimize saving the TOC in the prologue or do we need to do it at every call? */ - if (TARGET_SAVE_TOC_INDIRECT - && !cfun->calls_alloca - && (rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT - || optimize_function_for_speed_p (cfun))) + if (TARGET_SAVE_TOC_INDIRECT && !cfun->calls_alloca) cfun->machine->save_toc_in_prologue = true; else { diff --git a/gcc/testsuite/gcc.target/powerpc/pr108184-3.c b/gcc/testsuite/gcc.target/powerpc/pr108184-3.c index ceaa96e4421..a1ce3a18855 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr108184-3.c +++ b/gcc/testsuite/gcc.target/powerpc/pr108184-3.c @@ -2,15 +2,22 @@ /* { dg-require-effective-target fpic } */ /* { dg-options "-fpic -mno-pcrel -O2" } */ -/* Verify it doesn't imply -msave-toc-indirect, so - it doesn't take effect and we have two separated - toc savings for these two long calls. */ +/* Verify -msave-toc-indirect is implicitly enabled + for both optimizing for speed and size, so one + toc saving for each function. */ void foo (void) __attribute__((__longcall__)); int baz (void) __attribute__((__longcall__)); -__attribute__ ((cold)) int -bar (void) +__attribute__ ((cold, noipa)) int +bar1 (void) +{ + foo (); + return baz () + 1; +} + +__attribute__ ((noipa)) int +bar2 (void) { foo (); return baz () + 1; -- 2.27.0