This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 09/89] Introduce gimple_phi_iterator


gcc/
	* gimple-iterator.h (struct gimple_phi_iterator): New subclass of
	gimple_stmt_iterator with identical layout, but adding...
	(gimple_phi_iterator::phi): ...new method, equivalent to
	gsi_stmt (), but casting the underlying gimple to gimple_phi,
	checking that code == GIMPLE_PHI in a checked build.
	(gsi_start_phis): Return a gimple_phi_iterator, rather than just a
	gimple_stmt_iterator.

	* tree-if-conv.c (bb_with_exit_edge_p): Require a gimple_phi rather
	than just a gimple.
	(if_convertible_phi_p): Likewise.
	* tree-phinodes.h (add_phi_node_to_bb): Likewise.
	* tree-ssa-phiprop.c (propagate_with_phi): Likewise.

	* tree-ssa-uninit.c (warn_uninitialized_phi): Require a gimple_phi
	and a vec<gimple_phi> *, rather than just a gimple and vec<gimple> *.
	(find_uninit_use): Likewise; add checked cast to gimple_phi when
	adding to worklist.
	(execute_late_warn_uninitialized): Strengthen types of various locals,
	"worklist" from vec<gimple> to vec<gimple_phi>, "gsi" to a
	gimple_phi_iterator, and "phi" and "cur_phi" to a gimple_phi.

	* tree-ssa-loop-manip.c (rewrite_phi_with_iv): Require a
	gimple_phi_iterator * rather than a gimple_stmt_iterator *;
	use it to strengthen local from a gimple to a gimple_phi.

	* cfgloop.c (find_subloop_latch_edge_by_ivs): Convert local from a
	gimple_stmt_iterator to a gimple_phi_iterator.  Use the iterator's
	"phi" method rather than gsi_stmt.  Use this checked cast to convert
	the type of related local from a plain gimple to a gimple_phi.
	* gimple-pretty-print.c (dump_phi_nodes): Likewise.
	* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behaviour):
	Likewise.
	* sese.c (sese_add_exit_phis_edge): Likewise.
	* tree-cfg.c (reinstall_phi_args): Likewise.
	(gimple_make_forwarder_block): Likewise.
	(add_phi_args_after_copy_edge): Likewise.
	(gimple_lv_adjust_loop_header_phi): Likewise.
	* tree-cfgcleanup.c (phi_alternatives_equal): Likewise.
	(remove_forwarder_block_with_phi): Likewise.
	(merge_phi_nodes): Likewise.
	* tree-complex.c (update_phi_components): Likewise.
	* tree-if-conv.c (if_convertible_loop_p_1): Likewise.
	* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
	(copy_phis_for_bb): Likewise.
	* tree-into-ssa.c (rewrite_add_phi_arguments): Likewise.
	* tree-outof-ssa.c (eliminate_build): Likewise.
	(eliminate_useless_phis): Likewise.
	(rewrite_trees): Likewise.
	(insert_backedge_copies): Likewise.
	* tree-phinodes.c (reserve_phi_args_for_new_edge): Likewise.
	(remove_phi_args): Likewise.
	(remove_phi_nodes): Likewise.
	* tree-predcom.c (find_looparound_phi): Likewise.
	(eliminate_temp_copies): Likewise.
	* tree-scalar-evolution.c (loop_closed_phi_def): Likewise.
	(scev_const_prop): Likewise; also, add checked cast to phi.
	* tree-ssa-coalesce.c (coalesce_partitions): Likewise.
	* tree-ssa-dce.c (remove_dead_phis): Likewise.
	(forward_edge_to_pdom): Likewise.
	* tree-ssa-dom.c (record_equivalences_from_phis): Likewise.
	(cprop_into_successor_phis): Likewise.
	(propagate_rhs_into_lhs): Likewise.
	(eliminate_degenerate_phis_1): Likewise.
	* tree-ssa-ifcombine.c (same_phi_args_p): Likewise.
	* tree-ssa-live.c (calculate_live_on_exit): Likewise.
	(verify_live_on_entry): Likewise.
	* tree-ssa-loop-im.c
	(move_computations_dom_walker::before_dom_children): Likewise.
	* tree-ssa-loop-ivopts.c (find_bivs): Likewise.
	(mark_bivs): Likewise.
	(find_interesting_uses_outside): Likewise.
	(determine_set_costs): Likewise.
	* tree-ssa-loop-manip.c (split_loop_exit_edge): Likewise.
	(tree_transform_and_unroll_loop): Likewise.
	(rewrite_all_phi_nodes_with_iv): Likewise.
	(canonicalize_loop_ivs): Likewise.
	* tree-ssa-loop-niter.c (determine_value_range): Likewise.
	* tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise.
	* tree-ssa-phiprop.c (tree_ssa_phiprop): Likewise.
	* tree-ssa-reassoc.c (suitable_cond_bb): Likewise.
	* tree-ssa-tail-merge.c (same_phi_alternatives_1): Likewise.
	(vop_phi): Likewise.
	* tree-ssa-threadedge.c (record_temporary_equivalences_from_phis):
	Likewise.
	* tree-ssa-threadupdate.c (copy_phi_arg_into_existing_phi): Likewise.
	(copy_phi_args): Likewise.
	(phi_args_equal_on_edges): Likewise.
	* tree-ssa.c (ssa_redirect_edge): Likewise.
	(flush_pending_stmts): Likewise.
	* tree-switch-conversion.c (check_final_bb): Likewise.
	(gather_default_values): Likewise.
	(build_constructors): Likewise.
	(fix_phi_nodes): Likewise.
	* tree-tailcall.c (propagate_through_phis): Likewise.
	(add_successor_phi_arg): Likewise.
	* 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_can_advance_ivs_p): Likewise.
	(vect_update_ivs_after_vectorizer): Likewise.
	* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Likewise.
	* tree-vrp.c (find_assert_locations): Likewise.
	* value-prof.c (gimple_ic): Likewise.

	* omp-low.c (expand_parallel_call): Convert local to a gimple_phi.
