Avoid sreal in cgrpah_maybe_hot_p
diff mbox series

Message ID 20191110181311.lirntjqdq2mo5eut@kam.mff.cuni.cz
State New
Headers show
Series
  • Avoid sreal in cgrpah_maybe_hot_p
Related show

Commit Message

Jan Hubicka Nov. 10, 2019, 6:13 p.m. UTC
Hi,
while looking into performance issues with too much of sreal use in
inliner I nocited that in maybe_hot_p it is used just to hold a fraction
which is easily done on profile_counters, too.

This has also advantage that it will work with partially guessed static
profiles which are there during early inlining.

Bootstrapped/regtested x86_64-linux, comitted.

	* cgraph.c (cgraph_edge::maybe_hot_p): Do not use sreal_frequency.

Patch
diff mbox series

Index: cgraph.c
===================================================================
--- cgraph.c	(revision 278020)
+++ cgraph.c	(working copy)
@@ -2697,14 +2697,18 @@  cgraph_edge::maybe_hot_p (void)
     return false;
   if (caller->frequency == NODE_FREQUENCY_HOT)
     return true;
-  /* If profile is now known yet, be conservative.
-     FIXME: this predicate is used by early inliner and can do better there.  */
-  if (symtab->state < IPA_SSA)
+  if (!count.initialized_p ())
     return true;
-  if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE
-      && sreal_frequency () * 2 < 3)
+  cgraph_node *where = caller->inlined_to ? caller->inlined_to : caller;
+  if (!where->count.initialized_p ())
     return false;
-  if (sreal_frequency () * PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) <= 1)
+  if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE)
+    {
+      if (count.apply_scale (2, 1) < where->count.apply_scale (3, 1))
+	return false;
+    }
+  else if (count.apply_scale (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION), 1)
+	   < where->count)
     return false;
   return true;
 }