Patchwork [3/n] Allow anonymous SSA names, add copy_ssa_name

login
register
mail settings
Submitter Richard Guenther
Date Aug. 7, 2012, 1:53 p.m.
Message ID <alpine.LNX.2.00.1208071549040.17088@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/175636/
State New
Headers show

Comments

Richard Guenther - Aug. 7, 2012, 1:53 p.m.
This adds copy_ssa_name similar to duplicate_ssa_name but not copying
any annotations (thus, just make a new SSA name that looks similar
to a template).  This avoids a bunch of SSA_NAME_VAR uses which will
no longer work to create SSA names off.

The 2nd part is stuff I came along when working on the overall patch.
We should release default defs of unused decls as they leak otherwise.
Also may_propagate_copy_into_asm always returns true as
DECL_HARD_REGISTER vars are never is_gimple_reg()s and thus never
have SSA names associated.  set_ssa_default_def should clear
SSA_NAME_DEFAULT_DEF off the name it replaces, even if the replacement
is NULL.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

I will commit it with two revisions separating the changes to allow
easier bisection (the copy_ssa_name is a complete no-op).

Richard.

2012-08-07  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (copy_ssa_name_fn): New function.
	(duplicate_ssa_name_fn): Likewise.
	* tree-flow-inline.h (copy_ssa_name): New function.
	(duplicate_ssa_name): Likewise.
	* tree-ssanames.c (copy_ssa_name_fn): New function.
	(duplicate_ssa_name): Rename to ...
	(duplicate_ssa_name_fn): ... this and adjust.
	* tree-tailcall.c (update_accumulator_with_ops): Use copy_ssa_name.
	* tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard1): Likewise.
	(slpeel_update_phi_nodes_for_guard2): Likewise.
	(slpeel_tree_peel_loop_to_edge): Likewise.
	(vect_loop_versioning): Likewise.
	* tree-parloops.c (transform_to_exit_first_loop): Likewise.
	(create_parallel_loop): Likewise.
	* ipa-split.c (split_function): Likewise.
	* tree-vect-loop.c (vect_is_simple_reduction_1): Likewise.
	(vect_create_epilog_for_reduction): Likewise.
	* tree-vect-data-refs.c (bump_vector_ptr): Likewise.
	(vect_setup_realignment): Likewise.
	* tree-vect-stmts.c (vectorizable_load): Likewise.
	* tree-switch-conversion.c (build_one_array): Likewise.
	(gen_def_assigns): Likewise.
	* tree-cfg.c (gimple_make_forwarder_block): Likewise.
	* graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Call
	create_zero_dim_array with the SSA name.
	(rewrite_phi_out_of_ssa): Likewise.
	(rewrite_cross_bb_scalar_dependence): Likewise.  Use copy_ssa_name.

	* tree-dfa.c (set_ssa_default_def): Clear the SSA_NAME_DEFAULT_DEF
	bit of the old name when we clear the slot.
	* tree-ssa-live.c (remove_unused_locals): Release any default
	def associated with an unused var.
	* tree-ssa-copy.c (may_propagate_copy_into_asm): Always return true.

Patch

Index: gcc/tree-tailcall.c
===================================================================
--- gcc/tree-tailcall.c	(revision 190199)
+++ gcc/tree-tailcall.c	(working copy)
@@ -644,9 +644,9 @@  update_accumulator_with_ops (enum tree_c
 			     gimple_stmt_iterator gsi)
 {
   gimple stmt;
-  tree var;
+  tree var = copy_ssa_name (acc, NULL);
   if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1)))
-    stmt = gimple_build_assign_with_ops (code, SSA_NAME_VAR (acc), acc, op1);
+    stmt = gimple_build_assign_with_ops (code, var, acc, op1);
   else
     {
       tree rhs = fold_convert (TREE_TYPE (acc),
@@ -656,11 +656,8 @@  update_accumulator_with_ops (enum tree_c
 					    op1));
       rhs = force_gimple_operand_gsi (&gsi, rhs,
 				      false, NULL, false, GSI_CONTINUE_LINKING);
-      stmt = gimple_build_assign (NULL_TREE, rhs);
+      stmt = gimple_build_assign (var, rhs);
     }
