public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jan Hubicka <jh@suse.cz>, Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH 06/12] ipa-cp: Leave removal of unused parameters to IPA-SRA
Date: Sat, 12 Nov 2022 02:46:28 +0100	[thread overview]
Message-ID: <ri6o7tdkkqz.fsf@suse.cz> (raw)

Hi,

looking at some benchmarks I have noticed many cases when IPA-CP
cloned a function for all contexts just because it knew that some
parameters were not used at all.  Then IPA-SRA looked at the function
and cloned it again to split another parameter or two.  The latter
pass is better equipped to detect when parameters can be altogether
removed and so the IPA-CP cloning was for no good reason.

This patch simply alters the IPA-CP not to do that in the situations
where IPA-SRA can (for nodes which can be made local).

Bootstrapped and tested on x86_64-linux.  OK for master?

Thanks,

Martin


gcc/ChangeLog:

2022-11-11  Martin Jambor  <mjambor@suse.cz>

	* ipa-cp.cc (estimate_local_effects): Do not clone potentionally local
	nodes for all contexts just to remove unused parameters.
---
 gcc/ipa-cp.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 02bd6a0fd1a..eb4474eb8b3 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -3722,7 +3722,10 @@ estimate_local_effects (struct cgraph_node *node)
 						    &removable_params_cost);
   int devirt_bonus = devirtualization_time_bonus (node, &avals);
   if (always_const || devirt_bonus
-      || (removable_params_cost && node->can_change_signature))
+      || (removable_params_cost
+	  && node->can_change_signature
+	  /* If IPA-SRA can do it, it can do it better.  */
+	  && !node->can_be_local_p ()))
     {
       struct caller_statistics stats;
       ipa_call_estimates estimates;
-- 
2.38.0


                 reply	other threads:[~2022-11-12  1:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ri6o7tdkkqz.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jh@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).