public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid some unnecessary set_cfun calls
@ 2013-11-13 10:52 Jakub Jelinek
  2013-11-13 11:17 ` Richard Biener
  2013-11-13 14:13 ` Martin Jambor
  0 siblings, 2 replies; 42+ messages in thread
From: Jakub Jelinek @ 2013-11-13 10:52 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

void f1 (void) {}
__attribute__((target ("avx"))) void f2 (void) {}
__attribute__((target ("avx2"))) void f3 (void) {}
__attribute__((target ("sse3"))) void f4 (void) {}
__attribute__((target ("ssse3"))) void f5 (void) {}
__attribute__((target ("sse4"))) void f6 (void) {}
takes about 3 seconds to compile at -O2, because set_cfun is terribly
expensive and there are hundreds of such calls.
The following patch is just a quick change to avoid some of them:
execute_function_todo starts with:
  unsigned int flags = (size_t)data;
  flags &= ~cfun->last_verified;
  if (!flags)
    return;
and if flags is initially zero, it does nothing.
Similarly, execute_function_dump has the whole body surrounded by
  if (dump_file && current_function_decl)
and thus if dump_file is NULL, there is nothing to do.
So IMHO in neither case (which happens pretty frequently) we need to
set_cfun to every function during IPA.

Also, I wonder if we couldn't defer the expensive ira_init, if the info
computed by it is used only during RTL optimization passes (haven't verified
it yet), then supposedly we could just remember using some target hook
what the last state was when we did ira_init last time, and call ira_init
again at the start of expansion or so if it is different from the last time.
For i?86/x86_64/ppc* this would be whether the current function's
DECL_FUNCTION_SPECIFIC_TARGET is the same as one for which ira_init has been
called, for rx whether interrupt attribute is the same and for mips whatever
is needed.

2013-11-13  Jakub Jelinek  <jakub@redhat.com>

	* passes.c (execute_todo): Don't call do_per_function if
	flags are zero.
	(execute_one_ipa_transform_pass, execute_one_pass): Don't call
	execute_function_dump if dump_file is NULL.

--- gcc/passes.c.jj	2013-11-12 11:31:30.000000000 +0100
+++ gcc/passes.c	2013-11-12 18:52:40.590727542 +0100
@@ -1875,7 +1875,8 @@ execute_todo (unsigned int flags)
 
   statistics_fini_pass ();
 
-  do_per_function (execute_function_todo, (void *)(size_t) flags);
+  if (flags)
+    do_per_function (execute_function_todo, (void *)(size_t) flags);
 
   /* Always remove functions just as before inlining: IPA passes might be
      interested to see bodies of extern inline functions that are not inlined
@@ -2065,7 +2066,8 @@ execute_one_ipa_transform_pass (struct c
   if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
     check_profile_consistency (pass->static_pass_number, 1, true);
 
-  do_per_function (execute_function_dump, NULL);
+  if (dump_file)
+    do_per_function (execute_function_dump, NULL);
   pass_fini_dump_file (pass);
 
   current_pass = NULL;
@@ -2231,7 +2233,8 @@ execute_one_pass (struct opt_pass *pass)
     check_profile_consistency (pass->static_pass_number, 1, true);
 
   verify_interpass_invariants ();
-  do_per_function (execute_function_dump, NULL);
+  if (dump_file)
+    do_per_function (execute_function_dump, NULL);
   if (pass->type == IPA_PASS)
     {
       struct cgraph_node *node;

	Jakub

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

end of thread, other threads:[~2013-12-10  9:43 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 10:52 [PATCH] Avoid some unnecessary set_cfun calls Jakub Jelinek
2013-11-13 11:17 ` Richard Biener
2013-11-13 11:27   ` Jakub Jelinek
2013-11-13 11:38     ` Richard Biener
2013-11-13 11:45       ` Jakub Jelinek
2013-11-13 11:51         ` Richard Biener
2013-11-16 12:58     ` Richard Sandiford
2013-11-13 14:13 ` Martin Jambor
2013-11-13 14:20   ` Richard Biener
2013-11-13 14:40     ` Martin Jambor
2013-11-13 14:46     ` David Malcolm
2013-11-13 15:22       ` Richard Biener
2013-11-16 10:49         ` [PATCH] Eliminate n_basic_blocks macro (was Re: [PATCH] Avoid some unnecessary set_cfun calls) David Malcolm
2013-11-19  5:27           ` David Malcolm
2013-11-19  9:19             ` Richard Biener
2013-11-19 17:29               ` Committed: removal of n_edges macro David Malcolm
2013-11-19 17:33                 ` Richard Biener
2013-11-20  1:12                 ` Committed: removal of ENTRY_BLOCK_PTR and EXIT_BLOCK_PTR macros David Malcolm
2013-12-06 14:52                   ` [PATCH 00/13] Remove remaining cfun-using macros from basic-block.h David Malcolm
2013-12-06 14:52                     ` [PATCH 01/13] Rename macros (basic_block_info_for_function, BASIC_BLOCK_FOR_FUNCTION, SET_BASIC_BLOCK_FOR_FUNCTION) David Malcolm
2013-12-06 14:53                     ` [PATCH 07/13] Eliminate basic_block_info macro David Malcolm
2013-12-06 14:53                     ` [PATCH 02/13] Rename last_basic_block_for_function to last_basic_block_for_fn David Malcolm
2013-12-06 14:53                     ` [PATCH 03/13] Rename label_to_block_map_for_function to label_to_block_map_for_fn David Malcolm
2013-12-06 14:53                     ` [PATCH 04/13] Rename profile_status_for_function to profile_status_for_fn David Malcolm
2013-12-06 14:53                     ` [PATCH 12/13] Eliminate FOR_EACH_BB_REVERSE macro David Malcolm
2013-12-07  7:14                       ` Oleg Endo
2013-12-06 14:53                     ` [PATCH 05/13] Eliminate SET_BASIC_BLOCK macro David Malcolm
2013-12-06 15:08                     ` [PATCH 09/13] Eliminate profile_status macro David Malcolm
2013-12-06 15:08                     ` [PATCH 11/13] Eliminate FOR_EACH_BB macro David Malcolm
2013-12-07  7:13                       ` Oleg Endo
2013-12-06 15:08                     ` [PATCH 08/13] Eliminate label_to_block_map macro David Malcolm
2013-12-06 15:09                     ` [PATCH 10/13] Eliminate last_basic_block macro David Malcolm
2013-12-06 15:58                       ` Steven Bosscher
2013-12-06 18:57                         ` Oleg Endo
2013-12-06 20:25                           ` Richard Biener
2013-12-09 21:48                             ` David Malcolm
2013-12-09 21:53                               ` Oleg Endo
2013-12-10  9:43                               ` Richard Biener
2013-12-06 15:12                     ` [PATCH 13/13] Eliminate FOR_ALL_BB macro David Malcolm
2013-12-06 15:12                     ` [PATCH 06/13] Eliminate BASIC_BLOCK macro David Malcolm
2013-12-06 15:39                     ` [PATCH 00/13] Remove remaining cfun-using macros from basic-block.h Richard Biener
2013-12-09 22:07                       ` David Malcolm

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).