public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Conditional TODOs on SSA-CCP
@ 2007-01-17 10:55 Jan Hubicka
  2007-01-17 11:26 ` Jan Hubicka
  2007-01-17 15:12 ` Ian Lance Taylor
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Hubicka @ 2007-01-17 10:55 UTC (permalink / raw)
  To: gcc-patches

Hi,
this patch updates ssa-ccp to return update flags conditionally.  As an extra
I've removed removal of unreferenced vars that might happen quite rarely (such
as for optimized out uninitalized locals) but it probably should still be
handled if we don't want to rely on some later pass unconditinally cleaning up.

I've bootstrapped/regtested on i686-linux and verified that the extra TODO
don't seem to cause off-noise slowdowns.  In fact both runs was little bit (2
seconds out of 4 minutes) faster.

:ADDPATCH tree-optimization:
OK?
Honza
	* tree-ssa-ccp.c (ccp_finalize): Return if something changed.
	(execute_ssa_ccp): Return flags conditionally.
	* tree-ssa-propagate.c (substitue_and_fold): Return if something was
	changed.
	* tree-ssa-propagate.h (substitute_and_fold): Update prototype.
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c	(revision 120796)
--- tree-ssa-ccp.c	(working copy)
*************** ccp_initialize (void)
*** 665,679 ****
  
  
  /* Do final substitution of propagated values, cleanup the flowgraph and
!    free allocated storage.  */
  
! static void
  ccp_finalize (void)
  {
    /* Perform substitutions based on the known constant values.  */
!   substitute_and_fold (const_val, false);
  
    free (const_val);
  }
  
  
--- 665,682 ----
  
  
  /* Do final substitution of propagated values, cleanup the flowgraph and
!    free allocated storage.  
  
!    Return TRUE when something was optimized.  */
! 
! static bool
  ccp_finalize (void)
  {
    /* Perform substitutions based on the known constant values.  */
!   bool something_changed = substitute_and_fold (const_val, false);
  
    free (const_val);
+   return something_changed;;
  }
  
  
*************** ccp_visit_stmt (tree stmt, edge *taken_e
*** 1397,1417 ****
  
  /* Main entry point for SSA Conditional Constant Propagation.  */
  
! static void
  execute_ssa_ccp (bool store_ccp)
  {
    do_store_ccp = store_ccp;
    ccp_initialize ();
    ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
!   ccp_finalize ();
  }
  
  
  static unsigned int
  do_ssa_ccp (void)
  {
!   execute_ssa_ccp (false);
!   return 0;
  }
  
  
--- 1400,1423 ----
  
  /* Main entry point for SSA Conditional Constant Propagation.  */
  
! static unsigned int
  execute_ssa_ccp (bool store_ccp)
  {
    do_store_ccp = store_ccp;
    ccp_initialize ();
    ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
!   if (ccp_finalize ())
!     return (TODO_cleanup_cfg | TODO_update_ssa | TODO_update_smt_usage
! 	    | TODO_remove_unused_locals);
!   else
!     return 0;
  }
  
  
  static unsigned int
  do_ssa_ccp (void)
  {
!   return execute_ssa_ccp (false);
  }
  
  
*************** struct tree_opt_pass pass_ccp = 
*** 1435,1447 ****
    0,					/* properties_provided */
    0,					/* properties_destroyed */
    0,					/* todo_flags_start */
!   TODO_cleanup_cfg
!     | TODO_dump_func
!     | TODO_update_ssa
!     | TODO_ggc_collect
!     | TODO_verify_ssa
!     | TODO_verify_stmts
!     | TODO_update_smt_usage,		/* todo_flags_finish */
    0					/* letter */
  };
  
--- 1441,1448 ----
    0,					/* properties_provided */
    0,					/* properties_destroyed */
    0,					/* todo_flags_start */
!   TODO_dump_func | TODO_verify_ssa
!   | TODO_verify_stmts | TODO_ggc_collect,/* todo_flags_finish */
    0					/* letter */
  };
  
*************** static unsigned int
*** 1450,1457 ****
  do_ssa_store_ccp (void)
  {
    /* If STORE-CCP is not enabled, we just run regular CCP.  */
!   execute_ssa_ccp (flag_tree_store_ccp != 0);
!   return 0;
  }
  
  static bool
--- 1451,1457 ----
  do_ssa_store_ccp (void)
  {
    /* If STORE-CCP is not enabled, we just run regular CCP.  */
!   return execute_ssa_ccp (flag_tree_store_ccp != 0);
  }
  
  static bool
*************** struct tree_opt_pass pass_store_ccp = 
*** 1477,1489 ****
    0,					/* properties_provided */
    0,					/* properties_destroyed */
    0,					/* todo_flags_start */
!   TODO_dump_func
!     | TODO_update_ssa
!     | TODO_ggc_collect
!     | TODO_verify_ssa
!     | TODO_cleanup_cfg
!     | TODO_verify_stmts
!     | TODO_update_smt_usage,		/* todo_flags_finish */
    0					/* letter */
  };
  
