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-profiling]: A few small MEM_REF cleanups


in preparation for moving MEM_REF to the mainline, i've made a few
cleanups.

force_gimple_operand_nossa is no more, it was replaced by an in_ssa_p
use in force_gimple_operand.

MEM_REF is now counted as a pointer dereference and lowering mem_ref was
moved to after SSA to make sure all the code in tree-ssa-operands, etc
is used for testing purposes.


Bootstrapped and regtested on i686-pc-linux-gnu.



2005-05-06  Daniel Berlin  <dberlin@dberlin.org>

	* gimple-low.c (lower_memref): Use force_gimple_operand, call
	update_stmt if we are in SSA.
	* gimplify.c: Remove force_gimple_operand_nossa.
	(force_gimple_operand): Use in_ssa_p to determine
	whether to create ssa names or not.
	* tree-flow.h (force_gimple_operand_nossa): Remove.
	* tree-optimize.c (init_tree_optimization_passes): Move
	pass_lower_memref.
	* tree-ssa-alias.c (count_ptr_derefs): MEM_REF is a dereference.

Index: gimple-low.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimple-low.c,v
retrieving revision 1.1.4.17.2.17
diff -u -p -r1.1.4.17.2.17 gimple-low.c
--- gimple-low.c	20 Apr 2005 01:37:38 -0000	1.1.4.17.2.17
+++ gimple-low.c	6 May 2005 13:55:28 -0000
@@ -693,7 +693,7 @@ lower_memref (tree *tp,
 		     MEM_REF_SYMBOL (*tp), with);
       
 
-      with = force_gimple_operand_nossa (with, &stmts, false, NULL_TREE);
+      with = force_gimple_operand (with, &stmts, false, NULL_TREE);
       if (stmts)
 	bsi_insert_before (bsip, stmts, BSI_SAME_STMT);
       
