From d21e0e2eb7671ebb30fd73a186c9a4c1e109b971 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 27 Mar 2014 11:16:05 -0400
Subject: [PATCH 50/88] Make gimple_phi_arg_edge require a gimple_phi

gcc/
	* gimple.h (gimple_phi_arg_edge): Require a gimple_phi rather
	than a plain gimple.

	* gimple-ssa-strength-reduction.c (ncd_with_phi): Strengthen
	param "phi" from gimple to gimple_phi.  Add a checked cast.
	(ncd_of_cand_and_phis): Add a checked cast.

	* graphite-sese-to-poly.c (rewrite_phi_out_of_ssa): Require a
	gimple_phi_iterator; strengthen local "phi" from gimple to a
	gimple_phi.
	(rewrite_cross_bb_scalar_deps): Strengthen local "psi" from
	a gimple_stmt_iterator to a gimple_phi_iterator.
	(edge_initial_value_for_loop_phi): Require a gimple phi.
	(initial_value_for_loop_phi): Likewise.

	* ipa-split.c (consider_split): Convert "bsi" to a
	gimple_phi_iterator and "stmt" to a gimple_phi.

	* predict.c (predict_extra_loop_exits): Convert "phi_stmt" to be
	a gimple_phi; introduce "lhs_def_stmt" as plain gimple.
	(apply_return_prediction): Convert "phi" to be a gimple_phi.

	* tree-cfg.c (replace_uses_by): Add checked cast to gimple_phi.
	(verify_gimple_in_cfg): Introduce gimple_phi_iterator "gpi" and use
	it to convert "phi" to a gimple_phi.

	* tree-eh.c (cleanup_empty_eh_merge_phis): Convert "ngsi", "ogsi"
	to be gimple_phi_iterators.  Convert "ophi", "nphi" to be
	gimple_phi.

	* tree-into-ssa.c (prepare_use_sites_for): Add checked cast to
	gimple_phi.

	* tree-ssa-coalesce.c (create_outofssa_var_map): Introduce
	gimple_phi_iterator "gpi" and use it to convert "phi" to a
	gimple_phi.

	* tree-ssa-dce.c (propagate_necessity): Introduce local "phi",
	from checked cast to gimple_phi.

	* tree-ssa-live.c (set_var_live_on_entry): Add checked cast to
	gimple_phi.

	* tree-ssa-propagate.c (replace_phi_args_in): Require a gimple_phi
	rather than a plain gimple.
	(substitute_and_fold_dom_walker::before_dom_children): Introduce
	gimple_phi_iterator "gpi".

	* tree-ssa-sink.c (find_bb_for_arg): Require a gimple_phi rather
	than a plain gimple.
	(nearest_common_dominator_of_uses): Replace check of code against
	GIMPLE_PHI with a dyn_cast<gimple_phi>, introducing a new local.
	(statement_sink_location): Add checked cast to gimple_phi.

	* tree-ssa-uninit.c (compute_uninit_opnds_pos): Require a
	gimple_phi rather than a plain gimple.
	(collect_phi_def_edges): Likewise.  Add a checked cast.
	(find_def_preds): Strengthen param "phi" from gimple to
	gimple_phi.
	(prune_uninit_phi_opnds_in_unrealizable_paths): Likewise for
	params "phi" and "flag_def".  Strenghen param "visited_phis" from
	hash_set<gimple> * to hash_set<gimple_phi> *.  Convert
	"flag_arg_def", "phi_arg_def" to gimple_phi using
	dyn_cast<gimple_phi>.  Similarly, introduce new local
	"opnd_def_phi".
	(use_pred_not_overlap_with_undef_path_pred): Strengthen param
	"phi" from gimple to gimple_phi, and param "visited_phis" from
	hash_set<gimple> * to hash_set<gimple_phi> *.  Add a checked cast.
	(is_use_properly_guarded): Likewise for params.
	(find_uninit_use): Replace check of code against GIMPLE_PHI with
	a dyn_cast<gimple_phi>, introducing a new local "use_phi".
	Strengthen local "visited_phis" from hash_set<gimple> to
	hash_set<gimple_phi>.