--- 1477,1484 ----
    0,					/* properties_provided */
    0,					/* properties_destroyed */
    0,					/* todo_flags_start */
!   TODO_dump_func | TODO_verify_ssa
!   | TODO_verify_stmts | TODO_ggc_collect,/* todo_flags_finish */
    0					/* letter */
  };
  
Index: tree-ssa-propagate.c
===================================================================
*** tree-ssa-propagate.c	(revision 120796)
--- tree-ssa-propagate.c	(working copy)
*************** fold_predicate_in (tree stmt)
*** 1137,1151 ****
     expressions are evaluated with a call to vrp_evaluate_conditional.
     This will only give meaningful results when called from tree-vrp.c
     (the information used by vrp_evaluate_conditional is built by the
!    VRP pass).  */
  
! void
  substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
  {
    basic_block bb;
  
    if (prop_value == NULL && !use_ranges_p)
!     return;
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "\nSubstituing values and folding statements\n\n");
--- 1137,1154 ----
     expressions are evaluated with a call to vrp_evaluate_conditional.
     This will only give meaningful results when called from tree-vrp.c
     (the information used by vrp_evaluate_conditional is built by the
!    VRP pass).  
  
!    Return TRUE when something changed.  */
! 
! bool
  substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
  {
    basic_block bb;
+   bool something_changed = false;
  
    if (prop_value == NULL && !use_ranges_p)
!     return false;
  
    if (dump_file && (dump_flags & TDF_DETAILS))
      fprintf (dump_file, "\nSubstituing values and folding statements\n\n");
*************** substitute_and_fold (prop_value_t *prop_
*** 1234,1239 ****
--- 1237,1243 ----
  
  	      /* Determine what needs to be done to update the SSA form.  */
  	      pop_stmt_changes (bsi_stmt_ptr (i));
+ 	      something_changed = true;
  	    }
  	  else
  	    {
*************** substitute_and_fold (prop_value_t *prop_
*** 1261,1266 ****
--- 1265,1271 ----
        fprintf (dump_file, "Predicates folded:    %6ld\n",
  	       prop_stats.num_pred_folded);
      }
+   return something_changed;
  }
  
  #include "gt-tree-ssa-propagate.h"
Index: tree-ssa-propagate.h
===================================================================
*** tree-ssa-propagate.h	(revision 120796)
--- tree-ssa-propagate.h	(working copy)
*************** bool stmt_makes_single_load (tree);
*** 120,125 ****
  bool stmt_makes_single_store (tree);
  prop_value_t *get_value_loaded_by (tree, prop_value_t *);
  bool replace_uses_in (tree, bool *, prop_value_t *);
! void substitute_and_fold (prop_value_t *, bool);
  
  #endif /* _TREE_SSA_PROPAGATE_H  */
--- 120,125 ----
  bool stmt_makes_single_store (tree);
  prop_value_t *get_value_loaded_by (tree, prop_value_t *);
  bool replace_uses_in (tree, bool *, prop_value_t *);
! bool substitute_and_fold (prop_value_t *, bool);
  
  #endif /* _TREE_SSA_PROPAGATE_H  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Conditional TODOs on SSA-CCP
  2007-01-17 10:55 Conditional TODOs on SSA-CCP Jan Hubicka
@ 2007-01-17 11:26 ` Jan Hubicka
  2007-01-17 15:12 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Hubicka @ 2007-01-17 11:26 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

> Hi,
> this patch updates ssa-ccp to return update flags conditionally.  As an extra
> I've removed removal of unreferenced vars that might happen quite rarely (such
        ^^ added
> as for optimized out uninitalized locals) but it probably should still be
> handled if we don't want to rely on some later pass unconditinally cleaning up.

The hidden dependency was what caused David's bootstrap to break after
DCE change.  My plan is to add removal of unreferenced vars to early
passes that can do it and also make cfgcleanup to drop in the TODO as
needed since removal of dead basic blocks is common source of making
variables unused.

Honza

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Conditional TODOs on SSA-CCP
  2007-01-17 10:55 Conditional TODOs on SSA-CCP Jan Hubicka
  2007-01-17 11:26 ` Jan Hubicka
@ 2007-01-17 15:12 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2007-01-17 15:12 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

Jan Hubicka <jh@suse.cz> writes:

> 	* tree-ssa-ccp.c (ccp_finalize): Return if something changed.
> 	(execute_ssa_ccp): Return flags conditionally.
> 	* tree-ssa-propagate.c (substitue_and_fold): Return if something was
> 	changed.
> 	* tree-ssa-propagate.h (substitute_and_fold): Update prototype.

This is OK.

Thanks.

:REVIEWMAIL:

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-17 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-17 10:55 Conditional TODOs on SSA-CCP Jan Hubicka
2007-01-17 11:26 ` Jan Hubicka
2007-01-17 15:12 ` Ian Lance Taylor

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