From 9244203345ddb7570a946e982b40a459c69208f1 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 27 Mar 2014 11:16:05 -0400
Subject: [PATCH 52/89] 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.

	* 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): 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.
	(find_def_preds): Likewise.
	(is_use_properly_guarded): Likewise.
	(prune_uninit_phi_opnds_in_unrealizable_paths): Likewise.  Also,
	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): Require a
	gimple_phi rather than a plain gimple; add a checked cast.
	(find_uninit_use): Replace check of code against GIMPLE_PHI with
	a dyn_cast_gimple_phi, introducing a new local.
---
 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    |  6 +++---
 gcc/tree-ssa-sink.c         |  8 ++++----
 gcc/tree-ssa-uninit.c       | 41 +++++++++++++++++++++--------------------
 13 files changed, 65 insertions(+), 53 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6007516..72f67ce 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -4251,12 +4251,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 8dca109..11ea1d3 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2234,10 +2234,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");
@@ -2447,7 +2447,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);
@@ -2739,7 +2739,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;
 
@@ -2759,7 +2759,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 e294dc3..0797abff 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -383,7 +383,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;
@@ -440,7 +440,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 249433f..7b4bb12 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1462,7 +1462,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);
 
@@ -1483,8 +1484,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 = lhs_def_stmt->dyn_cast_gimple_phi ();
+  if (!phi_stmt)
     return;
 
   for (i = 0; i < gimple_phi_num_args (phi_stmt); i++)
@@ -2215,7 +2220,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;
@@ -2237,7 +2242,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 = SSA_NAME_DEF_STMT (return_val)->as_a_gimple_phi ();
   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 347b6b3..9efb01c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -1692,7 +1692,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 (stmt->as_a_gimple_phi (),
+				       PHI_ARG_INDEX_FROM_USE (use));
 	      if (e->flags & EDGE_ABNORMAL)
 		{
 		  /* This can only occur for virtual operands, since
@@ -4804,9 +4805,11 @@ verify_gimple_in_cfg (struct function *fn)
     {
       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 70a284b..928d397 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -4156,7 +4156,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;
@@ -4186,7 +4186,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);
@@ -4197,7 +4197,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 dfe9108..217adeb 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -2604,7 +2604,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 (stmt->as_a_gimple_phi (), 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 fa1c3cf..cd4f5a1 100644
--- a/gcc/tree-ssa-coalesce.c
+++ b/gcc/tree-ssa-coalesce.c
@@ -933,9 +933,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 294fc33..2953a1b 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -657,6 +657,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 = stmt->as_a_gimple_phi ();
 	  size_t k;
 
 	  for (k = 0; k < gimple_phi_num_args (stmt); k++)
@@ -739,7 +740,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 2c431e7..3223a71 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1108,7 +1108,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 (use_stmt->as_a_gimple_phi (), 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 a2afcdd..ad7f008 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -954,7 +954,7 @@ replace_uses_in (gimple stmt, ssa_prop_get_value_fn get_value)
    values from PROP_VALUE.  */
 
 static void
-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;
@@ -1103,8 +1103,8 @@ substitute_and_fold (ssa_prop_get_value_fn get_value_fn,
 
       /* Propagate known values into PHI nodes.  */
       if (get_value_fn)
-	for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
-	  replace_phi_args_in (gsi_stmt (i), get_value_fn);
+	for (gimple_phi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); gsi_next (&gpi))
+	  replace_phi_args_in (gpi.phi (), get_value_fn);
 
       /* Propagate known values into stmts.  Do a backward walk if
          do_dce is true. In some case it exposes
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 6d02975..295cf48 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;
@@ -157,11 +157,11 @@ nearest_common_dominator_of_uses (gimple stmt, bool *debug_stmts)
 	  gimple usestmt = USE_STMT (use_p);
 	  basic_block useblock;
 
-	  if (gimple_code (usestmt) == GIMPLE_PHI)
+	  if (gimple_phi phi = usestmt->dyn_cast_gimple_phi ())
 	    {
 	      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))
 	    {
@@ -417,7 +417,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 (use->as_a_gimple_phi (), 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 43be808..60c9cad 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -284,7 +284,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;
@@ -636,7 +636,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,
                        pointer_set_t *visited_phis)
 {
@@ -669,7 +669,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 (def->as_a_gimple_phi (), cd_root, edges,
                                    visited_phis);
           else if (!uninit_undefined_value_p (opnd))
             {
@@ -689,7 +689,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];
@@ -930,7 +930,7 @@ 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,
                          pointer_set_t *visited_phis);
 
@@ -969,9 +969,9 @@ 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,
 					      pointer_set_t *visited_phis,
@@ -989,22 +989,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 = SSA_NAME_DEF_STMT (flag_arg)->dyn_cast_gimple_phi ();
+	  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 = SSA_NAME_DEF_STMT (phi_arg)->dyn_cast_gimple_phi ();
+	  if (!phi_arg_def)
             return false;
 
           if (gimple_bb (phi_arg_def) != gimple_bb (flag_arg_def))
@@ -1045,16 +1045,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 = opnd_def->dyn_cast_gimple_phi ())
             {
               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;
@@ -1143,7 +1143,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,
+				           gimple_phi phi,
+					   unsigned uninit_opnds,
 					   pointer_set_t *visited_phis)
 {
   unsigned int i, n;
@@ -1217,7 +1218,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,
+                                                             flag_def->as_a_gimple_phi (),
                                                              boundary_cst,
                                                              cmp_code,
                                                              visited_phis,
@@ -2101,7 +2102,7 @@ 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,
                          pointer_set_t *visited_phis)
 {
@@ -2192,8 +2193,8 @@ find_uninit_use (gimple_phi phi, unsigned uninit_opnds,
 
       visited_phis = pointer_set_create ();
 
-      if (gimple_code (use_stmt) == GIMPLE_PHI)
-	use_bb = gimple_phi_arg_edge (use_stmt,
+      if (gimple_phi use_phi = use_stmt->dyn_cast_gimple_phi ())
+	use_bb = gimple_phi_arg_edge (use_phi,
 				      PHI_ARG_INDEX_FROM_USE (use_p))->src;
       else
 	use_bb = gimple_bb (use_stmt);
-- 
1.8.5.3

