Patchwork remove superfluous sets to SSA_NAME_DEF_STMT

login
register
mail settings
Submitter Aldy Hernandez
Date Nov. 7, 2013, 8:14 p.m.
Message ID <527BF49E.4050004@redhat.com>
Download mbox | patch
Permalink /patch/289476/
State New
Headers show

Comments

Aldy Hernandez - Nov. 7, 2013, 8:14 p.m.
SSA_NAME_DEF_STMT is set by default in gimple_build_assign(), by virtue 
of gimple_assign_set_lhs:

> static inline void
> gimple_assign_set_lhs (gimple gs, tree lhs)
> {
>   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
>   gimple_set_op (gs, 0, lhs);
>
>   if (lhs && TREE_CODE (lhs) == SSA_NAME)
>     SSA_NAME_DEF_STMT (lhs) = gs;
> }

This patch removes all the unnecessary sets to SSA_NAME_DEF_STMT in the 
compiler.

Tested on x86-64 Linux.

OK for trunk?
* gimplify.c (gimple_regimplify_operands): Do not set
    	SSA_NAME_DEF_STMT.
    	* graphite-sese-to-poly.c (remove_simple_copy_phi): Same.
    	(rewrite_close_phi_out_of_ssa): Same.
    	(rewrite_phi_out_of_ssa): Same.
    	(rewrite_degenerate_phi): Same.
    	(handle_scalar_deps_crossing_scop_limits): Same.
    	* tree-if-conv.c (predicate_scalar_phi): Same.
    	* tree-parloops.c (create_loads_for_reductions): Same.
    	(create_final_loads_for_reduction): Same.
    	(create_loads_and_stores_for_name): Same.
    	(transform_to_exit_first_loop): Same.
    	(create_parallel_loop): Same.
    	* tree-ssa-loop-im.c
    	(move_computations_dom_walker::before_dom_children): Same.
    	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Same.
    	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
    	Same.
    	* tree-ssa-propagate.c (substitute_and_fold): Same.
    	* tree-vect-loop.c (vect_finalize_reduction): Same.
    	* tree-vect-stmts.c (vectorizable_call): Same.
Diego Novillo - Nov. 7, 2013, 8:19 p.m.
On Thu, Nov 7, 2013 at 3:14 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> SSA_NAME_DEF_STMT is set by default in gimple_build_assign(), by virtue of
> gimple_assign_set_lhs:
>
>> static inline void
>> gimple_assign_set_lhs (gimple gs, tree lhs)
>> {
>>   GIMPLE_CHECK (gs, GIMPLE_ASSIGN);
>>   gimple_set_op (gs, 0, lhs);
>>
>>   if (lhs && TREE_CODE (lhs) == SSA_NAME)
>>     SSA_NAME_DEF_STMT (lhs) = gs;
>> }
>
>
> This patch removes all the unnecessary sets to SSA_NAME_DEF_STMT in the
> compiler.
>
> Tested on x86-64 Linux.
>
> OK for trunk?

OK.


Diego.

Patch

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 721e8fb..2875a07 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9191,8 +9191,6 @@  gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
 		temp = make_ssa_name (temp, NULL);
 	      gimple_set_lhs (stmt, temp);
 	      post_stmt = gimple_build_assign (lhs, temp);
-	      if (TREE_CODE (lhs) == SSA_NAME)
-		SSA_NAME_DEF_STMT (lhs) = post_stmt;
 	    }
 	}
       break;
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 6c2ac41..514be1d 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -101,7 +101,6 @@  remove_simple_copy_phi (gimple_stmt_iterator *psi)
 
   remove_phi_node (psi, false);
   gsi_insert_on_edge_immediate (e, stmt);
