Fix computation of min_size in ipa-fnsummary.c
diff mbox series

Message ID 20191109174405.c2bmicjtclr3vadu@kam.mff.cuni.cz
State New
Headers show
Series
  • Fix computation of min_size in ipa-fnsummary.c
Related show

Commit Message

Jan Hubicka Nov. 9, 2019, 5:44 p.m. UTC
Hi,
this patch fixes two different bugs in computation of min_size in
ipa-fnsummary.c.  This computes minimal size of any clone or version 
of given function and is used to avoid some harder work to compute
actual size for given context in the inlining heuristics.

In estimate_size_and_time we mistakely reset min_size to size of first
entry of size/time table (which is only unconditional entry) forgetting
that it already cumulated info about calls sizes.

In update_overall_fn_summary we forgot to account the size/time table
and then divide result by size scale.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

	* ipa-fnsummary.c (ipa_call_context::estimate_size_and_time): Fix
	calculation of min_size.
	(ipa_update_overall_fn_summary): Likewise.

Patch
diff mbox series

Index: ipa-fnsummary.c
===================================================================
--- ipa-fnsummary.c	(revision 278005)
+++ ipa-fnsummary.c	(working copy)
@@ -3243,6 +3243,7 @@  ipa_call_context::estimate_size_and_time
 
   sreal nonspecialized_time = time;
 
+  min_size += (*info->size_time_table)[0].size;
   for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++)
     {
       bool exec = e->exec_predicate.evaluate (m_nonspec_possible_truths);
@@ -3288,7 +3289,7 @@  ipa_call_context::estimate_size_and_time
      }
   gcc_checking_assert ((*info->size_time_table)[0].exec_predicate == true);
   gcc_checking_assert ((*info->size_time_table)[0].nonconst_predicate == true);
-  min_size = (*info->size_time_table)[0].size;
+  gcc_checking_assert (min_size >= 0);
   gcc_checking_assert (size >= 0);
   gcc_checking_assert (time >= 0);
   /* nonspecialized_time should be always bigger than specialized time.
@@ -3685,12 +3686,13 @@  ipa_update_overall_fn_summary (struct cg
       size_info->size += e->size;
       info->time += e->time;
     }
+  info->min_size = (*info->size_time_table)[0].size;
   estimate_calls_size_and_time (node, &size_info->size, &info->min_size,
 				&info->time, NULL,
 				~(clause_t) (1 << predicate::false_condition),
 				vNULL, vNULL, vNULL);
-  size_info->size = (size_info->size + ipa_fn_summary::size_scale / 2)
-		    / ipa_fn_summary::size_scale;
+  size_info->size = RDIV (size_info->size, ipa_fn_summary::size_scale);
+  info->min_size = RDIV (info->min_size, ipa_fn_summary::size_scale);
 }