It's the only LHS setter that does not so and that results in the
asymmetry of create_phi_node needing a SSA_NAME_DEF_STMT adjustment
if you fed it an SSA name result as opposed to a VAR_DECL result
in which case it will be already adjusted.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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

        * gimple.h (gimple_phi_set_result): Adjust SSA_NAME_DEF_STMT.
        * tree-phinodes.c (make_phi_node): Allow a NULL var.
        * tree-into-ssa.c (insert_phi_nodes_for): Simplify.
        * tree-complex.c (update_phi_components): Likewise.
        * tree-ssa-loop-manip.c (create_iv): Likewise.
        (add_exit_phis_edge): Likewise.
        (split_loop_exit_edge): Likewise.
        (tree_transform_and_unroll_loop): Likewise.
        * value-prof.c (gimple_ic): Likewise.
        (gimple_stringop_fixed_value): Likewise.
        * tree-tailcall.c (tree_optimize_tail_calls_1): Likewise.
        * omp-low.c (expand_parallel_call): Likewise.
        (expand_omp_for_static_chunk): Likewise.
        (expand_omp_atomic_pipeline): Likewise.
        * tree-parloops.c (create_phi_for_local_result): Likewise.
        (transform_to_exit_first_loop): Likewise.
        * tree-vect-data-refs.c (vect_setup_realignment): Likewise.
        * graphite-scop-detection.c (canonicalize_loop_closed_ssa): Likewise.
        * tree-predcom.c (initialize_root_vars): Likewise.
        (initialize_root_vars_lm): Likewise.
        * sese.c (sese_add_exit_phis_edge): Likewise.
        * gimple-streamer-in.c (input_phi): Likewise.
        * tree-inline.c (copy_phis_for_bb): Likewise.
        * tree-ssa-phiprop.c (phiprop_insert_phi): Likewise.
        * tree-cfg.c (gimple_make_forwarder_block): Likewise.
        (gimple_duplicate_bb): Likewise.

Index: gcc/tree-into-ssa.c
===================================================================
--- gcc/tree-into-ssa.c (revision 190197)
+++ gcc/tree-into-ssa.c (working copy)
@@ -1039,10 +1039,8 @@ insert_phi_nodes_for (tree var, bitmap p
          tree new_lhs;
 
          gcc_assert (update_p);
-         phi = create_phi_node (var, bb);
-
-         new_lhs = duplicate_ssa_name (var, phi);
-         gimple_phi_set_result (phi, new_lhs);
+         new_lhs = duplicate_ssa_name (var, NULL);
+         phi = create_phi_node (new_lhs, bb);
          add_new_name_mapping (new_lhs, var);
 
          /* Add VAR to every argument slot of PHI.  We need VAR in
Index: gcc/tree-complex.c
===================================================================
--- gcc/tree-complex.c  (revision 190197)
+++ gcc/tree-complex.c  (working copy)
@@ -720,17 +720,11 @@ update_phi_components (basic_block bb)
 
          lr = get_component_ssa_name (gimple_phi_result (phi), false);
          if (TREE_CODE (lr) == SSA_NAME)
-           {
-             pr = create_phi_node (lr, bb);
-             SSA_NAME_DEF_STMT (lr) = pr;
-           }
+           pr = create_phi_node (lr, bb);
 
          li = get_component_ssa_name (gimple_phi_result (phi), true);
          if (TREE_CODE (li) == SSA_NAME)
-           {
-             pi = create_phi_node (li, bb);
-             SSA_NAME_DEF_STMT (li) = pi;
-           }
+           pi = create_phi_node (li, bb);
 
          for (i = 0, n = gimple_phi_num_args (phi); i < n; ++i)
            {
Index: gcc/tree-ssa-loop-manip.c
===================================================================
--- gcc/tree-ssa-loop-manip.c   (revision 190197)
+++ gcc/tree-ssa-loop-manip.c   (working copy)
@@ -116,7 +116,6 @@ create_iv (tree base, tree step, tree va
     gsi_insert_seq_on_edge_immediate (pe, stmts);
 
   stmt = create_phi_node (vb, loop->header);
-  SSA_NAME_DEF_STMT (vb) = stmt;
   add_phi_arg (stmt, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
   add_phi_arg (stmt, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
 }
@@ -144,9 +143,8 @@ add_exit_phis_edge (basic_block exit, tr
   if (!e)
     return;
 
-  phi = create_phi_node (use, exit);
-  create_new_def_for (gimple_phi_result (phi), phi,
-                     gimple_phi_result_ptr (phi));
+  phi = create_phi_node (NULL_TREE, exit);
+  create_new_def_for (use, phi, gimple_phi_result_ptr (phi));
   FOR_EACH_EDGE (e, ei, exit->preds)
     add_phi_arg (phi, use, e, UNKNOWN_LOCATION);
 }
@@ -499,7 +497,6 @@ split_loop_exit_edge (edge exit)
         of the SSA name out of the loop.  */
       new_name = duplicate_ssa_name (name, NULL);
       new_phi = create_phi_node (new_name, bb);
-      SSA_NAME_DEF_STMT (new_name) = new_phi;
       add_phi_arg (new_phi, name, exit, locus);
       SET_USE (op_p, new_name);
     }