@@ -702,7 +702,7 @@ lower_memref (tree *tp,
       TREE_SIDE_EFFECTS (indirect) = TREE_SIDE_EFFECTS (*tp);
       TREE_THIS_VOLATILE (indirect) = TREE_THIS_VOLATILE (*tp);
       
-      indirect = force_gimple_operand_nossa (indirect, &stmts, false, 
+      indirect = force_gimple_operand (indirect, &stmts, false, 
 					     NULL_TREE);
       if (stmts)
 	bsi_insert_before (bsip, stmts, BSI_SAME_STMT);
@@ -730,6 +730,8 @@ lower_memrefs (void)
 	tree stmt = bsi_stmt (bsi);
 	visited_nodes = pointer_set_create ();
 	walk_tree (&stmt,  lower_memref, (void *)&bsi, visited_nodes);
+	if (in_ssa_p)
+	  update_stmt (stmt);
 	pointer_set_destroy (visited_nodes);
 		   
       }
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 1.1.2.141.2.28
diff -u -p -r1.1.2.141.2.28 gimplify.c
--- gimplify.c	27 Apr 2005 13:10:07 -0000	1.1.2.141.2.28
+++ gimplify.c	6 May 2005 13:55:28 -0000
@@ -4683,13 +4683,11 @@ gimplify_function_tree (tree fndecl)
 /* Expands EXPR to list of gimple statements STMTS.  If SIMPLE is true,
    force the result to be either ssa_name or an invariant, otherwise
    just force it to be a rhs expression.  If VAR is not NULL, make the
-   base variable of the final destination be VAR if suitable.
-   If MAKE_SSA is true, make the build expressions use SSA names,
-   otherwise, do not.  */
-
-static tree
-force_gimple_operand_main (tree expr, tree *stmts, bool simple, tree var,
-			   bool make_ssa)
+   base variable of the final destination be VAR if suitable. */
+
+tree
+force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
+
 {
   tree t;
   enum gimplify_status ret;
@@ -4703,7 +4701,7 @@ force_gimple_operand_main (tree expr, tr
   gimple_test_f = simple ? is_gimple_val : is_gimple_reg_rhs;
 
   push_gimplify_context ();
-  gimplify_ctxp->into_ssa = make_ssa;
+  gimplify_ctxp->into_ssa = in_ssa_p;
 
   if (var)
     expr = build (MODIFY_EXPR, TREE_TYPE (var), var, expr);
@@ -4723,18 +4721,6 @@ force_gimple_operand_main (tree expr, tr
   return expr;
 }
 
-tree
-force_gimple_operand (tree expr, tree *stmts, bool simple, tree var)
-{
-  return force_gimple_operand_main (expr, stmts, simple, var, true);
-}
-
-tree
-force_gimple_operand_nossa (tree expr, tree *stmts, bool simple, tree var)
-{
-  return force_gimple_operand_main (expr, stmts, simple, var, false);
-}
-
 /* Invokes force_gimple_operand for EXPR with parameters SIMPLE_P and VAR.  If
    some statements are produced, emits them before BSI.  */
 
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 1.1.4.187.2.35
diff -u -p -r1.1.4.187.2.35 tree-flow.h
--- tree-flow.h	27 Apr 2005 13:10:55 -0000	1.1.4.187.2.35
+++ tree-flow.h	6 May 2005 13:55:28 -0000
@@ -802,7 +802,6 @@ extern bool expr_invariant_in_loop_p (st
 
 /* In gimplify.c  */
 tree force_gimple_operand (tree, tree *, bool, tree);
-tree force_gimple_operand_nossa (tree, tree *, bool, tree);
 tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree);
 
 #include "tree-flow-inline.h"
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.122.2.45
diff -u -p -r1.1.4.122.2.45 tree-optimize.c
--- tree-optimize.c	30 Apr 2005 20:22:36 -0000	1.1.4.122.2.45
+++ tree-optimize.c	6 May 2005 13:55:28 -0000
@@ -516,9 +516,9 @@ init_tree_optimization_passes (void)
   p = &pass_all_early_optimizations.sub;
   NEXT_PASS (pass_init_datastructures);
   NEXT_PASS (pass_referenced_vars);
-  NEXT_PASS (pass_lower_memref);
   NEXT_PASS (pass_create_structure_vars);
   NEXT_PASS (pass_build_ssa);
+  NEXT_PASS (pass_lower_memref);
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_dce);
   NEXT_PASS (pass_dominator);
@@ -551,10 +551,10 @@ init_tree_optimization_passes (void)
 
   p = &pass_all_optimizations.sub;
   NEXT_PASS (pass_referenced_vars);
-  NEXT_PASS (pass_lower_memref);
   NEXT_PASS (pass_promote_statics);
   NEXT_PASS (pass_create_structure_vars);
   NEXT_PASS (pass_build_ssa);
+  NEXT_PASS (pass_lower_memref);
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_rename_ssa_copies);
   NEXT_PASS (pass_early_warn_uninitialized);
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 1.1.2.1.2.29
diff -u -p -r1.1.2.1.2.29 tree-ssa-alias.c
--- tree-ssa-alias.c	2 May 2005 17:46:50 -0000	1.1.2.1.2.29
+++ tree-ssa-alias.c	6 May 2005 13:55:28 -0000
@@ -400,7 +400,8 @@ count_ptr_derefs (tree *tp, int *walk_su
 {
   struct count_ptr_d *count_p = (struct count_ptr_d *) data;
 
-  if (INDIRECT_REF_P (*tp) && TREE_OPERAND (*tp, 0) == count_p->ptr)
+  if ((INDIRECT_REF_P (*tp) && TREE_OPERAND (*tp, 0) == count_p->ptr)
+      || (TREE_CODE (*tp) == MEM_REF && MEM_REF_SYMBOL (*tp) == count_p->ptr))
     count_p->count++;
 
   return NULL_TREE;

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