[PATCH] Optimization pass-pipeline re-organization [2/n]

Richard Guenther rguenther@suse.de
Thu Aug 14 16:22:00 GMT 2008


As promised here is the further instrumentation of passes with
statistics.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Richard.

2008-08-14  Richard Guenther  <rguenther@suse.de>

	* tree-cfgcleanup.c (remove_forwarder_block): Count the event.
	(remove_forwarder_block_with_phi): Likewise.
	* tree-sra.c (tree_sra): Count the number of scalarized variables.
	* tree-ssa-dse.c (dse_optimize_stmt): Count the number of
	deleted stores.
	(execute_simple_dse): Likewise.
	* tree-ssa-forwprop.c (remove_prop_source_from_use): Count the
	number of deleted statements.
	(forward_propagate_into_gimple_cond): Count the number of
	simplified conditions.
	(forward_propagate_into_cond): Likewise.
	(forward_propagate_addr_expr): Count the number of propagated
	addresses.  Count the number of deleted statements.
	(forward_propagate_comparison): Count the number of propagated
	conversions.
	(simplify_not_neg_expr): Count the number of propagated negations.
	(simplify_gimple_switch): Count the number of propagated conversions.
	(tree_ssa_forward_propagate_single_use_vars): Count the number of
	deleted statements.
	* tree-ssa.c (execute_update_addresses_taken): Count the number
	of variables promoted to registers.
	* tree-tailcall.c (optimize_tail_call): Count the number of
	converted tail recursions.
	* cfghooks.c (delete_basic_block): Count the number of deleted
	basic blocks.
	(merge_blocks): Count the number of merged blocks.
	* tree-inline.c (expand_call_inline): Count the number of calls
	inlined.
	* tree-ssa-phiprop.c (propagate_with_phi): Count the number of
	converted loads.
	(pass_phiprop): Require PROP_alias.


Index: trunk/gcc/tree-cfgcleanup.c
===================================================================
*** trunk.orig/gcc/tree-cfgcleanup.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-cfgcleanup.c	2008-08-13 16:22:40.000000000 +0200
*************** remove_forwarder_block (basic_block bb)
*** 464,469 ****
--- 464,471 ----
    /* And kill the forwarder block.  */
    delete_basic_block (bb);
  
+   statistics_counter_event (cfun, "Forwarder blocks removed", 1);
+ 
    return true;
  }
  
*************** remove_forwarder_block_with_phi (basic_b
*** 806,811 ****
--- 808,815 ----
    /* Remove BB since all of BB's incoming edges have been redirected
       to DEST.  */
    delete_basic_block (bb);
+ 
+   statistics_counter_event (cfun, "Forwarder blocks removed", 1);
  }
  
  /* This pass merges PHI nodes if one feeds into another.  For example,
Index: trunk/gcc/tree-sra.c
===================================================================
*** trunk.orig/gcc/tree-sra.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-sra.c	2008-08-13 16:22:40.000000000 +0200
*************** tree_sra (void)
*** 3666,3672 ****
        decide_instantiations ();
        scalarize_function ();
        if (!bitmap_empty_p (sra_candidates))
! 	todoflags |= TODO_rebuild_alias;
      }
  
    /* Free allocated memory.  */
--- 3666,3676 ----
        decide_instantiations ();
        scalarize_function ();
        if (!bitmap_empty_p (sra_candidates))
! 	{
! 	  statistics_counter_event (cfun, "Variables scalarized",
! 				    bitmap_count_bits (sra_candidates));
! 	  todoflags |= TODO_rebuild_alias;
! 	}
      }
  
    /* Free allocated memory.  */
Index: trunk/gcc/tree-ssa-dse.c
===================================================================
*** trunk.orig/gcc/tree-ssa-dse.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-ssa-dse.c	2008-08-13 16:22:40.000000000 +0200
*************** dse_optimize_stmt (struct dom_walk_data
*** 476,481 ****
--- 476,482 ----
                print_gimple_stmt (dump_file, gsi_stmt (gsi), dump_flags, 0);
                fprintf (dump_file, "'\n");
              }
+ 	  statistics_counter_event (cfun, "Stores deleted", 1);
  
  	  /* Then we need to fix the operand of the consuming stmt.  */
  	  stmt_lhs = USE_FROM_PTR (first_use_p);
*************** execute_simple_dse (void)
*** 723,728 ****
--- 724,730 ----
  		    push_stmt_changes (gsi_stmt_ptr (&gsi));
                      gimple_call_set_lhs (stmt, NULL);
  		    pop_stmt_changes (gsi_stmt_ptr (&gsi));
