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]

[tree-ssa-branch]: Patch for misc things


Bootstrapped on x86-linux.

Fixes a few things, adds the find_expr_in_tree change we talked about.


2002-08-08  Daniel Berlin  <dberlin@dberlin.org>

        * tree-cfg.c (find_expr_in_tree_helper): Renamed from find_expr_in_tree.
        (find_expr_in_tree): Redone.

2002-07-30  Daniel Berlin  <dberlin@dberlin.org>

        * tree-cfg.c (insert_before_ctrl_stmt): Fix insertion for various
        parts of for loop.

        * tree-ssa-pre.c (finalize_1): Set EXPR_STMT type to type of
        expression in it.


Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.3
diff -c -3 -p -w -B -b -r1.1.4.3 tree-cfg.c
*** tree-cfg.c	7 Aug 2002 16:02:58 -0000	1.1.4.3
--- tree-cfg.c	8 Aug 2002 20:41:41 -0000
*************** static void insert_before_normal_stmt PA
*** 89,94 ****
--- 89,95 ----
  static void insert_after_ctrl_stmt PARAMS ((tree, basic_block));
  static void insert_after_normal_stmt PARAMS ((tree, tree, basic_block));
  static void insert_after_loop_body PARAMS ((tree, basic_block));
+ static tree *find_expr_in_tree_helper PARAMS ((tree, tree, int, bool));
  
  
  /* Create basic blocks.  */
*************** first_exec_stmt (t)
*** 1515,1521 ****
  
    /* If we still haven't found one and T is at the end of a tree chain, try
       the successor of the enclosing compound statement.  */
!   if (TREE_CHAIN (t) == NULL)
      {
        chain = first_exec_stmt (TREE_CHAIN (TREE_COMPOUND_STMT (t)));
        if (chain)
--- 1516,1522 ----
  
    /* If we still haven't found one and T is at the end of a tree chain, try
       the successor of the enclosing compound statement.  */
!   if (TREE_CHAIN (t) == NULL && TREE_COMPOUND_STMT (t) != NULL)
      {
        chain = first_exec_stmt (TREE_CHAIN (TREE_COMPOUND_STMT (t)));
        if (chain)
*************** insert_before_ctrl_stmt (stmt, where, bb
*** 1733,1741 ****
  	      tree init_stmt_expr = EXPR_STMT_EXPR (init_stmt);
  
  	      EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR, 
! 						  TREE_TYPE (init_stmt_expr),
! 						  init_stmt_expr, 
  						  EXPR_STMT_EXPR (stmt), 
  						  init_stmt_expr);
  	    }
  	  else
--- 1734,1742 ----
  	      tree init_stmt_expr = EXPR_STMT_EXPR (init_stmt);
  
  	      EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR, 
! 			      			  TREE_TYPE (EXPR_STMT_EXPR (stmt)),
  						  EXPR_STMT_EXPR (stmt),
+ 
  						  init_stmt_expr) ;
  	    }
  	  else
*************** insert_before_ctrl_stmt (stmt, where, bb
*** 1755,1762 ****
                EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR,  
                                                    TREE_TYPE (init_stmt_expr), 
                                                    init_stmt_expr,  
!                                                   EXPR_STMT_EXPR (stmt),  
!                                                   init_stmt_expr); 
  	  }
  	  else
  	    FOR_INIT_STMT (parent) = stmt;
--- 1756,1762 ----
                EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR,  
                                                    TREE_TYPE (init_stmt_expr), 
                                                    init_stmt_expr,  
!                                                   EXPR_STMT_EXPR (stmt));
  	  }
  	  else
  	    FOR_INIT_STMT (parent) = stmt;
*************** insert_before_ctrl_stmt (stmt, where, bb
*** 1765,1772 ****
--- 1765,1780 ----
  	    insert_after_normal_stmt (copy_node (stmt), last_stmt,
  				      BB_FOR_STMT (last_stmt));
  	  else
+ 	    {
+ 	      if (FOR_EXPR (parent))
+ 		FOR_EXPR (parent) = build (COMPOUND_EXPR, 
+ 					   TREE_TYPE (stmt), 
+ 					   copy_node (stmt), 
+ 					   FOR_EXPR (parent));
+ 	      else
  		FOR_EXPR (parent) = copy_node (stmt);
  	    }
+ 	}
        
        /* FOR_EXPR block.  Insert at the end of the loop body.  */
        else if (bb == FOR_EXPR_BB (parent_bb))
*************** insert_after_ctrl_stmt (stmt, bb)
*** 2005,2012 ****
                EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR,  
                                                    TREE_TYPE (init_stmt_expr), 
                                                    init_stmt_expr,  
!                                                   EXPR_STMT_EXPR (stmt),  
!                                                   init_stmt_expr); 
  	    }
  	  else
  	    insert_after_normal_stmt (stmt, t, bb);
--- 2013,2019 ----
                EXPR_STMT_EXPR (init_stmt) = build (COMPOUND_EXPR,  
                                                    TREE_TYPE (init_stmt_expr), 
                                                    init_stmt_expr,  
!                                                   EXPR_STMT_EXPR (stmt));
  	    }
  	  else
  	    insert_after_normal_stmt (stmt, t, bb);
