diff mbox series

Accumulate time in sreals in ipa-fnsplit

Message ID 20171116165743.GG76038@kam.mff.cuni.cz
State New
Headers show
Series Accumulate time in sreals in ipa-fnsplit | expand

Commit Message

Jan Hubicka Nov. 16, 2017, 4:57 p.m. UTC
Hi,
this patch does same change to ipa-split as previous patch did to fnsummary.

Bootstrapped/regtested x86_64-linux.

Honza

	* ipa-split.c (split_bb_info): Turn time to sreal.
	(split_point): Likewise.
	(dump_split_point): Likewise.
	(fine_split_points): Likewise.
	(execute_split_functions): Only zero split_bbs; turn time to sreals.
diff mbox series

Patch

Index: ipa-split.c
===================================================================
--- ipa-split.c	(revision 254812)
+++ ipa-split.c	(working copy)
@@ -111,7 +111,7 @@  along with GCC; see the file COPYING3.
 struct split_bb_info
 {
   unsigned int size;
-  unsigned int time;
+  sreal time;
 };
 
 static vec<split_bb_info> bb_info_vec;
@@ -121,7 +121,8 @@  static vec<split_bb_info> bb_info_vec;
 struct split_point
 {
   /* Size of the partitions.  */
-  unsigned int header_time, header_size, split_time, split_size;
+  sreal header_time, split_time;
+  unsigned int header_size, split_size;
 
   /* SSA names that need to be passed into spit function.  */
   bitmap ssa_names_to_pass;
@@ -195,10 +196,11 @@  dump_split_point (FILE * file, struct sp
 {
   fprintf (file,
 	   "Split point at BB %i\n"
-	   "  header time: %i header size: %i\n"
-	   "  split time: %i split size: %i\n  bbs: ",
-	   current->entry_bb->index, current->header_time,
-	   current->header_size, current->split_time, current->split_size);
+	   "  header time: %f header size: %i\n"
+	   "  split time: %f split size: %i\n  bbs: ",
+	   current->entry_bb->index, current->header_time.to_double (),
+	   current->header_size, current->split_time.to_double (),
+	   current->split_size);
   dump_bitmap (file, current->split_bbs);
   fprintf (file, "  SSA names to pass: ");
   dump_bitmap (file, current->ssa_names_to_pass);
@@ -1034,7 +1036,8 @@  struct stack_entry
   int earliest;
 
   /* Overall time and size of all BBs reached from this BB in DFS walk.  */
-  int overall_time, overall_size;
+  sreal overall_time;
+  int overall_size;
 
   /* When false we can not split on this BB.  */
   bool can_split;
@@ -1059,7 +1062,7 @@  struct stack_entry
    the component used by consider_split.  */
 
 static void
-find_split_points (basic_block return_bb, int overall_time, int overall_size)
+find_split_points (basic_block return_bb, sreal overall_time, int overall_size)
 {
   stack_entry first;
   vec<stack_entry> stack = vNULL;
@@ -1731,7 +1734,8 @@  execute_split_functions (void)
 {
   gimple_stmt_iterator bsi;
   basic_block bb;
-  int overall_time = 0, overall_size = 0;
+  sreal overall_time = 0;
+  int overall_size = 0;
   int todo = 0;
   struct cgraph_node *node = cgraph_node::get (current_function_decl);
 
@@ -1822,33 +1826,36 @@  execute_split_functions (void)
 
   /* Compute local info about basic blocks and determine function size/time.  */
   bb_info_vec.safe_grow_cleared (last_basic_block_for_fn (cfun) + 1);
-  memset (&best_split_point, 0, sizeof (best_split_point));
+  best_split_point.split_bbs = NULL;
   basic_block return_bb = find_return_bb ();
   int tsan_exit_found = -1;
   FOR_EACH_BB_FN (bb, cfun)
     {
-      int time = 0;
+      sreal time = 0;
       int size = 0;
-      int freq = compute_call_stmt_bb_frequency (current_function_decl, bb);
+      sreal freq = bb->count.to_sreal_scale
+			 (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count);
 
       if (dump_file && (dump_flags & TDF_DETAILS))
 	fprintf (dump_file, "Basic block %i\n", bb->index);
 
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
-	  int this_time, this_size;
+	  sreal this_time;
+	  int this_size;
 	  gimple *stmt = gsi_stmt (bsi);
 
 	  this_size = estimate_num_insns (stmt, &eni_size_weights);
-	  this_time = estimate_num_insns (stmt, &eni_time_weights) * freq;
+	  this_time = (sreal)estimate_num_insns (stmt, &eni_time_weights)
+			 * freq;
 	  size += this_size;
 	  time += this_time;
 	  check_forbidden_calls (stmt);
 
 	  if (dump_file && (dump_flags & TDF_DETAILS))
 	    {
-	      fprintf (dump_file, "  freq:%6i size:%3i time:%3i ",
-		       freq, this_size, this_time);
+	      fprintf (dump_file, "  freq:%4.2f size:%3i time:%4.2f ",
+		       freq.to_double (), this_size, this_time.to_double ());
 	      print_gimple_stmt (dump_file, stmt, 0);
 	    }