diff options
-rw-r--r-- | gcc/ChangeLog | 83 | ||||
-rw-r--r-- | gcc/cfg.c | 2 | ||||
-rw-r--r-- | gcc/cfgloop.c | 6 | ||||
-rw-r--r-- | gcc/cfgloop.h | 32 | ||||
-rw-r--r-- | gcc/cfgloopanal.c | 6 | ||||
-rw-r--r-- | gcc/cfgloopmanip.c | 12 | ||||
-rw-r--r-- | gcc/function.h | 17 | ||||
-rw-r--r-- | gcc/graph.c | 6 | ||||
-rw-r--r-- | gcc/graphite-clast-to-gimple.c | 2 | ||||
-rw-r--r-- | gcc/graphite-sese-to-poly.c | 7 | ||||
-rw-r--r-- | gcc/graphite.c | 2 | ||||
-rw-r--r-- | gcc/ira-build.c | 20 | ||||
-rw-r--r-- | gcc/ira-emit.c | 2 | ||||
-rw-r--r-- | gcc/loop-init.c | 16 | ||||
-rw-r--r-- | gcc/lto-streamer-in.c | 6 | ||||
-rw-r--r-- | gcc/lto-streamer-out.c | 6 | ||||
-rw-r--r-- | gcc/modulo-sched.c | 4 | ||||
-rw-r--r-- | gcc/predict.c | 6 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 25 | ||||
-rw-r--r-- | gcc/tree-chrec.c | 14 | ||||
-rw-r--r-- | gcc/tree-if-conv.c | 2 | ||||
-rw-r--r-- | gcc/tree-inline.c | 8 | ||||
-rw-r--r-- | gcc/tree-loop-distribution.c | 4 | ||||
-rw-r--r-- | gcc/tree-scalar-evolution.c | 6 | ||||
-rw-r--r-- | gcc/tree-scalar-evolution.h | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ch.c | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-im.c | 16 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-manip.c | 6 | ||||
-rw-r--r-- | gcc/tree-ssa-loop.c | 24 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 3 | ||||
-rw-r--r-- | gcc/tree-vectorizer.c | 4 |
31 files changed, 226 insertions, 125 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ed8f7197604..62248a6e258 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,86 @@ +2013-04-30 Richard Biener <rguenther@suse.de> + + * function.h (loops_for_fn): New inline function. + (set_loops_for_fn): Likewise. + * cfgloop.h (place_new_loop): Add struct function parameter. + (get_loop): Likewise. + (get_loops): Likewise. + (number_of_loops): Likewise. + (fel_next): Adjust. + (fel_init): Likewise. + * cfg.c (get_loop_copy): Adjust. + * cfgloop.c (flow_loops_dump): Likewise. + (record_loop_exits): Likewise. + (verify_loop_structure): Likewise. + * cfgloopanal.c (mark_irreducible_loops): Likewise. + (estimate_reg_pressure_cost): Likewise. + (mark_loop_exit_edges): Likewise. + * cfgloopmanip.c (place_new_loop): Likewise. + (add_loop): Likewise. + (duplicate_loop): Likewise. + * graph.c (draw_cfg_nodes): Likewise. + * graphite-clast-to-gimple.c (translate_clast_user): Likewise. + * graphite-sese-to-poly.c (build_scop_scattering): Likewise. + (extract_affine_chrec): Likewise. + (build_scop_iteration_domain): Likewise. + * graphite.c (graphite_initialize): Likewise. + * ira-build.c (create_loop_tree_nodes): Likewise. + (more_one_region_p): Likewise. + (rebuild_regno_allocno_maps): Likewise. + (mark_loops_for_removal): Likewise. + (mark_all_loops_for_removal): Likewise. + (remove_unnecessary_regions): Likewise. + (ira_build): Likewise. + * ira-emit.c (setup_entered_from_non_parent_p): Likewise. + * loop-init.c (fix_loop_structure): Likewise. + (gate_rtl_move_loop_invariants): Likewise. + (gate_rtl_unswitch): Likewise. + (gate_rtl_unroll_and_peel_loops): Likewise. + (rtl_doloop): Likewise. + * lto-streamer-in.c (input_cfg): Likewise. + * lto-streamer-out.c (output_cfg): Likewise. + * modulo-sched.c (sms_schedule): Likewise. + * predict.c (tree_estimate_probability): Likewise. + (tree_estimate_probability_driver): Likewise. + (estimate_loops): Likewise. + * tree-cfg.c (fixup_loop_arrays_after_move): Likewise. + (move_sese_region_to_fn): Likewise. + (debug_loop_num): Likewise. + * tree-chrec.c (chrec_evaluate): Likewise. + (hide_evolution_in_other_loops_than_loop): Likewise. + (chrec_component_in_loop_num): Likewise. + (reset_evolution_in_loop): Likewise. + (evolution_function_is_invariant_rec_p): Likewise. + * tree-if-conv.c (main_tree_if_conversion): Likewise. + * tree-inline.c (copy_loops): Likewise. + (copy_cfg_body): Likewise. + (tree_function_versioning): Likewise. + * tree-loop-distribution.c (rdg_flag_loop_exits): Likewise. + * tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop): + Likewise. + (add_to_evolution_1): Likewise. + (scev_const_prop): Likewise. + * tree-scalar-evolution.h (get_chrec_loop): Likewise. + * tree-ssa-loop-ch.c (copy_loop_headers): Likewise. + * tree-ssa-loop-im.c (analyze_memory_references): Likewise. + (tree_ssa_lim_initialize): Likewise. + * tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa): Likewise. + (verify_loop_closed_ssa): Likewise. + * tree-ssa-loop.c (tree_ssa_loop_init): Likewise. + (tree_ssa_loop_im): Likewise. + (tree_ssa_loop_unswitch): Likewise. + (tree_vectorize): Likewise. + (check_data_deps): Likewise. + (tree_ssa_loop_ivcanon): Likewise. + (tree_ssa_loop_bounds): Likewise. + (tree_complete_unroll): Likewise. + (tree_complete_unroll_inner): Likewise. + (tree_parallelize_loops): Likewise. + (tree_ssa_loop_prefetch): Likewise. + (tree_ssa_loop_ivopts): Likewise. + * tree-ssa.c (execute_update_addresses_taken): Liekwise. + * tree-vectorizer.c (vectorize_loops): Likewise. + 2013-04-29 Mike Frysinger <vapier@gentoo.org> * config/arm/bpabi.h (EABI_LINK_SPEC): Define. diff --git a/gcc/cfg.c b/gcc/cfg.c index 2bcd790d306..6405f93f429 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -1180,7 +1180,7 @@ get_loop_copy (struct loop *loop) key.index1 = loop->num; entry = loop_copy.find (&key); if (entry) - return get_loop (entry->index2); + return get_loop (cfun, entry->index2); else return NULL; } diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 28b63ae2f36..01287246c33 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -160,7 +160,7 @@ flow_loops_dump (FILE *file, void (*loop_dump_aux) (const struct loop *, FILE *, if (!current_loops || ! file) return; - fprintf (file, ";; %d loops found\n", number_of_loops ()); + fprintf (file, ";; %d loops found\n", number_of_loops (cfun)); FOR_EACH_LOOP (li, loop, LI_INCLUDE_ROOT) { @@ -1077,7 +1077,7 @@ record_loop_exits (void) loops_state_set (LOOPS_HAVE_RECORDED_EXITS); gcc_assert (current_loops->exits == NULL); - current_loops->exits = htab_create_ggc (2 * number_of_loops (), + current_loops->exits = htab_create_ggc (2 * number_of_loops (cfun), loop_exit_hash, loop_exit_eq, loop_exit_free); @@ -1324,7 +1324,7 @@ verify_loop_structure (void) struct loop *loop; int err = 0; edge e; - unsigned num = number_of_loops (); + unsigned num = number_of_loops (cfun); loop_iterator li; struct loop_exit *exit, *mexit; bool dom_available = dom_info_available_p (CDI_DOMINATORS); diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 5c38599cc6c..0f247996630 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -234,7 +234,7 @@ void rescan_loop_exit (edge, bool, bool); /* Loop data structure manipulation/querying. */ extern void flow_loop_tree_node_add (struct loop *, struct loop *); extern void flow_loop_tree_node_remove (struct loop *); -extern void place_new_loop (struct loop *); +extern void place_new_loop (struct function *, struct loop *); extern void add_loop (struct loop *, struct loop *); extern bool flow_loop_nested_p (const struct loop *, const struct loop *); extern bool flow_bb_inside_loop_p (const struct loop *, const_basic_block); @@ -436,12 +436,12 @@ simple_loop_desc (struct loop *loop) /* Accessors for the loop structures. */ -/* Returns the loop with index NUM from current_loops. */ +/* Returns the loop with index NUM from FNs loop tree. */ static inline struct loop * -get_loop (unsigned num) +get_loop (struct function *fn, unsigned num) { - return (*current_loops->larray)[num]; + return (*loops_for_fn (fn)->larray)[num]; } /* Returns the number of superloops of LOOP. */ @@ -482,27 +482,29 @@ loop_has_exit_edges (const struct loop *loop) return loop->exits->next->e != NULL; } -/* Returns the list of loops in current_loops. */ +/* Returns the list of loops in FN. */ -static inline vec<loop_p, va_gc> * -get_loops (void) +inline vec<loop_p, va_gc> * +get_loops (struct function *fn) { - if (!current_loops) + struct loops *loops = loops_for_fn (fn); + if (!loops) return NULL; - return current_loops->larray; + return loops->larray; } -/* Returns the number of loops in current_loops (including the removed +/* Returns the number of loops in FN (including the removed ones and the fake loop that forms the root of the loop tree). */ static inline unsigned -number_of_loops (void) +number_of_loops (struct function *fn) { - if (!current_loops) + struct loops *loops = loops_for_fn (fn); + if (!fn) return 0; - return vec_safe_length (current_loops->larray); + return vec_safe_length (loops->larray); } /* Returns true if state of the loops satisfies all properties @@ -563,7 +565,7 @@ fel_next (loop_iterator *li, loop_p *loop) while (li->to_visit.iterate (li->idx, &anum)) { li->idx++; - *loop = get_loop (anum); + *loop = get_loop (cfun, anum); if (*loop) return; } @@ -587,7 +589,7 @@ fel_init (loop_iterator *li, loop_p *loop, unsigned flags) return; } - li->to_visit.create (number_of_loops ()); + li->to_visit.create (number_of_loops (cfun)); mn = (flags & LI_INCLUDE_ROOT) ? 0 : 1; if (flags & LI_ONLY_INNERMOST) diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index b41701b8293..9300237c670 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -77,7 +77,7 @@ mark_irreducible_loops (void) int src, dest; unsigned depth; struct graph *g; - int num = number_of_loops (); + int num = number_of_loops (cfun); struct loop *cloop; bool irred_loop_found = false; int i; @@ -409,7 +409,7 @@ estimate_reg_pressure_cost (unsigned n_new, unsigned n_old, bool speed, if (optimize && (flag_ira_region == IRA_REGION_ALL || flag_ira_region == IRA_REGION_MIXED) - && number_of_loops () <= (unsigned) IRA_MAX_LOOPS_NUM) + && number_of_loops (cfun) <= (unsigned) IRA_MAX_LOOPS_NUM) /* IRA regional allocation deals with high register pressure better. So decrease the cost (to do more accurate the cost calculation for IRA, we need to know how many registers lives @@ -427,7 +427,7 @@ mark_loop_exit_edges (void) basic_block bb; edge e; - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return; FOR_EACH_BB (bb) diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index f2d6a3b7050..9581677da9f 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -408,13 +408,13 @@ remove_path (edge e) return true; } -/* Creates place for a new LOOP in loops structure. */ +/* Creates place for a new LOOP in loops structure of FN. */ void -place_new_loop (struct loop *loop) +place_new_loop (struct function *fn, struct loop *loop) { - loop->num = number_of_loops (); - vec_safe_push (current_loops->larray, loop); + loop->num = number_of_loops (fn); + vec_safe_push (loops_for_fn (fn)->larray, loop); } /* Given LOOP structure with filled header and latch, find the body of the @@ -431,7 +431,7 @@ add_loop (struct loop *loop, struct loop *outer) edge_iterator ei; /* Add it to loop structure. */ - place_new_loop (loop); + place_new_loop (cfun, loop); flow_loop_tree_node_add (outer, loop); /* Find its nodes. */ @@ -1010,7 +1010,7 @@ duplicate_loop (struct loop *loop, struct loop *target) { struct loop *cloop; cloop = alloc_loop (); - place_new_loop (cloop); + place_new_loop (cfun, cloop); copy_loop_info (loop, cloop); diff --git a/gcc/function.h b/gcc/function.h index 89d71e592dd..c0e42d3c39c 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -700,6 +700,23 @@ extern void push_cfun (struct function *new_cfun); extern void pop_cfun (void); extern void instantiate_decl_rtl (rtx x); +/* Return the loop tree of FN. */ + +inline struct loops * +loops_for_fn (struct function *fn) +{ + return fn->x_current_loops; +} + +/* Set the loop tree of FN to LOOPS. */ + +inline void +set_loops_for_fn (struct function *fn, struct loops *loops) +{ + gcc_checking_assert (fn->x_current_loops == NULL || loops == NULL); + fn->x_current_loops = loops; +} + /* For backward compatibility... eventually these should all go away. */ #define current_function_funcdef_no (cfun->funcdef_no) diff --git a/gcc/graph.c b/gcc/graph.c index 6aebb22afff..97930d0fabe 100644 --- a/gcc/graph.c +++ b/gcc/graph.c @@ -258,10 +258,8 @@ draw_cfg_nodes_for_loop (pretty_printer *pp, int funcdef_no, static void draw_cfg_nodes (pretty_printer *pp, struct function *fun) { - /* ??? This x_current_loops should be enapsulated. */ - if (fun->x_current_loops) - draw_cfg_nodes_for_loop (pp, fun->funcdef_no, - fun->x_current_loops->tree_root); + if (loops_for_fn (fun)) + draw_cfg_nodes_for_loop (pp, fun->funcdef_no, get_loop (fun, 0)); else draw_cfg_nodes_no_loops (pp, fun); } diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index dcf8b94eaa1..82cae2fe4b8 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -1094,7 +1094,7 @@ translate_clast_user (struct clast_user_stmt *stmt, edge next_e, if (GBB_BB (gbb) == ENTRY_BLOCK_PTR) return next_e; - nb_loops = number_of_loops (); + nb_loops = number_of_loops (cfun); iv_map.create (nb_loops); for (i = 0; i < nb_loops; i++) iv_map.quick_push (NULL_TREE); diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 34057e948da..c4c3eb40449 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -550,7 +550,7 @@ build_scop_scattering (scop_p scop) isl_space *dc = isl_set_get_space (scop->context); isl_aff *static_sched; - dc = isl_space_add_dims (dc, isl_dim_set, number_of_loops()); + dc = isl_space_add_dims (dc, isl_dim_set, number_of_loops (cfun)); static_sched = isl_aff_zero_on_domain (isl_local_space_from_space (dc)); /* We have to start schedules at 0 on the first component and @@ -590,8 +590,7 @@ extract_affine_chrec (scop_p s, tree e, __isl_take isl_space *space) isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e), isl_space_copy (space)); isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e), isl_space_copy (space)); isl_local_space *ls = isl_local_space_from_space (space); - unsigned pos = sese_loop_depth ((sese) s->region, - get_loop (CHREC_VARIABLE (e))) - 1; + unsigned pos = sese_loop_depth ((sese) s->region, get_chrec_loop (e)) - 1; isl_aff *loop = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1); isl_pw_aff *l = isl_pw_aff_from_aff (loop); @@ -1404,7 +1403,7 @@ build_scop_iteration_domain (scop_p scop) sese region = SCOP_REGION (scop); int i; poly_bb_p pbb; - int nb_loops = number_of_loops (); + int nb_loops = number_of_loops (cfun); isl_set **doms = XCNEWVEC (isl_set *, nb_loops); FOR_EACH_VEC_ELT (SESE_LOOP_NEST (region), i, loop) diff --git a/gcc/graphite.c b/gcc/graphite.c index 10d1dd510c9..f9536639412 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -198,7 +198,7 @@ print_graphite_statistics (FILE* file, vec<scop_p> scops) static bool graphite_initialize (isl_ctx *ctx) { - if (number_of_loops () <= 1 + if (number_of_loops (cfun) <= 1 /* FIXME: This limit on the number of basic blocks of a function should be removed when the SCOP detection is faster. */ || n_basic_blocks > PARAM_VALUE (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION)) diff --git a/gcc/ira-build.c b/gcc/ira-build.c index 70be92174a4..0e2fd0c5510 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -151,11 +151,11 @@ create_loop_tree_nodes (void) init_loop_tree_node (ira_loop_nodes, 0); return; } - ira_loop_nodes_count = number_of_loops (); + ira_loop_nodes_count = number_of_loops (cfun); ira_loop_nodes = ((struct ira_loop_tree_node *) ira_allocate (sizeof (struct ira_loop_tree_node) * ira_loop_nodes_count)); - FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) + FOR_EACH_VEC_SAFE_ELT (get_loops (cfun), i, loop) { if (loop_outer (loop) != NULL) { @@ -194,7 +194,7 @@ more_one_region_p (void) loop_p loop; if (current_loops != NULL) - FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) + FOR_EACH_VEC_SAFE_ELT (get_loops (cfun), i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL && ira_loop_tree_root != &ira_loop_nodes[i]) return true; @@ -379,7 +379,7 @@ rebuild_regno_allocno_maps (void) ira_assert (current_loops != NULL); max_regno = max_reg_num (); - FOR_EACH_VEC_SAFE_ELT (get_loops (), l, loop) + FOR_EACH_VEC_SAFE_ELT (get_loops (cfun), l, loop) if (ira_loop_nodes[l].regno_allocno_map != NULL) { ira_free (ira_loop_nodes[l].regno_allocno_map); @@ -2053,8 +2053,8 @@ mark_loops_for_removal (void) ira_assert (current_loops != NULL); sorted_loops = (ira_loop_tree_node_t *) ira_allocate (sizeof (ira_loop_tree_node_t) - * number_of_loops ()); - for (n = i = 0; vec_safe_iterate (get_loops (), i, &loop); i++) + * number_of_loops (cfun)); + for (n = i = 0; vec_safe_iterate (get_loops (cfun), i, &loop); i++) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) @@ -2098,7 +2098,7 @@ mark_all_loops_for_removal (void) loop_p loop; ira_assert (current_loops != NULL); - FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) + FOR_EACH_VEC_SAFE_ELT (get_loops (cfun), i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) @@ -2408,8 +2408,8 @@ remove_unnecessary_regions (bool all_p) mark_all_loops_for_removal (); else mark_loops_for_removal (); - children_vec.create(last_basic_block + number_of_loops ()); - removed_loop_vec.create(last_basic_block + number_of_loops ()); + children_vec.create(last_basic_block + number_of_loops (cfun)); + removed_loop_vec.create(last_basic_block + number_of_loops (cfun)); remove_uneccesary_loop_nodes_from_loop_tree (ira_loop_tree_root); children_vec.release (); if (all_p) @@ -3290,7 +3290,7 @@ ira_build (void) } } fprintf (ira_dump_file, " regions=%d, blocks=%d, points=%d\n", - current_loops == NULL ? 1 : number_of_loops (), + current_loops == NULL ? 1 : number_of_loops (cfun), n_basic_blocks, ira_max_point); fprintf (ira_dump_file, " allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\n", diff --git a/gcc/ira-emit.c b/gcc/ira-emit.c index c18391fc3e5..cdd694176aa 100644 --- a/gcc/ira-emit.c +++ b/gcc/ira-emit.c @@ -434,7 +434,7 @@ setup_entered_from_non_parent_p (void) loop_p loop; ira_assert (current_loops != NULL); - FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) + FOR_EACH_VEC_SAFE_ELT (get_loops (cfun), i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL) ira_loop_nodes[i].entered_from_non_parent_p = entered_from_non_parent_p (&ira_loop_nodes[i]); diff --git a/gcc/loop-init.c b/gcc/loop-init.c index 1f605c97606..65f9c6c9d4a 100644 --- a/gcc/loop-init.c +++ b/gcc/loop-init.c @@ -251,7 +251,7 @@ fix_loop_structure (bitmap changed_bbs) /* Remember the number of loops so we can return how many new loops flow_loops_find discovered. */ - old_nloops = number_of_loops (); + old_nloops = number_of_loops (cfun); /* Re-compute loop structure in-place. */ flow_loops_find (current_loops); @@ -269,10 +269,10 @@ fix_loop_structure (bitmap changed_bbs) } /* Finally free deleted loops. */ - FOR_EACH_VEC_ELT (*get_loops (), i, loop) + FOR_EACH_VEC_ELT (*get_loops (cfun), i, loop) if (loop && loop->header == NULL) { - (*get_loops ())[i] = NULL; + (*get_loops (cfun))[i] = NULL; flow_loop_free (loop); } @@ -287,7 +287,7 @@ fix_loop_structure (bitmap changed_bbs) timevar_pop (TV_LOOP_INIT); - return number_of_loops () - old_nloops; + return number_of_loops (cfun) - old_nloops; } /* Gate for the RTL loop superpass. The actual passes are subpasses. @@ -426,7 +426,7 @@ gate_rtl_move_loop_invariants (void) static unsigned int rtl_move_loop_invariants (void) { - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) move_loop_invariants (); return 0; } @@ -463,7 +463,7 @@ gate_rtl_unswitch (void) static unsigned int rtl_unswitch (void) { - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) unswitch_loops (); return 0; } @@ -499,7 +499,7 @@ gate_rtl_unroll_and_peel_loops (void) static unsigned int rtl_unroll_and_peel_loops (void) { - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) { int flags = 0; if (dump_file) @@ -553,7 +553,7 @@ static unsigned int rtl_doloop (void) { #ifdef HAVE_doloop_end - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) doloop_optimize_loops (); #endif return 0; diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 87158bf0b33..02889a99501 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -673,6 +673,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn, struct loops *loops = ggc_alloc_cleared_loops (); init_loops_structure (fn, loops, n_loops); + set_loops_for_fn (fn, loops); /* Input each loop and associate it with its loop header so flow_loops_find can rebuild the loop tree. */ @@ -686,7 +687,6 @@ input_cfg (struct lto_input_block *ib, struct function *fn, } struct loop *loop = alloc_loop (); - loop->num = loops->larray->length (); loop->header = BASIC_BLOCK_FOR_FUNCTION (fn, header_index); loop->header->loop_father = loop; @@ -705,7 +705,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn, loop->nb_iterations_estimate.high = streamer_read_hwi (ib); } - loops->larray->quick_push (loop); + place_new_loop (fn, loop); /* flow_loops_find doesn't like loops not in the tree, hook them all as siblings of the tree root temporarily. */ @@ -713,7 +713,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn, } /* Rebuild the loop tree. */ - fn->x_current_loops = flow_loops_find (loops); + flow_loops_find (loops); } diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 110cc3e580a..dfaf2806b74 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -664,12 +664,12 @@ output_cfg (struct output_block *ob, struct function *fn) gcc_assert (cfun == fn); /* Output the number of loops. */ - streamer_write_uhwi (ob, number_of_loops ()); + streamer_write_uhwi (ob, number_of_loops (fn)); /* Output each loop, skipping the tree root which has number zero. */ - for (unsigned i = 1; i < number_of_loops (); ++i) + for (unsigned i = 1; i < number_of_loops (fn); ++i) { - struct loop *loop = get_loop (i); + struct loop *loop = get_loop (fn, i); /* Write the index of the loop header. That's enough to rebuild the loop tree on the reader side. Stream -1 for an unused diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index 6ce79a96f6e..1e9b16c6fcb 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -1360,7 +1360,7 @@ sms_schedule (void) loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_RECORDED_EXITS); - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) { loop_optimizer_finalize (); return; /* There are no loops to schedule. */ @@ -1384,7 +1384,7 @@ sms_schedule (void) /* Allocate memory to hold the DDG array one entry for each loop. We use loop->num as index into this array. */ - g_arr = XCNEWVEC (ddg_ptr, number_of_loops ()); + g_arr = XCNEWVEC (ddg_ptr, number_of_loops (cfun)); if (dump_file) { diff --git a/gcc/predict.c b/gcc/predict.c index b6786f7c516..9a15c87dac9 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -2338,7 +2338,7 @@ tree_estimate_probability (void) tree_bb_level_predictions (); record_loop_exits (); - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) predict_loops (); FOR_EACH_BB (bb) @@ -2372,7 +2372,7 @@ tree_estimate_probability_driver (void) mark_irreducible_loops (); - nb_loops = number_of_loops (); + nb_loops = number_of_loops (cfun); if (nb_loops > 1) scev_initialize (); @@ -2694,7 +2694,7 @@ estimate_loops (void) basic_block bb; /* Start by estimating the frequencies in the loops. */ - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) estimate_loops_at_level (current_loops->tree_root->inner); /* Now propagate the frequencies through all the blocks. */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 9b00248ece6..798a2f74057 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6586,11 +6586,11 @@ fixup_loop_arrays_after_move (struct function *fn1, struct function *fn2, struct loop *loop) { /* Discard it from the old loop array. */ - (*fn1->x_current_loops->larray)[loop->num] = NULL; + (*get_loops (fn1))[loop->num] = NULL; /* Place it in the new loop array, assigning it a new number. */ - loop->num = vec_safe_length (fn2->x_current_loops->larray); - vec_safe_push (fn2->x_current_loops->larray, loop); + loop->num = number_of_loops (fn2); + vec_safe_push (loops_for_fn (fn2)->larray, loop); /* Recurse to children. */ for (loop = loop->inner; loop; loop = loop->next) @@ -6717,9 +6717,10 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, } /* Initialize an empty loop tree. */ - dest_cfun->x_current_loops = ggc_alloc_cleared_loops (); - init_loops_structure (dest_cfun, dest_cfun->x_current_loops, 1); - dest_cfun->x_current_loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES; + struct loops *loops = ggc_alloc_cleared_loops (); + init_loops_structure (dest_cfun, loops, 1); + loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES; + set_loops_for_fn (dest_cfun, loops); /* Move the outlined loop tree part. */ FOR_EACH_VEC_ELT (bbs, i, bb) @@ -6729,25 +6730,25 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, { struct loop *loop = bb->loop_father; flow_loop_tree_node_remove (bb->loop_father); - flow_loop_tree_node_add (dest_cfun->x_current_loops->tree_root, loop); + flow_loop_tree_node_add (get_loop (dest_cfun, 0), loop); fixup_loop_arrays_after_move (saved_cfun, cfun, loop); } /* Remove loop exits from the outlined region. */ - if (saved_cfun->x_current_loops->exits) + if (loops_for_fn (saved_cfun)->exits) FOR_EACH_EDGE (e, ei, bb->succs) { void **slot = htab_find_slot_with_hash - (saved_cfun->x_current_loops->exits, e, + (loops_for_fn (saved_cfun)->exits, e, htab_hash_pointer (e), NO_INSERT); if (slot) - htab_clear_slot (saved_cfun->x_current_loops->exits, slot); + htab_clear_slot (loops_for_fn (saved_cfun)->exits, slot); } } /* Adjust the number of blocks in the tree root of the outlined part. */ - dest_cfun->x_current_loops->tree_root->num_nodes = bbs.length () + 2; + get_loop (dest_cfun, 0)->num_nodes = bbs.length () + 2; /* Setup a mapping to be used by move_block_to_fn. */ loop->aux = current_loops->tree_root; @@ -7226,7 +7227,7 @@ debug_loop (struct loop *loop, int verbosity) DEBUG_FUNCTION void debug_loop_num (unsigned num, int verbosity) { - debug_loop (get_loop (num), verbosity); + debug_loop (get_loop (cfun, num), verbosity); } /* Return true if BB ends with a call, possibly followed by some diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index ca31a9d065c..c18ccd3f933 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -517,7 +517,7 @@ chrec_evaluate (unsigned var, tree chrec, tree n, unsigned int k) { tree arg0, arg1, binomial_n_k; tree type = TREE_TYPE (chrec); - struct loop *var_loop = get_loop (var); + struct loop *var_loop = get_loop (cfun, var); while (TREE_CODE (chrec) == POLYNOMIAL_CHREC && flow_loop_nested_p (var_loop, get_chrec_loop (chrec))) @@ -690,7 +690,7 @@ tree hide_evolution_in_other_loops_than_loop (tree chrec, unsigned loop_num) { - struct loop *loop = get_loop (loop_num), *chloop; + struct loop *loop = get_loop (cfun, loop_num), *chloop; if (automatically_generated_chrec_p (chrec)) return chrec; @@ -731,7 +731,7 @@ chrec_component_in_loop_num (tree chrec, bool right) { tree component; - struct loop *loop = get_loop (loop_num), *chloop; + struct loop *loop = get_loop (cfun, loop_num), *chloop; if (automatically_generated_chrec_p (chrec)) return chrec; @@ -813,7 +813,7 @@ reset_evolution_in_loop (unsigned loop_num, tree chrec, tree new_evol) { - struct loop *loop = get_loop (loop_num); + struct loop *loop = get_loop (cfun, loop_num); if (POINTER_TYPE_P (chrec_type (chrec))) gcc_assert (ptrofftype_p (chrec_type (new_evol))); @@ -986,14 +986,14 @@ evolution_function_is_invariant_rec_p (tree chrec, int loopnum) if (TREE_CODE (chrec) == SSA_NAME && (loopnum == 0 - || expr_invariant_in_loop_p (get_loop (loopnum), chrec))) + || expr_invariant_in_loop_p (get_loop (cfun, loopnum), chrec))) return true; if (TREE_CODE (chrec) == POLYNOMIAL_CHREC) { if (CHREC_VARIABLE (chrec) == (unsigned) loopnum - || flow_loop_nested_p (get_loop (loopnum), - get_loop (CHREC_VARIABLE (chrec))) + || flow_loop_nested_p (get_loop (cfun, loopnum), + get_chrec_loop (chrec)) || !evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec), loopnum) || !evolution_function_is_invariant_rec_p (CHREC_LEFT (chrec), diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 95d0394fc51..0ebb8c36cea 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1818,7 +1818,7 @@ main_tree_if_conversion (void) bool changed = false; unsigned todo = 0; - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; FOR_EACH_LOOP (li, loop, 0) diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 35cdb787538..3abaadc5d2e 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2223,7 +2223,7 @@ copy_loops (bitmap blocks_to_copy, copy_loop_info (src_loop, dest_loop); /* Finally place it into the loop array and the loop tree. */ - place_new_loop (dest_loop); + place_new_loop (cfun, dest_loop); flow_loop_tree_node_add (dest_parent, dest_loop); /* Recurse. */ @@ -2332,11 +2332,11 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale, } /* Duplicate the loop tree, if available and wanted. */ - if (id->src_cfun->x_current_loops != NULL + if (loops_for_fn (src_cfun) != NULL && current_loops != NULL) { copy_loops (blocks_to_copy, entry_block_map->loop_father, - id->src_cfun->x_current_loops->tree_root); + get_loop (src_cfun, 0)); /* Defer to cfgcleanup to update loop-father fields of basic-blocks. */ loops_state_set (LOOPS_NEED_FIXUP); } @@ -5199,7 +5199,7 @@ tree_function_versioning (tree old_decl, tree new_decl, } /* Set up the destination functions loop tree. */ - if (DECL_STRUCT_FUNCTION (old_decl)->x_current_loops) + if (loops_for_fn (DECL_STRUCT_FUNCTION (old_decl)) != NULL) { cfun->curr_properties &= ~PROP_loops; loop_optimizer_init (AVOID_CFG_MODIFICATIONS); diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 5c2c7db4400..13b78cc37d2 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -774,7 +774,7 @@ rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition, conds.create (3); EXECUTE_IF_SET_IN_BITMAP (loops, 0, i, bi) - collect_condition_stmts (get_loop (i), &conds); + collect_condition_stmts (get_loop (cfun, i), &conds); while (!conds.is_empty ()) { @@ -787,7 +787,7 @@ rdg_flag_loop_exits (struct graph *rdg, bitmap loops, partition_t partition, EXECUTE_IF_SET_IN_BITMAP (new_loops, 0, i, bi) if (bitmap_set_bit (loops, i)) - collect_condition_stmts (get_loop (i), &conds); + collect_condition_stmts (get_loop (cfun, i), &conds); BITMAP_FREE (new_loops); } diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index d5dde5fedb7..f68cd7f4124 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -422,7 +422,7 @@ chrec_contains_symbols_defined_in_loop (const_tree chrec, unsigned loop_nb) def = SSA_NAME_DEF_STMT (chrec); def_loop = loop_containing_stmt (def); - loop = get_loop (loop_nb); + loop = get_loop (cfun, loop_nb); if (def_loop == NULL) return false; @@ -629,7 +629,7 @@ add_to_evolution_1 (unsigned loop_nb, tree chrec_before, tree to_add, gimple at_stmt) { tree type, left, right; - struct loop *loop = get_loop (loop_nb), *chloop; + struct loop *loop = get_loop (cfun, loop_nb), *chloop; switch (TREE_CODE (chrec_before)) { @@ -3258,7 +3258,7 @@ scev_const_prop (void) loop_iterator li; gimple_stmt_iterator psi; - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; FOR_EACH_BB (bb) diff --git a/gcc/tree-scalar-evolution.h b/gcc/tree-scalar-evolution.h index 7e7f6f23833..55ba82c5dbd 100644 --- a/gcc/tree-scalar-evolution.h +++ b/gcc/tree-scalar-evolution.h @@ -64,7 +64,7 @@ instantiate_parameters (struct loop *loop, tree chrec) static inline struct loop * get_chrec_loop (const_tree chrec) { - return get_loop (CHREC_VARIABLE (chrec)); + return get_loop (cfun, CHREC_VARIABLE (chrec)); } #endif /* GCC_TREE_SCALAR_EVOLUTION_H */ diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index b8dd1a361a9..a1d02997eda 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -136,7 +136,7 @@ copy_loop_headers (void) loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES); - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) { loop_optimizer_finalize (); return 0; diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 90e4d361e2f..e5e502b2901 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -1593,7 +1593,7 @@ analyze_memory_references (void) /* Initialize bb_loop_postorder with a mapping from loop->num to its postorder index. */ i = 0; - bb_loop_postorder = XNEWVEC (unsigned, number_of_loops ()); + bb_loop_postorder = XNEWVEC (unsigned, number_of_loops (cfun)); FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST) bb_loop_postorder[loop->num] = i++; /* Collect all basic-blocks in loops and sort them after their @@ -2563,14 +2563,14 @@ tree_ssa_lim_initialize (void) memory_accesses.refs_list.quick_push (mem_ref_alloc (error_mark_node, 0, UNANALYZABLE_MEM_ID)); - memory_accesses.refs_in_loop.create (number_of_loops ()); - memory_accesses.refs_in_loop.quick_grow (number_of_loops ()); - memory_accesses.refs_stored_in_loop.create (number_of_loops ()); - memory_accesses.refs_stored_in_loop.quick_grow (number_of_loops ()); - memory_accesses.all_refs_stored_in_loop.create (number_of_loops ()); - memory_accesses.all_refs_stored_in_loop.quick_grow (number_of_loops ()); + memory_accesses.refs_in_loop.create (number_of_loops (cfun)); + memory_accesses.refs_in_loop.quick_grow (number_of_loops (cfun)); + memory_accesses.refs_stored_in_loop.create (number_of_loops (cfun)); + memory_accesses.refs_stored_in_loop.quick_grow (number_of_loops (cfun)); + memory_accesses.all_refs_stored_in_loop.create (number_of_loops (cfun)); + memory_accesses.all_refs_stored_in_loop.quick_grow (number_of_loops (cfun)); - for (i = 0; i < number_of_loops (); i++) + for (i = 0; i < number_of_loops (cfun); i++) { bitmap_initialize (&memory_accesses.refs_in_loop[i], &lim_bitmap_obstack); diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index 7101f30d4e6..edc5b7b5fdd 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -493,7 +493,7 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag) bitmap names_to_rename; loops_state_set (LOOP_CLOSED_SSA); - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return; /* If the pass has caused the SSA form to be out-of-date, update it @@ -516,7 +516,7 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag) { /* An array of bitmaps where LOOP_EXITS[I] is the set of basic blocks that are the destination of an edge exiting loop number I. */ - bitmap *loop_exits = XNEWVEC (bitmap, number_of_loops ()); + bitmap *loop_exits = XNEWVEC (bitmap, number_of_loops (cfun)); get_loops_exits (loop_exits); /* Add the PHI nodes on exits of the loops for the names we need to @@ -578,7 +578,7 @@ verify_loop_closed_ssa (bool verify_ssa_p) edge e; edge_iterator ei; - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return; if (verify_ssa_p) diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index ae5b500d1ca..99e27a1359a 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -74,7 +74,7 @@ tree_ssa_loop_init (void) regions into reducible. */ scev_initialize (); - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return 0; @@ -105,7 +105,7 @@ struct gimple_opt_pass pass_tree_loop_init = static unsigned int tree_ssa_loop_im (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return tree_ssa_lim (); @@ -142,7 +142,7 @@ struct gimple_opt_pass pass_lim = static unsigned int tree_ssa_loop_unswitch (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return tree_ssa_unswitch_loops (); @@ -216,7 +216,7 @@ struct gimple_opt_pass pass_predcom = static unsigned int tree_vectorize (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return vectorize_loops (); @@ -323,7 +323,7 @@ struct gimple_opt_pass pass_graphite_transforms = static unsigned int check_data_deps (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; tree_check_data_deps (); @@ -361,7 +361,7 @@ struct gimple_opt_pass pass_check_data_deps = static unsigned int tree_ssa_loop_ivcanon (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return canonicalize_induction_variables (); @@ -428,7 +428,7 @@ struct gimple_opt_pass pass_scev_cprop = static unsigned int tree_ssa_loop_bounds (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; estimate_numbers_of_iterations (); @@ -461,7 +461,7 @@ struct gimple_opt_pass pass_record_bounds = static unsigned int tree_complete_unroll (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return tree_unroll_loops_completely (flag_unroll_loops @@ -504,7 +504,7 @@ tree_complete_unroll_inner (void) loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); - if (number_of_loops () > 1) + if (number_of_loops (cfun) > 1) { scev_initialize (); ret = tree_unroll_loops_completely (optimize >= 3, false); @@ -553,7 +553,7 @@ gate_tree_parallelize_loops (void) static unsigned tree_parallelize_loops (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; if (parallelize_loops ()) @@ -586,7 +586,7 @@ struct gimple_opt_pass pass_parallelize_loops = static unsigned int tree_ssa_loop_prefetch (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; return tree_ssa_prefetch_arrays (); @@ -623,7 +623,7 @@ struct gimple_opt_pass pass_loop_prefetch = static unsigned int tree_ssa_loop_ivopts (void) { - if (number_of_loops () <= 1) + if (number_of_loops (cfun) <= 1) return 0; tree_ssa_iv_optimize (); diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 15a91766892..215206743e8 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -2117,7 +2117,8 @@ execute_update_addresses_taken (void) } /* Update SSA form here, we are called as non-pass as well. */ - if (number_of_loops () > 1 && loops_state_satisfies_p (LOOP_CLOSED_SSA)) + if (number_of_loops (cfun) > 1 + && loops_state_satisfies_p (LOOP_CLOSED_SSA)) rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); else update_ssa (TODO_update_ssa); diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 0227d08c9f0..843a03ca85c 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -87,7 +87,7 @@ vectorize_loops (void) loop_iterator li; struct loop *loop; - vect_loops_num = number_of_loops (); + vect_loops_num = number_of_loops (cfun); /* Bail out if there are no loops. */ if (vect_loops_num <= 1) @@ -139,7 +139,7 @@ vectorize_loops (void) { loop_vec_info loop_vinfo; - loop = get_loop (i); + loop = get_loop (cfun, i); if (!loop) continue; loop_vinfo = (loop_vec_info) loop->aux; |