public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix hot/cold code in ipa-cp
@ 2011-04-19 14:59 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2011-04-19 14:59 UTC (permalink / raw)
  To: gcc-patches

Hi,
while removing use of optimize_function_for_size_p from the ipa-inliner (since we already
check cgraph_maybe_hot_edge_p that include the test), I noticed that
optimize_function_for_size_p (DECL_STRUCT_FUNCTION (node->decl)) won't give the expected
results on WPA when DECL_STRUCT_FUNCTION is NULL.
Fixed by adding cgraph_optimize_for_size_p.

Bootstrapped/regtested x86_64-linux.

Honza
	* cgraph.h (cgraph_optimize_for_size_p): Declare.
	* ipa-cp.c (ipcp_insert_stage): Use cgraph_optimize_for_size_p.
	* predict.c (cgraph_optimize_for_size_p): Break out from ...
	(optimize_function_for_size_p) ... here.
Index: cgraph.h
===================================================================
*** cgraph.h	(revision 172709)
--- cgraph.h	(working copy)
*************** bool cgraph_comdat_can_be_unshared_p (st
*** 656,661 ****
--- 656,662 ----
  
  /* In predict.c  */
  bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
+ bool cgraph_optimize_for_size_p (struct cgraph_node *);
  
  /* In varpool.c  */
  extern GTY(()) struct varpool_node *varpool_nodes_queue;
Index: ipa-cp.c
===================================================================
*** ipa-cp.c	(revision 172709)
--- ipa-cp.c	(working copy)
*************** ipcp_insert_stage (void)
*** 1410,1416 ****
        if (new_size + growth > max_new_size)
  	break;
        if (growth
! 	  && optimize_function_for_size_p (DECL_STRUCT_FUNCTION (node->decl)))
  	{
  	  if (dump_file)
  	    fprintf (dump_file, "Not versioning, cold code would grow");
--- 1410,1416 ----
        if (new_size + growth > max_new_size)
  	break;
        if (growth
! 	  && cgraph_optimize_for_size_p (node))
  	{
  	  if (dump_file)
  	    fprintf (dump_file, "Not versioning, cold code would grow");
Index: predict.c
===================================================================
*** predict.c	(revision 172709)
--- predict.c	(working copy)
*************** maybe_hot_edge_p (edge e)
*** 196,202 ****
--- 196,204 ----
    return maybe_hot_frequency_p (EDGE_FREQUENCY (e));
  }
  
+ 
  /* Return true in case BB is probably never executed.  */
+ 
  bool
  probably_never_executed_bb_p (const_basic_block bb)
  {
*************** probably_never_executed_bb_p (const_basi
*** 209,214 ****
--- 211,229 ----
    return false;
  }
  
+ /* Return true if NODE should be optimized for size.  */
+ 
+ bool
+ cgraph_optimize_for_size_p (struct cgraph_node *node)
+ {
+   if (optimize_size)
+     return true;
+   if (node && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))
+     return true;
+   else
+     return false;
+ }
+ 
  /* Return true when current function should always be optimized for size.  */
  
  bool
*************** optimize_function_for_size_p (struct fun
*** 220,230 ****
      return true;
    if (!fun || !fun->decl)
      return false;
!   node = cgraph_get_node (fun->decl);
!   if (node && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))
!     return true;
!   else
!     return false;
  }
  
  /* Return true when current function should always be optimized for speed.  */
--- 235,241 ----
      return true;
    if (!fun || !fun->decl)
      return false;
!   return cgraph_optimize_for_size_p (cgraph_get_node (fun->decl));
  }
  
  /* Return true when current function should always be optimized for speed.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-19 14:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19 14:59 Fix hot/cold code in ipa-cp Jan Hubicka

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