This corresponds to: [PATCH 88/89] Use gimple_phi in many more places. https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01176.html from the original 89-patch kit
That earlier patch was approved by Jeff: > Fine once prereqs go in. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00879.html This patch converts almost every usage of gsi_start_phis to act on a gimple_phi_iterator: everywhere (I believe) where the underlying statements are then accessed via a gimple_phi_ accessor. There are some places where the phi nodes then just go through generic gimple APIs; in these cases I didn't bother converting the iterators. gcc/ * gimple-ssa-strength-reduction.c (slsr_process_phi): Require a gimple_phi. * ipa-inline-analysis.c (predicate_for_phi_result): Likewise. * tree-emutls.c (lower_emutls_phi_arg): Likewise. * tree-if-conv.c (predicate_scalar_phi): Likewise. * tree-into-ssa.c (mark_virtual_phi_result_for_renaming): Likewise. * tree-into-ssa.h (mark_virtual_phi_result_for_renaming): Likewise. * tree-phinodes.c (degenerate_phi_result): Likewise. * tree-phinodes.h (degenerate_phi_result): Likewise. * tree-ssa.c (verify_use): Likewise. * tree-switch-conversion.c (array_value_type): Likewise. * graphite-scop-detection.c (same_close_phi_node): Require a pair of gimple_phi. (remove_duplicate_close_phi): Require a gimple_phi and a gimple_phi_iterator. (make_close_phi_nodes_unique): Convert a local into a gimple_phi_iterator. * gimple-pretty-print.c (gimple_dump_bb_for_graph): Split iterator into gimple_stmt_iterator and gimple_phi_iterator, converting local from gimple to gimple_phi. * gimple-ssa-strength-reduction.c (find_candidates_dom_walker::before_dom_children): Likewise. * ipa-inline-analysis.c (estimate_function_body_sizes): Likewise. * ipa-split.c (verify_non_ssa_vars): Likewise. (visit_bb): Likewise. (split_function): Likewise. * lto-streamer-out.c (output_function): Likewise. * sese.c (sese_build_liveouts_bb): Likewise. * tree-cfg.c (gimple_can_merge_blocks_p): Likewise. * tree-complex.c (init_dont_simulate_again): Likewise. * tree-dfa.c (collect_dfa_stats): Likewise. * tree-eh.c (sink_clobbers): Likewise. * tree-emutls.c (lower_emutls_function_body): Likewise. * tree-into-ssa.c (rewrite_dom_walker::before_dom_children): Likewise. (rewrite_update_dom_walker::before_dom_children): Likewise. (prepare_block_for_update): Likewise. * tree-loop-distribution.c (stmts_from_loop): Likewise. (generate_loops_for_partition): Likewise. (destroy_loop): Likewise. (tree_loop_distribution): Likewise. * tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise. * tree-ssa-copy.c (init_copy_prop): Likewise. * tree-ssa-copyrename.c (rename_ssa_copies): Likewise. * tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): Likewise. * tree-ssa-loop-manip.c (find_uses_to_rename_bb): Likewise. (verify_loop_closed_ssa): Likewise. * tree-ssa-math-opts.c (execute_cse_reciprocals): Likewise. * tree-ssa-pre.c (compute_avail): Likewise. (eliminate_dom_walker::before_dom_children): Likewise. * tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Likewise. * tree-ssa-structalias.c (compute_points_to_sets): Likewise. (ipa_pta_execute): Likewise. * tree-ssa-tail-merge.c (same_succ_hash): Likewise. (release_last_vdef): Likewise. * tree-ssa.c (verify_ssa): Likewise. (execute_update_addresses_taken): Likewise. * tree-stdarg.c (check_all_va_list_escapes): Likewise. (execute_optimize_stdarg): Likewise. * tree-switch-conversion.c (build_arrays): Likewise. * tree-vect-loop-manip.c (rename_variables_in_bb): Likewise. * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. (vect_analyze_loop_operations): Likewise. (vect_transform_loop): Likewise. * tree-vrp.c (find_assert_locations_1): Likewise. (vrp_initialize): Likewise. * graphite-sese-to-poly.c (gsi_for_phi_node): Convert psi to a gimple_phi_iterator. (rewrite_degenerate_phi): Require a gimple_phi_iterator; strengthen local "phi" from gimple to gimple-phi. * ipa-split.c (consider_split): Convert local psi to a gimple_phi_iterator. * tree-cfg.c (gimple_merge_blocks): Likewise. * tree-eh.c (unsplit_eh): Replace reuse of gsi with a new gimple_phi_iterator gpi, using it to convert statement from gimple to a gimple_phi. (cleanup_empty_eh_merge_phis): Strengthen ophi from gimple to gimple_phi. * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace reuse of gsi with a new gimple_phi_iterator gpi, using it to convert expressions from gimple to gimple_phi; add a checked cast to gimple_phi. * tree-if-conv.c (predicate_all_scalar_phis): Convert local phi_gsi to be a gimple_phi_iterator; convert "phi" to be a gimple_phi. * tree-parloops.c (loop_has_vector_phi_nodes): Convert local to be a gimple_phi_iterator. * tree-ssa-ccp.c (ccp_initialize): Likewise. * tree-scalar-evolution.c (analyze_initial_condition): Add checked cast to a gimple_phi. * tree-ssa.c (insert_debug_temp_for_var_def): Likewise. * tree-ssa-dom.c (get_rhs_or_phi_arg): Likewise. --- gcc/ChangeLog.gimple-classes | 103 ++++++++++++++++++++++++++++++++++++ gcc/gimple-pretty-print.c | 10 ++-- gcc/gimple-ssa-strength-reduction.c | 11 ++-- gcc/graphite-scop-detection.c | 16 +++--- gcc/graphite-sese-to-poly.c | 6 +-- gcc/ipa-inline-analysis.c | 11 ++-- gcc/ipa-split.c | 48 +++++++++-------- gcc/lto-streamer-out.c | 15 +++--- gcc/sese.c | 9 ++-- gcc/tree-cfg.c | 12 +++-- gcc/tree-complex.c | 10 ++-- gcc/tree-dfa.c | 10 ++-- gcc/tree-eh.c | 18 ++++--- gcc/tree-emutls.c | 11 ++-- gcc/tree-if-conv.c | 9 ++-- gcc/tree-into-ssa.c | 28 +++++----- gcc/tree-into-ssa.h | 2 +- gcc/tree-loop-distribution.c | 48 +++++++++-------- gcc/tree-parloops.c | 4 +- gcc/tree-phinodes.c | 2 +- gcc/tree-phinodes.h | 2 +- gcc/tree-scalar-evolution.c | 16 +++--- gcc/tree-ssa-ccp.c | 4 +- gcc/tree-ssa-coalesce.c | 10 ++-- gcc/tree-ssa-copy.c | 10 ++-- gcc/tree-ssa-copyrename.c | 12 ++--- gcc/tree-ssa-dce.c | 10 ++-- gcc/tree-ssa-dom.c | 2 +- gcc/tree-ssa-loop-ivcanon.c | 8 ++- gcc/tree-ssa-loop-manip.c | 19 +++---- gcc/tree-ssa-math-opts.c | 13 ++--- gcc/tree-ssa-pre.c | 28 +++++----- gcc/tree-ssa-strlen.c | 13 ++--- gcc/tree-ssa-structalias.c | 19 ++++--- gcc/tree-ssa-tail-merge.c | 19 +++---- gcc/tree-ssa.c | 24 ++++----- gcc/tree-stdarg.c | 19 ++++--- gcc/tree-switch-conversion.c | 9 ++-- gcc/tree-vect-loop-manip.c | 9 ++-- gcc/tree-vect-loop.c | 34 ++++++------ gcc/tree-vrp.c | 19 +++---- 41 files changed, 409 insertions(+), 273 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 030df86..015940e 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,108 @@ 2014-10-24 David Malcolm <dmalc...@redhat.com> + Use gimple_phi in many more places. + + * gimple-ssa-strength-reduction.c (slsr_process_phi): Require a + gimple_phi. + * ipa-inline-analysis.c (predicate_for_phi_result): Likewise. + * tree-emutls.c (lower_emutls_phi_arg): Likewise. + * tree-if-conv.c (predicate_scalar_phi): Likewise. + * tree-into-ssa.c (mark_virtual_phi_result_for_renaming): Likewise. + * tree-into-ssa.h (mark_virtual_phi_result_for_renaming): Likewise. + * tree-phinodes.c (degenerate_phi_result): Likewise. + * tree-phinodes.h (degenerate_phi_result): Likewise. + * tree-ssa.c (verify_use): Likewise. + * tree-switch-conversion.c (array_value_type): Likewise. + + * graphite-scop-detection.c (same_close_phi_node): Require a pair + of gimple_phi. + (remove_duplicate_close_phi): Require a gimple_phi and a + gimple_phi_iterator. + (make_close_phi_nodes_unique): Convert a local into a + gimple_phi_iterator. + + * gimple-pretty-print.c (gimple_dump_bb_for_graph): Split iterator + into gimple_stmt_iterator and gimple_phi_iterator, converting local + from gimple to gimple_phi. + * gimple-ssa-strength-reduction.c + (find_candidates_dom_walker::before_dom_children): Likewise. + * ipa-inline-analysis.c (estimate_function_body_sizes): Likewise. + * ipa-split.c (verify_non_ssa_vars): Likewise. + (visit_bb): Likewise. + (split_function): Likewise. + * lto-streamer-out.c (output_function): Likewise. + * sese.c (sese_build_liveouts_bb): Likewise. + * tree-cfg.c (gimple_can_merge_blocks_p): Likewise. + * tree-complex.c (init_dont_simulate_again): Likewise. + * tree-dfa.c (collect_dfa_stats): Likewise. + * tree-eh.c (sink_clobbers): Likewise. + * tree-emutls.c (lower_emutls_function_body): Likewise. + * tree-into-ssa.c (rewrite_dom_walker::before_dom_children): + Likewise. + (rewrite_update_dom_walker::before_dom_children): Likewise. + (prepare_block_for_update): Likewise. + * tree-loop-distribution.c (stmts_from_loop): Likewise. + (generate_loops_for_partition): Likewise. + (destroy_loop): Likewise. + (tree_loop_distribution): Likewise. + * tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise. + * tree-ssa-copy.c (init_copy_prop): Likewise. + * tree-ssa-copyrename.c (rename_ssa_copies): Likewise. + * tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): Likewise. + * tree-ssa-loop-manip.c (find_uses_to_rename_bb): Likewise. + (verify_loop_closed_ssa): Likewise. + * tree-ssa-math-opts.c (execute_cse_reciprocals): Likewise. + * tree-ssa-pre.c (compute_avail): Likewise. + (eliminate_dom_walker::before_dom_children): Likewise. + * tree-ssa-strlen.c (strlen_dom_walker::before_dom_children): Likewise. + * tree-ssa-structalias.c (compute_points_to_sets): Likewise. + (ipa_pta_execute): Likewise. + * tree-ssa-tail-merge.c (same_succ_hash): Likewise. + (release_last_vdef): Likewise. + * tree-ssa.c (verify_ssa): Likewise. + (execute_update_addresses_taken): Likewise. + * tree-stdarg.c (check_all_va_list_escapes): Likewise. + (execute_optimize_stdarg): Likewise. + * tree-switch-conversion.c (build_arrays): Likewise. + * tree-vect-loop-manip.c (rename_variables_in_bb): Likewise. + * tree-vect-loop.c (vect_determine_vectorization_factor): Likewise. + (vect_analyze_loop_operations): Likewise. + (vect_transform_loop): Likewise. + * tree-vrp.c (find_assert_locations_1): Likewise. + (vrp_initialize): Likewise. + + * graphite-sese-to-poly.c (gsi_for_phi_node): Convert psi to a + gimple_phi_iterator. + (rewrite_degenerate_phi): Require a gimple_phi_iterator; strengthen + local "phi" from gimple to gimple-phi. + + * ipa-split.c (consider_split): Convert local psi to a + gimple_phi_iterator. + * tree-cfg.c (gimple_merge_blocks): Likewise. + + * tree-eh.c (unsplit_eh): Replace reuse of gsi with a new + gimple_phi_iterator gpi, using it to convert statement from gimple + to a gimple_phi. + (cleanup_empty_eh_merge_phis): Strengthen ophi from gimple to + gimple_phi. + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace reuse of + gsi with a new gimple_phi_iterator gpi, using it to convert + expressions from gimple to gimple_phi; add a checked cast to + gimple_phi. + + * tree-if-conv.c (predicate_all_scalar_phis): Convert local phi_gsi + to be a gimple_phi_iterator; convert "phi" to be a gimple_phi. + * tree-parloops.c (loop_has_vector_phi_nodes): Convert local to be a + gimple_phi_iterator. + * tree-ssa-ccp.c (ccp_initialize): Likewise. + + * tree-scalar-evolution.c (analyze_initial_condition): Add checked cast + to a gimple_phi. + * tree-ssa.c (insert_debug_temp_for_var_def): Likewise. + * tree-ssa-dom.c (get_rhs_or_phi_arg): Likewise. + +2014-10-24 David Malcolm <dmalc...@redhat.com> + Use gimple_call in some places within tree-ssa-dom.c * tree-ssa-dom.c (struct hashable_expr): Strengthen field diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 40e79b1..8246052 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -2472,14 +2472,13 @@ gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags) void gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) { - gimple_stmt_iterator gsi; - pp_printf (pp, "<bb %d>:\n", bb->index); pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true); - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (!virtual_operand_p (gimple_phi_result (phi)) || (dump_flags & TDF_VOPS)) { @@ -2492,7 +2491,8 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb) } } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); pp_bar (pp); diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 1b6138f..ea1f99a 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -742,7 +742,7 @@ add_cand_for_stmt (gimple gs, slsr_cand_t c) is used to help find a basis for subsequent candidates. */ static void -slsr_process_phi (gimple phi, bool speed) +slsr_process_phi (gimple_phi phi, bool speed) { unsigned i; tree arg0_base = NULL_TREE, base_type; @@ -1667,12 +1667,13 @@ void find_candidates_dom_walker::before_dom_children (basic_block bb) { bool speed = optimize_bb_for_speed_p (bb); - gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - slsr_process_phi (gsi_stmt (gsi), speed); + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + slsr_process_phi (gsi.phi (), speed); - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple gs = gsi_stmt (gsi); diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 5e0c507..c81e85f 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -1255,7 +1255,7 @@ limit_scops (vec<scop_p> *scops) argument. */ static inline bool -same_close_phi_node (gimple p1, gimple p2) +same_close_phi_node (gimple_phi p1, gimple_phi p2) { return operand_equal_p (gimple_phi_arg_def (p1, 0), gimple_phi_arg_def (p2, 0), 0); @@ -1265,15 +1265,15 @@ same_close_phi_node (gimple p1, gimple p2) of PHI. */ static void -remove_duplicate_close_phi (gimple phi, gimple_stmt_iterator *gsi) +remove_duplicate_close_phi (gimple_phi phi, gimple_phi_iterator *gsi) { gimple use_stmt; use_operand_p use_p; imm_use_iterator imm_iter; tree res = gimple_phi_result (phi); - tree def = gimple_phi_result (gsi_stmt (*gsi)); + tree def = gimple_phi_result (gsi->phi ()); - gcc_assert (same_close_phi_node (phi, gsi_stmt (*gsi))); + gcc_assert (same_close_phi_node (phi, gsi->phi ())); FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) { @@ -1298,12 +1298,12 @@ remove_duplicate_close_phi (gimple phi, gimple_stmt_iterator *gsi) static void make_close_phi_nodes_unique (basic_block bb) { - gimple_stmt_iterator psi; + gimple_phi_iterator psi; for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) { - gimple_stmt_iterator gsi = psi; - gimple phi = gsi_stmt (psi); + gimple_phi_iterator gsi = psi; + gimple_phi phi = psi.phi (); /* At this point, PHI should be a close phi in normal form. */ gcc_assert (gimple_phi_num_args (phi) == 1); @@ -1311,7 +1311,7 @@ make_close_phi_nodes_unique (basic_block bb) /* Iterate over the next phis and remove duplicates. */ gsi_next (&gsi); while (!gsi_end_p (gsi)) - if (same_close_phi_node (phi, gsi_stmt (gsi))) + if (same_close_phi_node (phi, gsi.phi ())) remove_duplicate_close_phi (phi, &gsi); else gsi_next (&gsi); diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 33a661d..e2ca6fc 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -1938,7 +1938,7 @@ gsi_for_phi_node (gimple_phi stmt) basic_block bb = gimple_bb (stmt); for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) - if (stmt == gsi_stmt (psi)) + if (stmt == psi.phi ()) return psi; gcc_unreachable (); @@ -2269,12 +2269,12 @@ rewrite_phi_out_of_ssa (scop_p scop, gimple_phi_iterator *psi) form "x = phi (y, y, ..., y)" to "x = y". */ static void -rewrite_degenerate_phi (gimple_stmt_iterator *psi) +rewrite_degenerate_phi (gimple_phi_iterator *psi) { tree rhs; gimple stmt; gimple_stmt_iterator gsi; - gimple phi = gsi_stmt (*psi); + gimple_phi phi = psi->phi (); tree res = gimple_phi_result (phi); basic_block bb; diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 1fb7ef3..8b22a43 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -2260,7 +2260,7 @@ phi_result_unknown_predicate (struct ipa_node_params *info, NONCONSTANT_NAMES, if possible. */ static void -predicate_for_phi_result (struct inline_summary *summary, gimple phi, +predicate_for_phi_result (struct inline_summary *summary, gimple_phi phi, struct predicate *p, vec<predicate_t> nonconstant_names) { @@ -2443,7 +2443,6 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) /* Benefits are scaled by probability of elimination that is in range <0,2>. */ basic_block bb; - gimple_stmt_iterator bsi; struct function *my_function = DECL_STRUCT_FUNCTION (node->decl); int freq; struct inline_summary *info = inline_summary (node); @@ -2524,7 +2523,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) struct predicate phi_predicate; bool first_phi = true; - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { if (first_phi && !phi_result_unknown_predicate (parms_info, info, bb, @@ -2537,14 +2537,15 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) fprintf (dump_file, " "); print_gimple_stmt (dump_file, gsi_stmt (bsi), 0, 0); } - predicate_for_phi_result (info, gsi_stmt (bsi), &phi_predicate, + predicate_for_phi_result (info, bsi.phi (), &phi_predicate, nonconstant_names); } } fix_builtin_expect_stmt = find_foldable_builtin_expect (bb); - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); int this_size = estimate_num_insns (stmt, &eni_size_weights); diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 08dbf7d..56bd9ca 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -229,8 +229,6 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars, while (!worklist.is_empty ()) { - gimple_stmt_iterator bsi; - bb = worklist.pop (); FOR_EACH_EDGE (e, ei, bb->preds) if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) @@ -240,7 +238,8 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars, e->src->index)); worklist.safe_push (e->src); } - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); if (is_gimple_debug (stmt)) @@ -260,7 +259,8 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars, goto done; } } - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { if (walk_stmt_load_store_addr_ops (gsi_stmt (bsi), non_ssa_vars, test_nonssa_use, test_nonssa_use, @@ -274,10 +274,11 @@ verify_non_ssa_vars (struct split_point *current, bitmap non_ssa_vars, { if (e->dest != return_bb) continue; - for (bsi = gsi_start_phis (return_bb); !gsi_end_p (bsi); + for (gimple_phi_iterator bsi = gsi_start_phis (return_bb); + !gsi_end_p (bsi); gsi_next (&bsi)) { - gimple stmt = gsi_stmt (bsi); + gimple_phi stmt = bsi.phi (); tree op = gimple_phi_arg_def (stmt, e->dest_idx); if (virtual_operand_p (gimple_phi_result (stmt))) @@ -622,15 +623,15 @@ consider_split (struct split_point *current, bitmap non_ssa_vars, for the return value. If there are other PHIs, give up. */ if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun)) { - gimple_stmt_iterator psi; + gimple_phi_iterator psi; for (psi = gsi_start_phis (return_bb); !gsi_end_p (psi); gsi_next (&psi)) - if (!virtual_operand_p (gimple_phi_result (gsi_stmt (psi))) + if (!virtual_operand_p (gimple_phi_result (psi.phi ())) && !(retval && current->split_part_set_retval && TREE_CODE (retval) == SSA_NAME && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl)) - && SSA_NAME_DEF_STMT (retval) == gsi_stmt (psi))) + && SSA_NAME_DEF_STMT (retval) == psi.phi ())) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, @@ -798,12 +799,12 @@ visit_bb (basic_block bb, basic_block return_bb, bitmap set_ssa_names, bitmap used_ssa_names, bitmap non_ssa_vars) { - gimple_stmt_iterator bsi; edge e; edge_iterator ei; bool can_split = true; - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); tree op; @@ -872,9 +873,10 @@ visit_bb (basic_block bb, basic_block return_bb, mark_nonssa_use, mark_nonssa_use); } - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { - gimple stmt = gsi_stmt (bsi); + gimple_phi stmt = bsi.phi (); unsigned int i; if (virtual_operand_p (gimple_phi_result (stmt))) @@ -896,9 +898,11 @@ visit_bb (basic_block bb, basic_block return_bb, FOR_EACH_EDGE (e, ei, bb->succs) if (e->dest == return_bb) { - for (bsi = gsi_start_phis (return_bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (return_bb); + !gsi_end_p (bsi); + gsi_next (&bsi)) { - gimple stmt = gsi_stmt (bsi); + gimple_phi stmt = bsi.phi (); tree op = gimple_phi_arg_def (stmt, e->dest_idx); if (virtual_operand_p (gimple_phi_result (stmt))) @@ -1122,7 +1126,6 @@ split_function (struct split_point *split_point) cgraph_node *node, *cur_node = cgraph_node::get (current_function_decl); basic_block return_bb = find_return_bb (); basic_block call_bb; - gimple_stmt_iterator gsi; gimple_call call; edge e; edge_iterator ei; @@ -1225,9 +1228,10 @@ split_function (struct split_point *split_point) if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun)) { bool phi_p = false; - for (gsi = gsi_start_phis (return_bb); !gsi_end_p (gsi);) + for (gimple_phi_iterator gsi = gsi_start_phis (return_bb); + !gsi_end_p (gsi);) { - gimple stmt = gsi_stmt (gsi); + gimple_phi stmt = gsi.phi (); if (!virtual_operand_p (gimple_phi_result (stmt))) { gsi_next (&gsi); @@ -1246,7 +1250,9 @@ split_function (struct split_point *split_point) entry of the SESE region as the vuse of the call and the reaching vdef of the exit of the SESE region as the vdef of the call. */ if (!phi_p) - for (gsi = gsi_start_bb (return_bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (return_bb); + !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); if (gimple_vuse (stmt)) @@ -1289,7 +1295,7 @@ split_function (struct split_point *split_point) /* Create the basic block we place call into. It is the entry basic block split after last label. */ call_bb = split_point->entry_bb; - for (gsi = gsi_start_bb (call_bb); !gsi_end_p (gsi);) + for (gimple_stmt_iterator gsi = gsi_start_bb (call_bb); !gsi_end_p (gsi);) if (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL) { last_stmt = gsi_stmt (gsi); @@ -1301,7 +1307,7 @@ split_function (struct split_point *split_point) remove_edge (e); /* Produce the call statement. */ - gsi = gsi_last_bb (call_bb); + gimple_stmt_iterator gsi = gsi_last_bb (call_bb); FOR_EACH_VEC_ELT (args_to_pass, i, arg) if (!is_gimple_val (arg)) { diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index dad751b..0eb3f3c 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -2013,16 +2013,17 @@ output_function (struct cgraph_node *node) set_gimple_stmt_max_uid (cfun, 0); FOR_ALL_BB_FN (bb, cfun) { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple stmt = gsi_stmt (gsi); + gimple_phi stmt = gsi.phi (); /* Virtual PHIs are not going to be streamed. */ if (!virtual_operand_p (gimple_phi_result (stmt))) gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); @@ -2032,10 +2033,10 @@ output_function (struct cgraph_node *node) virtual phis now. */ FOR_ALL_BB_FN (bb, cfun) { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple stmt = gsi_stmt (gsi); + gimple_phi stmt = gsi.phi (); if (virtual_operand_p (gimple_phi_result (stmt))) gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } diff --git a/gcc/sese.c b/gcc/sese.c index 5445dc0..dc3dc47 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -175,18 +175,19 @@ sese_build_liveouts_use (sese region, bitmap liveouts, basic_block bb, static void sese_build_liveouts_bb (sese region, bitmap liveouts, basic_block bb) { - gimple_stmt_iterator bsi; edge e; edge_iterator ei; ssa_op_iter iter; use_operand_p use_p; FOR_EACH_EDGE (e, ei, bb->succs) - for (bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); + gsi_next (&bsi)) sese_build_liveouts_use (region, liveouts, bb, - PHI_ARG_DEF_FROM_EDGE (gsi_stmt (bsi), e)); + PHI_ARG_DEF_FROM_EDGE (bsi.phi (), e)); - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index ad530f3..97d5ffd 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1643,7 +1643,6 @@ static bool gimple_can_merge_blocks_p (basic_block a, basic_block b) { gimple stmt; - gimple_stmt_iterator gsi; if (!single_succ_p (a)) return false; @@ -1673,7 +1672,8 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b) return false; /* Examine the labels at the beginning of B. */ - for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (b); !gsi_end_p (gsi); + gsi_next (&gsi)) { tree lab; gimple_label label_stmt = dyn_cast <gimple_label> (gsi_stmt (gsi)); @@ -1693,9 +1693,10 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b) /* It must be possible to eliminate all phi nodes in B. If ssa form is not up-to-date and a name-mapping is registered, we cannot eliminate any phis. Symbols marked for renaming are never a problem though. */ - for (gsi = gsi_start_phis (b); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); /* Technically only new names matter. */ if (name_registered_for_update_p (PHI_RESULT (phi))) return false; @@ -1807,7 +1808,8 @@ replace_uses_by (tree name, tree val) static void gimple_merge_blocks (basic_block a, basic_block b) { - gimple_stmt_iterator last, gsi, psi; + gimple_stmt_iterator last, gsi; + gimple_phi_iterator psi; if (dump_file) fprintf (dump_file, "Merging blocks %d and %d\n", a->index, b->index); diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 6f6fef5..e155d11 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -201,20 +201,20 @@ static bool init_dont_simulate_again (void) { basic_block bb; - gimple_stmt_iterator gsi; - gimple phi; bool saw_a_complex_op = false; FOR_EACH_BB_FN (bb, cfun) { - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); prop_set_simulate_again (phi, is_complex_reg (gimple_phi_result (phi))); } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt; tree op0, op1; diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 9e39028..22f486c 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -282,18 +282,18 @@ collect_dfa_stats (struct dfa_stats_d *dfa_stats_p ATTRIBUTE_UNUSED) /* Walk all the statements in the function counting references. */ FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator si; - - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - gimple phi = gsi_stmt (si); + gimple_phi phi = si.phi (); dfa_stats_p->num_phis++; dfa_stats_p->num_phi_args += gimple_phi_num_args (phi); if (gimple_phi_num_args (phi) > dfa_stats_p->max_num_phi_args) dfa_stats_p->max_num_phi_args = gimple_phi_num_args (phi); } - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt = gsi_stmt (si); dfa_stats_p->num_defs += NUM_SSA_OPERANDS (stmt, SSA_OP_DEF); diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index cd84756..ed087a1 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -3469,14 +3469,15 @@ sink_clobbers (basic_block bb) /* See if there is a virtual PHI node to take an updated virtual operand from. */ - gimple vphi = NULL; + gimple_phi vphi = NULL; tree vuse = NULL_TREE; - for (gsi = gsi_start_phis (succbb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gpi = gsi_start_phis (succbb); + !gsi_end_p (gpi); gsi_next (&gpi)) { - tree res = gimple_phi_result (gsi_stmt (gsi)); + tree res = gimple_phi_result (gpi.phi ()); if (virtual_operand_p (res)) { - vphi = gsi_stmt (gsi); + vphi = gpi.phi (); vuse = res; break; } @@ -4031,9 +4032,10 @@ unsplit_eh (eh_landing_pad lp) that doesn't appear to handle virtuals. Propagate by hand. */ if (!gimple_seq_empty_p (phi_nodes (bb))) { - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); ) + for (gimple_phi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); ) { - gimple use_stmt, phi = gsi_stmt (gsi); + gimple use_stmt; + gimple_phi phi = gpi.phi (); tree lhs = gimple_phi_result (phi); tree rhs = gimple_phi_arg_def (phi, 0); use_operand_p use_p; @@ -4048,7 +4050,7 @@ unsplit_eh (eh_landing_pad lp) if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs) = 1; - remove_phi_node (&gsi, true); + remove_phi_node (&gpi, true); } } @@ -4191,7 +4193,7 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb, we don't know what values from the other edges into NEW_BB to use. */ for (ogsi = gsi_start_phis (old_bb); !gsi_end_p (ogsi); gsi_next (&ogsi)) { - gimple ophi = gsi_stmt (ogsi); + gimple_phi ophi = ogsi.phi (); tree oresult = gimple_phi_result (ophi); if (!bitmap_bit_p (ophi_handled, SSA_NAME_VERSION (oresult))) goto fail; diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c index 8d62dba..94efc6f 100644 --- a/gcc/tree-emutls.c +++ b/gcc/tree-emutls.c @@ -556,7 +556,8 @@ lower_emutls_stmt (gimple stmt, struct lower_emutls_data *d) /* Lower the I'th operand of PHI. */ static void -lower_emutls_phi_arg (gimple phi, unsigned int i, struct lower_emutls_data *d) +lower_emutls_phi_arg (gimple_phi phi, unsigned int i, + struct lower_emutls_data *d) { struct walk_stmt_info wi; struct phi_arg_d *pd = gimple_phi_arg (phi, i); @@ -617,7 +618,6 @@ lower_emutls_function_body (struct cgraph_node *node) FOR_EACH_BB_FN (d.bb, cfun) { - gimple_stmt_iterator gsi; unsigned int i, nedge; /* Lower each of the PHI nodes of the block, as we may have @@ -639,10 +639,10 @@ lower_emutls_function_body (struct cgraph_node *node) clear_access_vars (); d.seq = NULL; - for (gsi = gsi_start_phis (d.bb); + for (gimple_phi_iterator gsi = gsi_start_phis (d.bb); !gsi_end_p (gsi); gsi_next (&gsi)) - lower_emutls_phi_arg (gsi_stmt (gsi), i, &d); + lower_emutls_phi_arg (gsi.phi (), i, &d); /* Insert all statements generated by all phi nodes for this particular edge all at once. */ @@ -660,7 +660,8 @@ lower_emutls_function_body (struct cgraph_node *node) clear_access_vars (); /* Lower each of the statements of the block. */ - for (gsi = gsi_start_bb (d.bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (d.bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { d.seq = NULL; lower_emutls_stmt (gsi_stmt (gsi), &d); diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index f7f27da..61bc882 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1561,7 +1561,7 @@ convert_scalar_cond_reduction (gimple reduc, gimple_stmt_iterator *gsi, TRUE_BB is selected. */ static void -predicate_scalar_phi (gimple phi, tree cond, +predicate_scalar_phi (gimple_phi phi, tree cond, basic_block true_bb, gimple_stmt_iterator *gsi) { @@ -1636,9 +1636,10 @@ predicate_all_scalar_phis (struct loop *loop) for (i = 1; i < orig_loop_num_nodes; i++) { - gimple phi; + gimple_phi phi; tree cond = NULL_TREE; - gimple_stmt_iterator gsi, phi_gsi; + gimple_stmt_iterator gsi; + gimple_phi_iterator phi_gsi; basic_block true_bb = NULL; bb = ifc_bbs[i]; @@ -1656,7 +1657,7 @@ predicate_all_scalar_phis (struct loop *loop) while (!gsi_end_p (phi_gsi)) { - phi = gsi_stmt (phi_gsi); + phi = phi_gsi.phi (); predicate_scalar_phi (phi, cond, true_bb, &gsi); release_phi_node (phi); gsi_next (&phi_gsi); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index b4e0e4b..9733217 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1434,8 +1434,6 @@ public: void rewrite_dom_walker::before_dom_children (basic_block bb) { - gimple_stmt_iterator gsi; - if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index); @@ -1445,7 +1443,8 @@ rewrite_dom_walker::before_dom_children (basic_block bb) /* Step 1. Register new definitions for every PHI node in the block. Conceptually, all the PHI nodes are executed in parallel and each PHI node introduces a new version for the associated variable. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { tree result = gimple_phi_result (gsi_stmt (gsi)); register_new_def (result, SSA_NAME_VAR (result)); @@ -1455,7 +1454,8 @@ rewrite_dom_walker::before_dom_children (basic_block bb) with its immediate reaching definitions. Update the current definition of a variable when a new real or virtual definition is found. */ if (bitmap_bit_p (interesting_blocks, bb->index)) - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) rewrite_stmt (&gsi); /* Step 3. Visit all the successor blocks of BB looking for PHI nodes. @@ -2084,7 +2084,6 @@ void rewrite_update_dom_walker::before_dom_children (basic_block bb) { bool is_abnormal_phi; - gimple_stmt_iterator gsi; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Registering new PHI nodes in block #%d\n", @@ -2105,10 +2104,11 @@ rewrite_update_dom_walker::before_dom_children (basic_block bb) register it as a new definition for its corresponding name. Also register definitions for names whose underlying symbols are marked for renaming. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { tree lhs, lhs_sym; - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (!register_defs_p (phi)) continue; @@ -2140,7 +2140,8 @@ rewrite_update_dom_walker::before_dom_children (basic_block bb) if (bitmap_bit_p (interesting_blocks, bb->index)) { gcc_checking_assert (bitmap_bit_p (blocks_to_update, bb->index)); - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) rewrite_update_stmt (gsi_stmt (gsi), gsi); } @@ -2495,7 +2496,6 @@ static void prepare_block_for_update (basic_block bb, bool insert_phi_p) { basic_block son; - gimple_stmt_iterator si; edge e; edge_iterator ei; @@ -2503,9 +2503,10 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p) /* Process PHI nodes marking interesting those that define or use the symbols that we are interested in. */ - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - gimple phi = gsi_stmt (si); + gimple_phi phi = si.phi (); tree lhs_sym, lhs = gimple_phi_result (phi); if (TREE_CODE (lhs) == SSA_NAME @@ -2529,7 +2530,8 @@ prepare_block_for_update (basic_block bb, bool insert_phi_p) } /* Process the statements. */ - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt; ssa_op_iter i; @@ -2908,7 +2910,7 @@ mark_virtual_operand_for_renaming (tree name) removed. */ void -mark_virtual_phi_result_for_renaming (gimple phi) +mark_virtual_phi_result_for_renaming (gimple_phi phi) { if (dump_file && (dump_flags & TDF_DETAILS)) { diff --git a/gcc/tree-into-ssa.h b/gcc/tree-into-ssa.h index 977f6e7..8d82074 100644 --- a/gcc/tree-into-ssa.h +++ b/gcc/tree-into-ssa.h @@ -26,7 +26,7 @@ void delete_update_ssa (void); tree create_new_def_for (tree, gimple, def_operand_p); void mark_virtual_operands_for_renaming (struct function *); void mark_virtual_operand_for_renaming (tree); -void mark_virtual_phi_result_for_renaming (gimple); +void mark_virtual_phi_result_for_renaming (gimple_phi); bool need_ssa_update_p (struct function *); bool name_registered_for_update_p (tree); void release_ssa_name_after_update_ssa (tree); diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index a6cd30f..4bb9b0c 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -393,16 +393,16 @@ stmts_from_loop (struct loop *loop, vec<gimple> *stmts) for (i = 0; i < loop->num_nodes; i++) { basic_block bb = bbs[i]; - gimple_stmt_iterator bsi; - gimple stmt; - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) - if (!virtual_operand_p (gimple_phi_result (gsi_stmt (bsi)))) - stmts->safe_push (gsi_stmt (bsi)); + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) + if (!virtual_operand_p (gimple_phi_result (bsi.phi ()))) + stmts->safe_push (bsi.phi ()); - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { - stmt = gsi_stmt (bsi); + gimple stmt = gsi_stmt (bsi); if (gimple_code (stmt) != GIMPLE_LABEL && !is_gimple_debug (stmt)) stmts->safe_push (stmt); } @@ -620,7 +620,6 @@ generate_loops_for_partition (struct loop *loop, partition_t partition, bool copy_p) { unsigned i; - gimple_stmt_iterator bsi; basic_block *bbs; if (copy_p) @@ -639,15 +638,16 @@ generate_loops_for_partition (struct loop *loop, partition_t partition, { basic_block bb = bbs[i]; - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { - gimple phi = gsi_stmt (bsi); + gimple_phi phi = bsi.phi (); if (!virtual_operand_p (gimple_phi_result (phi)) && !bitmap_bit_p (partition->stmts, gimple_uid (phi))) reset_debug_uses (phi); } - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); if (gimple_code (stmt) != GIMPLE_LABEL @@ -661,9 +661,9 @@ generate_loops_for_partition (struct loop *loop, partition_t partition, { basic_block bb = bbs[i]; - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi);) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi);) { - gimple phi = gsi_stmt (bsi); + gimple_phi phi = bsi.phi (); if (!virtual_operand_p (gimple_phi_result (phi)) && !bitmap_bit_p (partition->stmts, gimple_uid (phi))) remove_phi_node (&bsi, true); @@ -671,7 +671,7 @@ generate_loops_for_partition (struct loop *loop, partition_t partition, gsi_next (&bsi); } - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi);) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi);) { gimple stmt = gsi_stmt (bsi); if (gimple_code (stmt) != GIMPLE_LABEL @@ -902,14 +902,15 @@ destroy_loop (struct loop *loop) Make sure we replace all uses of virtual defs that will remain outside of the loop with the bare symbol as delete_basic_block will release them. */ - gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (virtual_operand_p (gimple_phi_result (phi))) mark_virtual_phi_result_for_renaming (phi); } - for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); tree vdef = gimple_vdef (stmt); @@ -1742,10 +1743,11 @@ pass_loop_distribution::execute (function *fun) bbs = get_loop_body_in_dom_order (loop); for (i = 0; i < loop->num_nodes; ++i) { - gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bbs[i]); + !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (virtual_operand_p (gimple_phi_result (phi))) continue; /* Distribute stmts which have defs that are used outside of @@ -1754,7 +1756,9 @@ pass_loop_distribution::execute (function *fun) continue; work_list.safe_push (phi); } - for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); + !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index ac37b0f..d7159cf 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1926,12 +1926,12 @@ loop_has_vector_phi_nodes (struct loop *loop ATTRIBUTE_UNUSED) { unsigned i; basic_block *bbs = get_loop_body_in_dom_order (loop); - gimple_stmt_iterator gsi; + gimple_phi_iterator gsi; bool res = true; for (i = 0; i < loop->num_nodes; i++) for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) - if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi_stmt (gsi)))) == VECTOR_TYPE) + if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi.phi ()))) == VECTOR_TYPE) goto end; res = false; diff --git a/gcc/tree-phinodes.c b/gcc/tree-phinodes.c index 4f86090..0213ecd 100644 --- a/gcc/tree-phinodes.c +++ b/gcc/tree-phinodes.c @@ -478,7 +478,7 @@ remove_phi_nodes (basic_block bb) NULL. */ tree -degenerate_phi_result (gimple phi) +degenerate_phi_result (gimple_phi phi) { tree lhs = gimple_phi_result (phi); tree val = NULL; diff --git a/gcc/tree-phinodes.h b/gcc/tree-phinodes.h index dcde99e..0ff7fda 100644 --- a/gcc/tree-phinodes.h +++ b/gcc/tree-phinodes.h @@ -29,7 +29,7 @@ extern void add_phi_arg (gimple_phi, tree, edge, source_location); extern void remove_phi_args (edge); extern void remove_phi_node (gimple_stmt_iterator *, bool); extern void remove_phi_nodes (basic_block); -extern tree degenerate_phi_result (gimple); +extern tree degenerate_phi_result (gimple_phi); extern void set_phi_nodes (basic_block, gimple_seq); static inline use_operand_p diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index bb67cc7..19b63f5 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1596,13 +1596,15 @@ analyze_initial_condition (gimple_phi loop_phi_node) if (TREE_CODE (init_cond) == SSA_NAME) { gimple def = SSA_NAME_DEF_STMT (init_cond); - tree res; - if (gimple_code (def) == GIMPLE_PHI - && (res = degenerate_phi_result (def)) != NULL_TREE - /* Only allow invariants here, otherwise we may break - loop-closed SSA form. */ - && is_gimple_min_invariant (res)) - init_cond = res; + if (gimple_phi phi = dyn_cast <gimple_phi> (def)) + { + tree res = degenerate_phi_result (phi); + if (res != NULL_TREE + /* Only allow invariants here, otherwise we may break + loop-closed SSA form. */ + && is_gimple_min_invariant (res)) + init_cond = res; + } } if (dump_file && (dump_flags & TDF_SCEV)) diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 33fa392..114a063 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -829,11 +829,11 @@ ccp_initialize (void) except for phi nodes for virtual operands when we do not do store ccp. */ FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator i; + gimple_phi_iterator i; for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) { - gimple phi = gsi_stmt (i); + gimple_phi phi = i.phi (); if (virtual_operand_p (gimple_phi_result (phi))) prop_set_simulate_again (phi, false); diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index a21cea6..bf75455 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -824,12 +824,11 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator gsi; - /* Start with live on exit temporaries. */ live_track_init (live, live_on_exit (liveinfo, bb)); - for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) + for (gimple_stmt_iterator gsi = gsi_last_bb (bb); !gsi_end_p (gsi); + gsi_prev (&gsi)) { tree var; gimple stmt = gsi_stmt (gsi); @@ -866,9 +865,10 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) There must be a conflict recorded between the result of the PHI and any variables that are live. Otherwise the out-of-ssa translation may create incorrect code. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree result = PHI_RESULT (phi); if (live_track_live_p (live, result)) live_track_process_def (live, result, graph); diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index f7e8566..9864aee 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -452,9 +452,8 @@ init_copy_prop (void) FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator si; - - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt = gsi_stmt (si); ssa_op_iter iter; @@ -478,9 +477,10 @@ init_copy_prop (void) set_copy_of_val (def, def); } - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - gimple phi = gsi_stmt (si); + gimple_phi phi = si.phi (); tree def; def = gimple_phi_result (phi); diff --git a/gcc/tree-ssa-copyrename.c b/gcc/tree-ssa-copyrename.c index 4412381..37a47cd 100644 --- a/gcc/tree-ssa-copyrename.c +++ b/gcc/tree-ssa-copyrename.c @@ -339,9 +339,8 @@ pass_rename_ssa_copies::execute (function *fun) { var_map map; basic_block bb; - gimple_stmt_iterator gsi; tree var, part_var; - gimple stmt, phi; + gimple stmt; unsigned x; FILE *debug; @@ -357,7 +356,8 @@ pass_rename_ssa_copies::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { /* Scan for real copies. */ - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { stmt = gsi_stmt (gsi); if (gimple_assign_ssa_name_copy_p (stmt)) @@ -373,12 +373,12 @@ pass_rename_ssa_copies::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { /* Treat PHI nodes as copies between the result and each argument. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { size_t i; tree res; - - phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); res = gimple_phi_result (phi); /* Do not process virtual SSA_NAMES. */ diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index aba2d98..3b7b39d 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1278,13 +1278,15 @@ eliminate_unnecessary_stmts (void) if (!bitmap_bit_p (bb_contains_live_stmts, bb->index) || !(bb->flags & BB_REACHABLE)) { - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - if (virtual_operand_p (gimple_phi_result (gsi_stmt (gsi)))) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + if (virtual_operand_p (gimple_phi_result (gsi.phi ()))) { bool found = false; imm_use_iterator iter; - FOR_EACH_IMM_USE_STMT (stmt, iter, gimple_phi_result (gsi_stmt (gsi))) + FOR_EACH_IMM_USE_STMT (stmt, iter, + gimple_phi_result (gsi.phi ())) { if (!(gimple_bb (stmt)->flags & BB_REACHABLE)) continue; @@ -1296,7 +1298,7 @@ eliminate_unnecessary_stmts (void) } } if (found) - mark_virtual_phi_result_for_renaming (gsi_stmt (gsi)); + mark_virtual_phi_result_for_renaming (gsi.phi ()); } if (!(bb->flags & BB_REACHABLE)) diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index a49601c..2edee91 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -2645,7 +2645,7 @@ static tree get_rhs_or_phi_arg (gimple stmt) { if (gimple_code (stmt) == GIMPLE_PHI) - return degenerate_phi_result (stmt); + return degenerate_phi_result (as_a <gimple_phi> (stmt)); else if (gimple_assign_single_p (stmt)) return gimple_assign_rhs1 (stmt); else diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index a07d3a1..82009f1 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -1069,12 +1069,10 @@ propagate_into_all_uses (tree ssa_name, tree val) static void propagate_constants_for_unrolling (basic_block bb) { - gimple_stmt_iterator gsi; - /* Look for degenerate PHI nodes with constant argument. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); ) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); ) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree result = gimple_phi_result (phi); tree arg = gimple_phi_arg_def (phi, 0); @@ -1089,7 +1087,7 @@ propagate_constants_for_unrolling (basic_block bb) } /* Look for assignments to SSA names with constant RHS. */ - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) { gimple stmt = gsi_stmt (gsi); tree lhs; diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index bb3da81..65157d7 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -431,20 +431,21 @@ find_uses_to_rename_stmt (gimple stmt, bitmap *use_blocks, bitmap need_phis) static void find_uses_to_rename_bb (basic_block bb, bitmap *use_blocks, bitmap need_phis) { - gimple_stmt_iterator bsi; edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) - for (bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (e->dest); !gsi_end_p (bsi); + gsi_next (&bsi)) { - gimple phi = gsi_stmt (bsi); + gimple_phi phi = bsi.phi (); if (! virtual_operand_p (gimple_phi_result (phi))) find_uses_to_rename_use (bb, PHI_ARG_DEF_FROM_EDGE (phi, e), use_blocks, need_phis); } - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) find_uses_to_rename_stmt (gsi_stmt (bsi), use_blocks, need_phis); } @@ -590,8 +591,6 @@ DEBUG_FUNCTION void verify_loop_closed_ssa (bool verify_ssa_p) { basic_block bb; - gimple_stmt_iterator bsi; - gimple phi; edge e; edge_iterator ei; @@ -605,15 +604,17 @@ verify_loop_closed_ssa (bool verify_ssa_p) FOR_EACH_BB_FN (bb, cfun) { - for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_phi_iterator bsi = gsi_start_phis (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) { - phi = gsi_stmt (bsi); + gimple_phi phi = bsi.phi (); FOR_EACH_EDGE (e, ei, bb->preds) check_loop_closed_ssa_use (e->src, PHI_ARG_DEF_FROM_EDGE (phi, e)); } - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + for (gimple_stmt_iterator bsi = gsi_start_bb (bb); !gsi_end_p (bsi); + gsi_next (&bsi)) check_loop_closed_ssa_stmt (bb, gsi_stmt (bsi)); } diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 1010ff0..8dca2af 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -566,20 +566,20 @@ pass_cse_reciprocals::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { - gimple_stmt_iterator gsi; - gimple phi; tree def; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); def = PHI_RESULT (phi); if (! virtual_operand_p (def) && FLOAT_TYPE_P (TREE_TYPE (def))) execute_cse_reciprocals_1 (NULL, def); } - for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_after_labels (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); @@ -594,7 +594,8 @@ pass_cse_reciprocals::execute (function *fun) continue; /* Scan for a/func(b) and convert it to reciprocal a*rfunc(b). */ - for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_after_labels (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); tree fndecl; diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index c5e1f85..96f2bea 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3614,7 +3614,6 @@ compute_avail (void) /* Loop until the worklist is empty. */ while (sp) { - gimple_stmt_iterator gsi; gimple stmt; basic_block dom; @@ -3631,9 +3630,10 @@ compute_avail (void) } /* Generate values for PHI nodes. */ - for (gsi = gsi_start_phis (block); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (block); !gsi_end_p (gsi); + gsi_next (&gsi)) { - tree result = gimple_phi_result (gsi_stmt (gsi)); + tree result = gimple_phi_result (gsi.phi ()); /* We have no need for virtual phis, as they don't represent actual computations. */ @@ -3653,7 +3653,8 @@ compute_avail (void) /* Now compute value numbers and populate value sets with all the expressions computed in BLOCK. */ - for (gsi = gsi_start_bb (block); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (block); !gsi_end_p (gsi); + gsi_next (&gsi)) { ssa_op_iter iter; tree op; @@ -3949,9 +3950,6 @@ public: void eliminate_dom_walker::before_dom_children (basic_block b) { - gimple_stmt_iterator gsi; - gimple stmt; - /* Mark new bb. */ el_avail_stack.safe_push (NULL_TREE); @@ -3959,9 +3957,9 @@ eliminate_dom_walker::before_dom_children (basic_block b) tailmerging. Eventually we can reduce its reliance on SCCVN now that we fully copy/constant-propagate (most) things. */ - for (gsi = gsi_start_phis (b); !gsi_end_p (gsi);) + for (gimple_phi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi);) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree res = PHI_RESULT (phi); if (virtual_operand_p (res)) @@ -4022,10 +4020,12 @@ eliminate_dom_walker::before_dom_children (basic_block b) gsi_next (&gsi); } - for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (b); + !gsi_end_p (gsi); + gsi_next (&gsi)) { tree sprime = NULL_TREE; - stmt = gsi_stmt (gsi); + gimple stmt = gsi_stmt (gsi); tree lhs = gimple_get_lhs (stmt); if (lhs && TREE_CODE (lhs) == SSA_NAME && !gimple_has_volatile_ops (stmt) @@ -4412,9 +4412,11 @@ eliminate_dom_walker::before_dom_children (basic_block b) edge e; FOR_EACH_EDGE (e, ei, b->succs) { - for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (e->dest); + !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, e); tree arg = USE_FROM_PTR (use_p); if (TREE_CODE (arg) != SSA_NAME diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index bb42cc7..e29efcb 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2025,7 +2025,6 @@ public: void strlen_dom_walker::before_dom_children (basic_block bb) { - gimple_stmt_iterator gsi; basic_block dombb = get_immediate_dominator (CDI_DOMINATORS, bb); if (dombb == NULL) @@ -2035,9 +2034,10 @@ strlen_dom_walker::before_dom_children (basic_block bb) stridx_to_strinfo = ((vec<strinfo, va_heap, vl_embed> *) dombb->aux); if (stridx_to_strinfo) { - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (virtual_operand_p (gimple_phi_result (phi))) { bitmap visited = BITMAP_ALLOC (NULL); @@ -2074,9 +2074,10 @@ strlen_dom_walker::before_dom_children (basic_block bb) /* If all PHI arguments have the same string index, the PHI result has it as well. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree result = gimple_phi_result (phi); if (!virtual_operand_p (result) && POINTER_TYPE_P (TREE_TYPE (result))) { @@ -2094,7 +2095,7 @@ strlen_dom_walker::before_dom_children (basic_block bb) } /* Attempt to optimize individual statements. */ - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) if (strlen_optimize_stmt (&gsi)) gsi_next (&gsi); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 550bfb4..193607d 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -6776,17 +6776,17 @@ compute_points_to_sets (void) /* Now walk all statements and build the constraint set. */ FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator gsi; - - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (! virtual_operand_p (gimple_phi_result (phi))) find_func_aliases (cfun, phi); } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); @@ -7166,18 +7166,17 @@ ipa_pta_execute (void) /* Build constriants for the function body. */ FOR_EACH_BB_FN (bb, func) { - gimple_stmt_iterator gsi; - - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (! virtual_operand_p (gimple_phi_result (phi))) find_func_aliases (func, phi); } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index a98fc90..e7a865a 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -457,13 +457,12 @@ same_succ_hash (const_same_succ e) unsigned int first = bitmap_first_set_bit (e->bbs); basic_block bb = BASIC_BLOCK_FOR_FN (cfun, first); int size = 0; - gimple_stmt_iterator gsi; gimple stmt; tree arg; unsigned int s; bitmap_iterator bs; - for (gsi = gsi_start_nondebug_bb (bb); + for (gimple_stmt_iterator gsi = gsi_start_nondebug_bb (bb); !gsi_end_p (gsi); gsi_next_nondebug (&gsi)) { stmt = gsi_stmt (gsi); @@ -506,10 +505,12 @@ same_succ_hash (const_same_succ e) EXECUTE_IF_SET_IN_BITMAP (e->succs, 0, s, bs) { int n = find_edge (bb, BASIC_BLOCK_FOR_FN (cfun, s))->dest_idx; - for (gsi = gsi_start_phis (BASIC_BLOCK_FOR_FN (cfun, s)); !gsi_end_p (gsi); + for (gimple_phi_iterator gsi = + gsi_start_phis (BASIC_BLOCK_FOR_FN (cfun, s)); + !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); tree lhs = gimple_phi_result (phi); tree val = gimple_phi_arg_def (phi, n); @@ -846,9 +847,8 @@ same_succ_flush_bbs (bitmap bbs) static void release_last_vdef (basic_block bb) { - gimple_stmt_iterator i; - - for (i = gsi_last_bb (bb); !gsi_end_p (i); gsi_prev_nondebug (&i)) + for (gimple_stmt_iterator i = gsi_last_bb (bb); !gsi_end_p (i); + gsi_prev_nondebug (&i)) { gimple stmt = gsi_stmt (i); if (gimple_vdef (stmt) == NULL_TREE) @@ -858,9 +858,10 @@ release_last_vdef (basic_block bb) return; } - 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)) diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index a85dff9..9721413 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -358,7 +358,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) we'll have to drop debug information. */ if (gimple_code (def_stmt) == GIMPLE_PHI) { - value = degenerate_phi_result (def_stmt); + value = degenerate_phi_result (as_a <gimple_phi> (def_stmt)); if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL)) value = NULL; /* error_mark_node is what fixup_noreturn_call changes PHI arguments @@ -830,7 +830,7 @@ verify_use (basic_block bb, basic_block def_bb, use_operand_p use_p, definition of SSA_NAME. */ static bool -verify_phi_args (gimple phi, basic_block bb, basic_block *definition_block) +verify_phi_args (gimple_phi phi, basic_block bb, basic_block *definition_block) { edge e; bool err = false; @@ -961,9 +961,7 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) FOR_EACH_BB_FN (bb, cfun) { edge e; - gimple phi; edge_iterator ei; - gimple_stmt_iterator gsi; /* Make sure that all edges have a clear 'aux' field. */ FOR_EACH_EDGE (e, ei, bb->preds) @@ -977,9 +975,9 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) } /* Verify the arguments for every PHI node in the block. */ - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); if (verify_phi_args (phi, bb, definition_block)) goto err; @@ -988,7 +986,8 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) } /* Now verify all the uses and vuses in every statement of the block. */ - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); use_operand_p use_p; @@ -1397,7 +1396,6 @@ maybe_optimize_var (tree var, bitmap addresses_taken, bitmap not_reg_needs, void execute_update_addresses_taken (void) { - gimple_stmt_iterator gsi; basic_block bb; bitmap addresses_taken = BITMAP_ALLOC (NULL); bitmap not_reg_needs = BITMAP_ALLOC (NULL); @@ -1411,7 +1409,8 @@ execute_update_addresses_taken (void) the function body. */ FOR_EACH_BB_FN (bb, cfun) { - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); enum gimple_code code = gimple_code (stmt); @@ -1481,10 +1480,11 @@ execute_update_addresses_taken (void) } } - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { size_t i; - gimple phi = gsi_stmt (gsi); + gimple_phi phi = gsi.phi (); for (i = 0; i < gimple_phi_num_args (phi); i++) { @@ -1513,7 +1513,7 @@ execute_update_addresses_taken (void) if (!bitmap_empty_p (suitable_for_renaming)) { FOR_EACH_BB_FN (bb, cfun) - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) { gimple stmt = gsi_stmt (gsi); diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index a9d0a48..973e866 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -538,14 +538,13 @@ check_all_va_list_escapes (struct stdarg_info *si) FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator i; - - 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)) { tree lhs; use_operand_p uop; ssa_op_iter soi; - gimple phi = gsi_stmt (i); + gimple_phi phi = i.phi (); lhs = PHI_RESULT (phi); if (virtual_operand_p (lhs) @@ -571,7 +570,8 @@ check_all_va_list_escapes (struct stdarg_info *si) } } - 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)) { gimple stmt = gsi_stmt (i); tree use; @@ -835,8 +835,6 @@ pass_stdarg::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { - gimple_stmt_iterator i; - si.compute_sizes = -1; si.bb = bb; @@ -850,9 +848,10 @@ pass_stdarg::execute (function *fun) use_operand_p uop; ssa_op_iter soi; - 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 (); lhs = PHI_RESULT (phi); if (virtual_operand_p (lhs)) @@ -882,7 +881,7 @@ pass_stdarg::execute (function *fun) } } - for (i = gsi_start_bb (bb); + for (gimple_stmt_iterator i = gsi_start_bb (bb); !gsi_end_p (i) && !va_list_escapes; gsi_next (&i)) { diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 692b0d1..dc84ef2 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -1052,7 +1052,7 @@ array_value_type (gimple_switch swtch, tree type, int num, static void build_one_array (gimple_switch swtch, int num, tree arr_index_type, - gimple phi, tree tidx, struct switch_conv_info *info) + gimple_phi phi, tree tidx, struct switch_conv_info *info) { tree name, cst; gimple load; @@ -1123,6 +1123,7 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info) tree tidx, sub, utype; gimple stmt; gimple_stmt_iterator gsi; + gimple_phi_iterator gpi; int i; location_t loc = gimple_location (swtch); @@ -1148,9 +1149,9 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info) update_stmt (stmt); info->arr_ref_first = stmt; - for (gsi = gsi_start_phis (info->final_bb), i = 0; - !gsi_end_p (gsi); gsi_next (&gsi), i++) - build_one_array (swtch, i, arr_index_type, gsi_stmt (gsi), tidx, info); + for (gpi = gsi_start_phis (info->final_bb), i = 0; + !gsi_end_p (gpi); gsi_next (&gpi), i++) + build_one_array (swtch, i, arr_index_type, gpi.phi (), tidx, info); } /* Generates and appropriately inserts loads of default values at the position diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 95c00fa..c6a5c4f 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -85,7 +85,6 @@ rename_use_op (use_operand_p op_p) static void rename_variables_in_bb (basic_block bb) { - gimple_stmt_iterator gsi; gimple stmt; use_operand_p use_p; ssa_op_iter iter; @@ -93,7 +92,8 @@ rename_variables_in_bb (basic_block bb) edge_iterator ei; struct loop *loop = bb->loop_father; - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { stmt = gsi_stmt (gsi); FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) @@ -104,8 +104,9 @@ rename_variables_in_bb (basic_block bb) { if (!flow_bb_inside_loop_p (loop, e->src)) continue; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - rename_use_op (PHI_ARG_DEF_PTR_FROM_EDGE (gsi_stmt (gsi), e)); + for (gimple_phi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + rename_use_op (PHI_ARG_DEF_PTR_FROM_EDGE (gsi.phi (), e)); } } diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 19535b3..6c5053f 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -187,10 +187,9 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo) struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); int nbbs = loop->num_nodes; - gimple_stmt_iterator si; unsigned int vectorization_factor = 0; tree scalar_type; - gimple phi; + gimple_phi phi; tree vectype; unsigned int nunits; stmt_vec_info stmt_info; @@ -209,9 +208,10 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo) { basic_block bb = bbs[i]; - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - phi = gsi_stmt (si); + phi = si.phi (); stmt_info = vinfo_for_stmt (phi); if (dump_enabled_p ()) { @@ -269,7 +269,8 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo) } } - for (si = gsi_start_bb (bb); !gsi_end_p (si) || analyze_pattern_stmt;) + for (gimple_stmt_iterator si = gsi_start_bb (bb); + !gsi_end_p (si) || analyze_pattern_stmt;) { tree vf_vectype; @@ -1334,10 +1335,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); int nbbs = loop->num_nodes; - gimple_stmt_iterator si; unsigned int vectorization_factor = 0; int i; - gimple phi; stmt_vec_info stmt_info; bool need_to_vectorize = false; int min_profitable_iters; @@ -1364,7 +1363,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) for (i = 0; i < nbbs; i++) { basic_block bb = bbs[i]; - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt = gsi_stmt (si); stmt_vec_info stmt_info = vinfo_for_stmt (stmt); @@ -1394,9 +1394,10 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) { basic_block bb = bbs[i]; - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - phi = gsi_stmt (si); + gimple_phi phi = si.phi (); ok = true; stmt_info = vinfo_for_stmt (phi); @@ -1499,7 +1500,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) } } - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt = gsi_stmt (si); if (!gimple_clobber_p (stmt) @@ -5773,7 +5775,6 @@ vect_transform_loop (loop_vec_info loop_vinfo) struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); int nbbs = loop->num_nodes; - gimple_stmt_iterator si; int i; tree ratio = NULL; int vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo); @@ -5882,11 +5883,11 @@ vect_transform_loop (loop_vec_info loop_vinfo) { basic_block bb = bbs[i]; stmt_vec_info stmt_info; - gimple phi; - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - phi = gsi_stmt (si); + gimple_phi phi = si.phi (); if (dump_enabled_p ()) { dump_printf_loc (MSG_NOTE, vect_location, @@ -5920,7 +5921,8 @@ vect_transform_loop (loop_vec_info loop_vinfo) } pattern_stmt = NULL; - for (si = gsi_start_bb (bb); !gsi_end_p (si) || transform_pattern_stmt;) + for (gimple_stmt_iterator si = gsi_start_bb (bb); + !gsi_end_p (si) || transform_pattern_stmt;) { bool is_store; diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 303af8d..a164870 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5930,7 +5930,6 @@ find_switch_asserts (basic_block bb, gimple_switch last) static bool find_assert_locations_1 (basic_block bb, sbitmap live) { - gimple_stmt_iterator si; gimple last; bool need_assert; @@ -5954,7 +5953,8 @@ find_assert_locations_1 (basic_block bb, sbitmap live) /* Traverse all the statements in BB marking used names and looking for statements that may infer assertions for their used operands. */ - for (si = gsi_last_bb (bb); !gsi_end_p (si); gsi_prev (&si)) + for (gimple_stmt_iterator si = gsi_last_bb (bb); !gsi_end_p (si); + gsi_prev (&si)) { gimple stmt; tree op; @@ -6027,11 +6027,12 @@ find_assert_locations_1 (basic_block bb, sbitmap live) } /* Traverse all PHI nodes in BB, updating live. */ - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { use_operand_p arg_p; ssa_op_iter i; - gimple phi = gsi_stmt (si); + gimple_phi phi = si.phi (); tree res = gimple_phi_result (phi); if (virtual_operand_p (res)) @@ -6833,11 +6834,10 @@ vrp_initialize (void) FOR_EACH_BB_FN (bb, cfun) { - gimple_stmt_iterator si; - - for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_phi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) { - gimple phi = gsi_stmt (si); + gimple_phi phi = si.phi (); if (!stmt_interesting_for_vrp (phi)) { tree lhs = PHI_RESULT (phi); @@ -6848,7 +6848,8 @@ vrp_initialize (void) prop_set_simulate_again (phi, true); } - for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si); + gsi_next (&si)) { gimple stmt = gsi_stmt (si); -- 1.8.5.3