public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples][patch] Converting several easy passes
@ 2008-03-04 22:19 Oleg Ryjkov
  2008-03-05  0:12 ` Diego Novillo
  0 siblings, 1 reply; 7+ messages in thread
From: Oleg Ryjkov @ 2008-03-04 22:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: dnovillo

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

This patch enables pass_warn_function_return, pass_update_address_taken,
pass_simple_dse and pass_build_alias passes; also fixes the copying of the
NO_WARNING flag to a newly created gimple_return. Tested yesterday, with
couple of tests being fixed. I'm running the testsuite with the most
up-to-date codebase.
OK, provided that nothing new breaks?

2008-03-04  Oleg Ryjkov  <olegr@google.com>

  * tree-ssa-dse.c (execute_simple_dse): Tuplified.
  * gimplify.c (gimplify_return_expr): Copy the NO_WARNING flag
  to the newly created expr from the tree.
  * tree-cfg.c (gimplify_build1): Tuplified.
  * passes.c (init_optimization_passes): Enabled
  pass_warn_function_return, pass_update_address_taken,
  pass_simple_dse and pass_build_alias passes.

[-- Attachment #2: 1.diff --]
[-- Type: text/plain, Size: 9486 bytes --]

Index: tree-ssa-dse.c
===================================================================
--- tree-ssa-dse.c	(revision 132872)
+++ tree-ssa-dse.c	(working copy)
@@ -663,9 +663,7 @@ struct tree_opt_pass pass_dse = {
 static unsigned int
 execute_simple_dse (void)
 {
-  /* FIXME tuples.  */
-#if 0
-  block_stmt_iterator bsi;
+  gimple_stmt_iterator gsi;
   basic_block bb;
   bitmap variables_loaded = BITMAP_ALLOC (NULL);
   unsigned int todo = 0;
@@ -673,24 +671,25 @@ execute_simple_dse (void)
   /* Collect into VARIABLES LOADED all variables that are read in function
      body.  */
   FOR_EACH_BB (bb)
-    for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
-      if (LOADED_SYMS (bsi_stmt (bsi)))
+    for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      if (gimple_loaded_syms (gsi_stmt (gsi)))
 	bitmap_ior_into (variables_loaded,
-			 LOADED_SYMS (bsi_stmt (bsi)));
+			 gimple_loaded_syms (gsi_stmt (gsi)));
 
   /* Look for statements writing into the write only variables.
      And try to remove them.  */
 
   FOR_EACH_BB (bb)
-    for (bsi = bsi_start (bb); !bsi_end_p (bsi);)
+    for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
       {
-	tree stmt = bsi_stmt (bsi), op;
+	gimple stmt = gsi_stmt (gsi);
+        tree op;
 	bool removed = false;
         ssa_op_iter iter;
 
-	if (STORED_SYMS (stmt) && TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
-	    && TREE_CODE (stmt) != RETURN_EXPR
-	    && !bitmap_intersect_p (STORED_SYMS (stmt), variables_loaded))
+	if (gimple_stored_syms (stmt) && (gimple_code (stmt) == GIMPLE_ASSIGN
+	    || gimple_code (stmt) != GIMPLE_CALL)
+	    && !bitmap_intersect_p (gimple_stored_syms (stmt), variables_loaded))
 	  {
 	    unsigned int i;
 	    bitmap_iterator bi;
@@ -705,7 +704,7 @@ execute_simple_dse (void)
 	       from removing them as dead.  The flag thus has no use for us
 	       and we need to look into all operands.  */
 	      
-	    EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
+	    EXECUTE_IF_SET_IN_BITMAP (gimple_stored_syms (stmt), 0, i, bi)
 	      {
 		tree var = referenced_var_lookup (i);
 		if (TREE_ADDRESSABLE (var)
@@ -714,8 +713,8 @@ execute_simple_dse (void)
 		  dead = false;
 	      }
 
-	    if (dead && LOADED_SYMS (stmt))
-	      EXECUTE_IF_SET_IN_BITMAP (LOADED_SYMS (stmt), 0, i, bi)
+	    if (dead && gimple_loaded_syms (stmt))
+	      EXECUTE_IF_SET_IN_BITMAP (gimple_loaded_syms (stmt), 0, i, bi)
 		if (TREE_THIS_VOLATILE (referenced_var_lookup (i)))
 		  dead = false;
 
@@ -727,56 +726,46 @@ execute_simple_dse (void)
 	    /* Look for possible occurence var = indirect_ref (...) where
 	       indirect_ref itself is volatile.  */
 
-	    if (dead && TREE_THIS_VOLATILE (GIMPLE_STMT_OPERAND (stmt, 1)))
+	    if (dead && gimple_code (stmt) == GIMPLE_ASSIGN &&
+                TREE_THIS_VOLATILE (gimple_assign_rhs1 (stmt)))
 	      dead = false;
 
-	    if (dead)
+	    if (dead && gimple_code (stmt) == GIMPLE_CALL)
 	      {
-		tree call = get_call_expr_in (stmt);
-
 		/* When LHS of var = call (); is dead, simplify it into
 		   call (); saving one operand.  */
-		if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
-		    && call
-		    && TREE_SIDE_EFFECTS (call))
+                if (gimple_has_side_effects (stmt))
 		  {
 		    if (dump_file && (dump_flags & TDF_DETAILS))
 		      {
 			fprintf (dump_file, "Deleted LHS of call: ");
-			print_generic_stmt (dump_file, stmt, TDF_SLIM);
+			print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
 			fprintf (dump_file, "\n");
 		      }
-		    push_stmt_changes (bsi_stmt_ptr (bsi));
-		    TREE_BLOCK (call) = TREE_BLOCK (stmt);
-		    bsi_replace (&bsi, call, false);
-		    maybe_clean_or_replace_eh_stmt (stmt, call);
-		    mark_symbols_for_renaming (call);
-		    pop_stmt_changes (bsi_stmt_ptr (bsi));
+		    push_stmt_changes (gsi_stmt_ptr (&gsi));
+                    gimple_call_set_lhs (stmt, NULL);
+		    pop_stmt_changes (gsi_stmt_ptr (&gsi));
 		  }
 		else
 		  {
 		    if (dump_file && (dump_flags & TDF_DETAILS))
 		      {
 			fprintf (dump_file, "  Deleted dead store '");
-			print_generic_expr (dump_file, stmt, dump_flags);
+			print_gimple_stmt (dump_file, stmt, 0, dump_flags);
 			fprintf (dump_file, "'\n");
 		      }
 		    removed = true;
-		    bsi_remove (&bsi, true);
+		    gsi_remove (&gsi, true);
 		    todo |= TODO_cleanup_cfg;
 		  }
 		todo |= TODO_remove_unused_locals | TODO_ggc_collect;
 	      }
 	  }
 	if (!removed)
-	  bsi_next (&bsi);
+	  gsi_next (&gsi);
       }
   BITMAP_FREE (variables_loaded);
   return todo;
-#else
-  gimple_unreachable ();
-  return 0;
-#endif
 }
 
 struct tree_opt_pass pass_simple_dse =
Index: ChangeLog.tuples
===================================================================
--- ChangeLog.tuples	(revision 132872)
+++ ChangeLog.tuples	(working copy)
@@ -1,3 +1,13 @@
+2008-03-04  Oleg Ryjkov  <olegr@google.com>
+
+	* tree-ssa-dse.c (execute_simple_dse): Tuplified.
+	* gimplify.c (gimplify_return_expr): Copy the NO_WARNING flag
+	to the newly created expr from the tree.
+	* tree-cfg.c (gimplify_build1): Tuplified.
+	* passes.c (init_optimization_passes): Enabled
+	pass_warn_function_return, pass_update_address_taken,
+	pass_simple_dse and pass_build_alias passes.
+
 2008-03-04  Rafael Espindola  <espindola@google.com>
 
 	* fold-const.c (tree_simple_nonnegative_warnv_p): New.
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 132872)
+++ gimplify.c	(working copy)
@@ -1192,6 +1192,7 @@ gimplify_return_expr (tree stmt, gimple_
       || ret_expr == error_mark_node)
     {
       gimple ret = gimple_build_return (ret_expr);
+      gimple_set_no_warning (ret, TREE_NO_WARNING (stmt));
       gimple_seq_add_stmt (pre_p, ret);
       return GS_ALL_DONE;
     }
@@ -1248,7 +1249,9 @@ gimplify_return_expr (tree stmt, gimple_
 
   gimplify_and_add (TREE_OPERAND (stmt, 0), pre_p);
 
-  gimple_seq_add_stmt (pre_p, gimple_build_return (result));
+  gimple ret = gimple_build_return (result);
+  gimple_set_no_warning (ret, TREE_NO_WARNING (stmt));
+  gimple_seq_add_stmt (pre_p, ret);
 
   return GS_ALL_DONE;
 }
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 132872)
+++ tree-cfg.c	(working copy)
@@ -6689,14 +6689,12 @@ gimplify_build1 (gimple_stmt_iterator *g
 static unsigned int
 execute_warn_function_return (void)
 {
-/* FIXME tuples  */
-#if 0
 #ifdef USE_MAPPED_LOCATION
   source_location location;
 #else
   location_t *locus;
 #endif
-  tree last;
+  gimple last;
   edge e;
   edge_iterator ei;
 
@@ -6712,9 +6710,9 @@ execute_warn_function_return (void)
       FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
 	{
 	  last = last_stmt (e->src);
-	  if (TREE_CODE (last) == RETURN_EXPR
+	  if (gimple_code (last) == GIMPLE_RETURN
 #ifdef USE_MAPPED_LOCATION
-	      && (location = EXPR_LOCATION (last)) != UNKNOWN_LOCATION)
+	      && (location = gimple_locus (last)) != UNKNOWN_LOCATION)
 #else
 	      && (locus = EXPR_LOCUS (last)) != NULL)
 #endif
@@ -6740,13 +6738,13 @@ execute_warn_function_return (void)
     {
       FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
 	{
-	  tree last = last_stmt (e->src);
-	  if (TREE_CODE (last) == RETURN_EXPR
-	      && TREE_OPERAND (last, 0) == NULL
-	      && !TREE_NO_WARNING (last))
+	  gimple last = last_stmt (e->src);
+	  if (gimple_code (last) == GIMPLE_RETURN
+	      && gimple_return_retval (last) == NULL
+	      && !gimple_no_warning_p (last))
 	    {
 #ifdef USE_MAPPED_LOCATION
-	      location = EXPR_LOCATION (last);
+	      location = gimple_locus (last);
 	      if (location == UNKNOWN_LOCATION)
 		  location = cfun->function_end_locus;
 	      warning (OPT_Wreturn_type, "%Hcontrol reaches end of non-void function", &location);
@@ -6762,10 +6760,6 @@ execute_warn_function_return (void)
 	}
     }
   return 0;
-#else
-  gimple_unreachable ();
-  return 0;
-#endif
 }
 
 
Index: passes.c
===================================================================
--- passes.c	(revision 132872)
+++ passes.c	(working copy)
@@ -491,10 +491,7 @@ init_optimization_passes (void)
   NEXT_PASS (pass_build_cfg);
   NEXT_PASS (pass_lower_complex_O0);
   NEXT_PASS (pass_lower_vector);
-  /* FIXME tuples.  */
-#if 0
   NEXT_PASS (pass_warn_function_return);
-#endif
   NEXT_PASS (pass_build_cgraph_edges);
   NEXT_PASS (pass_inline_parameters);
   *p = NULL;
@@ -538,13 +535,19 @@ init_optimization_passes (void)
 #if 0
 	  NEXT_PASS (pass_ccp);
 	  NEXT_PASS (pass_forwprop);
+#endif
 	  NEXT_PASS (pass_update_address_taken);
 	  NEXT_PASS (pass_simple_dse);
+/* FIXME tuples.  */
+#if 0
 	  NEXT_PASS (pass_sra_early);
 	  NEXT_PASS (pass_copy_prop);
 	  NEXT_PASS (pass_merge_phi);
 	  NEXT_PASS (pass_dce);
+#endif
 	  NEXT_PASS (pass_update_address_taken);
+/* FIXME tuples.  */
+#if 0
 	  NEXT_PASS (pass_simple_dse);
 	  NEXT_PASS (pass_tail_recursion);
           NEXT_PASS (pass_profile);
@@ -582,12 +585,12 @@ init_optimization_passes (void)
     {
       struct tree_opt_pass **p = &pass_all_optimizations.sub;
       NEXT_PASS (pass_create_structure_vars);
-      /* FIXME tuples.  */
-#if 0
       /* ??? pass_build_alias is a dummy pass that ensures that we
 	 execute TODO_rebuild_alias at this point even if
 	 pass_create_structure_vars was disabled.  */
       NEXT_PASS (pass_build_alias);
+      /* FIXME tuples.  */
+#if 0
       NEXT_PASS (pass_return_slot);
       NEXT_PASS (pass_rename_ssa_copies);
 

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

end of thread, other threads:[~2008-03-24 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-04 22:19 [tuples][patch] Converting several easy passes Oleg Ryjkov
2008-03-05  0:12 ` Diego Novillo
2008-03-05  0:47   ` Oleg Ryjkov
2008-03-05  3:43     ` Oleg Ryjkov
2008-03-05  3:46       ` Diego Novillo
2008-03-23  0:30         ` Jakub Staszak
2008-03-24 14:25           ` Diego Novillo

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