---
 gcc/cfgloop.c                  |  6 +++---
 gcc/gimple-iterator.c          | 12 ++++++++++--
 gcc/gimple-iterator.h          | 11 ++++++++++-
 gcc/gimple-pretty-print.c      |  4 ++--
 gcc/gimple-ssa-isolate-paths.c |  4 ++--
 gcc/omp-low.c                  |  2 +-
 gcc/sese.c                     |  2 +-
 gcc/tree-cfg.c                 | 26 +++++++++++++-------------
 gcc/tree-cfgcleanup.c          | 12 ++++++------
 gcc/tree-complex.c             |  4 ++--
 gcc/tree-if-conv.c             |  6 +++---
 gcc/tree-inline.c              | 14 +++++++-------
 gcc/tree-into-ssa.c            |  6 +++---
 gcc/tree-outof-ssa.c           | 16 ++++++++--------
 gcc/tree-phinodes.c            | 13 ++++++-------
 gcc/tree-phinodes.h            |  2 +-
 gcc/tree-predcom.c             | 14 ++++++++------
 gcc/tree-scalar-evolution.c    | 17 +++++++++--------
 gcc/tree-ssa-coalesce.c        |  4 ++--
 gcc/tree-ssa-dce.c             | 10 +++++-----
 gcc/tree-ssa-dom.c             | 17 +++++++++--------
 gcc/tree-ssa-ifcombine.c       |  6 +++---
 gcc/tree-ssa-live.c            |  8 ++++----
 gcc/tree-ssa-loop-im.c         |  4 ++--
 gcc/tree-ssa-loop-ivopts.c     | 20 ++++++++++----------
 gcc/tree-ssa-loop-manip.c      | 24 +++++++++++++-----------
 gcc/tree-ssa-loop-niter.c      |  4 ++--
 gcc/tree-ssa-phiopt.c          |  4 ++--
 gcc/tree-ssa-phiprop.c         |  6 +++---
 gcc/tree-ssa-reassoc.c         |  4 ++--
 gcc/tree-ssa-tail-merge.c      |  8 ++++----
 gcc/tree-ssa-threadedge.c      |  4 ++--
 gcc/tree-ssa-threadupdate.c    | 16 ++++++++--------
 gcc/tree-ssa-uninit.c          | 16 ++++++++--------
 gcc/tree-ssa.c                 | 12 ++++++------
 gcc/tree-switch-conversion.c   | 16 ++++++++--------
 gcc/tree-tailcall.c            |  8 ++++----
 gcc/tree-vect-loop-manip.c     | 34 +++++++++++++++++-----------------
 gcc/tree-vect-loop.c           |  4 ++--
 gcc/tree-vrp.c                 |  4 ++--
 gcc/value-prof.c               |  4 ++--
 41 files changed, 215 insertions(+), 193 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 70744d8..4391dd9 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -577,8 +577,8 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec<edge> la
 {
   edge e, latch = latches[0];
   unsigned i;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree lop;
   basic_block bb;
 
@@ -596,7 +596,7 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec<edge> la
      a subloop.  */
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       lop = PHI_ARG_DEF_FROM_EDGE (phi, latch);
 
       /* Ignore the values that are not changed inside the subloop.  */
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index 1cfeb73..95fbad3 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -874,9 +874,17 @@ gsi_commit_one_edge_insert (edge e, basic_block *new_bb)
 
 /* Returns iterator at the start of the list of phi nodes of BB.  */
 
-gimple_stmt_iterator
+gimple_phi_iterator
 gsi_start_phis (basic_block bb)
 {
   gimple_seq *pseq = phi_nodes_ptr (bb);
-  return gsi_start_1 (pseq);
+
+  /* Adapted from gsi_start_1. */
+  gimple_phi_iterator i;
+
+  i.ptr = gimple_seq_first (*pseq);
+  i.seq = pseq;
+  i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
+
+  return i;
 }
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index c35dc81..735b6a0 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -34,6 +34,15 @@ struct gimple_stmt_iterator
   gimple_seq *seq;
   basic_block bb;
 };