@@ -1012,7 +1009,6 @@ tree_transform_and_unroll_loop (struct l
 
       new_init = make_ssa_name (var, NULL);
       phi_rest = create_phi_node (new_init, rest);
-      SSA_NAME_DEF_STMT (new_init) = phi_rest;
 
       add_phi_arg (phi_rest, init, precond_edge, UNKNOWN_LOCATION);
       add_phi_arg (phi_rest, next, new_exit, UNKNOWN_LOCATION);
Index: gcc/value-prof.c
===================================================================
--- gcc/value-prof.c    (revision 190197)
+++ gcc/value-prof.c    (working copy)
@@ -1275,7 +1275,6 @@ gimple_ic (gimple icall_stmt, struct cgr
     {
       tree result = gimple_call_lhs (icall_stmt);
       gimple phi = create_phi_node (result, join_bb);
-      SSA_NAME_DEF_STMT (result) = phi;
       gimple_call_set_lhs (icall_stmt,
                           make_ssa_name (SSA_NAME_VAR (result), icall_stmt));
       add_phi_arg (phi, gimple_call_lhs (icall_stmt), e_ij, UNKNOWN_LOCATION);
@@ -1507,7 +1506,6 @@ gimple_stringop_fixed_value (gimple vcal
     {
       tree result = gimple_call_lhs (vcall_stmt);
       gimple phi = create_phi_node (result, join_bb);
-      SSA_NAME_DEF_STMT (result) = phi;
       gimple_call_set_lhs (vcall_stmt,
                           make_ssa_name (SSA_NAME_VAR (result), vcall_stmt));
       add_phi_arg (phi, gimple_call_lhs (vcall_stmt), e_vj, UNKNOWN_LOCATION);
Index: gcc/tree-tailcall.c
===================================================================
--- gcc/tree-tailcall.c (revision 190197)
+++ gcc/tree-tailcall.c (working copy)
@@ -975,7 +975,6 @@ tree_optimize_tail_calls_1 (bool opt_tai
 
                set_ssa_default_def (cfun, param, new_name);
                phi = create_phi_node (name, first);
-               SSA_NAME_DEF_STMT (name) = phi;
                add_phi_arg (phi, new_name, single_pred_edge (first),
                             EXPR_LOCATION (param));
              }
Index: gcc/tree-phinodes.c
===================================================================
--- gcc/tree-phinodes.c (revision 190197)
+++ gcc/tree-phinodes.c (working copy)
@@ -189,7 +189,9 @@ make_phi_node (tree var, int len)
   gimple_init_singleton (phi);
   phi->gimple_phi.nargs = len;
   phi->gimple_phi.capacity = capacity;
-  if (TREE_CODE (var) == SSA_NAME)
+  if (!var)
+    ;
+  else if (TREE_CODE (var) == SSA_NAME)
     gimple_phi_set_result (phi, var);
   else
     gimple_phi_set_result (phi, make_ssa_name (var, phi));
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c       (revision 190197)
+++ gcc/omp-low.c       (working copy)
@@ -3059,7 +3059,6 @@ expand_parallel_call (struct omp_region
          if (gimple_in_ssa_p (cfun))
            {
              gimple phi = create_phi_node (tmp_join, bb);
-             SSA_NAME_DEF_STMT (tmp_join) = phi;
              add_phi_arg (phi, tmp_then, e_then, UNKNOWN_LOCATION);
              add_phi_arg (phi, tmp_else, e_else, UNKNOWN_LOCATION);
            }
@@ -4592,7 +4591,6 @@ expand_omp_for_static_chunk (struct omp_
          t = gimple_phi_result (phi);
          gcc_assert (t == redirect_edge_var_map_result (vm));
          nphi = create_phi_node (t, iter_part_bb);
-         SSA_NAME_DEF_STMT (t) = nphi;
 
          t = PHI_ARG_DEF_FROM_EDGE (phi, se);
          locus = gimple_phi_arg_location_from_edge (phi, se);
@@ -4617,7 +4615,6 @@ expand_omp_for_static_chunk (struct omp_
 
       /* Make phi node for trip.  */
       phi = create_phi_node (trip_main, iter_part_bb);
-      SSA_NAME_DEF_STMT (trip_main) = phi;
       add_phi_arg (phi, trip_back, single_succ_edge (trip_update_bb),
                   UNKNOWN_LOCATION);
       add_phi_arg (phi, trip_init, single_succ_edge (entry_bb),
@@ -5319,7 +5316,6 @@ expand_omp_atomic_pipeline (basic_block
     {
       gcc_assert (gimple_seq_empty_p (phi_nodes (loop_header)));
       phi = create_phi_node (loadedi, loop_header);
-      SSA_NAME_DEF_STMT (loadedi) = phi;
       SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, single_succ_edge (load_bb)),
               initial);
     }
Index: gcc/tree-parloops.c
===================================================================
--- gcc/tree-parloops.c (revision 190197)
+++ gcc/tree-parloops.c (working copy)
@@ -1013,7 +1013,6 @@ create_phi_for_local_result (void **slot
                     NULL);
   locus = gimple_location (reduc->reduc_stmt);
   new_phi = create_phi_node (local_res, store_bb);
-  SSA_NAME_DEF_STMT (local_res) = new_phi;
   add_phi_arg (new_phi, reduc->init, e, locus);
   add_phi_arg (new_phi, gimple_assign_lhs (reduc->reduc_stmt),
               FALLTHRU_EDGE (loop->latch), locus);
@@ -1489,7 +1488,6 @@ transform_to_exit_first_loop (struct loo
       t = make_ssa_name (SSA_NAME_VAR (res), phi);
       SET_PHI_RESULT (phi, t);
       nphi = create_phi_node (res, orig_header);
-      SSA_NAME_DEF_STMT (res) = nphi;
       add_phi_arg (nphi, t, hpred, UNKNOWN_LOCATION);
 
       if (res == control)
Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c   (revision 190197)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -4446,7 +4446,6 @@ vect_setup_realignment (gimple stmt, gim
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
   msq = make_ssa_name (vec_dest, NULL);
   phi_stmt = create_phi_node (msq, containing_loop->header);
-  SSA_NAME_DEF_STMT (msq) = phi_stmt;
   add_phi_arg (phi_stmt, msq_init, pe, UNKNOWN_LOCATION);
 
   return msq;
Index: gcc/graphite-scop-detection.c
===================================================================
--- gcc/graphite-scop-detection.c       (revision 190197)
+++ gcc/graphite-scop-detection.c       (working copy)
@@ -1325,9 +1325,8 @@ canonicalize_loop_closed_ssa (loop_p loo
                if (TREE_CODE (arg) != SSA_NAME)
                  continue;
 
-               close_phi = create_phi_node (arg, close);
-               res = create_new_def_for (gimple_phi_result (close_phi),
-                                         close_phi,
+               close_phi = create_phi_node (NULL_TREE, close);
+               res = create_new_def_for (arg, close_phi,
                                          gimple_phi_result_ptr (close_phi));
                add_phi_arg (close_phi, arg,
                             gimple_phi_arg_edge (close_phi, 0),
Index: gcc/tree-predcom.c
===================================================================
--- gcc/tree-predcom.c  (revision 190197)
+++ gcc/tree-predcom.c  (working copy)
@@ -1495,7 +1495,6 @@ initialize_root_vars (struct loop *loop,
        gsi_insert_seq_on_edge_immediate (entry, stmts);
 
       phi = create_phi_node (var, loop->header);
-      SSA_NAME_DEF_STMT (var) = phi;
       add_phi_arg (phi, init, entry, UNKNOWN_LOCATION);
       add_phi_arg (phi, next, latch, UNKNOWN_LOCATION);
     }
@@ -1559,7 +1558,6 @@ initialize_root_vars_lm (struct loop *lo
     {
       next = VEC_index (tree, *vars, 1);
       phi = create_phi_node (var, loop->header);
-      SSA_NAME_DEF_STMT (var) = phi;
       add_phi_arg (phi, init, entry, UNKNOWN_LOCATION);
       add_phi_arg (phi, next, latch, UNKNOWN_LOCATION);
     }
Index: gcc/sese.c
===================================================================
--- gcc/sese.c  (revision 190197)
+++ gcc/sese.c  (working copy)
@@ -345,10 +345,8 @@ free_sese (sese region)
 static void
 sese_add_exit_phis_edge (basic_block exit, tree use, edge false_e, edge true_e)
 {
-  gimple phi = create_phi_node (use, exit);
-
-  create_new_def_for (gimple_phi_result (phi), phi,
-                     gimple_phi_result_ptr (phi));
+  gimple phi = create_phi_node (NULL_TREE, exit);
+  create_new_def_for (use, phi, gimple_phi_result_ptr (phi));
   add_phi_arg (phi, use, false_e, UNKNOWN_LOCATION);
   add_phi_arg (phi, use, true_e, UNKNOWN_LOCATION);
 }
Index: gcc/gimple-streamer-in.c
===================================================================
--- gcc/gimple-streamer-in.c    (revision 190197)
+++ gcc/gimple-streamer-in.c    (working copy)
@@ -45,7 +45,6 @@ input_phi (struct lto_input_block *ib, b
   phi_result = VEC_index (tree, SSANAMES (fn), ix);
   len = EDGE_COUNT (bb->preds);
   result = create_phi_node (phi_result, bb);
-  SSA_NAME_DEF_STMT (phi_result) = result;
 
   /* We have to go through a lookup process here because the preds in the
      reconstructed graph are generally in a different order than they
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c   (revision 190197)
+++ gcc/tree-inline.c   (working copy)
@@ -1941,8 +1941,7 @@ copy_phis_for_bb (basic_block bb, copy_b
       if (is_gimple_reg (res))
        {
          walk_tree (&new_res, copy_tree_body_r, id, NULL);
-         SSA_NAME_DEF_STMT (new_res)
-           = new_phi = create_phi_node (new_res, new_bb);
+         new_phi = create_phi_node (new_res, new_bb);
          FOR_EACH_EDGE (new_edge, ei, new_bb->preds)
            {
              edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb);
Index: gcc/tree-ssa-phiprop.c
===================================================================
--- gcc/tree-ssa-phiprop.c      (revision 190197)
+++ gcc/tree-ssa-phiprop.c      (working copy)
@@ -141,7 +141,7 @@ phiprop_insert_phi (basic_block bb, gimp
   /* Build a new PHI node to replace the definition of
      the indirect reference lhs.  */
   res = gimple_assign_lhs (use_stmt);
-  SSA_NAME_DEF_STMT (res) = new_phi = create_phi_node (res, bb);
+  new_phi = create_phi_node (res, bb);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
Index: gcc/gimple.h
===================================================================
--- gcc/gimple.h        (revision 190197)
+++ gcc/gimple.h        (working copy)
@@ -3494,6 +3494,8 @@ gimple_phi_set_result (gimple gs, tree r
 {
   GIMPLE_CHECK (gs, GIMPLE_PHI);
   gs->gimple_phi.result = result;
+  if (result && TREE_CODE (result) == SSA_NAME)
+    SSA_NAME_DEF_STMT (result) = gs;
 }
 
 
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c      (revision 190197)
+++ gcc/tree-cfg.c      (working copy)
@@ -5010,7 +5010,6 @@ gimple_make_forwarder_block (edge fallth
       phi = gsi_stmt (gsi);
       var = gimple_phi_result (phi);
       new_phi = create_phi_node (var, bb);
-      SSA_NAME_DEF_STMT (var) = new_phi;
       gimple_phi_set_result (phi, make_ssa_name (SSA_NAME_VAR (var), phi));
       add_phi_arg (new_phi, gimple_phi_result (phi), fallthru,
                   UNKNOWN_LOCATION);
@@ -5370,8 +5369,8 @@ gimple_duplicate_bb (basic_block bb)
   for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       phi = gsi_stmt (gsi);
-      copy = create_phi_node (gimple_phi_result (phi), new_bb);
-      create_new_def_for (gimple_phi_result (copy), copy,
+      copy = create_phi_node (NULL_TREE, new_bb);
+      create_new_def_for (gimple_phi_result (phi), copy,
                          gimple_phi_result_ptr (copy));
     }
 

Reply via email to