diff mbox

[gimple-classes,committed,47/92] Make add_phi_arg require a gimple_phi

Message ID 1414442490-14841-48-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Oct. 27, 2014, 8:40 p.m. UTC
This corresponds to:
  [PATCH 49/89] Make add_phi_arg require a gimple_phi
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01162.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> Fine once prereqs go in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00876.html

gcc/
	* tree-phinodes.h (add_phi_arg): Require a gimple_phi rather than
	a plain gimple.
	* tree-phinodes.c (add_phi_arg): Likewise.

	* gimple-ssa-strength-reduction.c (create_phi_basis): Strengthen
	local "phi" from plain gimple to gimple_phi.

	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
	Likewise for "close_phi".

	* ipa-split.c (split_function): Convert "psi" to
	gimple_phi_iterator.

	* omp-low.c (expand_omp_for_static_nochunk): Introduce
	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
	gimple_phi.
	(expand_omp_for_static_chunk): Likewise.

	* tree-cfg.c (gimple_duplicate_bb): Make topmost "gsi" decl more
	tightly-scoped, and eliminate decls "phis", "phi", "stmt", "copy"
	in favor of more tightly-scoped gimple_phi_iterator gpi and
	gimple_phi decls "phi" and "copy", and gimple decls "stmt" and
	"copy".

	* tree-parloops.c (create_parallel_loop): Introduce
	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
	gimple_phi.

	* tree-ssa-loop-im.c (execute_sm_if_changed): Likewise.

	* tree-ssa-loop-manip.c (create_iv): Split out new gimple_phi
	local "phi" from "stmt", and convert the latter into being a
	gimple_assign.

	* tree-ssa-pre.c (insert_into_preds_of_block): Strengthen local
	"phi" to be a gimple_phi.

	* tree-ssa-tail-merge.c (vop_phi): Require a gimple_phi rather
	than a plain gimple.
	(replace_block_by): Strengthen local "bb2_phi" to be a gimple_phi.

	* tree-tailcall.c (add_successor_phi_arg): Use gsi.phi when
	invoking add_phi_arg.
	(eliminate_tail_call): Introduce gimple_phi_iterator gpi, using it
	to strengthen "phi" to be a gimple_phi.
	(create_tailcall_accumulator): Strengthen local "phi" to be a
	gimple_phi.
	(tree_optimize_tail_calls_1): Likewise.

	* tree-vect-data-refs.c (vect_setup_realignment): Strengthen
	local "phi_stmt" to be a gimple_phi.

	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
	Strengthen "gsi", "gsi_orig", "gsi_new" to be
	gimple_phi_iterators, and "phi" "orig_phi", "new_phi" to be
	gimple_phi instances.
	(slpeel_tree_peel_loop_to_edge): Strengthen local "new_phi" to be
	a gimple_phi.

	* tree-vect-loop.c (get_initial_def_for_induction): Likewise for
	"induction_phi".
	(vect_create_epilog_for_reduction): Add checked casts to
	gimple_phi; strengthen local "outer_phi" to gimple_phi and
	"new_vec_stmt" to gimple_assign.
	(vect_finalize_reduction): Strengthen local "vect_phi" to
	gimple_phi.
	(vectorizable_reduction): Likewise for "new_phi".

	* tree-vect-stmts.c (vectorizable_simd_clone_call): Likewise.
	(vectorizable_load): Likewise for "phi".
---
 gcc/ChangeLog.gimple-classes        | 75 +++++++++++++++++++++++++++++++++++++
 gcc/gimple-ssa-strength-reduction.c |  2 +-
 gcc/graphite-scop-detection.c       |  2 +-
 gcc/ipa-split.c                     |  6 +--
 gcc/omp-low.c                       | 12 +++---
 gcc/tree-cfg.c                      | 16 +++++---
 gcc/tree-parloops.c                 |  5 ++-
 gcc/tree-phinodes.c                 |  2 +-
 gcc/tree-phinodes.h                 |  2 +-
 gcc/tree-ssa-loop-im.c              |  5 ++-
 gcc/tree-ssa-loop-manip.c           |  9 +++--
 gcc/tree-ssa-pre.c                  |  2 +-
 gcc/tree-ssa-tail-merge.c           |  6 +--
 gcc/tree-tailcall.c                 | 15 ++++----
 gcc/tree-vect-data-refs.c           |  2 +-
 gcc/tree-vect-loop-manip.c          | 12 +++---
 gcc/tree-vect-loop.c                | 18 +++++----
 gcc/tree-vect-stmts.c               |  6 +--
 18 files changed, 141 insertions(+), 56 deletions(-)