-  var = make_ssa_name (SSA_NAME_VAR (acc), stmt);
-  gimple_assign_set_lhs (stmt, var);
-  update_stmt (stmt);
   gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
   return var;
 }
Index: gcc/tree-vect-loop-manip.c
===================================================================
--- gcc/tree-vect-loop-manip.c	(revision 190199)
+++ gcc/tree-vect-loop-manip.c	(working copy)
@@ -511,14 +511,15 @@  slpeel_update_phi_nodes_for_guard1 (edge
        gsi_next (&gsi_orig), gsi_next (&gsi_update))
     {
       source_location loop_locus, guard_locus;
+      tree new_res;
       orig_phi = gsi_stmt (gsi_orig);
       update_phi = gsi_stmt (gsi_update);
 
       /** 1. Handle new-merge-point phis  **/
 
       /* 1.1. Generate new phi node in NEW_MERGE_BB:  */
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-                                 new_merge_bb);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, new_merge_bb);
 
       /* 1.2. NEW_MERGE_BB has two incoming edges: GUARD_EDGE and the exit-edge
             of LOOP. Set the two phi args in NEW_PHI for these edges:  */
@@ -547,8 +548,8 @@  slpeel_update_phi_nodes_for_guard1 (edge
 	continue;
 
       /* 2.1. Generate new phi node in NEW_EXIT_BB:  */
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-                                 *new_exit_bb);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, *new_exit_bb);
 
       /* 2.2. NEW_EXIT_BB has one incoming edge: the exit-edge of the loop.  */
       add_phi_arg (new_phi, loop_arg, single_exit (loop), loop_locus);
@@ -636,6 +637,7 @@  slpeel_update_phi_nodes_for_guard2 (edge
 
   for (gsi = gsi_start_phis (update_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
+      tree new_res;
       update_phi = gsi_stmt (gsi);
       orig_phi = update_phi;
       orig_def = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
@@ -649,8 +651,8 @@  slpeel_update_phi_nodes_for_guard2 (edge
       /** 1. Handle new-merge-point phis  **/
 
       /* 1.1. Generate new phi node in NEW_MERGE_BB:  */
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-                                 new_merge_bb);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, new_merge_bb);
 
       /* 1.2. NEW_MERGE_BB has two incoming edges: GUARD_EDGE and the exit-edge
             of LOOP. Set the two PHI args in NEW_PHI for these edges:  */
@@ -691,8 +693,8 @@  slpeel_update_phi_nodes_for_guard2 (edge
       /** 2. Handle loop-closed-ssa-form phis  **/
 
       /* 2.1. Generate new phi node in NEW_EXIT_BB:  */
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-                                 *new_exit_bb);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, *new_exit_bb);
 
       /* 2.2. NEW_EXIT_BB has one incoming edge: the exit-edge of the loop.  */
       add_phi_arg (new_phi, loop_arg, single_exit (loop), UNKNOWN_LOCATION);
@@ -726,8 +728,8 @@  slpeel_update_phi_nodes_for_guard2 (edge
       arg = guard_arg;
 
       /* 3.2. Generate new phi node in GUARD_BB:  */
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-                                 guard_edge->src);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, guard_edge->src);
 
       /* 3.3. GUARD_BB has one incoming edge:  */
       gcc_assert (EDGE_COUNT (guard_edge->src->preds) == 1);
@@ -1182,13 +1184,11 @@  slpeel_tree_peel_loop_to_edge (struct lo
 	    break;
 	if (gsi_end_p (gsi))
 	  {
-	    gimple new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
-					      exit_e->dest);
+	    tree new_vop = copy_ssa_name (PHI_RESULT (phi), NULL);
+	    gimple new_phi = create_phi_node (new_vop, exit_e->dest);
 	    tree vop = PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0));
 	    imm_use_iterator imm_iter;
 	    gimple stmt;
-	    tree new_vop = make_ssa_name (SSA_NAME_VAR (PHI_RESULT (phi)),
-					  new_phi);
 	    use_operand_p use_p;
 
 	    add_phi_arg (new_phi, vop, exit_e, UNKNOWN_LOCATION);