+ 		    statistics_counter_event (cfun, "Stores LHS deleted", 1);
  		  }
  		else
  		  {
*************** execute_simple_dse (void)
*** 735,740 ****
--- 737,743 ----
  		    removed = true;
  		    gsi_remove (&gsi, true);
  		    todo |= TODO_cleanup_cfg;
+ 		    statistics_counter_event (cfun, "Stores deleted", 1);
  		  }
  		todo |= TODO_remove_unused_locals | TODO_ggc_collect;
  	      }
Index: trunk/gcc/tree-ssa-forwprop.c
===================================================================
*** trunk.orig/gcc/tree-ssa-forwprop.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-ssa-forwprop.c	2008-08-13 16:22:40.000000000 +0200
*************** remove_prop_source_from_use (tree name,
*** 315,320 ****
--- 315,321 ----
      gsi = gsi_for_stmt (stmt);
      release_defs (stmt);
      gsi_remove (&gsi, true);
+     statistics_counter_event (cfun, "Statements deleted", 1);
  
      name = (gimple_assign_copy_p (stmt)) ? gimple_assign_rhs1 (stmt) : NULL;
    } while (name && TREE_CODE (name) == SSA_NAME);
*************** forward_propagate_into_gimple_cond (gimp
*** 449,454 ****
--- 450,456 ----
  
          gimple_cond_set_condition_from_tree (stmt, unshare_expr (tmp));
  	update_stmt (stmt);
+ 	statistics_counter_event (cfun, "Conditions simplified", 1);
  
  	/* Remove defining statements.  */
  	remove_prop_source_from_use (name, NULL);
*************** forward_propagate_into_cond (gimple_stmt
*** 554,559 ****
--- 556,562 ----
  	gimple_assign_set_rhs_from_tree (gsi_p, unshare_expr (tmp));
  	stmt = gsi_stmt (*gsi_p);
  	update_stmt (stmt);
+ 	statistics_counter_event (cfun, "Conditions simplified", 1);
  
  	/* Remove defining statements.  */
  	remove_prop_source_from_use (name, NULL);
*************** forward_propagate_addr_expr (tree name,
*** 880,885 ****
--- 883,889 ----
  	use_stmt = gsi_stmt (gsi);
        }
        all &= result;
+       statistics_counter_event (cfun, "Addresses propagated", 1);
  
        pop_stmt_changes (&use_stmt);
  
*************** forward_propagate_addr_expr (tree name,
*** 894,899 ****
--- 898,904 ----
  	  gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
  	  release_defs (use_stmt);
  	  gsi_remove (&gsi, true);
+ 	  statistics_counter_event (cfun, "Statements deleted", 1);
  	}
      }
  
*************** forward_propagate_comparison (gimple stm
*** 986,991 ****
--- 991,997 ----
  	gimple_assign_set_rhs_from_tree (&gsi, unshare_expr (tmp));
  	use_stmt = gsi_stmt (gsi);
  	update_stmt (use_stmt);
+ 	statistics_counter_event (cfun, "Conversions propagated", 1);
        }
  
        /* Remove defining statements.  */
*************** simplify_not_neg_expr (gimple_stmt_itera
*** 1042,1047 ****
--- 1048,1054 ----
  	  gimple_assign_set_rhs_from_tree (gsi_p, rhs_def_operand);
  	  stmt = gsi_stmt (*gsi_p);
  	  update_stmt (stmt);
+ 	  statistics_counter_event (cfun, "Negations propagated", 1);
  	}
      }
  }
*************** simplify_gimple_switch (gimple stmt)
*** 1097,1102 ****
--- 1104,1110 ----
  		{
  		  gimple_switch_set_index (stmt, def);
  		  update_stmt (stmt);
+ 		  statistics_counter_event (cfun, "Conversions propagated", 1);
  		}
  	    }
  	}
*************** tree_ssa_forward_propagate_single_use_va
*** 1149,1154 ****
--- 1157,1163 ----
  		      release_defs (stmt);
  		      todoflags |= TODO_remove_unused_locals;
  		      gsi_remove (&gsi, true);
+ 		      statistics_counter_event (cfun, "Statements deleted", 1);
  		    }
  		  else
  		    gsi_next (&gsi);
*************** tree_ssa_forward_propagate_single_use_va
*** 1181,1186 ****
--- 1190,1196 ----
  		      release_defs (stmt);
  		      todoflags |= TODO_remove_unused_locals;
  		      gsi_remove (&gsi, true);
+ 		      statistics_counter_event (cfun, "Statements deleted", 1);
  		    }
  		  else
  		    gsi_next (&gsi);