diff mbox

Patch

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b2ca765..a162b12 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,80 @@ 
 2014-10-24  David Malcolm  <dmalcolm@redhat.com>
 
+	Make add_phi_arg require a gimple_phi
+
+	* tree-phinodes.h (add_phi_arg): Require a gimple_phi rather than
+	a plain gimple.
+	* tree-phinodes.c (add_phi_arg): Likewise.
+
+	* gimple-ssa-strength-reduction.c (create_phi_basis): Strengthen
+	local "phi" from plain gimple to gimple_phi.
+
+	* graphite-scop-detection.c (canonicalize_loop_closed_ssa):
+	Likewise for "close_phi".
+
+	* ipa-split.c (split_function): Convert "psi" to
+	gimple_phi_iterator.
+
+	* omp-low.c (expand_omp_for_static_nochunk): Introduce
+	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
+	gimple_phi.
+	(expand_omp_for_static_chunk): Likewise.
+
+	* tree-cfg.c (gimple_duplicate_bb): Make topmost "gsi" decl more
+	tightly-scoped, and eliminate decls "phis", "phi", "stmt", "copy"
+	in favor of more tightly-scoped gimple_phi_iterator gpi and
+	gimple_phi decls "phi" and "copy", and gimple decls "stmt" and
+	"copy".
+
+	* tree-parloops.c (create_parallel_loop): Introduce
+	gimple_phi_iterator gpi, using it to strengthen "phi" to be a
+	gimple_phi.
+
+	* tree-ssa-loop-im.c (execute_sm_if_changed): Likewise.
+
+	* tree-ssa-loop-manip.c (create_iv): Split out new gimple_phi
+	local "phi" from "stmt", and convert the latter into being a
+	gimple_assign.
+
+	* tree-ssa-pre.c (insert_into_preds_of_block): Strengthen local
+	"phi" to be a gimple_phi.
+
+	* tree-ssa-tail-merge.c (vop_phi): Require a gimple_phi rather
+	than a plain gimple.
+	(replace_block_by): Strengthen local "bb2_phi" to be a gimple_phi.
+
+	* tree-tailcall.c (add_successor_phi_arg): Use gsi.phi when
+	invoking add_phi_arg.
+	(eliminate_tail_call): Introduce gimple_phi_iterator gpi, using it
+	to strengthen "phi" to be a gimple_phi.
+	(create_tailcall_accumulator): Strengthen local "phi" to be a
+	gimple_phi.
+	(tree_optimize_tail_calls_1): Likewise.
+
+	* tree-vect-data-refs.c (vect_setup_realignment): Strengthen
+	local "phi_stmt" to be a gimple_phi.
+
+	* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
+	Strengthen "gsi", "gsi_orig", "gsi_new" to be
+	gimple_phi_iterators, and "phi" "orig_phi", "new_phi" to be
+	gimple_phi instances.
+	(slpeel_tree_peel_loop_to_edge): Strengthen local "new_phi" to be
+	a gimple_phi.
+
+	* tree-vect-loop.c (get_initial_def_for_induction): Likewise for
+	"induction_phi".
+	(vect_create_epilog_for_reduction): Add checked casts to
+	gimple_phi; strengthen local "outer_phi" to gimple_phi and
+	"new_vec_stmt" to gimple_assign.
+	(vect_finalize_reduction): Strengthen local "vect_phi" to
+	gimple_phi.
+	(vectorizable_reduction): Likewise for "new_phi".
+
+	* tree-vect-stmts.c (vectorizable_simd_clone_call): Likewise.
+	(vectorizable_load): Likewise for "phi".
+
+2014-10-24  David Malcolm  <dmalcolm@redhat.com>
+
 	Make gimple_phi_arg_def_ptr and gimple_phi_arg_has_location require a gimple_phi
 
 	* gimple.h (gimple_phi_arg_def_ptr): Require a gimple_phi rather
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 2358bda..4b4c213 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2235,7 +2235,7 @@  create_phi_basis (slsr_cand_t c, gimple from_phi, tree basis_name,
 {
   int i;
   tree name, phi_arg;
-  gimple phi;
+  gimple_phi phi;
   vec<tree> phi_args;
   slsr_cand_t basis = lookup_cand (c->basis);
   int nargs = gimple_phi_num_args (from_phi);
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 53823b8..40ccad0 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1353,7 +1353,7 @@  canonicalize_loop_closed_ssa (loop_p loop)
 	      {
 		tree res, arg = gimple_phi_arg_def (phi, i);
 		use_operand_p use_p;
-		gimple close_phi;
+		gimple_phi close_phi;
 
 		if (TREE_CODE (arg) != SSA_NAME)
 		  continue;
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 9c02f96..94a0337 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1415,7 +1415,7 @@  split_function (struct split_point *split_point)
 
 	  if (real_retval && split_point->split_part_set_retval)
 	    {
-	      gimple_stmt_iterator psi;
+	      gimple_phi_iterator psi;
 
 	      /* See if we need new SSA_NAME for the result.
 		 When DECL_BY_REFERENCE is true, retval is actually pointer to
@@ -1428,13 +1428,13 @@  split_function (struct split_point *split_point)
 		  /* See if there is PHI defining return value.  */
 		  for (psi = gsi_start_phis (return_bb);
 		       !gsi_end_p (psi); gsi_next (&psi))
-		    if (!virtual_operand_p (gimple_phi_result (gsi_stmt (psi))))
+		    if (!virtual_operand_p (gimple_phi_result (psi.phi ())))
 		      break;
 
 		  /* When there is PHI, just update its value.  */
 		  if (TREE_CODE (retval) == SSA_NAME
 		      && !gsi_end_p (psi))
-		    add_phi_arg (gsi_stmt (psi), retval, e, UNKNOWN_LOCATION);
+		    add_phi_arg (psi.phi (), retval, e, UNKNOWN_LOCATION);
 		  /* Otherwise update the return BB itself.
 		     find_return_bb allows at most one assignment to return value,
 		     so update first statement.  */
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 720a885..327c6e1 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6108,10 +6108,10 @@  expand_omp_for_static_nochunk (struct omp_region *region,
       if (gimple_in_ssa_p (cfun))
 	{
 	  int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx;
-	  for (gsi = gsi_start_phis (fin_bb);
-	       !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gpi = gsi_start_phis (fin_bb);
+	       !gsi_end_p (gpi); gsi_next (&gpi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gpi.phi ();
 	      add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx),
 			   ep, UNKNOWN_LOCATION);
 	    }
@@ -6490,10 +6490,10 @@  expand_omp_for_static_chunk (struct omp_region *region,
       if (gimple_in_ssa_p (cfun))
 	{
 	  int dest_idx = find_edge (entry_bb, fin_bb)->dest_idx;
-	  for (gsi = gsi_start_phis (fin_bb);
-	       !gsi_end_p (gsi); gsi_next (&gsi))
+	  for (gimple_phi_iterator gpi = gsi_start_phis (fin_bb);
+	       !gsi_end_p (gpi); gsi_next (&gpi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gpi.phi ();
 	      add_phi_arg (phi, gimple_phi_arg_def (phi, dest_idx),
 			   se, UNKNOWN_LOCATION);
 	    }
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 479989f..038e3ef 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5756,17 +5756,18 @@  static basic_block
 gimple_duplicate_bb (basic_block bb)
 {
   basic_block new_bb;
-  gimple_stmt_iterator gsi, gsi_tgt;
-  gimple_seq phis = phi_nodes (bb);
-  gimple phi, stmt, copy;
+  gimple_stmt_iterator gsi_tgt;
 
   new_bb = create_empty_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb);
 
   /* Copy the PHI nodes.  We ignore PHI node arguments here because
      the incoming edges have not been setup yet.  */
-  for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+       !gsi_end_p (gpi);
+       gsi_next (&gpi))
     {
-      phi = gsi_stmt (gsi);
+      gimple_phi phi, copy;
+      phi = gpi.phi ();
       copy = create_phi_node (NULL_TREE, new_bb);
       create_new_def_for (gimple_phi_result (phi), copy,
 			  gimple_phi_result_ptr (copy));
@@ -5774,11 +5775,14 @@  gimple_duplicate_bb (basic_block bb)
     }
 
   gsi_tgt = gsi_start_bb (new_bb);
-  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+       !gsi_end_p (gsi);
+       gsi_next (&gsi))
     {
       def_operand_p def_p;
       ssa_op_iter op_iter;
       tree lhs;
+      gimple stmt, copy;
 
       stmt = gsi_stmt (gsi);
       if (gimple_code (stmt) == GIMPLE_LABEL)
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index fbb74a9..dcfd7fe 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1673,11 +1673,12 @@  create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   guard = make_edge (for_bb, ex_bb, 0);
   single_succ_edge (loop->latch)->flags = 0;
   end = make_edge (loop->latch, ex_bb, EDGE_FALLTHRU);
-  for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (gimple_phi_iterator gpi = gsi_start_phis (ex_bb);
+       !gsi_end_p (gpi); gsi_next (&gpi))
     {
       source_location locus;
       tree def;
-      phi = gsi_stmt (gsi);
+      gimple_phi phi = gpi.phi ();
       stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
 
       def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index d15d3b4..4f86090 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -362,7 +362,7 @@  create_phi_node (tree var, basic_block bb)
    PHI points to the reallocated phi node when we return.  */
 
 void
-add_phi_arg (gimple phi, tree def, edge e, source_location locus)
+add_phi_arg (gimple_phi phi, tree def, edge e, source_location locus)
 {
   basic_block bb = e->dest;
 
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index fe8b32d..dcde99e 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -25,7 +25,7 @@  extern void release_phi_node (gimple);
 extern void reserve_phi_args_for_new_edge (basic_block);
 extern void add_phi_node_to_bb (gimple_phi phi, basic_block bb);
 extern gimple_phi create_phi_node (tree, basic_block);
-extern void add_phi_arg (gimple, tree, edge, source_location);
+extern void add_phi_arg (gimple_phi, tree, edge, source_location);
 extern void remove_phi_args (edge);
 extern void remove_phi_node (gimple_stmt_iterator *, bool);
 extern void remove_phi_nodes (basic_block);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 92b4c7c..8ee47fc 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1878,9 +1878,10 @@  execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   }
 
   if (!loop_has_only_one_exit)
-    for (gsi = gsi_start_phis (old_dest); !gsi_end_p (gsi); gsi_next (&gsi))
+    for (gimple_phi_iterator gpi = gsi_start_phis (old_dest);
+	 !gsi_end_p (gpi); gsi_next (&gpi))
       {
-	gimple phi = gsi_stmt (gsi);
+	gimple_phi phi = gpi.phi ();
 	unsigned i;
 
 	for (i = 0; i < gimple_phi_num_args (phi); i++)
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index b73a9a5..9bd1a3b 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -71,7 +71,8 @@  create_iv (tree base, tree step, tree var, struct loop *loop,
 	   gimple_stmt_iterator *incr_pos, bool after,
 	   tree *var_before, tree *var_after)
 {
-  gimple stmt;
+  gimple_assign stmt;
+  gimple_phi phi;
   tree initial, step1;
   gimple_seq stmts;
   tree vb, va;
@@ -143,9 +144,9 @@  create_iv (tree base, tree step, tree var, struct loop *loop,
   if (stmts)
     gsi_insert_seq_on_edge_immediate (pe, stmts);
 
-  stmt = create_phi_node (vb, loop->header);
-  add_phi_arg (stmt, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
-  add_phi_arg (stmt, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
+  phi = create_phi_node (vb, loop->header);
+  add_phi_arg (phi, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
+  add_phi_arg (phi, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
 }
 
 /* Return the innermost superloop LOOP of USE_LOOP that is a superloop of
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index cf955b8..a9bacff 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2964,7 +2964,7 @@  insert_into_preds_of_block (basic_block block, unsigned int exprnum,
   edge_iterator ei;
   tree type = get_expr_type (expr);
   tree temp;
-  gimple phi;
+  gimple_phi phi;
 
   /* Make sure we aren't creating an induction variable.  */
   if (bb_loop_depth (block) > 0 && EDGE_COUNT (block->preds) == 2)
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 521378e..a98fc90 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1466,10 +1466,10 @@  find_clusters (void)
 
 /* Returns the vop phi of BB, if any.  */
 
-static gimple
+static gimple_phi
 vop_phi (basic_block bb)
 {
-  gimple stmt;
+  gimple_phi stmt;
   gimple_phi_iterator gsi;
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -1490,7 +1490,7 @@  replace_block_by (basic_block bb1, basic_block bb2)
   edge e1, e2;
   edge_iterator ei;
   unsigned int i;
-  gimple bb2_phi;
+  gimple_phi bb2_phi;
 
   bb2_phi = vop_phi (bb2);
 
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index bfe5b24..5a1763c 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -628,7 +628,7 @@  add_successor_phi_arg (edge e, tree var, tree phi_arg)
       break;
 
   gcc_assert (!gsi_end_p (gsi));
-  add_phi_arg (gsi_stmt (gsi), phi_arg, e, UNKNOWN_LOCATION);
+  add_phi_arg (gsi.phi (), phi_arg, e, UNKNOWN_LOCATION);
 }
 
 /* Creates a GIMPLE statement which computes the operation specified by
@@ -821,7 +821,8 @@  eliminate_tail_call (struct tailcall *t)
   size_t idx;
   basic_block bb, first;
   edge e;
-  gimple phi;
+  gimple_phi phi;
+  gimple_phi_iterator gpi;
   gimple_stmt_iterator gsi;
   gimple orig_stmt;
 
@@ -874,7 +875,7 @@  eliminate_tail_call (struct tailcall *t)
   /* Add phi node entries for arguments.  The ordering of the phi nodes should
      be the same as the ordering of the arguments.  */
   for (param = DECL_ARGUMENTS (current_function_decl),
-	 idx = 0, gsi = gsi_start_phis (first);
+	 idx = 0, gpi = gsi_start_phis (first);
        param;
        param = DECL_CHAIN (param), idx++)
     {
@@ -882,11 +883,11 @@  eliminate_tail_call (struct tailcall *t)
 	continue;
 
       arg = gimple_call_arg (stmt, idx);
-      phi = gsi_stmt (gsi);
+      phi = gpi.phi ();
       gcc_assert (param == SSA_NAME_VAR (PHI_RESULT (phi)));
 
       add_phi_arg (phi, arg, e, gimple_location (stmt));
-      gsi_next (&gsi);
+      gsi_next (&gpi);
     }
 
   /* Update the values of accumulators.  */
@@ -948,7 +949,7 @@  create_tailcall_accumulator (const char *label, basic_block bb, tree init)
     ret_type = sizetype;
 
   tree tmp = make_temp_ssa_name (ret_type, NULL, label);
-  gimple phi;
+  gimple_phi phi;
 
   phi = create_phi_node (tmp, bb);
   /* RET_TYPE can be a float when -ffast-maths is enabled.  */
@@ -1012,7 +1013,7 @@  tree_optimize_tail_calls_1 (bool opt_tailcalls)
 	      {
 		tree name = ssa_default_def (cfun, param);
 		tree new_name = make_ssa_name (param, SSA_NAME_DEF_STMT (name));
-		gimple phi;
+		gimple_phi phi;
 
 		set_ssa_default_def (cfun, param, new_name);
 		phi = create_phi_node (name, first);
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 5140992..5982487 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4772,7 +4772,7 @@  vect_setup_realignment (gimple stmt, gimple_stmt_iterator *gsi,
   basic_block new_bb;
   tree msq_init = NULL_TREE;
   tree new_temp;
-  gimple phi_stmt;
+  gimple_phi phi_stmt;
   tree msq = NULL_TREE;
   gimple_seq stmts = NULL;
   bool inv_p;
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 2aa3720..95c00fa 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -820,13 +820,13 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
     {
       if (scalar_loop != loop)
 	{
-	  gimple_stmt_iterator gsi;
+	  gimple_phi_iterator gsi;
 	  new_exit = redirect_edge_and_branch (new_exit, exit_dest);
 
 	  for (gsi = gsi_start_phis (exit_dest); !gsi_end_p (gsi);
 	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      tree orig_arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
 	      location_t orig_locus
 		= gimple_phi_arg_location_from_edge (phi, e);
@@ -886,7 +886,7 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
     {
       /* Update new_loop->header PHIs, so that on the preheader
 	 edge they are the ones from loop rather than scalar_loop.  */
-      gimple_stmt_iterator gsi_orig, gsi_new;
+      gimple_phi_iterator gsi_orig, gsi_new;
       edge orig_e = loop_preheader_edge (loop);
       edge new_e = loop_preheader_edge (new_loop);
 
@@ -895,8 +895,8 @@  slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *loop,
 	   !gsi_end_p (gsi_orig) && !gsi_end_p (gsi_new);
 	   gsi_next (&gsi_orig), gsi_next (&gsi_new))
 	{
-	  gimple orig_phi = gsi_stmt (gsi_orig);
-	  gimple new_phi = gsi_stmt (gsi_new);
+	  gimple_phi orig_phi = gsi_orig.phi ();
+	  gimple_phi new_phi = gsi_new.phi ();
 	  tree orig_arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, orig_e);
 	  location_t orig_locus
 	    = gimple_phi_arg_location_from_edge (orig_phi, orig_e);
@@ -1213,7 +1213,7 @@  slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
 	if (gsi_end_p (gsi))
 	  {
 	    tree new_vop = copy_ssa_name (PHI_RESULT (phi), NULL);
-	    gimple new_phi = create_phi_node (new_vop, exit_e->dest);
+	    gimple_phi 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;
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 560143e..19535b3 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3258,7 +3258,8 @@  get_initial_def_for_induction (gimple iv_phi)
   tree new_vec, vec_init, vec_step, t;
   tree new_var;
   tree new_name;
-  gimple init_stmt, induction_phi, new_stmt;
+  gimple init_stmt, new_stmt;
+  gimple_phi induction_phi;
   tree induc_def, vec_def, vec_dest;
   tree init_expr, step_expr;
   int vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -3964,14 +3965,15 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
       for (j = 0; j < ncopies; j++)
         {
           /* Set the loop-entry arg of the reduction-phi.  */
-          add_phi_arg (phi, vec_init_def, loop_preheader_edge (loop),
-                       UNKNOWN_LOCATION);
+          add_phi_arg (as_a <gimple_phi> (phi), vec_init_def,
+		       loop_preheader_edge (loop), UNKNOWN_LOCATION);
 
           /* Set the loop-latch arg for the reduction-phi.  */
           if (j > 0)
             def = vect_get_vec_def_for_stmt_copy (vect_unknown_def_type, def);
 
-          add_phi_arg (phi, def, loop_latch_edge (loop), UNKNOWN_LOCATION);
+          add_phi_arg (as_a <gimple_phi> (phi), def, loop_latch_edge (loop),
+		       UNKNOWN_LOCATION);
 
           if (dump_enabled_p ())
             {
@@ -4051,7 +4053,7 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
       FOR_EACH_VEC_ELT (new_phis, i, phi)
 	{
 	  tree new_result = copy_ssa_name (PHI_RESULT (phi), NULL);
-	  gimple outer_phi = create_phi_node (new_result, exit_bb);
+	  gimple_phi 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,
@@ -4138,7 +4140,7 @@  vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
     {
       tree first_vect = PHI_RESULT (new_phis[0]);
       tree tmp;
-      gimple new_vec_stmt = NULL;
+      gimple_assign new_vec_stmt = NULL;
 
       vec_dest = vect_create_destination_var (scalar_dest, vectype);
       for (k = 1; k < new_phis.length (); k++)
@@ -4514,7 +4516,7 @@  vect_finalize_reduction:
           if (outer_loop)
             {
               stmt_vec_info exit_phi_vinfo = vinfo_for_stmt (exit_phi);
-              gimple vect_phi;
+              gimple_phi vect_phi;
 
               /* FORNOW. Currently not supporting the case that an inner-loop
                  reduction is not used in the outer-loop (but only outside the
@@ -4729,7 +4731,7 @@  vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
   tree def;
   gimple def_stmt;
   enum vect_def_type dt;
-  gimple new_phi = NULL;
+  gimple_phi new_phi = NULL;
   tree scalar_type;
   bool is_simple_use;
   gimple orig_stmt;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 1797118..a301775 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2985,7 +2985,7 @@  vectorizable_simd_clone_call (gimple stmt, gimple_stmt_iterator *gsi,
 		      gcc_assert (!new_bb);
 		    }
 		  tree phi_res = copy_ssa_name (op, NULL);
-		  gimple new_phi = create_phi_node (phi_res, loop->header);
+		  gimple_phi new_phi = create_phi_node (phi_res, loop->header);
 		  set_vinfo_for_stmt (new_phi,
 				      new_stmt_vec_info (new_phi, loop_vinfo,
 							 NULL));
@@ -5604,7 +5604,7 @@  vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
   tree offset = NULL_TREE;
   tree byte_offset = NULL_TREE;
   tree realignment_token = NULL_TREE;
-  gimple phi = NULL;
+  gimple_phi phi = NULL;
   vec<tree> dr_chain = vNULL;
   bool grouped_load = false;
   bool load_lanes_p = false;
@@ -6263,7 +6263,7 @@  vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
 				    &at_loop);
       if (alignment_support_scheme == dr_explicit_realign_optimized)
 	{
-	  phi = SSA_NAME_DEF_STMT (msq);
+	  phi = as_a <gimple_phi> (SSA_NAME_DEF_STMT (msq));
 	  byte_offset = size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (vectype),
 				    size_one_node);
 	}