From 7576570a0fac6a2460452c28eaecdaadbec4f413 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 14 May 2014 12:01:29 -0400 Subject: [PATCH 11/29] Introduce gphi_iterator This corresponds to: "[PATCH 09/89] Introduce gimple_phi_iterator" https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01219.html from v1 of the patch series. gcc/ * gimple-iterator.h (struct gphi_iterator): New subclass of gimple_stmt_iterator with identical layout, but adding... (gphi_iterator::phi): ...new method, equivalent to gsi_stmt (), but casting the underlying gimple to gphi, checking that code == GIMPLE_PHI in a checked build. (gsi_start_phis): Return a gphi_iterator, rather than just a gimple_stmt_iterator. * tree-if-conv.c (bb_with_exit_edge_p): Require a gphi 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 gphi and a vec *, rather than just a gimple and vec *. (find_uninit_use): Likewise; add checked cast to gphi when adding to worklist. (execute_late_warn_uninitialized): Strengthen types of various locals, "worklist" from vec to vec, "gsi" to a gphi_iterator, and "phi" and "cur_phi" to a gphi. * tree-ssa-loop-manip.c (rewrite_phi_with_iv): Require a gphi_iterator * rather than a gimple_stmt_iterator *; use it to strengthen local from a gimple to a gphi. * cfgloop.c (find_subloop_latch_edge_by_ivs): Convert local from a gimple_stmt_iterator to a gphi_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 gphi. * 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 gphi. --- gcc/cfgloop.c | 6 +++--- gcc/gimple-iterator.c | 12 ++++++++++-- gcc/gimple-iterator.h | 11 ++++++++++- gcc/gimple-pretty-print.c | 6 +++--- 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 | 12 ++++++------ 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 | 36 ++++++++++++++++++------------------ gcc/tree-vect-loop.c | 4 ++-- gcc/tree-vrp.c | 4 ++-- gcc/value-prof.c | 4 ++-- 41 files changed, 217 insertions(+), 194 deletions(-) diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 8113ebc..fb950e7 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -578,8 +578,8 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec la { edge e, latch = latches[0]; unsigned i; - gimple *phi; - gimple_stmt_iterator psi; + gphi *phi; + gphi_iterator psi; tree lop; basic_block bb; @@ -597,7 +597,7 @@ find_subloop_latch_edge_by_ivs (struct loop *loop ATTRIBUTE_UNUSED, vec 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 a1bc469..c3562de 100644 --- a/gcc/gimple-iterator.c +++ b/gcc/gimple-iterator.c @@ -883,9 +883,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 +gphi_iterator gsi_start_phis (basic_block bb) { gimple_seq *pseq = phi_nodes_ptr (bb); - return gsi_start_1 (pseq); + + /* Adapted from gsi_start_1. */ + gphi_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 ff2c1a4..f4c6b26 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 gphi_iterator : public gimple_stmt_iterator +{ + gphi *phi () const + { + return as_a (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 gphi_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 6e270a8..9485fd6 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -2296,15 +2296,15 @@ 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; + gphi_iterator i; for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) { - gimple *phi = gsi_stmt (i); + gphi *phi = i.phi (); if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); - dump_gimple_phi (buffer, as_a (phi), indent, true, flags); + dump_gimple_phi (buffer, phi, indent, true, flags); pp_newline (buffer); } } diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index d263e68..cc280a1 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; + gphi_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); + gphi *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 23e8984..a104565 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -4292,7 +4292,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); + gphi *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 ae98c35..bc242a7 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); + gphi *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 6a22f8e..00ca8c2 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2567,7 +2567,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; + gphi_iterator phis; v = redirect_edge_var_map_vector (old_edge); if (!v) @@ -2577,7 +2577,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); + gphi *phi = phis.phi (); tree result = redirect_edge_var_map_result (vm); tree arg = redirect_edge_var_map_def (vm); @@ -5286,7 +5286,7 @@ gimple_make_forwarder_block (edge fallthru) edge_iterator ei; basic_block dummy, bb; tree var; - gimple_stmt_iterator gsi; + gphi_iterator gsi; dummy = fallthru->src; bb = fallthru->dest; @@ -5298,9 +5298,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; + gphi *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)); @@ -5767,9 +5767,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; + gphi *phi, *phi_copy; tree def; - gimple_stmt_iterator psi, psi_copy; + gphi_iterator psi, psi_copy; if (gimple_seq_empty_p (phi_nodes (e_copy->dest))) return; @@ -5802,8 +5802,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)); @@ -7923,8 +7923,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; + gphi *phi1, *phi2; + gphi_iterator psi1, psi2; tree def; edge e2 = find_edge (new_head, second); @@ -7940,8 +7940,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 501eae3..e26ed09 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; + gphi_iterator gsi; for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); tree val1 = gimple_phi_arg_def (phi, n1); tree val2 = gimple_phi_arg_def (phi, n2); @@ -827,7 +827,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; + gphi_iterator gsi; s = find_edge (e->src, dest); if (s) @@ -859,7 +859,7 @@ remove_forwarder_block_with_phi (basic_block bb) !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); tree def = gimple_phi_arg_def (phi, succ->dest_idx); source_location locus = gimple_phi_arg_location_from_edge (phi, succ); @@ -1010,7 +1010,7 @@ pass_merge_phi::execute (function *fun) } else { - gimple_stmt_iterator gsi; + gphi_iterator gsi; unsigned int dest_idx = single_succ_edge (bb)->dest_idx; /* BB dominates DEST. There may be many users of the PHI @@ -1021,7 +1021,7 @@ pass_merge_phi::execute (function *fun) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 509ed11..fc5c61b 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; + gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 2f7de22..81cbc9e 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, gphi *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; + gphi_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 9f1901e..ef80a69 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1926,8 +1926,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; + gphi *phi; + gphi_iterator si; if (!nonlocal_goto) gcc_assert (e->flags & EDGE_EH); @@ -1939,7 +1939,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. */ @@ -2092,17 +2092,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; + gphi *phi; + gphi_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; + gphi *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 cff9fbb..dd0c3d4 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; + gphi *phi; + gphi_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 27f7cd28..896b6c6 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; + gphi_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); + gphi *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; + gphi_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); + gphi *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; + gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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; + gphi_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); + gphi *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 8c78110..7caf5b7 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -290,11 +290,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; + gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gphi *stmt = as_a (gsi_stmt (gsi)); + gphi *stmt = gsi.phi (); if (len > gimple_phi_capacity (stmt)) { @@ -325,7 +325,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 (gphi *phi, basic_block bb) { gimple_seq seq = phi_nodes (bb); /* Add the new PHI node to the list of PHI nodes for block BB. */ @@ -430,10 +430,10 @@ remove_phi_arg_num (gphi *phi, int i) void remove_phi_args (edge e) { - gimple_stmt_iterator gsi; + gphi_iterator gsi; for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi)) - remove_phi_arg_num (as_a (gsi_stmt (gsi)), + remove_phi_arg_num (gsi.phi (), e->dest_idx); } @@ -465,7 +465,7 @@ remove_phi_node (gimple_stmt_iterator *gsi, bool release_lhs_p) void remove_phi_nodes (basic_block bb) { - gimple_stmt_iterator gsi; + gphi_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 6f294aa..430d6d2 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 (gphi *phi, basic_block bb); extern gphi *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 a29eaef..288156c 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; + gphi *phi = NULL; + gimple *init_stmt; edge latch = loop_latch_edge (loop); struct data_reference init_dr; - gimple_stmt_iterator psi; + gphi_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; + gphi *phi; + gimple *stmt; tree name, use, var; - gimple_stmt_iterator psi; + gphi_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 112840d..bfd7fc9 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; + gphi *phi; + gphi_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; + gphi *phi; + gimple *ass; struct loop *loop, *ex_loop; bitmap ssa_names_to_remove = NULL; unsigned i; - gimple_stmt_iterator psi; + gphi_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 = as_a (SSA_NAME_DEF_STMT (name)); 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 9757f12..13353a1 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; + gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 ce053f0..3d82f08 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -933,13 +933,13 @@ static bool remove_dead_phis (basic_block bb) { bool something_changed = false; - gimple *phi; - gimple_stmt_iterator gsi; + gphi *phi; + gphi_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. */ @@ -991,7 +991,7 @@ remove_dead_phis (basic_block bb) static edge forward_edge_to_pdom (edge e, basic_block post_dom_bb) { - gimple_stmt_iterator gsi; + gphi_iterator gsi; edge e2 = NULL; edge_iterator ei; @@ -1015,7 +1015,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); + gphi *phi = gsi.phi (); tree op; source_location locus; diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 49fc8c8..1cc95c6 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1181,11 +1181,11 @@ dom_opt_dom_walker::thread_across_edge (edge e) static void record_equivalences_from_phis (basic_block bb) { - gimple_stmt_iterator gsi; + gphi_iterator gsi; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); tree lhs = gimple_phi_result (phi); tree rhs = NULL; @@ -1705,7 +1705,7 @@ cprop_into_successor_phis (basic_block bb) FOR_EACH_EDGE (e, ei, bb->succs) { int indx; - gimple_stmt_iterator gsi; + gphi_iterator gsi; /* If this is an abnormal edge, then we do not want to copy propagate into the PHI alternative associated with this edge. */ @@ -1744,7 +1744,7 @@ cprop_into_successor_phis (basic_block bb) tree new_val; use_operand_p orig_p; tree orig_val; - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); /* The alternative may be associated with a constant, so verify it is an SSA_NAME before doing anything with it. */ @@ -2856,7 +2856,8 @@ propagate_rhs_into_lhs (gimple *stmt, tree lhs, tree rhs, bitmap interesting_nam edge te = find_taken_edge (bb, val); edge_iterator ei; edge e; - gimple_stmt_iterator gsi, psi; + gimple_stmt_iterator gsi; + gphi_iterator psi; /* Remove all outgoing edges except TE. */ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei));) @@ -2869,7 +2870,7 @@ propagate_rhs_into_lhs (gimple *stmt, tree lhs, tree rhs, bitmap interesting_nam !gsi_end_p (psi); gsi_next (&psi)) { - gimple *phi = gsi_stmt (psi); + gphi *phi = psi.phi (); tree result = gimple_phi_result (phi); int version = SSA_NAME_VERSION (result); @@ -2979,12 +2980,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; + gphi_iterator gsi; basic_block son; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 d424ce2..52a2ccf 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; + gphi_iterator gsi; + gphi *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 c046565..5772caf 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; + gphi_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); + gphi *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; + gphi_iterator gsi; for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi) && !ok; gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 38a4e5d..b50c5d7 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; + gphi_iterator gsi2; for (gsi2 = gsi_start_phis (e->dest); !gsi_end_p (gsi2); gsi_next (&gsi2)) { - gimple *phi = gsi_stmt (gsi2); + gphi *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 7bd00c1..20ac7e9 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1057,11 +1057,11 @@ find_bivs (struct ivopts_data *data) tree step, type, base; bool found = false; struct loop *loop = data->current_loop; - gimple_stmt_iterator psi; + gphi_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; @@ -1103,11 +1103,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; + gphi_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) @@ -1988,13 +1988,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; + gphi *phi; + gphi_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); @@ -5206,8 +5206,8 @@ static void determine_set_costs (struct ivopts_data *data) { unsigned j, n; - gimple *phi; - gimple_stmt_iterator psi; + gphi *phi; + gphi_iterator psi; tree op; struct loop *loop = data->current_loop; bitmap_iterator bi; @@ -5224,7 +5224,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 5d8d130..9f0725b 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; + gphi_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; + gphi *phi_old_loop, *phi_new_loop, *phi_rest; + gphi_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, + gphi_iterator *psi, gimple_stmt_iterator *gsi, tree main_iv) { affine_iv iv; - gimple *stmt, *phi = gsi_stmt (*psi); + gimple *stmt; + gphi *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; + gphi_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; + gphi_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); + gphi *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 00182e5..14acc12 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -147,7 +147,7 @@ determine_value_range (struct loop *loop, tree type, tree var, mpz_t off, { edge e = loop_preheader_edge (loop); signop sgn = TYPE_SIGN (type); - gimple_stmt_iterator gsi; + gphi_iterator gsi; /* Either for VAR itself... */ rtype = get_range_info (var, &minv, &maxv); @@ -155,7 +155,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); + gphi *phi = gsi.phi (); wide_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 6e7e4a7..cdcefc3 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1993,14 +1993,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; + gphi_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); + gphi *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 16e0d22..b4f2b2b 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, gphi *phi, struct phiprop_d *phivn, size_t n) { tree ptr = PHI_RESULT (phi); @@ -410,7 +410,7 @@ pass_phiprop::execute (function *fun) struct phiprop_d *phivn; bool did_something = false; basic_block bb; - gimple_stmt_iterator gsi; + gphi_iterator gsi; unsigned i; size_t n; @@ -425,7 +425,7 @@ pass_phiprop::execute (function *fun) single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun))); 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 94a4196..b569aa1 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -2491,7 +2491,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; + gphi_iterator gsi; bool other_edge_seen = false; bool is_cond; @@ -2553,7 +2553,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); + gphi *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 efc804f..118595d 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; + gphi_iterator gsi; for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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; + gphi_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 f7a4b07..20b051b 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 *stack, bool backedge_seen, bitmap src_map, bitmap dst_map) { - gimple_stmt_iterator gsi; + gphi_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); + gphi *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 5e28965..c5fe20d 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 (gphi_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); + gphi *src_phi = gsi.phi (); + gphi *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); @@ -457,12 +457,12 @@ static void copy_phi_args (basic_block bb, edge src_e, edge tgt_e, vec *path, int idx) { - gimple_stmt_iterator gsi; + gphi_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); + gphi *phi = gsi.phi (); tree def = gimple_phi_arg_def (phi, src_indx); source_location locus = gimple_phi_arg_location (phi, src_indx); @@ -1455,13 +1455,13 @@ fail: static bool phi_args_equal_on_edges (edge e1, edge e2) { - gimple_stmt_iterator gsi; + gphi_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); + gphi *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 8ae8d78..79eae94 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -2179,8 +2179,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 *worklist, +find_uninit_use (gphi *phi, unsigned uninit_opnds, + vec *worklist, pointer_set_t *added_to_worklist) { tree phi_result; @@ -2234,7 +2234,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 (as_a (use_stmt)); pointer_set_insert (possibly_undefined_names, phi_result); } } @@ -2251,7 +2251,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 *worklist, +warn_uninitialized_phi (gphi *phi, vec *worklist, pointer_set_t *added_to_worklist) { unsigned uninit_opnds; @@ -2338,8 +2338,8 @@ unsigned int pass_late_warn_uninitialized::execute (function *fun) { basic_block bb; - gimple_stmt_iterator gsi; - vec worklist = vNULL; + gphi_iterator gsi; + vec worklist = vNULL; pointer_set_t *added_to_worklist; calculate_dominance_info (CDI_DOMINATORS); @@ -2358,7 +2358,7 @@ pass_late_warn_uninitialized::execute (function *fun) FOR_EACH_BB_FN (bb, fun) for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); size_t n, i; n = gimple_phi_num_args (phi); @@ -2387,7 +2387,7 @@ pass_late_warn_uninitialized::execute (function *fun) while (worklist.length () != 0) { - gimple *cur_phi = 0; + gphi *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 a4fcb62..15375bf 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; + gphi_iterator gsi; + gphi *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; + gphi *phi; edge_var_map_vector *v; edge_var_map *vm; int i; - gimple_stmt_iterator gsi; + gphi_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 cb086c3..b3e02be 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -752,12 +752,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; + gphi_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); + gphi *phi = gsi.phi (); unsigned int i; info->phi_count++; @@ -833,7 +833,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; + gphi_iterator gsi; basic_block bb = label_to_block (CASE_LABEL (default_case)); edge e; int i = 0; @@ -847,7 +847,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); + gphi *phi = gsi.phi (); tree val = PHI_ARG_DEF_FROM_EDGE (phi, e); gcc_assert (val); info->default_values[i++] = val; @@ -870,7 +870,7 @@ build_constructors (gswitch *swtch, struct switch_conv_info *info) basic_block bb = label_to_block (CASE_LABEL (cs)); edge e; tree high; - gimple_stmt_iterator gsi; + gphi_iterator gsi; int j; if (bb == info->final_bb) @@ -905,7 +905,7 @@ build_constructors (gswitch *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); + gphi *phi = gsi.phi (); tree val = PHI_ARG_DEF_FROM_EDGE (phi, e); tree low = CASE_LOW (cs); pos = CASE_LOW (cs); @@ -1183,13 +1183,13 @@ static void fix_phi_nodes (edge e1f, edge e2f, basic_block bbf, struct switch_conv_info *info) { - gimple_stmt_iterator gsi; + gphi_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); + gphi *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 4d7c2e9..76e83b0 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -388,11 +388,11 @@ static tree propagate_through_phis (tree var, edge e) { basic_block dest = e->dest; - gimple_stmt_iterator gsi; + gphi_iterator gsi; for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var) return PHI_RESULT (phi); } @@ -620,10 +620,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; + gphi_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 015aa40..fb5bef8 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; + gphi *orig_phi, *new_phi; + gphi *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; + gphi_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; + gphi *orig_phi, *new_phi; + gphi *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; + gphi_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; + gphi_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); + gphi *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)))) @@ -1528,8 +1528,8 @@ 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; + gphi *phi; + gphi_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; + gphi *phi, *phi1; + gphi_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 6012510..c57d635 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 worklist; - gimple_stmt_iterator gsi; + gphi_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); + gphi *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 66a354e..bd1b2ea 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5832,10 +5832,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 (gphi_iterator gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple *phi = gsi_stmt (gsi); + gphi *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 967b01f..270f9b4 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1336,7 +1336,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; + gphi_iterator psi; cond_bb = gimple_bb (icall_stmt); gsi = gsi_for_stmt (icall_stmt); @@ -1449,7 +1449,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); + gphi *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