@@ -2535,9 +2535,10 @@  vect_loop_versioning (loop_vec_info loop
 
   for (gsi = gsi_start_phis (merge_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
+      tree new_res;
       orig_phi = gsi_stmt (gsi);
-      new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
-				  new_exit_bb);
+      new_res = copy_ssa_name (PHI_RESULT (orig_phi), NULL);
+      new_phi = create_phi_node (new_res, new_exit_bb);
       arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
       add_phi_arg (new_phi, arg, new_exit_e,
 		   gimple_phi_arg_location_from_edge (orig_phi, e));
Index: gcc/tree-parloops.c
===================================================================
--- gcc/tree-parloops.c	(revision 190199)
+++ gcc/tree-parloops.c	(working copy)
@@ -1485,7 +1485,7 @@  transform_to_exit_first_loop (struct loo
     {
       phi = gsi_stmt (gsi);
       res = PHI_RESULT (phi);
-      t = make_ssa_name (SSA_NAME_VAR (res), phi);
+      t = copy_ssa_name (res, phi);
       SET_PHI_RESULT (phi, t);
       nphi = create_phi_node (res, orig_header);
       add_phi_arg (nphi, t, hpred, UNKNOWN_LOCATION);
@@ -1623,7 +1623,7 @@  create_parallel_loop (struct loop *loop,
   cvar_base = SSA_NAME_VAR (cvar);
   phi = SSA_NAME_DEF_STMT (cvar);
   cvar_init = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
-  initvar = make_ssa_name (cvar_base, NULL);
+  initvar = copy_ssa_name (cvar, NULL);
   SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, loop_preheader_edge (loop)),
 	   initvar);
   cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
Index: gcc/ipa-split.c
===================================================================
--- gcc/ipa-split.c	(revision 190199)
+++ gcc/ipa-split.c	(working copy)
@@ -1267,7 +1267,7 @@  split_function (struct split_point *spli
 	      if (TREE_CODE (retval) == SSA_NAME
 		  && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl)))
 		{
-		  retval = make_ssa_name (SSA_NAME_VAR (retval), call);
+		  retval = copy_ssa_name (retval, call);
 
 		  /* See if there is PHI defining return value.  */
 		  for (psi = gsi_start_phis (return_bb);
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	(revision 190199)
+++ gcc/tree-vect-loop.c	(working copy)
@@ -2270,7 +2270,7 @@  vect_is_simple_reduction_1 (loop_vec_inf
   if (orig_code == MINUS_EXPR)
     {
       tree rhs = gimple_assign_rhs2 (def_stmt);
-      tree negrhs = make_ssa_name (SSA_NAME_VAR (rhs), NULL);
+      tree negrhs = copy_ssa_name (rhs, NULL);
       gimple negate_stmt = gimple_build_assign_with_ops (NEGATE_EXPR, negrhs,
 							 rhs, NULL);
       gimple_stmt_iterator gsi = gsi_for_stmt (def_stmt);
@@ -3700,7 +3700,8 @@  vect_create_epilog_for_reduction (VEC (t
     {
       for (j = 0; j < ncopies; j++)
         {
-          phi = create_phi_node (SSA_NAME_VAR (def), exit_bb);
+	  tree new_def = copy_ssa_name (def, NULL);
+          phi = create_phi_node (new_def, exit_bb);
           set_vinfo_for_stmt (phi, new_stmt_vec_info (phi, loop_vinfo, NULL));
           if (j == 0)
             VEC_quick_push (gimple, new_phis, phi);
@@ -3724,8 +3725,8 @@  vect_create_epilog_for_reduction (VEC (t
       inner_phis = VEC_alloc (gimple, heap, VEC_length (tree, vect_defs));
       FOR_EACH_VEC_ELT (gimple, new_phis, i, phi)
 	{
-	  gimple outer_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
-					      exit_bb);
+	  tree new_result = copy_ssa_name (PHI_RESULT (phi), NULL);
+	  gimple outer_phi = create_phi_node (new_result, exit_bb);
 	  SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,
 			   PHI_RESULT (phi));
 	  set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,
@@ -3736,8 +3737,8 @@  vect_create_epilog_for_reduction (VEC (t
           while (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi)))
             {
 	      phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));
-	      outer_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
-					   exit_bb);
+	      new_result = copy_ssa_name (PHI_RESULT (phi), NULL);
+	      outer_phi = create_phi_node (new_result, exit_bb);
 	      SET_PHI_ARG_DEF (outer_phi, single_exit (loop)->dest_idx,
 			       PHI_RESULT (phi));
 	      set_vinfo_for_stmt (outer_phi, new_stmt_vec_info (outer_phi,
Index: gcc/tree-flow-inline.h
===================================================================
--- gcc/tree-flow-inline.h	(revision 190199)
+++ gcc/tree-flow-inline.h	(working copy)
@@ -1144,6 +1144,25 @@  make_ssa_name (tree var, gimple stmt)
   return make_ssa_name_fn (cfun, var, stmt);
 }
 
+/* Return an SSA_NAME node using the template SSA name NAME defined in
+   statement STMT in function cfun.  */
+
+static inline tree
+copy_ssa_name (tree var, gimple stmt)
+{
+  return copy_ssa_name_fn (cfun, var, stmt);
+}
+
+/*  Creates a duplicate of a SSA name NAME tobe defined by statement STMT
+    in function cfun.  */
+
+static inline tree
+duplicate_ssa_name (tree var, gimple stmt)
+{
+  return duplicate_ssa_name_fn (cfun, var, stmt);
+}
+
+
 /* Returns the base object and a constant BITS_PER_UNIT offset in *POFFSET that
    denotes the starting address of the memory access EXP.
    Returns NULL_TREE if the offset is not constant or any component
Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	(revision 190199)
+++ gcc/tree-vect-data-refs.c	(working copy)
@@ -3941,7 +3941,6 @@  bump_vector_ptr (tree dataref_ptr, gimpl
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info);
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
-  tree ptr_var = SSA_NAME_VAR (dataref_ptr);
   tree update = TYPE_SIZE_UNIT (vectype);
   gimple incr_stmt;
   ssa_op_iter iter;
@@ -3951,10 +3950,9 @@  bump_vector_ptr (tree dataref_ptr, gimpl
   if (bump)
     update = bump;
 
-  incr_stmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, ptr_var,
+  new_dataref_ptr = copy_ssa_name (dataref_ptr, NULL);
+  incr_stmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, new_dataref_ptr,
 					    dataref_ptr, update);
-  new_dataref_ptr = make_ssa_name (ptr_var, incr_stmt);
-  gimple_assign_set_lhs (incr_stmt, new_dataref_ptr);
   vect_finish_stmt_generation (stmt, incr_stmt, gsi);
 
   /* Copy the points-to information if it exists. */
@@ -4356,12 +4354,11 @@  vect_setup_realignment (gimple stmt, gim
       ptr = vect_create_data_ref_ptr (stmt, vectype, loop_for_initial_load,
 				      NULL_TREE, &init_addr, NULL, &inc,
 				      true, &inv_p);
+      new_temp = copy_ssa_name (ptr, NULL);
       new_stmt = gimple_build_assign_with_ops
-		   (BIT_AND_EXPR, NULL_TREE, ptr,
+		   (BIT_AND_EXPR, new_temp, ptr,
 		    build_int_cst (TREE_TYPE (ptr),
 				   -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
-      new_temp = make_ssa_name (SSA_NAME_VAR (ptr), new_stmt);
-      gimple_assign_set_lhs (new_stmt, new_temp);
       new_bb = gsi_insert_on_edge_immediate (pe, new_stmt);
       gcc_assert (!new_bb);
       data_ref
Index: gcc/tree-dfa.c
===================================================================
--- gcc/tree-dfa.c	(revision 190199)
+++ gcc/tree-dfa.c	(working copy)
@@ -336,7 +336,10 @@  set_ssa_default_def (struct function *fn
       loc = htab_find_slot_with_hash (DEFAULT_DEFS (fn), &in,
 				      DECL_UID (var), NO_INSERT);
       if (*loc)
-	htab_clear_slot (DEFAULT_DEFS (fn), loc);
+	{
+	  SSA_NAME_IS_DEFAULT_DEF (*(tree *)loc) = false;
+	  htab_clear_slot (DEFAULT_DEFS (fn), loc);
+	}
       return;
     }
   gcc_assert (TREE_CODE (def) == SSA_NAME && SSA_NAME_VAR (def) == var);
@@ -349,7 +352,7 @@  set_ssa_default_def (struct function *fn
 
    /* Mark DEF as the default definition for VAR.  */
   *(tree *) loc = def;
-   SSA_NAME_IS_DEFAULT_DEF (def) = true;
+  SSA_NAME_IS_DEFAULT_DEF (def) = true;
 }
 
 /* Retrieve or create a default definition for VAR.  */
Index: gcc/tree-ssa-live.c
===================================================================
--- gcc/tree-ssa-live.c	(revision 190200)
+++ gcc/tree-ssa-live.c	(working copy)
@@ -798,9 +798,16 @@  remove_unused_locals (void)
 	{
 	  if (!is_used_p (var))
 	    {
+	      tree def;
 	      if (cfun->nonlocal_goto_save_area
 		  && TREE_OPERAND (cfun->nonlocal_goto_save_area, 0) == var)
 		cfun->nonlocal_goto_save_area = NULL;
+	      /* Release any default def associated with var.  */
+	      if ((def = ssa_default_def (cfun, var)) != NULL_TREE)
+		{
+		  set_ssa_default_def (cfun, var, NULL_TREE);
+		  release_ssa_name (def);
+		}
 	      continue;
 	    }
 	}
Index: gcc/tree-ssa-copy.c
===================================================================
--- gcc/tree-ssa-copy.c	(revision 190199)
+++ gcc/tree-ssa-copy.c	(working copy)
@@ -137,12 +137,9 @@  may_propagate_copy_into_stmt (gimple des
 /* Similarly, but we know that we're propagating into an ASM_EXPR.  */
 
 bool
-may_propagate_copy_into_asm (tree dest)
+may_propagate_copy_into_asm (tree dest ATTRIBUTE_UNUSED)
 {
-  /* Hard register operands of asms are special.  Do not bypass.  */
-  return !(TREE_CODE (dest) == SSA_NAME
-	   && TREE_CODE (SSA_NAME_VAR (dest)) == VAR_DECL
-	   && DECL_HARD_REGISTER (SSA_NAME_VAR (dest)));
+  return true;
 }
 
 
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 190199)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -4668,15 +4668,13 @@  vectorizable_load (gimple stmt, gimple_s
 						 NULL_TREE, true,
 						 GSI_SAME_STMT);
 	      CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, newref);
-	      newoff = SSA_NAME_VAR (running_off);
+	      newoff = copy_ssa_name (running_off, NULL);
 	      if (POINTER_TYPE_P (TREE_TYPE (newoff)))
 		incr = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, newoff,
 						     running_off, stride_step);
 	      else
 		incr = gimple_build_assign_with_ops (PLUS_EXPR, newoff,
 						     running_off, stride_step);
-	      newoff = make_ssa_name (newoff, incr);
-	      gimple_assign_set_lhs (incr, newoff);
 	      vect_finish_stmt_generation (stmt, incr, gsi);
 
 	      running_off = newoff;
@@ -4970,13 +4968,12 @@  vectorizable_load (gimple stmt, gimple_s
 						    dr_explicit_realign,
 						    dataref_ptr, NULL);
 
+		    ptr = copy_ssa_name (dataref_ptr, NULL);
 		    new_stmt = gimple_build_assign_with_ops
-				 (BIT_AND_EXPR, NULL_TREE, dataref_ptr,
+				 (BIT_AND_EXPR, ptr, dataref_ptr,
 				  build_int_cst
 				  (TREE_TYPE (dataref_ptr),
 				   -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
-		    ptr = make_ssa_name (SSA_NAME_VAR (dataref_ptr), new_stmt);
-		    gimple_assign_set_lhs (new_stmt, ptr);
 		    vect_finish_stmt_generation (stmt, new_stmt, gsi);
 		    data_ref
 		      = build2 (MEM_REF, vectype, ptr,
@@ -5000,7 +4997,7 @@  vectorizable_load (gimple stmt, gimple_s
 				  build_int_cst
 				  (TREE_TYPE (ptr),
 				   -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
-		    ptr = make_ssa_name (SSA_NAME_VAR (dataref_ptr), new_stmt);
+		    ptr = copy_ssa_name (dataref_ptr, new_stmt);
 		    gimple_assign_set_lhs (new_stmt, ptr);
 		    vect_finish_stmt_generation (stmt, new_stmt, gsi);
 		    data_ref
@@ -5010,14 +5007,12 @@  vectorizable_load (gimple stmt, gimple_s
 		    break;
 		  }
 		case dr_explicit_realign_optimized:
+		  new_temp = copy_ssa_name (dataref_ptr, NULL);
 		  new_stmt = gimple_build_assign_with_ops
-			       (BIT_AND_EXPR, NULL_TREE, dataref_ptr,
+			       (BIT_AND_EXPR, new_temp, dataref_ptr,
 				build_int_cst
 				  (TREE_TYPE (dataref_ptr),
 				   -(HOST_WIDE_INT)TYPE_ALIGN_UNIT (vectype)));
-		  new_temp = make_ssa_name (SSA_NAME_VAR (dataref_ptr),
-					    new_stmt);
-		  gimple_assign_set_lhs (new_stmt, new_temp);
 		  vect_finish_stmt_generation (stmt, new_stmt, gsi);
 		  data_ref
 		    = build2 (MEM_REF, vectype, new_temp,
Index: gcc/graphite-sese-to-poly.c
===================================================================
--- gcc/graphite-sese-to-poly.c	(revision 190199)
+++ gcc/graphite-sese-to-poly.c	(working copy)
@@ -2166,7 +2166,6 @@  rewrite_close_phi_out_of_ssa (scop_p sco
   sese region = SCOP_REGION (scop);
   gimple phi = gsi_stmt (*psi);
   tree res = gimple_phi_result (phi);
-  tree var = SSA_NAME_VAR (res);
   basic_block bb = gimple_bb (phi);
   gimple_stmt_iterator gsi = gsi_after_labels (bb);
   tree arg = gimple_phi_arg_def (phi, 0);
@@ -2222,7 +2221,7 @@  rewrite_close_phi_out_of_ssa (scop_p sco
     }
   else
     {
-      tree zero_dim_array = create_zero_dim_array (var, "Close_Phi");
+      tree zero_dim_array = create_zero_dim_array (res, "Close_Phi");
 
       stmt = gimple_build_assign (res, zero_dim_array);
 
@@ -2250,8 +2249,8 @@  rewrite_phi_out_of_ssa (scop_p scop, gim
   gimple phi = gsi_stmt (*psi);
   basic_block bb = gimple_bb (phi);
   tree res = gimple_phi_result (phi);
-  tree var = SSA_NAME_VAR (res);
-  tree zero_dim_array = create_zero_dim_array (var, "phi_out_of_ssa");
+  tree var;
+  tree zero_dim_array = create_zero_dim_array (res, "phi_out_of_ssa");
   gimple stmt;
   gimple_seq stmts;
 
@@ -2349,14 +2348,16 @@  static void
 rewrite_cross_bb_scalar_dependence (scop_p scop, tree zero_dim_array,
 				    tree def, gimple use_stmt)
 {
-  tree var = SSA_NAME_VAR (def);
-  gimple name_stmt = gimple_build_assign (var, zero_dim_array);
-  tree name = make_ssa_name (var, name_stmt);
+  gimple name_stmt;
+  tree name;
   ssa_op_iter iter;
   use_operand_p use_p;
 
   gcc_assert (gimple_code (use_stmt) != GIMPLE_PHI);
 
+  name = copy_ssa_name (def, NULL);
+  name_stmt = gimple_build_assign (name, zero_dim_array);
+
   gimple_assign_set_lhs (name_stmt, name);
   insert_stmts (scop, name_stmt, NULL, gsi_for_stmt (use_stmt));
 
@@ -2480,7 +2481,7 @@  rewrite_cross_bb_scalar_deps (scop_p sco
 	if (!zero_dim_array)
 	  {
 	    zero_dim_array = create_zero_dim_array
-	      (SSA_NAME_VAR (def), "Cross_BB_scalar_dependence");
+	      (def, "Cross_BB_scalar_dependence");
 	    insert_out_of_ssa_copy (scop, zero_dim_array, def,
 				    SSA_NAME_DEF_STMT (def));
 	    gsi_next (gsi);
Index: gcc/tree-flow.h
===================================================================
--- gcc/tree-flow.h	(revision 190199)
+++ gcc/tree-flow.h	(working copy)
@@ -530,7 +530,8 @@  void set_current_def (tree, tree);
 extern void init_ssanames (struct function *, int);
 extern void fini_ssanames (void);
 extern tree make_ssa_name_fn (struct function *, tree, gimple);
-extern tree duplicate_ssa_name (tree, gimple);
+extern tree copy_ssa_name_fn (struct function *, tree, gimple);
+extern tree duplicate_ssa_name_fn (struct function *, tree, gimple);
 extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
 extern void release_ssa_name (tree);
 extern void release_defs (gimple);
Index: gcc/tree-switch-conversion.c
===================================================================
--- gcc/tree-switch-conversion.c	(revision 190199)
+++ gcc/tree-switch-conversion.c	(working copy)
@@ -1031,7 +1031,7 @@  build_one_array (gimple swtch, int num,
 
   gcc_assert (info->default_values[num]);
 
-  name = make_ssa_name (SSA_NAME_VAR (PHI_RESULT (phi)), NULL);
+  name = copy_ssa_name (PHI_RESULT (phi), NULL);
   info->target_inbound_names[num] = name;
 
   cst = constructor_contains_same_values_p (info->constructors[num]);
@@ -1077,7 +1077,6 @@  build_one_array (gimple swtch, int num,
       load = gimple_build_assign (name, fetch);
     }
 
-  SSA_NAME_DEF_STMT (name) = load;
   gsi_insert_before (&gsi, load, GSI_SAME_STMT);
   update_stmt (load);
   info->arr_ref_last = load;
@@ -1137,12 +1136,9 @@  gen_def_assigns (gimple_stmt_iterator *g
 
   for (i = 0; i < info->phi_count; i++)
     {
-      tree name
-	= make_ssa_name (SSA_NAME_VAR (info->target_inbound_names[i]), NULL);
-
+      tree name = copy_ssa_name (info->target_inbound_names[i], NULL);
       info->target_outbound_names[i] = name;
       assign = gimple_build_assign (name, info->default_values[i]);
-      SSA_NAME_DEF_STMT (name) = assign;
       gsi_insert_before (gsi, assign, GSI_SAME_STMT);
       update_stmt (assign);
     }
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 190200)
+++ gcc/tree-cfg.c	(working copy)
@@ -5018,7 +5018,7 @@  gimple_make_forwarder_block (edge fallth
       phi = gsi_stmt (gsi);
       var = gimple_phi_result (phi);
       new_phi = create_phi_node (var, bb);
-      gimple_phi_set_result (phi, make_ssa_name (SSA_NAME_VAR (var), phi));
+      gimple_phi_set_result (phi, copy_ssa_name (var, phi));
       add_phi_arg (new_phi, gimple_phi_result (phi), fallthru,
 		   UNKNOWN_LOCATION);
     }
Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c	(revision 190199)
+++ gcc/tree-ssanames.c	(working copy)
@@ -312,6 +312,17 @@  get_ptr_info (tree t)
   return pi;
 }
 
+
+/* Creates a new SSA name using the template NAME tobe defined by
+   statement STMT in function FN.  */
+
+tree
+copy_ssa_name_fn (struct function *fn, tree name, gimple stmt)
+{
+  return make_ssa_name_fn (fn, SSA_NAME_VAR (name), stmt);
+}
+
+
 /* Creates a duplicate of the ptr_info_def at PTR_INFO for use by
    the SSA name NAME.  */
 
@@ -333,12 +344,13 @@  duplicate_ssa_name_ptr_info (tree name,
 }
 
 
-/* Creates a duplicate of a ssa name NAME tobe defined by statement STMT.  */
+/* Creates a duplicate of a ssa name NAME tobe defined by statement STMT
+   in function FN.  */
 
 tree
-duplicate_ssa_name (tree name, gimple stmt)
+duplicate_ssa_name_fn (struct function *fn, tree name, gimple stmt)
 {
-  tree new_name = make_ssa_name (SSA_NAME_VAR (name), stmt);
+  tree new_name = copy_ssa_name_fn (fn, name, stmt);
   struct ptr_info_def *old_ptr_info = SSA_NAME_PTR_INFO (name);
 
   if (old_ptr_info)