On Thu, 7 Feb 2013, Vladimir Makarov wrote: > On 02/07/2013 09:56 AM, Richard Biener wrote: > > The following gets rid of ira_loops (ok, without touching all uses > > yet but with a #define - I'll finish this if you are ok with it > > in general). > > > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > > > Ok for trunk for the IRA parts? (well, given I search & replace > > uses of ira_loops) > > > > > IRA parts are ok for me. Thanks, Richard.
Ok, I'll re-test the following complete transition then: ira_loops.larray -> get_loops () vec_safe_length (ira_loops.larray) -> number_of_loops () Richard. 2013-02-07 Richard Biener <rguent...@suse.de> * cfgloop.c (verify_loop_structure): Properly handle a loop exiting to another loop header. * ira-int.h (ira_loops): Remove. * ira.c (ira_loops): Remove. (ira): Use loop_optimizer_init and loop_optimizer_finalize. (do_reload): Use loop_optimizer_finalize. * ira-build.c (create_loop_tree_nodes): Use get_loops and number_of_loops to access the loop tree. (more_one_region_p): Likewise. (finish_loop_tree_nodes): 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. Index: gcc/cfgloop.c =================================================================== *** gcc/cfgloop.c.orig 2013-02-07 16:44:11.000000000 +0100 --- gcc/cfgloop.c 2013-02-07 16:48:47.840820001 +0100 *************** verify_loop_structure (void) *** 1550,1556 **** eloops++; for (loop = bb->loop_father; ! loop != e->dest->loop_father; loop = loop_outer (loop)) { eloops--; --- 1550,1561 ---- eloops++; for (loop = bb->loop_father; ! loop != e->dest->loop_father ! /* When a loop exit is also an entry edge which ! can happen when avoiding CFG manipulations ! then the last loop exited is the outer loop ! of the loop entered. */ ! && loop != loop_outer (e->dest->loop_father); loop = loop_outer (loop)) { eloops--; Index: gcc/ira-int.h =================================================================== *** gcc/ira-int.h.orig 2013-02-07 16:13:56.000000000 +0100 --- gcc/ira-int.h 2013-02-07 16:44:56.825055085 +0100 *************** along with GCC; see the file COPYING3. *** 47,55 **** ? REG_FREQ_MAX : (freq * REG_FREQ_MAX / BB_FREQ_MAX) \ ? (freq * REG_FREQ_MAX / BB_FREQ_MAX) : 1) - /* All natural loops. */ - extern struct loops ira_loops; - /* A modified value of flag `-fira-verbose' used internally. */ extern int internal_flag_ira_verbose; --- 47,52 ---- Index: gcc/ira.c =================================================================== *** gcc/ira.c.orig 2013-02-07 16:44:11.000000000 +0100 --- gcc/ira.c 2013-02-07 16:44:51.685993626 +0100 *************** allocate_initial_values (void) *** 4338,4346 **** function. */ bool ira_use_lra_p; - /* All natural loops. */ - struct loops ira_loops; - /* True if we have allocno conflicts. It is false for non-optimized mode or when the conflict table is too big. */ bool ira_conflicts_p; --- 4338,4343 ---- *************** ira (FILE *f) *** 4464,4474 **** ira_assert (current_loops == NULL); if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == IRA_REGION_MIXED) ! { ! flow_loops_find (&ira_loops); ! current_loops = &ira_loops; ! record_loop_exits (); ! } if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) fprintf (ira_dump_file, "Building IRA IR\n"); --- 4461,4467 ---- ira_assert (current_loops == NULL); if (flag_ira_region == IRA_REGION_ALL || flag_ira_region == IRA_REGION_MIXED) ! loop_optimizer_init (AVOID_CFG_MODIFICATIONS | LOOPS_HAVE_RECORDED_EXITS); if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) fprintf (ira_dump_file, "Building IRA IR\n"); *************** ira (FILE *f) *** 4526,4536 **** /* ??? Rebuild the loop tree, but why? Does the loop tree change if new insns were generated? Can that be handled by updating the loop tree incrementally? */ ! release_recorded_exits (); ! flow_loops_free (&ira_loops); ! flow_loops_find (&ira_loops); ! current_loops = &ira_loops; ! record_loop_exits (); if (! ira_use_lra_p) { --- 4519,4527 ---- /* ??? Rebuild the loop tree, but why? Does the loop tree change if new insns were generated? Can that be handled by updating the loop tree incrementally? */ ! loop_optimizer_finalize (); ! loop_optimizer_init (AVOID_CFG_MODIFICATIONS ! | LOOPS_HAVE_RECORDED_EXITS); if (! ira_use_lra_p) { *************** do_reload (void) *** 4607,4614 **** { if (current_loops != NULL) { ! release_recorded_exits (); ! flow_loops_free (&ira_loops); free_dominance_info (CDI_DOMINATORS); } FOR_ALL_BB (bb) --- 4598,4604 ---- { if (current_loops != NULL) { ! loop_optimizer_finalize (); free_dominance_info (CDI_DOMINATORS); } FOR_ALL_BB (bb) *************** do_reload (void) *** 4657,4664 **** ira_destroy (); if (current_loops != NULL) { ! release_recorded_exits (); ! flow_loops_free (&ira_loops); free_dominance_info (CDI_DOMINATORS); } FOR_ALL_BB (bb) --- 4647,4653 ---- ira_destroy (); if (current_loops != NULL) { ! loop_optimizer_finalize (); free_dominance_info (CDI_DOMINATORS); } FOR_ALL_BB (bb) Index: gcc/ira-build.c =================================================================== *** gcc/ira-build.c.orig 2013-02-07 15:23:45.000000000 +0100 --- gcc/ira-build.c 2013-02-07 16:47:31.335904018 +0100 *************** create_loop_tree_nodes (void) *** 149,158 **** } ira_loop_nodes = ((struct ira_loop_tree_node *) ira_allocate (sizeof (struct ira_loop_tree_node) ! * vec_safe_length (ira_loops.larray))); ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, i, loop) { ! if (loop != ira_loops.tree_root) { ira_loop_nodes[i].regno_allocno_map = NULL; skip_p = false; --- 149,158 ---- } ira_loop_nodes = ((struct ira_loop_tree_node *) ira_allocate (sizeof (struct ira_loop_tree_node) ! * number_of_loops ())); ! FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) { ! if (loop_outer (loop) != NULL) { ira_loop_nodes[i].regno_allocno_map = NULL; skip_p = false; *************** more_one_region_p (void) *** 189,195 **** loop_p loop; if (current_loops != NULL) ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL && ira_loop_tree_root != &ira_loop_nodes[i]) return true; --- 189,195 ---- loop_p loop; if (current_loops != NULL) ! FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL && ira_loop_tree_root != &ira_loop_nodes[i]) return true; *************** finish_loop_tree_nodes (void) *** 222,228 **** if (current_loops == NULL) finish_loop_tree_node (&ira_loop_nodes[0]); else ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, i, loop) finish_loop_tree_node (&ira_loop_nodes[i]); ira_free (ira_loop_nodes); for (i = 0; i < (unsigned int) last_basic_block_before_change; i++) --- 222,228 ---- if (current_loops == NULL) finish_loop_tree_node (&ira_loop_nodes[0]); else ! FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) finish_loop_tree_node (&ira_loop_nodes[i]); ira_free (ira_loop_nodes); for (i = 0; i < (unsigned int) last_basic_block_before_change; i++) *************** rebuild_regno_allocno_maps (void) *** 378,384 **** ira_assert (current_loops != NULL); max_regno = max_reg_num (); ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, l, loop) if (ira_loop_nodes[l].regno_allocno_map != NULL) { ira_free (ira_loop_nodes[l].regno_allocno_map); --- 378,384 ---- ira_assert (current_loops != NULL); max_regno = max_reg_num (); ! FOR_EACH_VEC_SAFE_ELT (get_loops (), l, loop) if (ira_loop_nodes[l].regno_allocno_map != NULL) { ira_free (ira_loop_nodes[l].regno_allocno_map); *************** mark_loops_for_removal (void) *** 2021,2028 **** ira_assert (current_loops != NULL); sorted_loops = (ira_loop_tree_node_t *) ira_allocate (sizeof (ira_loop_tree_node_t) ! * vec_safe_length (ira_loops.larray)); ! for (n = i = 0; vec_safe_iterate (ira_loops.larray, i, &loop); i++) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) --- 2021,2028 ---- 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++) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) *************** mark_all_loops_for_removal (void) *** 2066,2072 **** loop_p loop; ira_assert (current_loops != NULL); ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) --- 2066,2072 ---- loop_p loop; ira_assert (current_loops != NULL); ! FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop) if (ira_loop_nodes[i].regno_allocno_map != NULL) { if (ira_loop_nodes[i].parent == NULL) *************** remove_unnecessary_regions (bool all_p) *** 2376,2383 **** mark_all_loops_for_removal (); else mark_loops_for_removal (); ! children_vec.create(last_basic_block + vec_safe_length(ira_loops.larray)); ! removed_loop_vec.create(last_basic_block + vec_safe_length(ira_loops.larray)); remove_uneccesary_loop_nodes_from_loop_tree (ira_loop_tree_root); children_vec.release (); if (all_p) --- 2376,2383 ---- 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 ()); remove_uneccesary_loop_nodes_from_loop_tree (ira_loop_tree_root); children_vec.release (); if (all_p) *************** ira_build (void) *** 3258,3264 **** } } fprintf (ira_dump_file, " regions=%d, blocks=%d, points=%d\n", ! current_loops == NULL ? 1 : vec_safe_length (ira_loops.larray), n_basic_blocks, ira_max_point); fprintf (ira_dump_file, " allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\n", --- 3258,3264 ---- } } fprintf (ira_dump_file, " regions=%d, blocks=%d, points=%d\n", ! current_loops == NULL ? 1 : number_of_loops (), n_basic_blocks, ira_max_point); fprintf (ira_dump_file, " allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\n", Index: gcc/ira-emit.c =================================================================== *** gcc/ira-emit.c.orig 2013-02-07 15:23:45.000000000 +0100 --- gcc/ira-emit.c 2013-02-07 16:45:49.585686190 +0100 *************** setup_entered_from_non_parent_p (void) *** 434,440 **** loop_p loop; ira_assert (current_loops != NULL); ! FOR_EACH_VEC_SAFE_ELT (ira_loops.larray, 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]); --- 434,440 ---- loop_p loop; ira_assert (current_loops != NULL); ! FOR_EACH_VEC_SAFE_ELT (get_loops (), 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]);