This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] fold each statement


> > On Wed, Jan 07, 2004 at 11:14:29PM +0100, Jan Hubicka wrote:
> > > It can't be fully done in remove_useless_* because before SSA folding
> > > we miss come string simplification;
> > 
> > What do you mean by "ssa folding"?  Certainly there are no calls to
> > fold or fold_stmt from rewrite_into_ssa.
> 
> The string builtin folder in the fold_stmt walks SSA graph to get strlen
> of operand.  When program is not in SSA form these cases are missed.
> 
> > 
> > While I agree that it would be nice to do some builtin folding late
> > in the game, after constant propagation and the like, I don't see
> > what this has to do with this problem -- that of non-folded trees
> > coming out of gimplification.
> > 
> > Seems to me that we should fold during remove_useless_*, and then
> > fold just the builtins once more after (perhaps) ccp.
> 
> CCP folds only statements it propagate into, but it is still possible to
> have builtin that is foldable by walking SSA graph but none of it's
> operand constant propagate, so with current design we have to do
> fold_stmt call on each statement once in when the graph is in the SSA
> form.  
> 
> Or we can add a guard for the folding so only builtin calls are
> re-folded, but I don't this we want to maintain the invariant that only
> builtin folding walks the graph.
> 
> Alternatively we can move the folding that walks SSA graph somewhere
> else (I think reshaping pass shall take care of this)

Hi,
here is patch I used to make folding during remove_useless_stmts.
As a followup I can add an argument to fold_stmt whether SSA graph shall
be walked and I can verify just with local folding in verify_stmts.

Honza

2004-01-10  Jan Hubicka  <jh@suse.cz>
	* tree-cfg.c (remove_usless_stmts_cond):  Fold statement.
	(remove_useless_stmts_1):  Fold trees we know how to fold.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.241
diff -c -3 -p -r1.1.4.241 tree-cfg.c
*** tree-cfg.c	19 Dec 2003 07:01:36 -0000	1.1.4.241
--- tree-cfg.c	20 Dec 2003 22:23:01 -0000
*************** remove_useless_stmts_cond (tree *stmt_p,
*** 830,835 ****
--- 830,836 ----
    else_has_label = data->has_label;
    data->has_label = save_has_label | then_has_label | else_has_label;
  
+   fold_stmt (stmt_p);
    then_clause = COND_EXPR_THEN (*stmt_p);
    else_clause = COND_EXPR_ELSE (*stmt_p);
    cond = COND_EXPR_COND (*stmt_p);
*************** static void
*** 1128,1133 ****
--- 1129,1135 ----
  remove_useless_stmts_1 (tree *tp, struct rus_data *data)
  {
    tree t = *tp;
+ 
    switch (TREE_CODE (t))
      {
      case COND_EXPR:
*************** remove_useless_stmts_1 (tree *tp, struct
*** 1155,1165 ****
--- 1157,1169 ----
        break;
  
      case RETURN_EXPR:
+       fold_stmt (tp);
        data->last_goto = NULL;
        data->may_branch = true;
        break;
  
      case CALL_EXPR:
+       fold_stmt (tp);
        data->last_goto = NULL;
        notice_special_calls (t);
        update_call_expr_flags (t);
*************** remove_useless_stmts_1 (tree *tp, struct
*** 1169,1174 ****
--- 1173,1179 ----
  
      case MODIFY_EXPR:
        data->last_goto = NULL;
+       fold_stmt (tp);
        if (TREE_CODE (TREE_OPERAND (t, 1)) == CALL_EXPR)
  	{
  	  update_call_expr_flags (TREE_OPERAND (t, 1));
*************** remove_useless_stmts_1 (tree *tp, struct
*** 1203,1208 ****
--- 1208,1217 ----
  	  }
        }
        break;
+     case SWITCH_EXPR:
+       fold_stmt (tp);
+       data->last_goto = NULL;
+       break;
  
      default:
        data->last_goto = NULL;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]