---
 gcc/gimple-ssa-strength-reduction.c |  8 +++---
 gcc/gimple.h                        |  6 ++---
 gcc/graphite-sese-to-poly.c         | 10 ++++----
 gcc/ipa-split.c                     |  4 +--
 gcc/predict.c                       | 15 +++++++----
 gcc/tree-cfg.c                      |  9 ++++---
 gcc/tree-eh.c                       |  6 ++---
 gcc/tree-into-ssa.c                 |  2 +-
 gcc/tree-ssa-coalesce.c             |  6 +++--
 gcc/tree-ssa-dce.c                  |  3 ++-
 gcc/tree-ssa-live.c                 |  2 +-
 gcc/tree-ssa-propagate.c            | 14 ++++++-----
 gcc/tree-ssa-sink.c                 |  8 +++---
 gcc/tree-ssa-uninit.c               | 50 ++++++++++++++++++-------------------
 14 files changed, 79 insertions(+), 64 deletions(-)

diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 4b4c213..1b6138f 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2970,7 +2970,7 @@ ncd_for_two_cands (basic_block bb1, basic_block bb2,
    candidates, return the earliest candidate in the block in *WHERE.  */
 
 static basic_block
-ncd_with_phi (slsr_cand_t c, const widest_int &incr, gimple phi,
+ncd_with_phi (slsr_cand_t c, const widest_int &incr, gimple_phi phi,
 	      basic_block ncd, slsr_cand_t *where)
 {
   unsigned i;
@@ -2986,7 +2986,8 @@ ncd_with_phi (slsr_cand_t c, const widest_int &incr, gimple phi,
 	  gimple arg_def = SSA_NAME_DEF_STMT (arg);
 
 	  if (gimple_code (arg_def) == GIMPLE_PHI)
-	    ncd = ncd_with_phi (c, incr, arg_def, ncd, where);
+	    ncd = ncd_with_phi (c, incr, as_a <gimple_phi> (arg_def), ncd,
+				where);
 	  else 
 	    {
 	      slsr_cand_t arg_cand = base_cand_from_table (arg);
@@ -3020,7 +3021,8 @@ ncd_of_cand_and_phis (slsr_cand_t c, const widest_int &incr, slsr_cand_t *where)
     }
   
   if (phi_dependent_cand_p (c))
-    ncd = ncd_with_phi (c, incr, lookup_cand (c->def_phi)->cand_stmt,
+    ncd = ncd_with_phi (c, incr,
+			as_a <gimple_phi> (lookup_cand (c->def_phi)->cand_stmt),
 			ncd, where);
 
   return ncd;
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 5e49d97..96d9245 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3979,12 +3979,12 @@ gimple_phi_arg_def_ptr (gimple_phi phi, size_t index)
   return &gimple_phi_arg (phi, index)->def;
 }
 
-/* Return the edge associated with argument I of phi node GS.  */
+/* Return the edge associated with argument I of phi node PHI.  */
 
 static inline edge
-gimple_phi_arg_edge (gimple gs, size_t i)
+gimple_phi_arg_edge (gimple_phi phi, size_t i)
 {
-  return EDGE_PRED (gimple_bb (gs), i);
+  return EDGE_PRED (gimple_bb (phi), i);
 }
 
 /* Return the source location of gimple argument I of phi node GS.  */
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index f58f750..33a661d 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2235,10 +2235,10 @@ rewrite_close_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
    dimension array for it.  */
 
 static void
-rewrite_phi_out_of_ssa (scop_p scop, gimple_stmt_iterator *psi)
+rewrite_phi_out_of_ssa (scop_p scop, gimple_phi_iterator *psi)
 {
   size_t i;
-  gimple phi = gsi_stmt (*psi);
+  gimple_phi phi = psi->phi ();
   basic_block bb = gimple_bb (phi);
   tree res = gimple_phi_result (phi);
   tree zero_dim_array = create_zero_dim_array (res, "phi_out_of_ssa");
@@ -2449,7 +2449,7 @@ rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi)
     if (gimple_code (use_stmt) == GIMPLE_PHI
 	&& (res = true))
       {
-	gimple_stmt_iterator psi = gsi_for_stmt (use_stmt);
+	gimple_phi_iterator psi = gsi_start_phis (gimple_bb (use_stmt));
 
 	if (scalar_close_phi_node_p (gsi_stmt (psi)))
 	  rewrite_close_phi_out_of_ssa (scop, &psi);
@@ -2741,7 +2741,7 @@ follow_inital_value_to_phi (tree arg, tree lhs)
    from outside the loop.  */
 
 static edge
-edge_initial_value_for_loop_phi (gimple phi)
+edge_initial_value_for_loop_phi (gimple_phi phi)
 {
   size_t i;
 
@@ -2761,7 +2761,7 @@ edge_initial_value_for_loop_phi (gimple phi)
    from outside the loop.  */
 
 static tree
-initial_value_for_loop_phi (gimple phi)
+initial_value_for_loop_phi (gimple_phi phi)
 {
   size_t i;
 
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 94a0337..5678251 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -409,7 +409,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
   unsigned int call_overhead;
   edge e;
   edge_iterator ei;
-  gimple_stmt_iterator bsi;
+  gimple_phi_iterator bsi;
   unsigned int i;
   int incoming_freq = 0;
   tree retval;
@@ -466,7 +466,7 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
      incoming from header are the same.  */
   for (bsi = gsi_start_phis (current->entry_bb); !gsi_end_p (bsi); gsi_next (&bsi))
     {
-      gimple stmt = gsi_stmt (bsi);
+      gimple_phi stmt = bsi.phi ();
       tree val = NULL;
 
       if (virtual_operand_p (gimple_phi_result (stmt)))
diff --git a/gcc/predict.c b/gcc/predict.c
index b5556db..bd3f138 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1442,7 +1442,8 @@ predict_extra_loop_exits (edge exit_edge)
 {
   unsigned i;
   bool check_value_one;
-  gimple phi_stmt;
+  gimple lhs_def_stmt;
+  gimple_phi phi_stmt;
   tree cmp_rhs, cmp_lhs;
   gimple cmp_stmt = last_stmt (exit_edge->src);
 
@@ -1463,8 +1464,12 @@ predict_extra_loop_exits (edge exit_edge)
 		    ^ (gimple_cond_code (cmp_stmt) == EQ_EXPR))
 		    ^ ((exit_edge->flags & EDGE_TRUE_VALUE) != 0));
 
-  phi_stmt = SSA_NAME_DEF_STMT (cmp_lhs);
-  if (!phi_stmt || gimple_code (phi_stmt) != GIMPLE_PHI)
+  lhs_def_stmt = SSA_NAME_DEF_STMT (cmp_lhs);
+  if (!lhs_def_stmt)
+    return;
+
+  phi_stmt = dyn_cast <gimple_phi> (lhs_def_stmt);
+  if (!phi_stmt)
     return;
 
   for (i = 0; i < gimple_phi_num_args (phi_stmt); i++)
@@ -2143,7 +2148,7 @@ apply_return_prediction (void)
   gimple return_stmt = NULL;
   tree return_val;
   edge e;
-  gimple phi;
+  gimple_phi phi;
   int phi_num_args, i;
   enum br_predictor pred;
   enum prediction direction;
@@ -2165,7 +2170,7 @@ apply_return_prediction (void)
       || !SSA_NAME_DEF_STMT (return_val)
       || gimple_code (SSA_NAME_DEF_STMT (return_val)) != GIMPLE_PHI)
     return;
-  phi = SSA_NAME_DEF_STMT (return_val);
+  phi = as_a <gimple_phi> (SSA_NAME_DEF_STMT (return_val));
   phi_num_args = gimple_phi_num_args (phi);
   pred = return_prediction (PHI_ARG_DEF (phi, 0), &direction);
 
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 038e3ef..697a3f1 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1736,7 +1736,8 @@ replace_uses_by (tree name, tree val)
 
 	  if (gimple_code (stmt) == GIMPLE_PHI)
 	    {
-	      e = gimple_phi_arg_edge (stmt, PHI_ARG_INDEX_FROM_USE (use));
+	      e = gimple_phi_arg_edge (as_a <gimple_phi> (stmt),
+				       PHI_ARG_INDEX_FROM_USE (use));
 	      if (e->flags & EDGE_ABNORMAL)
 		{
 		  /* This can only occur for virtual operands, since
@@ -4876,9 +4877,11 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
     {
       gimple_stmt_iterator gsi;
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+	   !gsi_end_p (gpi);
+	   gsi_next (&gpi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gpi.phi ();
 	  bool err2 = false;
 	  unsigned i;
 
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index a593cc7..1138696 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -4093,7 +4093,7 @@ static bool
 cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
 			     edge old_bb_out, bool change_region)
 {
-  gimple_stmt_iterator ngsi, ogsi;
+  gimple_phi_iterator ngsi, ogsi;
   edge_iterator ei;
   edge e;
   bitmap ophi_handled;
@@ -4123,7 +4123,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
      for the edges we're going to move.  */
   for (ngsi = gsi_start_phis (new_bb); !gsi_end_p (ngsi); gsi_next (&ngsi))
     {
-      gimple ophi, nphi = gsi_stmt (ngsi);
+      gimple_phi ophi, nphi = ngsi.phi ();
       tree nresult, nop;
 
       nresult = gimple_phi_result (nphi);
@@ -4134,7 +4134,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
       ophi = NULL;
       for (ogsi = gsi_start_phis (old_bb); !gsi_end_p (ogsi); gsi_next (&ogsi))
 	{
-	  ophi = gsi_stmt (ogsi);
+	  ophi = ogsi.phi ();
 	  if (gimple_phi_result (ophi) == nop)
 	    break;
 	  ophi = NULL;
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 3150f6b..9291105 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2600,7 +2600,7 @@ prepare_use_sites_for (tree name, bool insert_phi_p)
       if (gimple_code (stmt) == GIMPLE_PHI)
 	{
 	  int ix = PHI_ARG_INDEX_FROM_USE (use_p);
-	  edge e = gimple_phi_arg_edge (stmt, ix);
+	  edge e = gimple_phi_arg_edge (as_a <gimple_phi> (stmt), ix);
 	  mark_use_interesting (name, stmt, e->src, insert_phi_p);
 	}
       else
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
index f043096..a21cea6 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -934,9 +934,11 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
     {
       tree arg;
 
-      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+      for (gimple_phi_iterator gpi = gsi_start_phis (bb);
+	   !gsi_end_p (gpi);
+	   gsi_next (&gpi))
 	{
-	  gimple phi = gsi_stmt (gsi);
+	  gimple_phi phi = gpi.phi ();
 	  size_t i;
 	  int ver;
 	  tree res;
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 5a10d18..f853512 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -659,6 +659,7 @@ propagate_necessity (bool aggressive)
 	     we also consider the control dependent edges leading to the
 	     predecessor block associated with each PHI alternative as
 	     necessary.  */
+	  gimple_phi phi = as_a <gimple_phi> (stmt);
 	  size_t k;
 
 	  for (k = 0; k < gimple_phi_num_args (stmt); k++)
@@ -741,7 +742,7 @@ propagate_necessity (bool aggressive)
 	    {
 	      for (k = 0; k < gimple_phi_num_args (stmt); k++)
 		{
-		  basic_block arg_bb = gimple_phi_arg_edge (stmt, k)->src;
+		  basic_block arg_bb = gimple_phi_arg_edge (phi, k)->src;
 
 		  if (gimple_bb (stmt)
 		      != get_immediate_dominator (CDI_POST_DOMINATORS, arg_bb))
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 49ddc10..5157ff0 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1106,7 +1106,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
 	     as this is where a copy would be inserted.  Check to see if it is
 	     defined in that block, or whether its live on entry.  */
 	  int index = PHI_ARG_INDEX_FROM_USE (use);
-	  edge e = gimple_phi_arg_edge (use_stmt, index);
+	  edge e = gimple_phi_arg_edge (as_a <gimple_phi> (use_stmt), index);
 	  if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
 	    {
 	      if (e->src != def_bb)
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 20f7554..986829f 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -966,7 +966,7 @@ replace_uses_in (gimple stmt, ssa_prop_get_value_fn get_value)
    values from PROP_VALUE.  */
 
 static bool
-replace_phi_args_in (gimple phi, ssa_prop_get_value_fn get_value)
+replace_phi_args_in (gimple_phi phi, ssa_prop_get_value_fn get_value)
 {
   size_t i;
   bool replaced = false;
@@ -1054,12 +1054,12 @@ public:
 void
 substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
 {
-  gimple_stmt_iterator i;
-
   /* Propagate known values into PHI nodes.  */
-  for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
+  for (gimple_phi_iterator i = gsi_start_phis (bb);
+       !gsi_end_p (i);
+       gsi_next (&i))
     {
-      gimple phi = gsi_stmt (i);
+      gimple_phi phi = i.phi ();
       tree res = gimple_phi_result (phi);
       if (virtual_operand_p (res))
 	continue;
@@ -1080,7 +1080,9 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
 
   /* Propagate known values into stmts.  In some case it exposes
      more trivially deletable stmts to walk backward.  */
-  for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
+  for (gimple_stmt_iterator i = gsi_start_bb (bb);
+       !gsi_end_p (i);
+       gsi_next (&i))
     {
       bool did_replace;
       gimple stmt = gsi_stmt (i);
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index d7fd159..325d9d9 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -85,7 +85,7 @@ static struct
    we return NULL.  */
 
 static basic_block
-find_bb_for_arg (gimple phi, tree def)
+find_bb_for_arg (gimple_phi phi, tree def)
 {
   size_t i;
   bool foundone = false;
@@ -149,11 +149,11 @@ nearest_common_dominator_of_uses (def_operand_p def_p, bool *debug_stmts)
       gimple usestmt = USE_STMT (use_p);
       basic_block useblock;
 
-      if (gimple_code (usestmt) == GIMPLE_PHI)
+      if (gimple_phi phi = dyn_cast <gimple_phi> (usestmt))
 	{
 	  int idx = PHI_ARG_INDEX_FROM_USE (use_p);
 
-	  useblock = gimple_phi_arg_edge (usestmt, idx)->src;
+	  useblock = gimple_phi_arg_edge (phi, idx)->src;
 	}
       else if (is_gimple_debug (usestmt))
 	{
@@ -446,7 +446,7 @@ statement_sink_location (gimple stmt, basic_block frombb,
 	}
     }
 
-  sinkbb = find_bb_for_arg (use, DEF_FROM_PTR (def_p));
+  sinkbb = find_bb_for_arg (as_a <gimple_phi> (use), DEF_FROM_PTR (def_p));
 
   /* This can happen if there are multiple uses in a PHI.  */
   if (!sinkbb)
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index bae72ff..6822bc6 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -294,7 +294,7 @@ can_skip_redundant_opnd (tree opnd, gimple phi)
    that have empty (or possibly empty) definitions.  */
 
 static unsigned
-compute_uninit_opnds_pos (gimple phi)
+compute_uninit_opnds_pos (gimple_phi phi)
 {
   size_t i, n;
   unsigned uninit_opnds = 0;
@@ -646,7 +646,7 @@ find_predicates (pred_chain_union *preds,
    VISITED_PHIS is a pointer set for detecting cycles.  */
 
 static void
-collect_phi_def_edges (gimple phi, basic_block cd_root,
+collect_phi_def_edges (gimple_phi phi, basic_block cd_root,
                        vec<edge> *edges,
                        hash_set<gimple> *visited_phis)
 {
@@ -679,7 +679,7 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
           if (gimple_code (def) == GIMPLE_PHI
               && dominated_by_p (CDI_DOMINATORS,
                                  gimple_bb (def), cd_root))
-            collect_phi_def_edges (def, cd_root, edges,
+            collect_phi_def_edges (as_a <gimple_phi> (def), cd_root, edges,
                                    visited_phis);
           else if (!uninit_undefined_value_p (opnd))
             {
@@ -699,7 +699,7 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
    composite predicates pointed to by PREDS.  */
 
 static bool
-find_def_preds (pred_chain_union *preds, gimple phi)
+find_def_preds (pred_chain_union *preds, gimple_phi phi)
 {
   size_t num_chains = 0, i, n;
   vec<edge> dep_chains[MAX_NUM_CHAINS];
@@ -937,9 +937,9 @@ find_matching_predicate_in_rest_chains (pred_info pred,
 static bool
 is_use_properly_guarded (gimple use_stmt,
                          basic_block use_bb,
-                         gimple phi,
+                         gimple_phi phi,
                          unsigned uninit_opnds,
-                         hash_set<gimple> *visited_phis);
+                         hash_set<gimple_phi> *visited_phis);
 
 /* Returns true if all uninitialized opnds are pruned. Returns false
    otherwise. PHI is the phi node with uninitialized operands,
@@ -976,12 +976,12 @@ is_use_properly_guarded (gimple use_stmt,
 */
 
 static bool
-prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
+prune_uninit_phi_opnds_in_unrealizable_paths (gimple_phi phi,
 					      unsigned uninit_opnds,
-					      gimple flag_def,
+					      gimple_phi flag_def,
 					      tree boundary_cst,
 					      enum tree_code cmp_code,
-					      hash_set<gimple> *visited_phis,
+					      hash_set<gimple_phi> *visited_phis,
 					      bitmap *visited_flag_phis)
 {
   unsigned i;
@@ -996,22 +996,22 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
       flag_arg = gimple_phi_arg_def (flag_def, i);
       if (!is_gimple_constant (flag_arg))
         {
-          gimple flag_arg_def, phi_arg_def;
+          gimple_phi flag_arg_def, phi_arg_def;
           tree phi_arg;
           unsigned uninit_opnds_arg_phi;
 
           if (TREE_CODE (flag_arg) != SSA_NAME)
             return false;
-          flag_arg_def = SSA_NAME_DEF_STMT (flag_arg);
-          if (gimple_code (flag_arg_def) != GIMPLE_PHI)
+          flag_arg_def = dyn_cast <gimple_phi> (SSA_NAME_DEF_STMT (flag_arg));
+	  if (!flag_arg_def)
             return false;
 
           phi_arg = gimple_phi_arg_def (phi, i);
           if (TREE_CODE (phi_arg) != SSA_NAME)
             return false;
 
-          phi_arg_def = SSA_NAME_DEF_STMT (phi_arg);
-          if (gimple_code (phi_arg_def) != GIMPLE_PHI)
+          phi_arg_def = dyn_cast <gimple_phi> (SSA_NAME_DEF_STMT (phi_arg));
+	  if (!phi_arg_def)
             return false;
 
           if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
@@ -1052,16 +1052,16 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
 
           opnd = gimple_phi_arg_def (phi, i);
           opnd_def = SSA_NAME_DEF_STMT (opnd);
-          if (gimple_code (opnd_def) == GIMPLE_PHI)
+          if (gimple_phi opnd_def_phi = dyn_cast <gimple_phi> (opnd_def))
             {
               edge opnd_edge;
               unsigned uninit_opnds2
-                  = compute_uninit_opnds_pos (opnd_def);
+                  = compute_uninit_opnds_pos (opnd_def_phi);
               gcc_assert (!MASK_EMPTY (uninit_opnds2));
               opnd_edge = gimple_phi_arg_edge (phi, i);
               if (!is_use_properly_guarded (phi,
                                             opnd_edge->src,
-                                            opnd_def,
+                                            opnd_def_phi,
                                             uninit_opnds2,
                                             visited_phis))
                   return false;
@@ -1150,8 +1150,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi,
 
 static bool
 use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
-				           gimple phi, unsigned uninit_opnds,
-					   hash_set<gimple> *visited_phis)
+				           gimple_phi phi, unsigned uninit_opnds,
+					   hash_set<gimple_phi> *visited_phis)
 {
   unsigned int i, n;
   gimple flag_def = 0;
@@ -1224,7 +1224,7 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
 
   all_pruned = prune_uninit_phi_opnds_in_unrealizable_paths (phi,
                                                              uninit_opnds,
-                                                             flag_def,
+                                                             as_a <gimple_phi> (flag_def),
                                                              boundary_cst,
                                                              cmp_code,
                                                              visited_phis,
@@ -2105,9 +2105,9 @@ normalize_preds (pred_chain_union preds, gimple use_or_def, bool is_use)
 static bool
 is_use_properly_guarded (gimple use_stmt,
                          basic_block use_bb,
-                         gimple phi,
+                         gimple_phi phi,
                          unsigned uninit_opnds,
-                         hash_set<gimple> *visited_phis)
+                         hash_set<gimple_phi> *visited_phis)
 {
   basic_block phi_bb;
   pred_chain_union preds = vNULL;
@@ -2193,13 +2193,13 @@ find_uninit_use (gimple_phi phi, unsigned uninit_opnds,
       if (is_gimple_debug (use_stmt))
 	continue;
 
-      if (gimple_code (use_stmt) == GIMPLE_PHI)
-	use_bb = gimple_phi_arg_edge (use_stmt,
+      if (gimple_phi use_phi = dyn_cast <gimple_phi> (use_stmt))
+	use_bb = gimple_phi_arg_edge (use_phi,
 				      PHI_ARG_INDEX_FROM_USE (use_p))->src;
       else
 	use_bb = gimple_bb (use_stmt);
 
-      hash_set<gimple> visited_phis;
+      hash_set<gimple_phi> visited_phis;
       if (is_use_properly_guarded (use_stmt, use_bb, phi, uninit_opnds,
                                    &visited_phis))
 	continue;
-- 
1.8.5.3