*************** insert_after_ctrl_stmt (stmt, bb)
*** 2029,2037 ****
  	{
  	  t = last_exec_stmt (FOR_EXPR (parent));
  	  if (t == NULL)
  	    FOR_EXPR (parent) = stmt;
  	  else
! 	    insert_after_normal_stmt (stmt, t, bb);
  	}
        
        else
--- 2036,2052 ----
  	{
  	  t = last_exec_stmt (FOR_EXPR (parent));
  	  if (t == NULL)
+ 	    {
+ 	      if (FOR_EXPR (parent))
+ 		FOR_EXPR (parent) = build (COMPOUND_EXPR, 
+ 					   TREE_TYPE (FOR_EXPR (parent)), 
+ 					   FOR_EXPR (parent), 
+ 					   stmt);
+ 	      else
  		FOR_EXPR (parent) = stmt;
+ 	    }
  	  else
! 	    insert_after_normal_stmt (stmt, t, BB_FOR_STMT (t));
  	}
        
        else
*************** replace_expr_in_tree (t, old_expr, new_e
*** 2198,2207 ****
      to not go outside statement nodes, only their sub-expressions are
      searched.  */
  
! tree *
! find_expr_in_tree (t, expr)
       tree t;
       tree expr;
  {
    int i;
    tree *loc;
--- 2212,2223 ----
      to not go outside statement nodes, only their sub-expressions are
      searched.  */
  
! static tree *
! find_expr_in_tree_helper (t, expr, level, substate)
       tree t;
       tree expr;
+      int level;
+      bool substate;
  {
    int i;
    tree *loc;
*************** find_expr_in_tree (t, expr)
*** 2233,2239 ****
  	    /* Not there?  Recurse into each of the list elements.  */
  	    for (op = t; op; op = TREE_CHAIN (op))
  	      {
! 		loc = find_expr_in_tree (TREE_VALUE (op), expr);
  		if (loc)
  		  return loc;
  	      }
--- 2249,2255 ----
  	    /* Not there?  Recurse into each of the list elements.  */
  	    for (op = t; op; op = TREE_CHAIN (op))
  	      {
! 		loc = find_expr_in_tree_helper (TREE_VALUE (op), expr, level++, substate);
  		if (loc)
  		  return loc;
  	      }
*************** find_expr_in_tree (t, expr)
*** 2253,2268 ****
    /* If we still haven't found it, recurse into each sub-expression of T.  */
    for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (t)); i++)
      {
!       loc = find_expr_in_tree (TREE_OPERAND (t, i), expr);
        if (loc)
  	return loc;
      }
  
    /* Finally, if T is not a statement, recurse into its chain (this limits
       the search to a single statement).  */
!   if (! statement_code_p (TREE_CODE (t)))
      {
!       loc = find_expr_in_tree (TREE_CHAIN (t), expr);
        if (loc)
  	return loc;
      }
--- 2269,2284 ----
    /* If we still haven't found it, recurse into each sub-expression of T.  */
    for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (t)); i++)
      {
!       loc = find_expr_in_tree_helper (TREE_OPERAND (t, i), expr, level++, substate);
        if (loc)
  	return loc;
      }
  
    /* Finally, if T is not a statement, recurse into its chain (this limits
       the search to a single statement).  */
!   if (! statement_code_p (TREE_CODE (t)) || (substate && level != 0))
      {
!       loc = find_expr_in_tree_helper (TREE_CHAIN (t), expr, level, substate);
        if (loc)
  	return loc;
      }
*************** find_expr_in_tree (t, expr)
*** 2270,2275 ****
--- 2286,2298 ----
    return NULL;
  }
  
+ tree *
+ find_expr_in_tree (t, expr)
+ 	tree t;
+ 	tree expr;
+ {
+ 	return find_expr_in_tree_helper (t, expr, 0, true);
+ }
  
  /*  Insert basic block NEW_BB before BB.  */
  
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.9
diff -c -3 -p -w -B -b -r1.1.4.9 tree-ssa-pre.c
*** tree-ssa-pre.c	30 Jul 2002 03:37:39 -0000	1.1.4.9
--- tree-ssa-pre.c	8 Aug 2002 20:41:42 -0000
*************** finalize_1 (ei, temp)
*** 1241,1246 ****
--- 1241,1247 ----
  		    }
  		  expr = build_modify_expr (temp, NOP_EXPR, ei->expr);
  		  stmt = build_stmt (EXPR_STMT, expr);
+ 		  TREE_TYPE (stmt) = TREE_TYPE (expr);
  		  bb = EXPRREF_BB (X);
  		  /* If it's a goto, we need to insert *before* it.
  		     This might not be necessary once goto elimination
*************** tree_perform_ssapre ()
*** 1782,1787 ****
--- 1783,1789 ----
    sbitmap_vector_zero (pre_dfs, last_basic_block);
    compute_dominance_frontiers (pre_dfs, pre_idom);
  
+   dump_file = dump_begin (TDI_ssa_pre, &dump_flags);
    calculate_preorder ();
    FOR_EACH_BB (bb)
      {    
*************** tree_perform_ssapre ()
*** 1859,1865 ****
       pre_part_1_trav (VARRAY_GENERIC_PTR (bexprs, j), pre_dfs);
    /*  simplify_stmt (fn, NULL_TREE); */
    /* Debugging dump after SSA PRE */
-   dump_file = dump_begin (TDI_ssa_pre, &dump_flags);
    if (dump_file)
      {
        fprintf (dump_file, "%s()\n",
--- 1861,1866 ----


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