diff options
-rw-r--r-- | gcc/analyzer/call-string.cc | 16 | ||||
-rw-r--r-- | gcc/analyzer/checker-path.cc | 4 | ||||
-rw-r--r-- | gcc/analyzer/constraint-manager.cc | 22 | ||||
-rw-r--r-- | gcc/analyzer/engine.cc | 12 | ||||
-rw-r--r-- | gcc/analyzer/program-state.cc | 4 | ||||
-rw-r--r-- | gcc/analyzer/region-model.cc | 4 | ||||
-rw-r--r-- | gcc/attribs.c | 13 | ||||
-rw-r--r-- | gcc/auto-profile.c | 6 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 20 | ||||
-rw-r--r-- | gcc/cp/decl.c | 15 | ||||
-rw-r--r-- | gcc/cp/parser.c | 4 | ||||
-rw-r--r-- | gcc/gcc.c | 13 | ||||
-rw-r--r-- | gcc/gimple-loop-jam.c | 4 | ||||
-rw-r--r-- | gcc/gimple-ssa-store-merging.c | 19 | ||||
-rw-r--r-- | gcc/graphite-poly.c | 41 | ||||
-rw-r--r-- | gcc/ifcvt.c | 6 | ||||
-rw-r--r-- | gcc/lower-subreg.c | 11 | ||||
-rw-r--r-- | gcc/regcprop.c | 5 | ||||
-rw-r--r-- | gcc/sanopt.c | 4 | ||||
-rw-r--r-- | gcc/sel-sched-dump.c | 5 | ||||
-rw-r--r-- | gcc/store-motion.c | 8 | ||||
-rw-r--r-- | gcc/timevar.c | 4 | ||||
-rw-r--r-- | gcc/tree-cfgcleanup.c | 8 | ||||
-rw-r--r-- | gcc/tree-data-ref.c | 103 | ||||
-rw-r--r-- | gcc/tree-inline.c | 5 | ||||
-rw-r--r-- | gcc/tree-into-ssa.c | 9 | ||||
-rw-r--r-- | gcc/tree-ssa-propagate.c | 4 | ||||
-rw-r--r-- | gcc/tree-vect-data-refs.c | 30 | ||||
-rw-r--r-- | gcc/tree-vectorizer.c | 9 |
29 files changed, 108 insertions, 300 deletions
diff --git a/gcc/analyzer/call-string.cc b/gcc/analyzer/call-string.cc index 224b2e2..9f4f77a 100644 --- a/gcc/analyzer/call-string.cc +++ b/gcc/analyzer/call-string.cc @@ -50,9 +50,7 @@ along with GCC; see the file COPYING3. If not see call_string::call_string (const call_string &other) : m_return_edges (other.m_return_edges.length ()) { - const return_superedge *e; - int i; - FOR_EACH_VEC_ELT (other.m_return_edges, i, e) + for (const return_superedge *e : other.m_return_edges) m_return_edges.quick_push (e); } @@ -118,9 +116,7 @@ call_string::to_json () const { json::array *arr = new json::array (); - const return_superedge *e; - int i; - FOR_EACH_VEC_ELT (m_return_edges, i, e) + for (const return_superedge *e : m_return_edges) { json::object *e_obj = new json::object (); e_obj->set ("src_snode_idx", @@ -141,9 +137,7 @@ hashval_t call_string::hash () const { inchash::hash hstate; - int i; - const return_superedge *e; - FOR_EACH_VEC_ELT (m_return_edges, i, e) + for (const return_superedge *e : m_return_edges) hstate.add_ptr (e); return hstate.end (); } @@ -173,9 +167,7 @@ call_string::calc_recursion_depth () const = m_return_edges[m_return_edges.length () - 1]; int result = 0; - const return_superedge *e; - int i; - FOR_EACH_VEC_ELT (m_return_edges, i, e) + for (const return_superedge *e : m_return_edges) if (e == top_return_sedge) ++result; return result; diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index 7d229bb..e6f838b 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -1001,9 +1001,7 @@ checker_path::add_final_event (const state_machine *sm, void checker_path::fixup_locations (pending_diagnostic *pd) { - checker_event *e; - int i; - FOR_EACH_VEC_ELT (m_events, i, e) + for (checker_event *e : m_events) e->set_location (pd->fixup_location (e->get_location ())); } diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 4dadd20..51cf522 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -270,9 +270,7 @@ equiv_class::equiv_class (const equiv_class &other) : m_constant (other.m_constant), m_cst_sval (other.m_cst_sval), m_vars (other.m_vars.length ()) { - int i; - const svalue *sval; - FOR_EACH_VEC_ELT (other.m_vars, i, sval) + for (const svalue *sval : other.m_vars) m_vars.quick_push (sval); } @@ -310,9 +308,7 @@ equiv_class::to_json () const json::object *ec_obj = new json::object (); json::array *sval_arr = new json::array (); - int i; - const svalue *sval; - FOR_EACH_VEC_ELT (m_vars, i, sval) + for (const svalue *sval : m_vars) sval_arr->append (sval->to_json ()); ec_obj->set ("svals", sval_arr); @@ -337,9 +333,7 @@ equiv_class::hash () const inchash::hash hstate; inchash::add_expr (m_constant, hstate); - int i; - const svalue *sval; - FOR_EACH_VEC_ELT (m_vars, i, sval) + for (const svalue * sval : m_vars) hstate.add_ptr (sval); return hstate.end (); } @@ -811,9 +805,7 @@ constraint_manager::to_json () const /* Equivalence classes. */ { json::array *ec_arr = new json::array (); - int i; - equiv_class *ec; - FOR_EACH_VEC_ELT (m_equiv_classes, i, ec) + for (const equiv_class *ec : m_equiv_classes) ec_arr->append (ec->to_json ()); cm_obj->set ("ecs", ec_arr); } @@ -821,10 +813,8 @@ constraint_manager::to_json () const /* Constraints. */ { json::array *con_arr = new json::array (); - int i; - constraint *c; - FOR_EACH_VEC_ELT (m_constraints, i, c) - con_arr->append (c->to_json ()); + for (const constraint &c : m_constraints) + con_arr->append (c.to_json ()); cm_obj->set ("constraints", con_arr); } diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 48320bc..50652b2 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -121,9 +121,7 @@ void impl_region_model_context::on_svalue_leak (const svalue *sval) { - int sm_idx; - sm_state_map *smap; - FOR_EACH_VEC_ELT (m_new_state->m_checker_states, sm_idx, smap) + for (sm_state_map *smap : m_new_state->m_checker_states) smap->on_svalue_leak (sval, this); } @@ -132,9 +130,7 @@ impl_region_model_context:: on_liveness_change (const svalue_set &live_svalues, const region_model *model) { - int sm_idx; - sm_state_map *smap; - FOR_EACH_VEC_ELT (m_new_state->m_checker_states, sm_idx, smap) + for (sm_state_map *smap : m_new_state->m_checker_states) smap->on_liveness_change (live_svalues, model, this); } @@ -142,9 +138,7 @@ void impl_region_model_context::on_unknown_change (const svalue *sval, bool is_mutable) { - int sm_idx; - sm_state_map *smap; - FOR_EACH_VEC_ELT (m_new_state->m_checker_states, sm_idx, smap) + for (sm_state_map *smap : m_new_state->m_checker_states) smap->on_unknown_change (sval, is_mutable, m_ext_state); } diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 5c690b0..76959c1 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -441,10 +441,8 @@ sm_state_map::set_state (const equiv_class &ec, const svalue *origin, const extrinsic_state &ext_state) { - int i; - const svalue *sval; bool any_changed = false; - FOR_EACH_VEC_ELT (ec.m_vars, i, sval) + for (const svalue *sval : ec.m_vars) any_changed |= impl_set_state (sval, state, origin, ext_state); return any_changed; } diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 551ee79..4b9620d 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -4294,9 +4294,7 @@ test_canonicalization_4 () region_model_manager mgr; region_model model (&mgr); - unsigned i; - tree cst; - FOR_EACH_VEC_ELT (csts, i, cst) + for (tree cst : csts) model.get_rvalue (cst, NULL); model.canonicalize (); diff --git a/gcc/attribs.c b/gcc/attribs.c index 70e0a2f..afa485e 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -165,15 +165,12 @@ register_scoped_attributes (const struct attribute_spec *attributes, static scoped_attributes* find_attribute_namespace (const char* ns) { - unsigned ix; - scoped_attributes *iter; - - FOR_EACH_VEC_ELT (attributes_table, ix, iter) - if (ns == iter->ns - || (iter->ns != NULL + for (scoped_attributes &iter : attributes_table) + if (ns == iter.ns + || (iter.ns != NULL && ns != NULL - && !strcmp (iter->ns, ns))) - return iter; + && !strcmp (iter.ns, ns))) + return &iter; return NULL; } diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index a460124..ed788dc 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -1156,14 +1156,12 @@ afdo_find_equiv_class (bb_set *annotated_bb) FOR_ALL_BB_FN (bb, cfun) { vec<basic_block> dom_bbs; - basic_block bb1; - int i; if (bb->aux != NULL) continue; bb->aux = bb; dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); - FOR_EACH_VEC_ELT (dom_bbs, i, bb1) + for (basic_block bb1 : dom_bbs) if (bb1->aux == NULL && dominated_by_p (CDI_POST_DOMINATORS, bb, bb1) && bb1->loop_father == bb->loop_father) { @@ -1175,7 +1173,7 @@ afdo_find_equiv_class (bb_set *annotated_bb) } } dom_bbs = get_dominated_by (CDI_POST_DOMINATORS, bb); - FOR_EACH_VEC_ELT (dom_bbs, i, bb1) + for (basic_block bb1 : dom_bbs) if (bb1->aux == NULL && dominated_by_p (CDI_DOMINATORS, bb, bb1) && bb1->loop_father == bb->loop_father) { diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 4f1c3d66..a26aead 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2793,9 +2793,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, /* Forget the saved values of the callee's SAVE_EXPRs and TARGET_EXPRs. */ - unsigned int i; - tree save_expr; - FOR_EACH_VEC_ELT (save_exprs, i, save_expr) + for (tree save_expr : save_exprs) ctx->global->values.remove (save_expr); /* Remove the parms/result from the values map. Is it worth @@ -5495,9 +5493,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, semantics are not applied on an object under construction. They come into effect when the constructor for the most derived object ends." */ - tree elt; - unsigned int i; - FOR_EACH_VEC_ELT (*ctors, i, elt) + for (tree elt : *ctors) if (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (const_object_being_modified), TREE_TYPE (elt))) { @@ -5605,12 +5601,10 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, /* Update TREE_CONSTANT and TREE_SIDE_EFFECTS on enclosing CONSTRUCTORs, if any. */ - tree elt; - unsigned i; bool c = TREE_CONSTANT (init); bool s = TREE_SIDE_EFFECTS (init); if (!c || s || activated_union_member_p) - FOR_EACH_VEC_ELT (*ctors, i, elt) + for (tree elt : *ctors) { if (!c) TREE_CONSTANT (elt) = false; @@ -5928,9 +5922,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t, } /* Forget saved values of SAVE_EXPRs and TARGET_EXPRs. */ - unsigned int i; - tree save_expr; - FOR_EACH_VEC_ELT (save_exprs, i, save_expr) + for (tree save_expr : save_exprs) ctx->global->values.remove (save_expr); save_exprs.truncate (0); @@ -5952,9 +5944,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t, && !*non_constant_p); /* Forget saved values of SAVE_EXPRs and TARGET_EXPRs. */ - unsigned int i; - tree save_expr; - FOR_EACH_VEC_ELT (save_exprs, i, save_expr) + for (tree save_expr : save_exprs) ctx->global->values.remove (save_expr); return NULL_TREE; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index da254d8..f5596b6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -841,9 +841,7 @@ wrapup_namespace_globals () { if (vec<tree, va_gc> *statics = static_decls) { - tree decl; - unsigned int i; - FOR_EACH_VEC_ELT (*statics, i, decl) + for (tree decl : *statics) { if (warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL @@ -8260,8 +8258,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, reference, insert it in the statement-tree now. */ if (cleanups) { - unsigned i; tree t; - FOR_EACH_VEC_ELT (*cleanups, i, t) + for (tree t : *cleanups) push_cleanup (decl, t, false); release_tree_vector (cleanups); } @@ -16415,11 +16412,9 @@ cxx_simulate_enum_decl (location_t loc, const char *name, SET_OPAQUE_ENUM_P (enumtype, false); DECL_SOURCE_LOCATION (TYPE_NAME (enumtype)) = loc; - string_int_pair *value; - unsigned int i; - FOR_EACH_VEC_ELT (values, i, value) - build_enumerator (get_identifier (value->first), - build_int_cst (integer_type_node, value->second), + for (const string_int_pair &value : values) + build_enumerator (get_identifier (value.first), + build_int_cst (integer_type_node, value.second), enumtype, NULL_TREE, loc); finish_enum_value_list (enumtype); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 686f98b..b5af387 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7299,8 +7299,6 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, case RID_BUILTIN_LAUNDER: { vec<tree, va_gc> *vec; - unsigned int i; - tree p; cp_lexer_consume_token (parser->lexer); vec = cp_parser_parenthesized_expression_list (parser, non_attr, @@ -7312,7 +7310,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, break; } - FOR_EACH_VEC_ELT (*vec, i, p) + for (tree p : *vec) mark_exp_read (p); switch (keyword) @@ -5838,10 +5838,7 @@ compile_input_file_p (struct infile *infile) static void do_specs_vec (vec<char_p> vec) { - unsigned ix; - char *opt; - - FOR_EACH_VEC_ELT (vec, ix, opt) + for (char *opt : vec) { do_spec_1 (opt, 1, NULL); /* Make each accumulated option a separate argument. */ @@ -6436,8 +6433,6 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) { const char *p1 = p; char *string; - char *opt; - unsigned ix; /* Skip past the option value and make a copy. */ if (*p != '{') @@ -6448,7 +6443,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) string = save_string (p1 + 1, p - p1 - 2); /* See if we already recorded this option. */ - FOR_EACH_VEC_ELT (linker_options, ix, opt) + for (const char *opt : linker_options) if (! strcmp (string, opt)) { free (string); @@ -8316,9 +8311,7 @@ driver::set_up_specs () const && do_spec_2 (startfile_prefix_spec, NULL) == 0 && do_spec_1 (" ", 0, NULL) == 0) { - const char *arg; - int ndx; - FOR_EACH_VEC_ELT (argbuf, ndx, arg) + for (const char *arg : argbuf) add_sysrooted_prefix (&startfile_prefixes, arg, "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1); } diff --git a/gcc/gimple-loop-jam.c b/gcc/gimple-loop-jam.c index 69dbaeb..4842f0d 100644 --- a/gcc/gimple-loop-jam.c +++ b/gcc/gimple-loop-jam.c @@ -365,11 +365,9 @@ static bool any_access_function_variant_p (const struct data_reference *a, const class loop *loop_nest) { - unsigned int i; vec<tree> fns = DR_ACCESS_FNS (a); - tree t; - FOR_EACH_VEC_ELT (fns, i, t) + for (tree t : fns) if (!evolution_function_is_invariant_p (t, loop_nest->num)) return true; diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 123c92d..6329479 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -2541,8 +2541,6 @@ compatible_load_p (merged_store_group *merged_store, clobbers those loads. */ gimple *first = merged_store->first_stmt; gimple *last = merged_store->last_stmt; - unsigned int i; - store_immediate_info *infoc; /* The stores are sorted by increasing store bitpos, so if info->stmt store comes before the so far first load, we'll be changing merged_store->first_stmt. In that case we need to give up if @@ -2550,7 +2548,7 @@ compatible_load_p (merged_store_group *merged_store, range. */ if (info->order < merged_store->first_order) { - FOR_EACH_VEC_ELT (merged_store->stores, i, infoc) + for (store_immediate_info *infoc : merged_store->stores) if (stmts_may_clobber_ref_p (info->stmt, first, infoc->ops[idx].val)) return false; first = info->stmt; @@ -2560,7 +2558,7 @@ compatible_load_p (merged_store_group *merged_store, processed loads. */ else if (info->order > merged_store->last_order) { - FOR_EACH_VEC_ELT (merged_store->stores, i, infoc) + for (store_immediate_info *infoc : merged_store->stores) if (stmts_may_clobber_ref_p (last, info->stmt, infoc->ops[idx].val)) return false; last = info->stmt; @@ -2884,9 +2882,7 @@ imm_store_chain_info::try_coalesce_bswap (merged_store_group *merged_store, gather_bswap_load_refs (&refs, gimple_assign_rhs1 (m_store_info[i]->stmt)); - unsigned int i; - tree ref; - FOR_EACH_VEC_ELT (refs, i, ref) + for (tree ref : refs) if (stmts_may_clobber_ref_p (first_stmt, last_stmt, ref)) return false; n.vuse = NULL_TREE; @@ -3199,9 +3195,7 @@ imm_store_chain_info::coalesce_immediate_stores () } else if (infof->rhs_code == MEM_REF && info->rhs_code != MEM_REF) { - store_immediate_info *infoj; - unsigned int j; - FOR_EACH_VEC_ELT (merged_store->stores, j, infoj) + for (store_immediate_info *infoj : merged_store->stores) { infoj->rhs_code = BIT_INSERT_EXPR; infoj->ops[0].val = gimple_assign_rhs1 (infoj->stmt); @@ -3323,10 +3317,7 @@ get_alias_type_for_stmts (vec<gimple *> &stmts, bool is_load, static location_t get_location_for_stmts (vec<gimple *> &stmts) { - gimple *stmt; - unsigned int i; - - FOR_EACH_VEC_ELT (stmts, i, stmt) + for (gimple *stmt : stmts) if (gimple_has_location (stmt)) return gimple_location (stmt); diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index 2e31b27..1dfc28e 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -63,10 +63,7 @@ print_iteration_domain (FILE *file, poly_bb_p pbb) void print_iteration_domains (FILE *file, scop_p scop) { - int i; - poly_bb_p pbb; - - FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) + for (poly_bb_p pbb : scop->pbbs) print_iteration_domain (file, pbb); } @@ -150,16 +147,13 @@ new_poly_bb (scop_p scop, gimple_poly_bb_p black_box) static void free_poly_bb (poly_bb_p pbb) { - int i; - poly_dr_p pdr; - isl_set_free (pbb->domain); pbb->domain = NULL; isl_set_free (pbb->iterators); pbb->iterators = NULL; if (PBB_DRS (pbb).exists ()) - FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) + for (poly_dr_p pdr : PBB_DRS (pbb)) free_poly_dr (pdr); PBB_DRS (pbb).release (); @@ -243,10 +237,7 @@ free_gimple_poly_bb (gimple_poly_bb_p gbb) static void remove_gbbs_in_scop (scop_p scop) { - int i; - poly_bb_p pbb; - - FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) + for (poly_bb_p pbb : scop->pbbs) free_gimple_poly_bb (PBB_BLACK_BOX (pbb)); } @@ -273,13 +264,10 @@ new_scop (edge entry, edge exit) void free_scop (scop_p scop) { - int i; - poly_bb_p pbb; - remove_gbbs_in_scop (scop); free_sese_info (scop->scop_info); - FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) + for (poly_bb_p pbb : scop->pbbs) free_poly_bb (pbb); scop->pbbs.release (); @@ -309,8 +297,6 @@ print_pbb_domain (FILE *file, poly_bb_p pbb) static void dump_gbb_cases (FILE *file, gimple_poly_bb_p gbb) { - int i; - gimple *stmt; vec<gimple *> cases; if (!gbb) @@ -322,7 +308,7 @@ dump_gbb_cases (FILE *file, gimple_poly_bb_p gbb) fprintf (file, "cases bb_%d (\n", GBB_BB (gbb)->index); - FOR_EACH_VEC_ELT (cases, i, stmt) + for (gimple *stmt : cases) print_gimple_stmt (file, stmt, 0); fprintf (file, ")\n"); @@ -333,8 +319,6 @@ dump_gbb_cases (FILE *file, gimple_poly_bb_p gbb) static void dump_gbb_conditions (FILE *file, gimple_poly_bb_p gbb) { - int i; - gimple *stmt; vec<gimple *> conditions; if (!gbb) @@ -346,7 +330,7 @@ dump_gbb_conditions (FILE *file, gimple_poly_bb_p gbb) fprintf (file, "conditions bb_%d (\n", GBB_BB (gbb)->index); - FOR_EACH_VEC_ELT (conditions, i, stmt) + for (gimple *stmt : conditions) print_gimple_stmt (file, stmt, 0); fprintf (file, ")\n"); @@ -357,8 +341,6 @@ dump_gbb_conditions (FILE *file, gimple_poly_bb_p gbb) void print_pdrs (FILE *file, poly_bb_p pbb) { - int i; - poly_dr_p pdr; int nb_reads = 0; int nb_writes = 0; @@ -367,7 +349,7 @@ print_pdrs (FILE *file, poly_bb_p pbb) fprintf (file, "Data references (\n"); - FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) + for (poly_dr_p pdr : PBB_DRS (pbb)) if (PDR_TYPE (pdr) == PDR_READ) nb_reads++; else @@ -375,13 +357,13 @@ print_pdrs (FILE *file, poly_bb_p pbb) fprintf (file, "Read data references (\n"); - FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) + for (poly_dr_p pdr : PBB_DRS (pbb)) if (PDR_TYPE (pdr) == PDR_READ) print_pdr (file, pdr); fprintf (file, ")\n"); fprintf (file, "Write data references (\n"); - FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr) + for (poly_dr_p pdr : PBB_DRS (pbb)) if (PDR_TYPE (pdr) != PDR_READ) print_pdr (file, pdr); fprintf (file, ")\n"); @@ -459,9 +441,6 @@ print_scop_context (FILE *file, scop_p scop) void print_scop (FILE *file, scop_p scop) { - int i; - poly_bb_p pbb; - fprintf (file, "SCoP (\n"); print_scop_context (file, scop); print_scop_params (file, scop); @@ -469,7 +448,7 @@ print_scop (FILE *file, scop_p scop) fprintf (file, "Number of statements: "); fprintf (file, "%d\n", scop->pbbs.length ()); - FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) + for (poly_bb_p pbb : scop->pbbs) print_pbb (file, pbb); fprintf (file, ")\n"); diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index d086ce8..017944f 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3889,11 +3889,9 @@ cond_move_process_if_block (struct noce_if_info *if_info) rtx_insn *jump = if_info->jump; rtx cond = if_info->cond; rtx_insn *seq, *loc_insn; - rtx reg; int c; vec<rtx> then_regs = vNULL; vec<rtx> else_regs = vNULL; - unsigned int i; int success_p = FALSE; int limit = param_max_rtl_if_conversion_insns; @@ -3915,7 +3913,7 @@ cond_move_process_if_block (struct noce_if_info *if_info) source register does not change after the assignment. Also count the number of registers set in only one of the blocks. */ c = 0; - FOR_EACH_VEC_ELT (then_regs, i, reg) + for (rtx reg : then_regs) { rtx *then_slot = then_vals.get (reg); rtx *else_slot = else_vals.get (reg); @@ -3934,7 +3932,7 @@ cond_move_process_if_block (struct noce_if_info *if_info) } /* Finish off c for MAX_CONDITIONAL_EXECUTE. */ - FOR_EACH_VEC_ELT (else_regs, i, reg) + for (rtx reg : else_regs) { gcc_checking_assert (else_vals.get (reg)); if (!then_vals.get (reg)) diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c index 34eb8b1..2107826 100644 --- a/gcc/lower-subreg.c +++ b/gcc/lower-subreg.c @@ -1731,14 +1731,9 @@ decompose_multiword_subregs (bool decompose_copies) } } - { - unsigned int i; - bitmap b; - - FOR_EACH_VEC_ELT (reg_copy_graph, i, b) - if (b) - BITMAP_FREE (b); - } + for (bitmap b : reg_copy_graph) + if (b) + BITMAP_FREE (b); reg_copy_graph.release (); diff --git a/gcc/regcprop.c b/gcc/regcprop.c index 44f6295..5ca7e8c 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -1404,12 +1404,9 @@ pass_cprop_hardreg::execute (function *fun) changed anything though. */ if (!worklist.is_empty ()) { - unsigned int i; - int index; - any_debug_changes = false; bitmap_clear (visited); - FOR_EACH_VEC_ELT (worklist, i, index) + for (int index : worklist) { bb = BASIC_BLOCK_FOR_FN (fun, index); cprop_hardreg_bb (bb, all_vd, visited); diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 41f20c3..18829ff 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -1246,9 +1246,7 @@ sanitize_rewrite_addressable_params (function *fun) /* Unset value expr for parameters for which we created debug bind expressions. */ - unsigned i; - tree arg; - FOR_EACH_VEC_ELT (clear_value_expr_list, i, arg) + for (tree arg : clear_value_expr_list) { DECL_HAS_VALUE_EXPR_P (arg) = 0; SET_DECL_VALUE_EXPR (arg, NULL_TREE); diff --git a/gcc/sel-sched-dump.c b/gcc/sel-sched-dump.c index 3d26483..993a16a 100644 --- a/gcc/sel-sched-dump.c +++ b/gcc/sel-sched-dump.c @@ -528,10 +528,7 @@ dump_flist (flist_t l) void dump_insn_vector (rtx_vec_t succs) { - int i; - rtx_insn *succ; - - FOR_EACH_VEC_ELT (succs, i, succ) + for (rtx_insn *succ : succs) if (succ) dump_insn (succ); else diff --git a/gcc/store-motion.c b/gcc/store-motion.c index 3f6e003..dd61701 100644 --- a/gcc/store-motion.c +++ b/gcc/store-motion.c @@ -251,9 +251,7 @@ print_store_motion_mems (FILE * file) static bool store_ops_ok (const vec<rtx> &x, int *regs_set) { - unsigned int i; - rtx temp; - FOR_EACH_VEC_ELT (x, i, temp) + for (rtx temp : x) if (regs_set[REGNO (temp)]) return false; @@ -386,9 +384,7 @@ store_killed_in_insn (const_rtx x, const vec<rtx> &x_regs, /* But even a const call reads its parameters. Check whether the base of some of registers used in mem is stack pointer. */ - rtx temp; - unsigned int i; - FOR_EACH_VEC_ELT (x_regs, i, temp) + for (rtx temp : x_regs) if (may_be_sp_based_p (temp)) return true; diff --git a/gcc/timevar.c b/gcc/timevar.c index 8fc122b..5f54215 100644 --- a/gcc/timevar.c +++ b/gcc/timevar.c @@ -198,10 +198,8 @@ timer::named_items::pop () void timer::named_items::print (FILE *fp, const timevar_time_def *total) { - unsigned int i; - const char *item_name; fprintf (fp, "Client items:\n"); - FOR_EACH_VEC_ELT (m_names, i, item_name) + for (const char *item_name : m_names) { timer::timevar_def *def = m_hash_map.get (item_name); gcc_assert (def); diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index b736e17..a016ee4 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -950,9 +950,7 @@ cleanup_control_flow_pre () /* If we've marked .ABNORMAL_DISPATCHER basic block(s) as visited above, but haven't marked any of their successors as visited, unmark them now, so that they can be removed as useless. */ - basic_block dispatcher_bb; - unsigned int k; - FOR_EACH_VEC_ELT (abnormal_dispatchers, k, dispatcher_bb) + for (basic_block dispatcher_bb : abnormal_dispatchers) { edge e; edge_iterator ei; @@ -1015,9 +1013,7 @@ cleanup_tree_cfg_noloop (unsigned ssa_update_flags) if (!dom_info_available_p (CDI_DOMINATORS)) mark_dfs_back_edges (); - loop_p loop; - unsigned i; - FOR_EACH_VEC_ELT (*get_loops (cfun), i, loop) + for (loop_p loop : *get_loops (cfun)) if (loop && loop->header) { basic_block bb = loop->header; diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b37c234..6f3352f 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -170,10 +170,7 @@ ref_contains_union_access_p (tree ref) static void dump_data_references (FILE *file, vec<data_reference_p> datarefs) { - unsigned int i; - struct data_reference *dr; - - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) dump_data_reference (file, dr); } @@ -378,10 +375,7 @@ DEBUG_FUNCTION void print_dir_vectors (FILE *outf, vec<lambda_vector> dir_vects, int length) { - unsigned j; - lambda_vector v; - - FOR_EACH_VEC_ELT (dir_vects, j, v) + for (lambda_vector v : dir_vects) print_direction_vector (outf, v, length); } @@ -403,10 +397,7 @@ DEBUG_FUNCTION void print_dist_vectors (FILE *outf, vec<lambda_vector> dist_vects, int length) { - unsigned j; - lambda_vector v; - - FOR_EACH_VEC_ELT (dist_vects, j, v) + for (lambda_vector v : dist_vects) print_lambda_vector (outf, v, length); } @@ -499,10 +490,7 @@ DEBUG_FUNCTION void dump_data_dependence_relations (FILE *file, vec<ddr_p> ddrs) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) dump_data_dependence_relation (file, ddr); } @@ -538,21 +526,17 @@ debug_data_dependence_relations (vec<ddr_p> ddrs) DEBUG_FUNCTION void dump_dist_dir_vectors (FILE *file, vec<ddr_p> ddrs) { - unsigned int i, j; - struct data_dependence_relation *ddr; - lambda_vector v; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE && DDR_AFFINE_P (ddr)) { - FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), j, v) + for (lambda_vector v : DDR_DIST_VECTS (ddr)) { fprintf (file, "DISTANCE_V ("); print_lambda_vector (file, v, DDR_NB_LOOPS (ddr)); fprintf (file, ")\n"); } - FOR_EACH_VEC_ELT (DDR_DIR_VECTS (ddr), j, v) + for (lambda_vector v : DDR_DIR_VECTS (ddr)) { fprintf (file, "DIRECTION_V ("); print_direction_vector (file, v, DDR_NB_LOOPS (ddr)); @@ -568,10 +552,7 @@ dump_dist_dir_vectors (FILE *file, vec<ddr_p> ddrs) DEBUG_FUNCTION void dump_ddrs (FILE *file, vec<ddr_p> ddrs) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) dump_data_dependence_relation (file, ddr); fprintf (file, "\n\n"); @@ -2668,19 +2649,17 @@ create_runtime_alias_checks (class loop *loop, tree part_cond_expr; fold_defer_overflow_warnings (); - dr_with_seg_len_pair_t *alias_pair; - unsigned int i; - FOR_EACH_VEC_ELT (*alias_pairs, i, alias_pair) + for (const dr_with_seg_len_pair_t &alias_pair : alias_pairs) { - gcc_assert (alias_pair->flags); + gcc_assert (alias_pair.flags); if (dump_enabled_p ()) dump_printf (MSG_NOTE, "create runtime check for data references %T and %T\n", - DR_REF (alias_pair->first.dr), - DR_REF (alias_pair->second.dr)); + DR_REF (alias_pair.first.dr), + DR_REF (alias_pair.second.dr)); /* Create condition expression for each pair data references. */ - create_intersect_range_checks (loop, &part_cond_expr, *alias_pair); + create_intersect_range_checks (loop, &part_cond_expr, alias_pair); if (*cond_expr) *cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, *cond_expr, part_cond_expr); @@ -3436,10 +3415,7 @@ free_conflict_function (conflict_function *f) static void free_subscripts (vec<subscript_p> subscripts) { - unsigned i; - subscript_p s; - - FOR_EACH_VEC_ELT (subscripts, i, s) + for (subscript_p s : subscripts) { free_conflict_function (s->conflicting_iterations_in_a); free_conflict_function (s->conflicting_iterations_in_b); @@ -4980,10 +4956,7 @@ analyze_overlapping_iterations (tree chrec_a, static void save_dist_v (struct data_dependence_relation *ddr, lambda_vector dist_v) { - unsigned i; - lambda_vector v; - - FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), i, v) + for (lambda_vector v : DDR_DIST_VECTS (ddr)) if (lambda_vector_equal (v, dist_v, DDR_NB_LOOPS (ddr))) return; @@ -4995,10 +4968,7 @@ save_dist_v (struct data_dependence_relation *ddr, lambda_vector dist_v) static void save_dir_v (struct data_dependence_relation *ddr, lambda_vector dir_v) { - unsigned i; - lambda_vector v; - - FOR_EACH_VEC_ELT (DDR_DIR_VECTS (ddr), i, v) + for (lambda_vector v : DDR_DIR_VECTS (ddr)) if (lambda_vector_equal (v, dir_v, DDR_NB_LOOPS (ddr))) return; @@ -5135,10 +5105,7 @@ static bool invariant_access_functions (const struct data_dependence_relation *ddr, int lnum) { - unsigned i; - subscript *sub; - - FOR_EACH_VEC_ELT (DDR_SUBSCRIPTS (ddr), i, sub) + for (subscript *sub : DDR_SUBSCRIPTS (ddr)) if (!evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 0), lnum) || !evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 1), lnum)) return false; @@ -5307,10 +5274,7 @@ add_distance_for_zero_overlaps (struct data_dependence_relation *ddr) static inline bool same_access_functions (const struct data_dependence_relation *ddr) { - unsigned i; - subscript *sub; - - FOR_EACH_VEC_ELT (DDR_SUBSCRIPTS (ddr), i, sub) + for (subscript *sub : DDR_SUBSCRIPTS (ddr)) if (!eq_evolutions_p (SUB_ACCESS_FN (sub, 0), SUB_ACCESS_FN (sub, 1))) return false; @@ -5587,11 +5551,8 @@ static bool access_functions_are_affine_or_constant_p (const struct data_reference *a, const class loop *loop_nest) { - unsigned int i; vec<tree> fns = DR_ACCESS_FNS (a); - tree t; - - FOR_EACH_VEC_ELT (fns, i, t) + for (tree t : fns) if (!evolution_function_is_invariant_p (t, loop_nest->num) && !evolution_function_is_affine_multivariate_p (t, loop_nest->num)) return false; @@ -5902,20 +5863,18 @@ opt_result find_data_references_in_stmt (class loop *nest, gimple *stmt, vec<data_reference_p> *datarefs) { - unsigned i; auto_vec<data_ref_loc, 2> references; - data_ref_loc *ref; data_reference_p dr; if (get_references_in_stmt (stmt, &references)) return opt_result::failure_at (stmt, "statement clobbers memory: %G", stmt); - FOR_EACH_VEC_ELT (references, i, ref) + for (const data_ref_loc &ref : references) { dr = create_data_ref (nest ? loop_preheader_edge (nest) : NULL, - loop_containing_stmt (stmt), ref->ref, - stmt, ref->is_read, ref->is_conditional_in_stmt); + loop_containing_stmt (stmt), ref.ref, + stmt, ref.is_read, ref.is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } @@ -5933,19 +5892,17 @@ bool graphite_find_data_references_in_stmt (edge nest, loop_p loop, gimple *stmt, vec<data_reference_p> *datarefs) { - unsigned i; auto_vec<data_ref_loc, 2> references; - data_ref_loc *ref; bool ret = true; data_reference_p dr; if (get_references_in_stmt (stmt, &references)) return false; - FOR_EACH_VEC_ELT (references, i, ref) + for (const data_ref_loc &ref : references) { - dr = create_data_ref (nest, loop, ref->ref, stmt, ref->is_read, - ref->is_conditional_in_stmt); + dr = create_data_ref (nest, loop, ref.ref, stmt, ref.is_read, + ref.is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } @@ -6253,10 +6210,7 @@ free_dependence_relation (struct data_dependence_relation *ddr) void free_dependence_relations (vec<ddr_p> dependence_relations) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (dependence_relations, i, ddr) + for (data_dependence_relation *ddr : dependence_relations) if (ddr) free_dependence_relation (ddr); @@ -6268,10 +6222,7 @@ free_dependence_relations (vec<ddr_p> dependence_relations) void free_data_refs (vec<data_reference_p> datarefs) { - unsigned int i; - struct data_reference *dr; - - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) free_data_ref (dr); datarefs.release (); } diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 9eb08d2..4a0dc3b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3260,13 +3260,10 @@ copy_debug_stmt (gdebug *stmt, copy_body_data *id) static void copy_debug_stmts (copy_body_data *id) { - size_t i; - gdebug *stmt; - if (!id->debug_stmts.exists ()) return; - FOR_EACH_VEC_ELT (id->debug_stmts, i, stmt) + for (gdebug *stmt : id->debug_stmts) copy_debug_stmt (stmt, id); id->debug_stmts.release (); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index 85adb1a..8045e34 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -1638,14 +1638,11 @@ debug_defs_stack (int n) void dump_currdefs (FILE *file) { - unsigned i; - tree var; - if (symbols_to_rename.is_empty ()) return; fprintf (file, "\n\nCurrent reaching definitions\n\n"); - FOR_EACH_VEC_ELT (symbols_to_rename, i, var) + for (tree var : symbols_to_rename) { common_info *info = get_common_info (var); fprintf (file, "CURRDEF ("); @@ -2069,18 +2066,16 @@ rewrite_update_phi_arguments (basic_block bb) { edge e; edge_iterator ei; - unsigned i; FOR_EACH_EDGE (e, ei, bb->succs) { - gphi *phi; vec<gphi *> phis; if (!bitmap_bit_p (blocks_with_phis_to_rewrite, e->dest->index)) continue; phis = phis_to_rewrite[e->dest->index]; - FOR_EACH_VEC_ELT (phis, i, phi) + for (gphi *phi : phis) { tree arg, lhs_sym, reaching_def = NULL; use_operand_p arg_p; diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index b3dcd43..d93ec90 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1258,8 +1258,6 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val) unsigned clean_up_loop_closed_phi (function *fun) { - unsigned i; - edge e; gphi *phi; tree rhs; tree lhs; @@ -1280,7 +1278,7 @@ clean_up_loop_closed_phi (function *fun) { /* Check each exit edege of loop. */ auto_vec<edge> exits = get_loop_exit_edges (loop); - FOR_EACH_VEC_ELT (exits, i, e) + for (edge e : exits) if (single_pred_p (e->dest)) /* Walk over loop-closed PHIs. */ for (gsi = gsi_start_phis (e->dest); !gsi_end_p (gsi);) diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index b317df5..2694d1a 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -290,9 +290,7 @@ vect_analyze_possibly_independent_ddr (data_dependence_relation *ddr, int loop_depth, unsigned int *max_vf) { class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); - lambda_vector dist_v; - unsigned int i; - FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), i, dist_v) + for (lambda_vector &dist_v : DDR_DIST_VECTS (ddr)) { int dist = dist_v[loop_depth]; if (dist != 0 && !(dist > 0 && DDR_REVERSED_P (ddr))) @@ -729,9 +727,8 @@ vect_slp_analyze_node_dependences (vec_info *vinfo, slp_tree node, { if (stmt_info != last_store_info) continue; - unsigned i; - stmt_vec_info store_info; - FOR_EACH_VEC_ELT (stores, i, store_info) + + for (stmt_vec_info &store_info : stores) { data_reference *store_dr = STMT_VINFO_DATA_REF (store_info); @@ -804,9 +801,8 @@ vect_slp_analyze_node_dependences (vec_info *vinfo, slp_tree node, { if (stmt_info != last_store_info) continue; - unsigned i; - stmt_vec_info store_info; - FOR_EACH_VEC_ELT (stores, i, store_info) + + for (stmt_vec_info &store_info : stores) { data_reference *store_dr = STMT_VINFO_DATA_REF (store_info); @@ -868,9 +864,7 @@ vect_slp_analyze_instance_dependence (vec_info *vinfo, slp_instance instance) /* Verify we can sink loads to the vectorized stmt insert location, special-casing stores of this instance. */ - slp_tree load; - unsigned int i; - FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, load) + for (slp_tree &load : SLP_INSTANCE_LOADS (instance)) if (! vect_slp_analyze_node_dependences (vinfo, load, store ? SLP_TREE_SCALAR_STMTS (store) @@ -927,9 +921,7 @@ vect_record_base_alignments (vec_info *vinfo) { loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo); class loop *loop = loop_vinfo ? LOOP_VINFO_LOOP (loop_vinfo) : NULL; - data_reference *dr; - unsigned int i; - FOR_EACH_VEC_ELT (vinfo->shared->datarefs, i, dr) + for (data_reference *dr : vinfo->shared->datarefs) { dr_vec_info *dr_info = vinfo->lookup_dr (dr); stmt_vec_info stmt_info = dr_info->stmt; @@ -1463,10 +1455,8 @@ vect_get_peeling_costs_all_drs (loop_vec_info loop_vinfo, bool unknown_misalignment) { vec<data_reference_p> datarefs = LOOP_VINFO_DATAREFS (loop_vinfo); - unsigned i; - data_reference *dr; - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) { dr_vec_info *dr_info = loop_vinfo->lookup_dr (dr); if (!vect_relevant_for_alignment_p (dr_info)) @@ -1575,13 +1565,11 @@ static bool vect_peeling_supportable (loop_vec_info loop_vinfo, dr_vec_info *dr0_info, unsigned npeel) { - unsigned i; - struct data_reference *dr = NULL; vec<data_reference_p> datarefs = LOOP_VINFO_DATAREFS (loop_vinfo); enum dr_alignment_support supportable_dr_alignment; /* Ensure that all data refs can be vectorized after the peel. */ - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) { int save_misalignment; diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 63ba594..9748043 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -469,10 +469,7 @@ vec_info::vec_info (vec_info::vec_kind kind_in, void *target_cost_data_in, vec_info::~vec_info () { - slp_instance instance; - unsigned int i; - - FOR_EACH_VEC_ELT (slp_instances, i, instance) + for (slp_instance &instance : slp_instances) vect_free_slp_instance (instance); destroy_cost_data (target_cost_data); @@ -739,9 +736,7 @@ vec_info::set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info, bool check_ro) void vec_info::free_stmt_vec_infos (void) { - unsigned int i; - stmt_vec_info info; - FOR_EACH_VEC_ELT (stmt_vec_infos, i, info) + for (stmt_vec_info &info : stmt_vec_infos) if (info != NULL) free_stmt_vec_info (info); stmt_vec_infos.release (); |