-  SSA_NAME_DEF_STMT (res) = stmt;
 }
 
 /* Removes an invariant phi node at position PSI by inserting on the
@@ -2174,7 +2173,6 @@  rewrite_close_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
       stmt = gimple_build_assign (res, arg);
       remove_phi_node (psi, false);
       gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
-      SSA_NAME_DEF_STMT (res) = stmt;
       return;
     }
 
@@ -2251,7 +2249,6 @@  rewrite_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
 
   stmt = gimple_build_assign (res, unshare_expr (zero_dim_array));
   remove_phi_node (psi, false);
-  SSA_NAME_DEF_STMT (res) = stmt;
   insert_stmts (scop, stmt, NULL, gsi_after_labels (bb));
 }
 
@@ -2274,7 +2271,6 @@  rewrite_degenerate_phi (gimple_stmt_iterator *psi)
 
   stmt = gimple_build_assign (res, rhs);
   remove_phi_node (psi, false);
-  SSA_NAME_DEF_STMT (res) = stmt;
 
   gsi = gsi_after_labels (bb);
   gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
@@ -2381,7 +2377,6 @@  handle_scalar_deps_crossing_scop_limits (scop_p scop, tree def, gimple stmt)
       gimple assign = gimple_build_assign (new_name, def);
       gimple_stmt_iterator psi = gsi_after_labels (SESE_EXIT (region)->dest);
 
-      SSA_NAME_DEF_STMT (new_name) = assign;
       update_stmt (assign);
       gsi_insert_before (&psi, assign, GSI_SAME_STMT);
     }
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 31994b7..bb8de6d 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1330,7 +1330,6 @@  predicate_scalar_phi (gimple phi, tree cond,
     }
 
   new_stmt = gimple_build_assign (res, rhs);
-  SSA_NAME_DEF_STMT (gimple_phi_result (phi)) = new_stmt;
   gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
   update_stmt (new_stmt);
 
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 25a0f0a..c357f1f 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1152,7 +1152,6 @@  create_loads_for_reductions (reduction_info **slot, struct clsn_data *clsn_data)
   x = load_struct;
   name = PHI_RESULT (red->keep_res);
   stmt = gimple_build_assign (name, x);
-  SSA_NAME_DEF_STMT (name) = stmt;
 
   gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
 
@@ -1182,7 +1181,6 @@  create_final_loads_for_reduction (reduction_info_table_type reduction_list,
   stmt = gimple_build_assign (ld_st_data->load, t);
 
   gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
-  SSA_NAME_DEF_STMT (ld_st_data->load) = stmt;
 
   reduction_list
     .traverse <struct clsn_data *, create_loads_for_reductions> (ld_st_data);
@@ -1236,7 +1234,6 @@  create_loads_and_stores_for_name (name_to_copy_elt **slot,
   load_struct = build_simple_mem_ref (clsn_data->load);
   t = build3 (COMPONENT_REF, type, load_struct, elt->field, NULL_TREE);
   stmt = gimple_build_assign (elt->new_name, t);
-  SSA_NAME_DEF_STMT (elt->new_name) = stmt;
   gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
 
   return 1;
@@ -1594,7 +1591,6 @@  transform_to_exit_first_loop (struct loop *loop,
 				  false, NULL_TREE, false, GSI_SAME_STMT);
   stmt = gimple_build_assign (control_name, nit_1);
   gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
-  SSA_NAME_DEF_STMT (control_name) = stmt;
 }
 
 /* Create the parallel constructs for LOOP as described in gen_parallel_loop.
@@ -1635,12 +1631,10 @@  create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
       param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL);
       stmt = gimple_build_assign (param, build_fold_addr_expr (data));
       gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
-      SSA_NAME_DEF_STMT (param) = stmt;
 
       stmt = gimple_build_assign (new_data,
 				  fold_convert (TREE_TYPE (new_data), param));
       gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
-      SSA_NAME_DEF_STMT (new_data) = stmt;
     }
 
   /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL.  */
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 339e7f2..2283b5b 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1238,7 +1238,6 @@  move_computations_dom_walker::before_dom_children (basic_block bb)
 	  new_stmt = gimple_build_assign_with_ops (TREE_CODE (arg),
 						   gimple_phi_result (stmt),
 						   arg, NULL_TREE);
-	  SSA_NAME_DEF_STMT (gimple_phi_result (stmt)) = new_stmt;
 	}
       else
 	{
@@ -1254,7 +1253,6 @@  move_computations_dom_walker::before_dom_children (basic_block bb)
 	  new_stmt = gimple_build_assign_with_ops (COND_EXPR,
 						   gimple_phi_result (stmt),
 						   t, arg0, arg1);
-	  SSA_NAME_DEF_STMT (gimple_phi_result (stmt)) = new_stmt;
 	  todo_ |= TODO_cleanup_cfg;
 	}
       gsi_insert_on_edge (loop_preheader_edge (level), new_stmt);
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index da9761b..2bb2253 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -1288,7 +1288,6 @@  rewrite_phi_with_iv (loop_p loop,
 				  GSI_SAME_STMT);
   stmt = gimple_build_assign (res, val);
   gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
-  SSA_NAME_DEF_STMT (res) = stmt;
 }
 
 /* Rewrite all the phi nodes of LOOP in function of the main induction
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 4d97b13..1f5ff23 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -4116,7 +4116,6 @@  eliminate_dom_walker::before_dom_children (basic_block b)
       if (!useless_type_conversion_p (TREE_TYPE (res), TREE_TYPE (sprime)))
 	sprime = fold_convert (TREE_TYPE (res), sprime);
       stmt = gimple_build_assign (res, sprime);
-      SSA_NAME_DEF_STMT (res) = stmt;
       gimple_set_plf (stmt, NECESSARY, gimple_plf (phi, NECESSARY));
 
       gsi2 = gsi_after_labels (b);
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index d5bcc9c..3456edb 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1079,7 +1079,6 @@  substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
 	  {
 	    gimple new_stmt = gimple_build_assign (name, val);
 	    gimple_stmt_iterator gsi2;
-	    SSA_NAME_DEF_STMT (name) = new_stmt;
 	    gsi2 = gsi_after_labels (gimple_bb (def_stmt));
 	    gsi_insert_before (&gsi2, new_stmt, GSI_SAME_STMT);
 	    remove_phi_node (&gsi, false);
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index d5f86ad..6e71eea 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -4327,7 +4327,6 @@  vect_finalize_reduction:
       epilog_stmt = gimple_build_assign (new_dest, expr);
       new_temp = make_ssa_name (new_dest, epilog_stmt);
       gimple_assign_set_lhs (epilog_stmt, new_temp);
-      SSA_NAME_DEF_STMT (new_temp) = epilog_stmt;
       gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT);
       if (nested_in_vect_loop)
         {
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index c1ba3c7..5a2bbb5 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2104,7 +2104,6 @@  vectorizable_call (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   set_vinfo_for_stmt (stmt, NULL);
   STMT_VINFO_STMT (stmt_info) = new_stmt;
   gsi_replace (gsi, new_stmt, false);
-  SSA_NAME_DEF_STMT (gimple_assign_lhs (new_stmt)) = new_stmt;
 
   return true;
 }