Index: trunk/gcc/tree-ssa.c
===================================================================
*** trunk.orig/gcc/tree-ssa.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-ssa.c	2008-08-13 16:22:40.000000000 +0200
*************** execute_update_addresses_taken (void)
*** 1610,1615 ****
--- 1610,1616 ----
    bitmap addresses_taken = BITMAP_ALLOC (NULL);
    bitmap vars_updated = BITMAP_ALLOC (NULL);
    bool update_vops = false;
+   unsigned cnt = 0;
  
    /* Collect into ADDRESSES_TAKEN all variables whose address is taken within
       the function body.  */
*************** execute_update_addresses_taken (void)
*** 1651,1656 ****
--- 1652,1658 ----
  	  mark_sym_for_renaming (var);
  	update_vops = true;
  	bitmap_set_bit (vars_updated, DECL_UID (var));
+ 	cnt++;
  	if (dump_file)
  	  {
  	    fprintf (dump_file, "No longer having address taken ");
*************** execute_update_addresses_taken (void)
*** 1658,1663 ****
--- 1660,1666 ----
  	    fprintf (dump_file, "\n");
  	  }
        }
+   statistics_counter_event (cfun, "Promoted to registers", cnt);
  
    /* Operand caches needs to be recomputed for operands referencing the updated
       variables.  */
Index: trunk/gcc/tree-tailcall.c
===================================================================
*** trunk.orig/gcc/tree-tailcall.c	2008-08-13 10:44:01.000000000 +0200
--- trunk/gcc/tree-tailcall.c	2008-08-13 16:22:40.000000000 +0200
*************** optimize_tail_call (struct tailcall *t,
*** 834,839 ****
--- 834,840 ----
    if (t->tail_recursion)
      {
        eliminate_tail_call (t);
+       statistics_counter_event (cfun, "Tail recursions", 1);
        return true;
      }
  
Index: trunk/gcc/cfghooks.c
===================================================================
*** trunk.orig/gcc/cfghooks.c	2008-08-13 10:45:15.000000000 +0200
--- trunk/gcc/cfghooks.c	2008-08-13 16:23:29.000000000 +0200
*************** delete_basic_block (basic_block bb)
*** 474,479 ****
--- 474,480 ----
      internal_error ("%s does not support delete_basic_block", cfg_hooks->name);
  
    cfg_hooks->delete_basic_block (bb);
+   statistics_counter_event (cfun, "Blocks deleted", 1);
  
    if (current_loops != NULL)
      {
*************** merge_blocks (basic_block a, basic_block
*** 659,664 ****
--- 660,666 ----
      internal_error ("%s does not support merge_blocks", cfg_hooks->name);
  
    cfg_hooks->merge_blocks (a, b);
+   statistics_counter_event (cfun, "Blocks merged", 1);
  
    if (current_loops != NULL)
      remove_bb_from_loops (b);
Index: trunk/gcc/tree-inline.c
===================================================================
*** trunk.orig/gcc/tree-inline.c	2008-08-13 10:45:31.000000000 +0200
--- trunk/gcc/tree-inline.c	2008-08-13 16:23:29.000000000 +0200
*************** expand_call_inline (basic_block bb, gimp
*** 3148,3153 ****
--- 3148,3154 ----
  	}
        goto egress;
      }
+   statistics_counter_event (cfun, "Functions inlined", 1);
    fn = cg_edge->callee->decl;
  
  #ifdef ENABLE_CHECKING
Index: trunk/gcc/tree-ssa-phiprop.c
===================================================================
*** trunk.orig/gcc/tree-ssa-phiprop.c	2008-08-13 10:44:00.000000000 +0200
--- trunk/gcc/tree-ssa-phiprop.c	2008-08-13 16:36:45.000000000 +0200
*************** propagate_with_phi (basic_block bb, gimp
*** 312,317 ****
--- 312,318 ----
  	  gsi_remove (&gsi, false);
  
  	  phi_inserted = true;
+ 	  statistics_counter_event (cfun, "Loads from PHIs promoted", 1);
  	}
        else
  	{
*************** struct gimple_opt_pass pass_phiprop =
*** 385,391 ****
    NULL,				/* next */
    0,				/* static_pass_number */
    TV_TREE_PHIPROP,		/* tv_id */
!   PROP_cfg | PROP_ssa,		/* properties_required */
    0,				/* properties_provided */
    0,				/* properties_destroyed */
    0,				/* todo_flags_start */
--- 386,392 ----
    NULL,				/* next */
    0,				/* static_pass_number */
    TV_TREE_PHIPROP,		/* tv_id */
!   PROP_cfg | PROP_ssa | PROP_alias, /* properties_required */
    0,				/* properties_provided */
    0,				/* properties_destroyed */
    0,				/* todo_flags_start */



More information about the Gcc-patches mailing list