+
+/* Iterator over GIMPLE_PHI statements.  */
+struct gimple_phi_iterator : public gimple_stmt_iterator
+{
+  gimple_phi phi () const
+  {
+    return as_a <gimple_statement_phi> (ptr);
+  }
+};
  
 enum gsi_iterator_update
 {
@@ -79,7 +88,7 @@ extern basic_block gsi_insert_on_edge_immediate (edge, gimple);
 extern basic_block gsi_insert_seq_on_edge_immediate (edge, gimple_seq);
 extern void gsi_commit_edge_inserts (void);
 extern void gsi_commit_one_edge_insert (edge, basic_block *);
-extern gimple_stmt_iterator gsi_start_phis (basic_block);
+extern gimple_phi_iterator gsi_start_phis (basic_block);
 
 /* Return a new iterator pointing to GIMPLE_SEQ's first statement.  */
 
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index c0f6ba9..bf5f286 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2303,11 +2303,11 @@ dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
 static void
 dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
 {
-  gimple_stmt_iterator i;
+  gimple_phi_iterator i;
 
   for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
     {
-      gimple phi = gsi_stmt (i);
+      gimple_phi phi = i.phi ();
       if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
         {
           INDENT (indent);
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index 56fcfc8..4e2b8a8 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -217,7 +217,7 @@ find_implicit_erroneous_behaviour (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator si;
+      gimple_phi_iterator si;
 
       /* Out of an abundance of caution, do not isolate paths to a
 	 block where the block has any abnormal outgoing edges.
@@ -236,7 +236,7 @@ find_implicit_erroneous_behaviour (void)
 	 cases.   */
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
 	{
-	  gimple phi = gsi_stmt (si);
+	  gimple_phi phi = si.phi ();
 	  tree lhs = gimple_phi_result (phi);
 
 	  /* If the result is not a pointer, then there is no need to
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 59e632f..cbf13d2 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4280,7 +4280,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb,
 
 	  if (gimple_in_ssa_p (cfun))
 	    {
-	      gimple phi = create_phi_node (tmp_join, bb);
+	      gimple_phi phi = create_phi_node (tmp_join, bb);
 	      add_phi_arg (phi, tmp_then, e_then, UNKNOWN_LOCATION);
 	      add_phi_arg (phi, tmp_else, e_else, UNKNOWN_LOCATION);
 	    }
diff --git a/gcc/sese.c b/gcc/sese.c
index 342c5e8..eb34c41 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -346,7 +346,7 @@ 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 (NULL_TREE, exit);
+  gimple_phi 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);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index f42d10b..53c4808 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2554,7 +2554,7 @@ reinstall_phi_args (edge new_edge, edge old_edge)
   edge_var_map_vector *v;
   edge_var_map *vm;
   int i;
-  gimple_stmt_iterator phis;
+  gimple_phi_iterator phis;
 
   v = redirect_edge_var_map_vector (old_edge);
   if (!v)
@@ -2564,7 +2564,7 @@ reinstall_phi_args (edge new_edge, edge old_edge)
        v->iterate (i, &vm) && !gsi_end_p (phis);
        i++, gsi_next (&phis))
     {
-      gimple phi = gsi_stmt (phis);
+      gimple_phi phi = phis.phi ();
       tree result = redirect_edge_var_map_result (vm);
       tree arg = redirect_edge_var_map_def (vm);
 
@@ -5272,7 +5272,7 @@ gimple_make_forwarder_block (edge fallthru)
   edge_iterator ei;
   basic_block dummy, bb;
   tree var;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   dummy = fallthru->src;
   bb = fallthru->dest;
@@ -5284,9 +5284,9 @@ gimple_make_forwarder_block (edge fallthru)
      start of BB.  */
   for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi, new_phi;
+      gimple_phi phi, new_phi;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       var = gimple_phi_result (phi);
       new_phi = create_phi_node (var, bb);
       gimple_phi_set_result (phi, copy_ssa_name (var, phi));
@@ -5753,9 +5753,9 @@ add_phi_args_after_copy_edge (edge e_copy)
   basic_block bb, bb_copy = e_copy->src, dest;
   edge e;
   edge_iterator ei;
-  gimple phi, phi_copy;
+  gimple_phi phi, phi_copy;
   tree def;
-  gimple_stmt_iterator psi, psi_copy;
+  gimple_phi_iterator psi, psi_copy;
 
   if (gimple_seq_empty_p (phi_nodes (e_copy->dest)))
     return;
@@ -5788,8 +5788,8 @@ add_phi_args_after_copy_edge (edge e_copy)
        !gsi_end_p (psi);
        gsi_next (&psi), gsi_next (&psi_copy))
     {
-      phi = gsi_stmt (psi);
-      phi_copy = gsi_stmt (psi_copy);
+      phi = psi.phi ();
+      phi_copy = psi_copy.phi ();
       def = PHI_ARG_DEF_FROM_EDGE (phi, e);
       add_phi_arg (phi_copy, def, e_copy,
 		   gimple_phi_arg_location_from_edge (phi, e));
@@ -7903,8 +7903,8 @@ static void
 gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second,
 				  basic_block new_head, edge e)
 {
-  gimple phi1, phi2;
-  gimple_stmt_iterator psi1, psi2;
+  gimple_phi phi1, phi2;
+  gimple_phi_iterator psi1, psi2;
   tree def;
   edge e2 = find_edge (new_head, second);
 
@@ -7920,8 +7920,8 @@ gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second,
        !gsi_end_p (psi2) && !gsi_end_p (psi1);
        gsi_next (&psi2),  gsi_next (&psi1))
     {
-      phi1 = gsi_stmt (psi1);
-      phi2 = gsi_stmt (psi2);
+      phi1 = psi1.phi ();
+      phi2 = psi2.phi ();
       def = PHI_ARG_DEF (phi2, e2->dest_idx);
       add_phi_arg (phi1, def, e, gimple_phi_arg_location_from_edge (phi2, e2));
     }
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 08401dd..64aeb6a 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -347,11 +347,11 @@ phi_alternatives_equal (basic_block dest, edge e1, edge e2)
 {
   int n1 = e1->dest_idx;
   int n2 = e2->dest_idx;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree val1 = gimple_phi_arg_def (phi, n1);
       tree val2 = gimple_phi_arg_def (phi, n2);
 
@@ -830,7 +830,7 @@ remove_forwarder_block_with_phi (basic_block bb)
   while (EDGE_COUNT (bb->preds) > 0)
     {
       edge e = EDGE_PRED (bb, 0), s;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       s = find_edge (e->src, dest);
       if (s)
@@ -862,7 +862,7 @@ remove_forwarder_block_with_phi (basic_block bb)
 	   !gsi_end_p (gsi);
 	   gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree def = gimple_phi_arg_def (phi, succ->dest_idx);
 	  source_location locus = gimple_phi_arg_location_from_edge (phi, succ);
 
@@ -984,7 +984,7 @@ merge_phi_nodes (void)
 	}
       else
 	{
-	  gimple_stmt_iterator gsi;
+	  gimple_phi_iterator gsi;
 	  unsigned int dest_idx = single_succ_edge (bb)->dest_idx;
 
 	  /* BB dominates DEST.  There may be many users of the PHI
@@ -995,7 +995,7 @@ merge_phi_nodes (void)
 	  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 	       gsi_next (&gsi))
 	    {
-	      gimple phi = gsi_stmt (gsi);
+	      gimple_phi phi = gsi.phi ();
 	      tree result = gimple_phi_result (phi);
 	      use_operand_p imm_use;
 	      gimple use_stmt;
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 4a657c0..5b54721 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -724,11 +724,11 @@ update_parameter_components (void)
 static void
 update_phi_components (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       if (is_complex_reg (gimple_phi_result (phi)))
 	{
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 0dc340f..6fe69ae 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -485,7 +485,7 @@ bb_with_exit_edge_p (struct loop *loop, basic_block bb)
    - there is a virtual PHI in a BB other than the loop->header.  */
 
 static bool
-if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi,
+if_convertible_phi_p (struct loop *loop, basic_block bb, gimple_phi phi,
 		      bool any_mask_load_store)
 {
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1251,10 +1251,10 @@ if_convertible_loop_p_1 (struct loop *loop,
   for (i = 0; i < loop->num_nodes; i++)
     {
       basic_block bb = ifc_bbs[i];
-      gimple_stmt_iterator itr;
+      gimple_phi_iterator itr;
 
       for (itr = gsi_start_phis (bb); !gsi_end_p (itr); gsi_next (&itr))
-	if (!if_convertible_phi_p (loop, bb, gsi_stmt (itr),
+	if (!if_convertible_phi_p (loop, bb, itr.phi (),
 				   *any_mask_load_store))
 	  return false;
     }
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 4d3c2ff..9cea36c 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1923,8 +1923,8 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
     if (!e->dest->aux
 	|| ((basic_block)e->dest->aux)->index == ENTRY_BLOCK)
       {
-	gimple phi;
-	gimple_stmt_iterator si;
+	gimple_phi phi;
+	gimple_phi_iterator si;
 
 	if (!nonlocal_goto)
 	  gcc_assert (e->flags & EDGE_EH);
@@ -1936,7 +1936,7 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
 	  {
 	    edge re;
 
-	    phi = gsi_stmt (si);
+	    phi = si.phi ();
 
 	    /* For abnormal goto/call edges the receiver can be the
 	       ENTRY_BLOCK.  Do not assert this cannot happen.  */
@@ -2089,17 +2089,17 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
 {
   basic_block const new_bb = (basic_block) bb->aux;
   edge_iterator ei;
-  gimple phi;
-  gimple_stmt_iterator si;
+  gimple_phi phi;
+  gimple_phi_iterator si;
   edge new_edge;
   bool inserted = false;
 
   for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
     {
       tree res, new_res;
-      gimple new_phi;
+      gimple_phi new_phi;
 
-      phi = gsi_stmt (si);
+      phi = si.phi ();
       res = PHI_RESULT (phi);
       new_res = res;
       if (!virtual_operand_p (res))
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index f12a246..dfe9108 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1394,8 +1394,8 @@ rewrite_add_phi_arguments (basic_block bb)
 
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
-      gimple phi;
-      gimple_stmt_iterator gsi;
+      gimple_phi phi;
+      gimple_phi_iterator gsi;
 
       for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi);
 	   gsi_next (&gsi))
@@ -1403,7 +1403,7 @@ rewrite_add_phi_arguments (basic_block bb)
 	  tree currdef, res;
 	  location_t loc;
 
-	  phi = gsi_stmt (gsi);
+	  phi = gsi.phi ();
 	  res = gimple_phi_result (phi);
 	  currdef = get_reaching_def (SSA_NAME_VAR (res));
 	  /* Virtual operand PHI args do not need a location.  */
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index d5a635b..7f87ffc 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -581,13 +581,13 @@ eliminate_build (elim_graph g)
 {
   tree Ti;
   int p0, pi;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   clear_elim_graph (g);
 
   for (gsi = gsi_start_phis (g->e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       source_location locus;
 
       p0 = var_to_partition (g->map, gimple_phi_result (phi));
@@ -832,14 +832,14 @@ static void
 eliminate_useless_phis (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   tree result;
 
   FOR_EACH_BB_FN (bb, cfun)
     {
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
         {
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  result = gimple_phi_result (phi);
 	  if (virtual_operand_p (result))
 	    {
@@ -895,10 +895,10 @@ rewrite_trees (var_map map ATTRIBUTE_UNUSED)
      create incorrect code.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree T0 = var_to_partition_to_var (map, gimple_phi_result (phi));
 	  if (T0 == NULL_TREE)
 	    {
@@ -1097,7 +1097,7 @@ static void
 insert_backedge_copies (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   mark_dfs_back_edges ();
 
@@ -1108,7 +1108,7 @@ insert_backedge_copies (void)
 
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree result = gimple_phi_result (phi);
 	  size_t i;
 
diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c
index 26f5793..222b4ed 100644
--- a/gcc/tree-phinodes.c
+++ b/gcc/tree-phinodes.c
@@ -292,12 +292,11 @@ reserve_phi_args_for_new_edge (basic_block bb)
 {
   size_t len = EDGE_COUNT (bb->preds);
   size_t cap = ideal_phi_node_len (len + 4);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple_phi stmt =
-	as_a <gimple_statement_phi> (gsi_stmt (gsi));
+      gimple_phi stmt = gsi.phi ();
 
       if (len > gimple_phi_capacity (stmt))
 	{
@@ -328,7 +327,7 @@ reserve_phi_args_for_new_edge (basic_block bb)
 /* Adds PHI to BB.  */
 
 void
-add_phi_node_to_bb (gimple phi, basic_block bb)
+add_phi_node_to_bb (gimple_phi phi, basic_block bb)
 {
   gimple_seq seq = phi_nodes (bb);
   /* Add the new PHI node to the list of PHI nodes for block BB.  */
@@ -433,10 +432,10 @@ remove_phi_arg_num (gimple_phi phi, int i)
 void
 remove_phi_args (edge e)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    remove_phi_arg_num (as_a <gimple_statement_phi> (gsi_stmt (gsi)),
+    remove_phi_arg_num (gsi.phi (),
 			e->dest_idx);
 }
 
@@ -468,7 +467,7 @@ remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p)
 void
 remove_phi_nodes (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
     remove_phi_node (&gsi, true);
diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h
index 0159d5d..fe8b32d 100644
--- a/gcc/tree-phinodes.h
+++ b/gcc/tree-phinodes.h
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 extern void phinodes_print_statistics (void);
 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, basic_block bb);
+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 remove_phi_args (edge);
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index 730bad4..e859959 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1116,10 +1116,11 @@ static gimple
 find_looparound_phi (struct loop *loop, dref ref, dref root)
 {
   tree name, init, init_ref;
-  gimple phi = NULL, init_stmt;
+  gimple_phi phi = NULL;
+  gimple init_stmt;
   edge latch = loop_latch_edge (loop);
   struct data_reference init_dr;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   if (is_gimple_assign (ref->stmt))
     {
@@ -1135,7 +1136,7 @@ find_looparound_phi (struct loop *loop, dref ref, dref root)
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, latch) == name)
 	break;
     }
@@ -1887,14 +1888,15 @@ static void
 eliminate_temp_copies (struct loop *loop, bitmap tmp_vars)
 {
   edge e;
-  gimple phi, stmt;
+  gimple_phi phi;
+  gimple stmt;
   tree name, use, var;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   e = loop_latch_edge (loop);
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       name = PHI_RESULT (phi);
       var = SSA_NAME_VAR (name);
       if (!var || !bitmap_bit_p (tmp_vars, DECL_UID (var)))
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index f1ddc24..fd51156 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -2239,8 +2239,8 @@ loop_closed_phi_def (tree var)
 {
   struct loop *loop;
   edge exit;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
 
   if (var == NULL_TREE
       || TREE_CODE (var) != SSA_NAME)
@@ -2253,7 +2253,7 @@ loop_closed_phi_def (tree var)
 
   for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, exit) == var)
 	return PHI_RESULT (phi);
     }
@@ -3342,11 +3342,12 @@ scev_const_prop (void)
 {
   basic_block bb;
   tree name, type, ev;
-  gimple phi, ass;
+  gimple_phi phi;
+  gimple ass;
   struct loop *loop, *ex_loop;
   bitmap ssa_names_to_remove = NULL;
   unsigned i;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   if (number_of_loops (cfun) <= 1)
     return 0;
@@ -3357,7 +3358,7 @@ scev_const_prop (void)
 
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi))
 	{
-	  phi = gsi_stmt (psi);
+	  phi = psi.phi ();
 	  name = PHI_RESULT (phi);
 
 	  if (virtual_operand_p (name))
@@ -3395,7 +3396,7 @@ scev_const_prop (void)
 	{
 	  gimple_stmt_iterator psi;
 	  name = ssa_name (i);
-	  phi = SSA_NAME_DEF_STMT (name);
+	  phi = SSA_NAME_DEF_STMT (name)->as_a_gimple_phi ();
 
 	  gcc_assert (gimple_code (phi) == GIMPLE_PHI);
 	  psi = gsi_for_stmt (phi);
@@ -3433,7 +3434,7 @@ scev_const_prop (void)
 
       for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); )
 	{
-	  phi = gsi_stmt (psi);
+	  phi = psi.phi ();
 	  rslt = PHI_RESULT (phi);
 	  def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
 	  if (virtual_operand_p (def))
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index 9a1ac67..c42a8eb 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -1188,11 +1188,11 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
       FOR_EACH_EDGE (e, ei, bb->preds)
 	if (e->flags & EDGE_ABNORMAL)
 	  {
-	    gimple_stmt_iterator gsi;
+	    gimple_phi_iterator gsi;
 	    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 		 gsi_next (&gsi))
 	      {
-		gimple phi = gsi_stmt (gsi);
+		gimple_phi phi = gsi.phi ();
 		tree res = PHI_RESULT (phi);
 	        tree arg = PHI_ARG_DEF (phi, e->dest_idx);
 		int v1 = SSA_NAME_VERSION (res);
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 13a71ce..c5a530b 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -929,13 +929,13 @@ static bool
 remove_dead_phis (basic_block bb)
 {
   bool something_changed = false;
-  gimple phi;
-  gimple_stmt_iterator gsi;
+  gimple_phi phi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi);)
     {
       stats.total_phis++;
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
 
       /* We do not track necessity of virtual PHI nodes.  Instead do
          very simple dead PHI removal here.  */
@@ -987,7 +987,7 @@ remove_dead_phis (basic_block bb)
 static edge
 forward_edge_to_pdom (edge e, basic_block post_dom_bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   edge e2 = NULL;
   edge_iterator ei;
 
@@ -1011,7 +1011,7 @@ forward_edge_to_pdom (edge e, basic_block post_dom_bb)
 	  break;
       for (gsi = gsi_start_phis (post_dom_bb); !gsi_end_p (gsi);)
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree op;
 	  source_location locus;
 
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 24099cc..b483289 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1190,11 +1190,11 @@ dom_opt_dom_walker::thread_across_edge (edge e)
 static void
 record_equivalences_from_phis (basic_block bb)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       tree lhs = gimple_phi_result (phi);
       tree rhs = NULL;
@@ -1714,7 +1714,7 @@ cprop_into_successor_phis (basic_block bb)
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
       int indx;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       /* If this is an abnormal edge, then we do not want to copy propagate
 	 into the PHI alternative associated with this edge.  */
@@ -1753,7 +1753,7 @@ cprop_into_successor_phis (basic_block bb)
 	  tree new_val;
 	  use_operand_p orig_p;
 	  tree orig_val;
-          gimple phi = gsi_stmt (gsi);
+          gimple_phi phi = gsi.phi ();
 
 	  /* The alternative may be associated with a constant, so verify
 	     it is an SSA_NAME before doing anything with it.  */
@@ -2866,7 +2866,8 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
 		  edge te = find_taken_edge (bb, val);
 		  edge_iterator ei;
 		  edge e;
-		  gimple_stmt_iterator gsi, psi;
+		  gimple_stmt_iterator gsi;
+		  gimple_phi_iterator psi;
 
 		  /* Remove all outgoing edges except TE.  */
 		  for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei));)
@@ -2879,7 +2880,7 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
                                !gsi_end_p (psi);
                                gsi_next (&psi))
                             {
-                              gimple phi = gsi_stmt (psi);
+                              gimple_phi phi = psi.phi ();
 
 			      tree result = gimple_phi_result (phi);
 			      int version = SSA_NAME_VERSION (result);
@@ -2989,12 +2990,12 @@ eliminate_const_or_copy (gimple stmt, bitmap interesting_names)
 static void
 eliminate_degenerate_phis_1 (basic_block bb, bitmap interesting_names)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   basic_block son;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       eliminate_const_or_copy (phi, interesting_names);
     }
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c
index 1a060b5..756bda2 100644
--- a/gcc/tree-ssa-ifcombine.c
+++ b/gcc/tree-ssa-ifcombine.c
@@ -154,12 +154,12 @@ same_phi_args_p (basic_block bb1, basic_block bb2, basic_block dest)
 {
   edge e1 = find_edge (bb1, dest);
   edge e2 = find_edge (bb2, dest);
-  gimple_stmt_iterator gsi;
-  gimple phi;
+  gimple_phi_iterator gsi;
+  gimple_phi phi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       if (!operand_equal_p (PHI_ARG_DEF_FROM_EDGE (phi, e1),
 			    PHI_ARG_DEF_FROM_EDGE (phi, e2), 0))
         return false;
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 3cd3613..2c431e7 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1156,13 +1156,13 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
   /* Set all the live-on-exit bits for uses in PHIs.  */
   FOR_EACH_BB_FN (bb, cfun)
     {
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       size_t i;
 
       /* Mark the PHI arguments which are live on exit to the pred block.  */
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  for (i = 0; i < gimple_phi_num_args (phi); i++)
 	    {
 	      tree t = PHI_ARG_DEF (phi, i);
@@ -1435,12 +1435,12 @@ verify_live_on_entry (tree_live_info_p live)
 		   if it occurs in a PHI argument of the block.  */
 		size_t z;
 		bool ok = false;
-		gimple_stmt_iterator gsi;
+		gimple_phi_iterator gsi;
 		for (gsi = gsi_start_phis (e->dest);
 		     !gsi_end_p (gsi) && !ok;
 		     gsi_next (&gsi))
 		  {
-		    gimple phi = gsi_stmt (gsi);
+		    gimple_phi phi = gsi.phi ();
 		    for (z = 0; z < gimple_phi_num_args (phi); z++)
 		      if (var == gimple_phi_arg_def (phi, z))
 			{
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index c75f257..aa51afb 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1251,11 +1251,11 @@ move_computations_dom_walker::before_dom_children (basic_block bb)
 	{
 	  /* The new VUSE is the one from the virtual PHI in the loop
 	     header or the one already present.  */
-	  gimple_stmt_iterator gsi2;
+	  gimple_phi_iterator gsi2;
 	  for (gsi2 = gsi_start_phis (e->dest);
 	       !gsi_end_p (gsi2); gsi_next (&gsi2))
 	    {
-	      gimple phi = gsi_stmt (gsi2);
+	      gimple_phi phi = gsi2.phi ();
 	      if (virtual_operand_p (gimple_phi_result (phi)))
 		{
 		  gimple_set_vuse (stmt, PHI_ARG_DEF_FROM_EDGE (phi, e));
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 14ba20f..ea18311 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1033,11 +1033,11 @@ find_bivs (struct ivopts_data *data)
   tree step, type, base;
   bool found = false;
   struct loop *loop = data->current_loop;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
 
       if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (PHI_RESULT (phi)))
 	continue;
@@ -1079,11 +1079,11 @@ mark_bivs (struct ivopts_data *data)
   struct iv *iv, *incr_iv;
   struct loop *loop = data->current_loop;
   basic_block incr_bb;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
 
       iv = get_iv (data, PHI_RESULT (phi));
       if (!iv)
@@ -1964,13 +1964,13 @@ find_interesting_uses_stmt (struct ivopts_data *data, gimple stmt)
 static void
 find_interesting_uses_outside (struct ivopts_data *data, edge exit)
 {
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree def;
 
   for (psi = gsi_start_phis (exit->dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
       if (!virtual_operand_p (def))
         find_interesting_uses_op (data, def);
@@ -5177,8 +5177,8 @@ static void
 determine_set_costs (struct ivopts_data *data)
 {
   unsigned j, n;
-  gimple phi;
-  gimple_stmt_iterator psi;
+  gimple_phi phi;
+  gimple_phi_iterator psi;
   tree op;
   struct loop *loop = data->current_loop;
   bitmap_iterator bi;
@@ -5195,7 +5195,7 @@ determine_set_costs (struct ivopts_data *data)
   n = 0;
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       op = PHI_RESULT (phi);
 
       if (virtual_operand_p (op))
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 9dcbc53..5b78ca4 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -630,12 +630,12 @@ split_loop_exit_edge (edge exit)
   gimple phi, new_phi;
   tree new_name, name;
   use_operand_p op_p;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
   source_location locus;
 
   for (psi = gsi_start_phis (dest); !gsi_end_p (psi); gsi_next (&psi))
     {
-      phi = gsi_stmt (psi);
+      phi = psi.phi ();
       op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, single_succ_edge (bb));
       locus = gimple_phi_arg_location_from_edge (phi, single_succ_edge (bb));
 
@@ -1034,8 +1034,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   tree ctr_before, ctr_after;
   tree enter_main_cond, exit_base, exit_step, exit_bound;
   enum tree_code exit_cmp;
-  gimple phi_old_loop, phi_new_loop, phi_rest;
-  gimple_stmt_iterator psi_old_loop, psi_new_loop;
+  gimple_phi phi_old_loop, phi_new_loop, phi_rest;
+  gimple_phi_iterator psi_old_loop, psi_new_loop;
   tree init, next, new_init;
   struct loop *new_loop;
   basic_block rest, exit_bb;
@@ -1142,8 +1142,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
        !gsi_end_p (psi_old_loop);
        gsi_next (&psi_old_loop), gsi_next (&psi_new_loop))
     {
-      phi_old_loop = gsi_stmt (psi_old_loop);
-      phi_new_loop = gsi_stmt (psi_new_loop);
+      phi_old_loop = psi_old_loop.phi ();
+      phi_new_loop = psi_new_loop.phi ();
 
       init = PHI_ARG_DEF_FROM_EDGE (phi_old_loop, old_entry);
       op = PHI_ARG_DEF_PTR_FROM_EDGE (phi_new_loop, new_entry);
@@ -1259,12 +1259,13 @@ tree_unroll_loop (struct loop *loop, unsigned factor,
 
 static void
 rewrite_phi_with_iv (loop_p loop,
-		     gimple_stmt_iterator *psi,
+		     gimple_phi_iterator *psi,
 		     gimple_stmt_iterator *gsi,
 		     tree main_iv)
 {
   affine_iv iv;
-  gimple stmt, phi = gsi_stmt (*psi);
+  gimple stmt;
+  gimple_phi phi = psi->phi ();
   tree atype, mtype, val, res = PHI_RESULT (phi);
 
   if (virtual_operand_p (res) || res == main_iv)
@@ -1302,7 +1303,7 @@ rewrite_all_phi_nodes_with_iv (loop_p loop, tree main_iv)
 {
   unsigned i;
   basic_block *bbs = get_loop_body_in_dom_order (loop);
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   for (i = 0; i < loop->num_nodes; i++)
     {
@@ -1335,7 +1336,8 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
   unsigned original_precision = precision;
   tree type, var_before;
-  gimple_stmt_iterator gsi, psi;
+  gimple_stmt_iterator gsi;
+  gimple_phi_iterator psi;
   gimple stmt;
   edge exit = single_dom_exit (loop);
   gimple_seq stmts;
@@ -1345,7 +1347,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   for (psi = gsi_start_phis (loop->header);
        !gsi_end_p (psi); gsi_next (&psi))
     {
-      gimple phi = gsi_stmt (psi);
+      gimple_phi phi = psi.phi ();
       tree res = PHI_RESULT (phi);
       bool uns;
 
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 7628363..76113dd 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -149,7 +149,7 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off,
   if (TREE_CODE (var) == SSA_NAME && INTEGRAL_TYPE_P (type))
     {
       edge e = loop_preheader_edge (loop);
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
 
       /* Either for VAR itself...  */
       rtype = get_range_info (var, &minv, &maxv);
@@ -157,7 +157,7 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off,
 	 PHI argument from the loop preheader edge.  */
       for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  double_int minc, maxc;
 	  if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var
 	      && (get_range_info (gimple_phi_result (phi), &minc, &maxc)
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 95cf4d4..da1cd37 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -2044,14 +2044,14 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1,
 {
   int param_align = PARAM_VALUE (PARAM_L1_CACHE_LINE_SIZE);
   unsigned param_align_bits = (unsigned) (param_align * BITS_PER_UNIT);
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Walk the phis in bb3 looking for an opportunity.  We are looking
      for phis of two SSA names, one each of which is defined in bb1 and
      bb2.  */
   for (gsi = gsi_start_phis (bb3); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi_stmt = gsi_stmt (gsi);
+      gimple_phi phi_stmt = gsi.phi ();
       gimple def1, def2, defswap;
       tree arg1, arg2, ref1, ref2, field1, field2, fieldswap;
       tree tree_offset1, tree_offset2, tree_size2, next;
diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c
index 4d66c12..f3dc67f 100644
--- a/gcc/tree-ssa-phiprop.c
+++ b/gcc/tree-ssa-phiprop.c
@@ -247,7 +247,7 @@ phiprop_insert_phi (basic_block bb, gimple phi, gimple use_stmt,
    with aliasing issues as we are moving memory reads.  */
 
 static bool
-propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn,
+propagate_with_phi (basic_block bb, gimple_phi phi, struct phiprop_d *phivn,
 		    size_t n)
 {
   tree ptr = PHI_RESULT (phi);
@@ -381,7 +381,7 @@ tree_ssa_phiprop (void)
   struct phiprop_d *phivn;
   bool did_something = false;
   basic_block bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   unsigned i;
   size_t n;
 
@@ -396,7 +396,7 @@ tree_ssa_phiprop (void)
 				  single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
   FOR_EACH_VEC_ELT (bbs, i, bb)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n);
+      did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n);
 
   if (did_something)
     gsi_commit_edge_inserts ();
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index e9e29e5..c8421b7 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2462,7 +2462,7 @@ suitable_cond_bb (basic_block bb, basic_block test_bb, basic_block *other_bb,
   edge_iterator ei, ei2;
   edge e, e2;
   gimple stmt;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   bool other_edge_seen = false;
   bool is_cond;
 
@@ -2524,7 +2524,7 @@ suitable_cond_bb (basic_block bb, basic_block test_bb, basic_block *other_bb,
   e2 = find_edge (test_bb, *other_bb);
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       /* If both BB and TEST_BB end with GIMPLE_COND, all PHI arguments
 	 corresponding to BB and TEST_BB predecessor must be the same.  */
       if (!operand_equal_p (gimple_phi_arg_def (phi, e->dest_idx),
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index f6b1ba0..93096cc 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1284,11 +1284,11 @@ static bool
 same_phi_alternatives_1 (basic_block dest, edge e1, edge e2)
 {
   int n1 = e1->dest_idx, n2 = e2->dest_idx;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree lhs = gimple_phi_result (phi);
       tree val1 = gimple_phi_arg_def (phi, n1);
       tree val2 = gimple_phi_arg_def (phi, n2);
@@ -1469,10 +1469,10 @@ static gimple
 vop_phi (basic_block bb)
 {
   gimple stmt;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      stmt = gsi_stmt (gsi);
+      stmt = gsi.phi ();
       if (! virtual_operand_p (gimple_phi_result (stmt)))
 	continue;
       return stmt;
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index ce1dee5..a332456 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -203,14 +203,14 @@ record_temporary_equivalences_from_phis (edge e, vec<tree> *stack,
 					 bool backedge_seen,
 					 bitmap src_map, bitmap dst_map)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Each PHI creates a temporary equivalence, record them.
      These are context sensitive equivalences and will be removed
      later.  */
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree src = PHI_ARG_DEF_FROM_EDGE (phi, e);
       tree dst = gimple_phi_result (phi);
 
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index f458d6a..7fd92ce 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -388,13 +388,13 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
   int tgt_idx = tgt_e->dest_idx;
 
   /* Iterate over each PHI in e->dest.  */
-  for (gimple_stmt_iterator gsi = gsi_start_phis (src_e->dest),
-			    gsi2 = gsi_start_phis (tgt_e->dest);
+  for (gimple_phi_iterator gsi = gsi_start_phis (src_e->dest),
+			   gsi2 = gsi_start_phis (tgt_e->dest);
        !gsi_end_p (gsi);
        gsi_next (&gsi), gsi_next (&gsi2))
     {
-      gimple src_phi = gsi_stmt (gsi);
-      gimple dest_phi = gsi_stmt (gsi2);
+      gimple_phi src_phi = gsi.phi ();
+      gimple_phi dest_phi = gsi2.phi ();
       tree val = gimple_phi_arg_def (src_phi, src_idx);
       source_location locus = gimple_phi_arg_location (src_phi, src_idx);
 
@@ -408,12 +408,12 @@ copy_phi_arg_into_existing_phi (edge src_e, edge tgt_e)
 static void
 copy_phi_args (basic_block bb, edge src_e, edge tgt_e)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int src_indx = src_e->dest_idx;
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       source_location locus = gimple_phi_arg_location (phi, src_indx);
       add_phi_arg (phi, gimple_phi_arg_def (phi, src_indx), tgt_e, locus);
     }
@@ -1390,13 +1390,13 @@ fail:
 static bool
 phi_args_equal_on_edges (edge e1, edge e2)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int indx1 = e1->dest_idx;
   int indx2 = e2->dest_idx;
 
   for (gsi = gsi_start_phis (e1->dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
 
       if (!operand_equal_p (gimple_phi_arg_def (phi, indx1),
 			    gimple_phi_arg_def (phi, indx2), 0))
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index eee83f7..43be808 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -2170,8 +2170,8 @@ is_use_properly_guarded (gimple use_stmt,
    if the new phi is already in the worklist.  */
 
 static gimple
-find_uninit_use (gimple phi, unsigned uninit_opnds,
-                 vec<gimple> *worklist,
+find_uninit_use (gimple_phi phi, unsigned uninit_opnds,
+                 vec<gimple_phi> *worklist,
 		 pointer_set_t *added_to_worklist)
 {
   tree phi_result;
@@ -2225,7 +2225,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds,
               print_gimple_stmt (dump_file, use_stmt, 0, 0);
             }
 
-          worklist->safe_push (use_stmt);
+          worklist->safe_push (use_stmt->as_a_gimple_phi ());
           pointer_set_insert (possibly_undefined_names, phi_result);
         }
     }
@@ -2242,7 +2242,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds,
    a pointer set tracking if the new phi is added to the worklist or not.  */
 
 static void
-warn_uninitialized_phi (gimple phi, vec<gimple> *worklist,
+warn_uninitialized_phi (gimple_phi phi, vec<gimple_phi> *worklist,
                         pointer_set_t *added_to_worklist)
 {
   unsigned uninit_opnds;
@@ -2289,8 +2289,8 @@ static unsigned int
 execute_late_warn_uninitialized (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
-  vec<gimple> worklist = vNULL;
+  gimple_phi_iterator gsi;
+  vec<gimple_phi> worklist = vNULL;
   pointer_set_t *added_to_worklist;
 
   calculate_dominance_info (CDI_DOMINATORS);
@@ -2309,7 +2309,7 @@ execute_late_warn_uninitialized (void)
   FOR_EACH_BB_FN (bb, cfun)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       {
-        gimple phi = gsi_stmt (gsi);
+        gimple_phi phi = gsi.phi ();
         size_t n, i;
 
         n = gimple_phi_num_args (phi);
@@ -2338,7 +2338,7 @@ execute_late_warn_uninitialized (void)
 
   while (worklist.length () != 0)
     {
-      gimple cur_phi = 0;
+      gimple_phi cur_phi = 0;
       cur_phi = worklist.pop ();
       warn_uninitialized_phi (cur_phi, &worklist, added_to_worklist);
     }
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 20f061f..2927e0b 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -189,8 +189,8 @@ redirect_edge_var_map_destroy (void)
 edge
 ssa_redirect_edge (edge e, basic_block dest)
 {
-  gimple_stmt_iterator gsi;
-  gimple phi;
+  gimple_phi_iterator gsi;
+  gimple_phi phi;
 
   redirect_edge_var_map_clear (e);
 
@@ -200,7 +200,7 @@ ssa_redirect_edge (edge e, basic_block dest)
       tree def;
       source_location locus ;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       def = gimple_phi_arg_def (phi, e->dest_idx);
       locus = gimple_phi_arg_location (phi, e->dest_idx);
 
@@ -222,11 +222,11 @@ ssa_redirect_edge (edge e, basic_block dest)
 void
 flush_pending_stmts (edge e)
 {
-  gimple phi;
+  gimple_phi phi;
   edge_var_map_vector *v;
   edge_var_map *vm;
   int i;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   v = redirect_edge_var_map_vector (e);
   if (!v)
@@ -238,7 +238,7 @@ flush_pending_stmts (edge e)
     {
       tree def;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       def = redirect_edge_var_map_def (vm);
       add_phi_arg (phi, def, e, redirect_edge_var_map_location (vm));
     }
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index e88f710..86e7840 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -749,12 +749,12 @@ check_all_empty_except_final (struct switch_conv_info *info)
 static bool
 check_final_bb (struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   info->phi_count = 0;
   for (gsi = gsi_start_phis (info->final_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       unsigned int i;
 
       info->phi_count++;
@@ -830,7 +830,7 @@ free_temp_arrays (struct switch_conv_info *info)
 static void
 gather_default_values (tree default_case, struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   basic_block bb = label_to_block (CASE_LABEL (default_case));
   edge e;
   int i = 0;
@@ -844,7 +844,7 @@ gather_default_values (tree default_case, struct switch_conv_info *info)
 
   for (gsi = gsi_start_phis (info->final_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree val = PHI_ARG_DEF_FROM_EDGE (phi, e);
       gcc_assert (val);
       info->default_values[i++] = val;
@@ -867,7 +867,7 @@ build_constructors (gimple_switch swtch, struct switch_conv_info *info)
       basic_block bb = label_to_block (CASE_LABEL (cs));
       edge e;
       tree high;
-      gimple_stmt_iterator gsi;
+      gimple_phi_iterator gsi;
       int j;
 
       if (bb == info->final_bb)
@@ -901,7 +901,7 @@ build_constructors (gimple_switch swtch, struct switch_conv_info *info)
       for (gsi = gsi_start_phis (info->final_bb);
 	   !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  tree val = PHI_ARG_DEF_FROM_EDGE (phi, e);
 	  tree low = CASE_LOW (cs);
 	  pos = CASE_LOW (cs);
@@ -1178,13 +1178,13 @@ static void
 fix_phi_nodes (edge e1f, edge e2f, basic_block bbf,
 	       struct switch_conv_info *info)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   int i;
 
   for (gsi = gsi_start_phis (bbf), i = 0;
        !gsi_end_p (gsi); gsi_next (&gsi), i++)
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       add_phi_arg (phi, info->target_inbound_names[i], e1f, UNKNOWN_LOCATION);
       add_phi_arg (phi, info->target_outbound_names[i], e2f, UNKNOWN_LOCATION);
     }
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index a436be7..4c85f3d 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -378,11 +378,11 @@ static tree
 propagate_through_phis (tree var, edge e)
 {
   basic_block dest = e->dest;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var)
         return PHI_RESULT (phi);
     }
@@ -610,10 +610,10 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
 static void
 add_successor_phi_arg (edge e, tree var, tree phi_arg)
 {
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi))
-    if (PHI_RESULT (gsi_stmt (gsi)) == var)
+    if (PHI_RESULT (gsi.phi ()) == var)
       break;
 
   gcc_assert (!gsi_end_p (gsi));
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 77d945e..15d9a53 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -391,8 +391,8 @@ static void
 slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
                                     bool is_new_loop, basic_block *new_exit_bb)
 {
-  gimple orig_phi, new_phi;
-  gimple update_phi, update_phi2;
+  gimple_phi orig_phi, new_phi;
+  gimple_phi update_phi, update_phi2;
   tree guard_arg, loop_arg;
   basic_block new_merge_bb = guard_edge->dest;
   edge e = EDGE_SUCC (new_merge_bb, 0);
@@ -400,7 +400,7 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
   basic_block orig_bb = loop->header;
   edge new_exit_e;
   tree current_new_name;
-  gimple_stmt_iterator gsi_orig, gsi_update;
+  gimple_phi_iterator gsi_orig, gsi_update;
 
   /* Create new bb between loop and new_merge_bb.  */
   *new_exit_bb = split_edge (single_exit (loop));
@@ -414,8 +414,8 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop,
     {
       source_location loop_locus, guard_locus;
       tree new_res;
-      orig_phi = gsi_stmt (gsi_orig);
-      update_phi = gsi_stmt (gsi_update);
+      orig_phi = gsi_orig.phi ();
+      update_phi = gsi_update.phi ();
 
       /** 1. Handle new-merge-point phis  **/
 
@@ -531,8 +531,8 @@ static void
 slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
                                     bool is_new_loop, basic_block *new_exit_bb)
 {
-  gimple orig_phi, new_phi;
-  gimple update_phi, update_phi2;
+  gimple_phi orig_phi, new_phi;
+  gimple_phi update_phi, update_phi2;
   tree guard_arg, loop_arg;
   basic_block new_merge_bb = guard_edge->dest;
   edge e = EDGE_SUCC (new_merge_bb, 0);
@@ -541,7 +541,7 @@ slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
   tree orig_def, orig_def_new_name;
   tree new_name, new_name2;
   tree arg;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Create new bb between loop and new_merge_bb.  */
   *new_exit_bb = split_edge (single_exit (loop));
@@ -551,7 +551,7 @@ slpeel_update_phi_nodes_for_guard2 (edge guard_edge, struct loop *loop,
   for (gsi = gsi_start_phis (update_bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       tree new_res;
-      update_phi = gsi_stmt (gsi);
+      update_phi = gsi.phi ();
       orig_phi = update_phi;
       orig_def = PHI_ARG_DEF_FROM_EDGE (orig_phi, e);
       /* This loop-closed-phi actually doesn't represent a use
@@ -1173,7 +1173,7 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
   basic_block bb_before_first_loop;
   basic_block bb_between_loops;
   basic_block new_exit_bb;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   edge exit_e = single_exit (loop);
   source_location loop_loc;
   /* There are many aspects to how likely the first loop is going to be executed.
@@ -1205,7 +1205,7 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, struct loop *scalar_loop,
   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
     if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
       {
-	gimple phi = gsi_stmt (gsi);
+	gimple_phi phi = gsi.phi ();
 	for (gsi = gsi_start_phis (exit_e->dest);
 	     !gsi_end_p (gsi); gsi_next (&gsi))
 	  if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi))))
@@ -1529,7 +1529,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block bb = loop->header;
   gimple phi;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
 
   /* Analyze phi functions of the loop header.  */
 
@@ -1539,7 +1539,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
     {
       tree evolution_part;
 
-      phi = gsi_stmt (gsi);
+      phi = gsi.phi ();
       if (dump_enabled_p ())
 	{
           dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
@@ -1638,8 +1638,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
 {
   struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   basic_block exit_bb = single_exit (loop)->dest;
-  gimple phi, phi1;
-  gimple_stmt_iterator gsi, gsi1;
+  gimple_phi phi, phi1;
+  gimple_phi_iterator gsi, gsi1;
   basic_block update_bb = update_e->dest;
 
   gcc_checking_assert (vect_can_advance_ivs_p (loop_vinfo));
@@ -1658,8 +1658,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
       gimple_stmt_iterator last_gsi;
       stmt_vec_info stmt_info;
 
-      phi = gsi_stmt (gsi);
-      phi1 = gsi_stmt (gsi1);
+      phi = gsi.phi ();
+      phi1 = gsi1.phi ();
       if (dump_enabled_p ())
         {
           dump_printf_loc (MSG_NOTE, vect_location,
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index df6ab6f..220f665 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -622,7 +622,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
   basic_block bb = loop->header;
   tree init, step;
   auto_vec<gimple, 64> worklist;
-  gimple_stmt_iterator gsi;
+  gimple_phi_iterator gsi;
   bool double_reduc;
 
   if (dump_enabled_p ())
@@ -634,7 +634,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
      changed.  */
   for (gsi = gsi_start_phis  (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
-      gimple phi = gsi_stmt (gsi);
+      gimple_phi phi = gsi.phi ();
       tree access_fn = NULL;
       tree def = PHI_RESULT (phi);
       stmt_vec_info stmt_vinfo = vinfo_for_stmt (phi);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 8c6d110..b784282 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5959,10 +5959,10 @@ find_assert_locations (void)
     {
       i = loop->latch->index;
       unsigned int j = single_succ_edge (loop->latch)->dest_idx;
-      for (gimple_stmt_iterator gsi = gsi_start_phis (loop->header);
+      for (gimple_phi_iterator gsi = gsi_start_phis (loop->header);
 	   !gsi_end_p (gsi); gsi_next (&gsi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gsi.phi ();
 	  if (virtual_operand_p (gimple_phi_result (phi)))
 	    continue;
 	  tree arg = gimple_phi_arg_def (phi, j);
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 2890093..555f3a4 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1328,7 +1328,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
   int lp_nr, dflags;
   edge e_eh, e;
   edge_iterator ei;
-  gimple_stmt_iterator psi;
+  gimple_phi_iterator psi;
 
   cond_bb = gimple_bb (icall_stmt);
   gsi = gsi_for_stmt (icall_stmt);
@@ -1441,7 +1441,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
 	for (psi = gsi_start_phis (e_eh->dest);
 	     !gsi_end_p (psi); gsi_next (&psi))
 	  {
-	    gimple phi = gsi_stmt (psi);
+	    gimple_phi phi = psi.phi ();
 	    SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e),
 		     PHI_ARG_DEF_FROM_EDGE (phi, e_eh));
 	  }
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]