diff options
author | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-10 22:17:15 +0000 |
---|---|---|
committer | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-10 22:17:15 +0000 |
commit | 17519ba0dc05161d1dd4fba308eee373e9a9841b (patch) | |
tree | 879533af06a5f9434bb047870e2878e104446c23 /gcc/cfgloop.c | |
parent | 2d043327e6bf9c316751af014a81548f08284a7b (diff) | |
download | gcc-17519ba0dc05161d1dd4fba308eee373e9a9841b.tar.gz |
* tree-vrp.c (adjust_range_with_scev): Use get_chrec_loop.
* loop-unswitch.c (unswitch_loops): Use FOR_EACH_LOOP.
* tree-loop-linear.c (linear_transform_loops): Ditto.
* tree-ssa-loop-im.c (determine_lsm): Ditto.
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations,
free_numbers_of_iterations_estimates): Ditto.
* tree_ssa_unswitch_loops (tree_ssa_unswitch_loops): Ditto.
* tree-ssa-loop-ch.c (copy_loop_headers): Ditto.
* tree-ssa-loop-ivopts.c (tree_ssa_iv_optimize): Ditto.
* modulo-sched.c (sms_schedule): Ditto.
* tree-ssa-loop-ivcanon.c (canonicalize_induction_variables,
tree_unroll_loops_completely): Ditto.
* predict.c (predict_loops): Ditto.
* tree-if-conv.c (main_tree_if_conversion): Ditto.
* loop-unroll.c (unroll_and_peel_loops, peel_loops_completely,
decide_unrolling_and_peeling): Ditto.
* cfgloopmanip.c (unloop): Use delete_loop.
(place_new_loop): Access larray vector instead of parray.
(create_preheaders, force_single_succ_latches,
fix_loop_structure): Use FOR_EACH_LOOP and delete_loop..
* loop-doloop.c (doloop_optimize_loops): Ditto.
* loop-invariant.c (move_loop_invariants): Ditto.
* tree-cfg.c (replace_uses_by): Ditto.
* tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Ditto.
* tree-chrec.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
Moved to ...
* tree.h (CHREC_VAR, CHREC_LEFT, CHREC_RIGHT, CHREC_VARIABLE):
... here.
* tree-scalar-evolution.c (chrec_contains_symbols_defined_in_loop,
compute_overall_effect_of_inner_loop, chrec_is_positive): Use
get_loop and get_chrec_loop.
(number_of_iterations_for_all_loops): Use number_of_loops.
(scev_initialize, scev_reset, scev_const_prop): Use FOR_EACH_LOOP.
* tree-scalar-evolution.h (get_chrec_loop): New inline function.
* cfgloopanal.c (mark_irreducible_loops): Use number_of_loops,
and FOR_EACH_LOOP.
* tree-chrec.c (evolution_function_is_invariant_rec_p,
chrec_convert_1): Use get_loop and get_chrec_loop.
* loop-init.c (loop_optimizer_init): Use number_of_loops.
(loop_optimizer_init): Use FOR_EACH_LOOP.
* tree-vectorizer.c (vect_loops_num): Removed.
(vectorize_loops): Store number of loops locally. Use
FOR_EACH_LOOP and get_loop.
* tree-vectorizer.h (vect_loops_num): Removed.
* tree-data-ref.c (get_number_of_iters_for_loop): Use get_loop.
(find_data_references_in_loop): Do not set parallel_p.
* tree-data-ref.h: Do not declare VEC(loop_p).
* cfgloop.c (flow_loops_dump, mark_single_exit_loops,
verify_loop_structure): Use FOR_EACH_LOOP.
(flow_loops_free): Use FOR_EACH_LOOP, free larray vector.
(initialize_loops_parallel_p): Removed.
(flow_loops_find): Push the loops into a vector.
(delete_loop): New function.
(cancel_loop): Use delete_loop.
* cfgloop.h: Declare VEC(loop_p).
(struct loop): Remove parallel_p field.
(struct loops): Replace num and parray field by larray vector.
Remove shared_headers field.
(delete_loop): Declare.
(get_loop, get_loops, number_of_loops, fel_next, fel_init,
FOR_EACH_LOOP): New.
* doc/loop.tex: Document new accessor functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119713 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloop.c')
-rw-r--r-- | gcc/cfgloop.c | 145 |
1 files changed, 57 insertions, 88 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 5a58fb257c1..52e1ab0c6a2 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -128,20 +128,16 @@ flow_loop_dump (const struct loop *loop, FILE *file, void flow_loops_dump (FILE *file, void (*loop_dump_aux) (const struct loop *, FILE *, int), int verbose) { - unsigned i; + loop_iterator li; + struct loop *loop; if (!current_loops || ! file) return; - fprintf (file, ";; %d loops found\n", current_loops->num); + fprintf (file, ";; %d loops found\n", number_of_loops ()); - for (i = 0; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, LI_INCLUDE_ROOT) { - struct loop *loop = current_loops->parray[i]; - - if (!loop) - continue; - flow_loop_dump (loop, file, loop_dump_aux, verbose); } @@ -163,25 +159,22 @@ flow_loop_free (struct loop *loop) void flow_loops_free (struct loops *loops) { - if (loops->parray) + if (loops->larray) { unsigned i; - - gcc_assert (loops->num); + loop_p loop; /* Free the loop descriptors. */ - for (i = 0; i < loops->num; i++) + for (i = 0; VEC_iterate (loop_p, loops->larray, i, loop); i++) { - struct loop *loop = loops->parray[i]; - if (!loop) continue; flow_loop_free (loop); } - free (loops->parray); - loops->parray = NULL; + VEC_free (loop_p, heap, loops->larray); + loops->larray = NULL; } } @@ -242,13 +235,11 @@ mark_single_exit_loops (void) basic_block bb; edge e; struct loop *loop; - unsigned i; + loop_iterator li; - for (i = 1; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, 0) { - loop = current_loops->parray[i]; - if (loop) - set_single_exit (loop, NULL); + set_single_exit (loop, NULL); } FOR_EACH_BB (bb) @@ -278,12 +269,8 @@ mark_single_exit_loops (void) } } - for (i = 1; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, 0) { - loop = current_loops->parray[i]; - if (!loop) - continue; - if (single_exit (loop) == single_succ_edge (ENTRY_BLOCK_PTR)) set_single_exit (loop, NULL); } @@ -499,20 +486,6 @@ canonicalize_loop_headers (void) #endif } -/* Initialize all the parallel_p fields of the loops structure to true. */ - -static void -initialize_loops_parallel_p (struct loops *loops) -{ - unsigned int i; - - for (i = 0; i < loops->num; i++) - { - struct loop *loop = loops->parray[i]; - loop->parallel_p = true; - } -} - /* Find all the natural loops in the function and save in LOOPS structure and recalculate loop_depth information in basic block structures. Return the number of natural loops found. */ @@ -528,6 +501,7 @@ flow_loops_find (struct loops *loops) int *rc_order; basic_block header; basic_block bb; + struct loop *root; memset (loops, 0, sizeof *loops); @@ -594,26 +568,21 @@ flow_loops_find (struct loops *loops) } /* Allocate loop structures. */ - loops->parray = XCNEWVEC (struct loop *, num_loops + 1); + loops->larray = VEC_alloc (loop_p, heap, num_loops + 1); /* Dummy loop containing whole function. */ - loops->parray[0] = XCNEW (struct loop); - loops->parray[0]->next = NULL; - loops->parray[0]->inner = NULL; - loops->parray[0]->outer = NULL; - loops->parray[0]->depth = 0; - loops->parray[0]->pred = NULL; - loops->parray[0]->num_nodes = n_basic_blocks; - loops->parray[0]->latch = EXIT_BLOCK_PTR; - loops->parray[0]->header = ENTRY_BLOCK_PTR; - ENTRY_BLOCK_PTR->loop_father = loops->parray[0]; - EXIT_BLOCK_PTR->loop_father = loops->parray[0]; - - loops->tree_root = loops->parray[0]; + root = XCNEW (struct loop); + root->num_nodes = n_basic_blocks; + root->latch = EXIT_BLOCK_PTR; + root->header = ENTRY_BLOCK_PTR; + ENTRY_BLOCK_PTR->loop_father = root; + EXIT_BLOCK_PTR->loop_father = root; + + VEC_quick_push (loop_p, loops->larray, root); + loops->tree_root = root; /* Find and record information about all the natural loops in the CFG. */ - loops->num = 1; FOR_EACH_BB (bb) bb->loop_father = loops->tree_root; @@ -639,7 +608,8 @@ flow_loops_find (struct loops *loops) header = BASIC_BLOCK (rc_order[b]); - loop = loops->parray[num_loops] = XCNEW (struct loop); + loop = XCNEW (struct loop); + VEC_quick_push (loop_p, loops->larray, loop); loop->header = header; loop->num = num_loops; @@ -662,9 +632,6 @@ flow_loops_find (struct loops *loops) loop->num_nodes = flow_loop_nodes_find (loop->header, loop); } - loops->num = num_loops; - initialize_loops_parallel_p (loops); - free (dfs_order); free (rc_order); } @@ -672,7 +639,7 @@ flow_loops_find (struct loops *loops) sbitmap_free (headers); loops->state = 0; - return loops->num; + return VEC_length (loop_p, loops->larray); } /* Return nonzero if basic block BB belongs to LOOP. */ @@ -924,6 +891,21 @@ find_common_loop (struct loop *loop_s, struct loop *loop_d) return loop_s; } +/* Removes LOOP from structures and frees its data. */ + +void +delete_loop (struct loop *loop) +{ + /* Remove the loop from structure. */ + flow_loop_tree_node_remove (loop); + + /* Remove loop from loops array. */ + VEC_replace (loop_p, current_loops->larray, loop->num, NULL); + + /* Free loop data. */ + flow_loop_free (loop); +} + /* Cancels the LOOP; it must be innermost one. */ static void @@ -939,14 +921,7 @@ cancel_loop (struct loop *loop) for (i = 0; i < loop->num_nodes; i++) bbs[i]->loop_father = loop->outer; - /* Remove the loop from structure. */ - flow_loop_tree_node_remove (loop); - - /* Remove loop from loops array. */ - current_loops->parray[loop->num] = NULL; - - /* Free loop data. */ - flow_loop_free (loop); + delete_loop (loop); } /* Cancels LOOP and all its subloops. */ @@ -974,52 +949,48 @@ verify_loop_structure (void) struct loop *loop; int err = 0; edge e; + unsigned num = number_of_loops (); + loop_iterator li; /* Check sizes. */ - sizes = XCNEWVEC (unsigned, current_loops->num); + sizes = XCNEWVEC (unsigned, num); sizes[0] = 2; FOR_EACH_BB (bb) for (loop = bb->loop_father; loop; loop = loop->outer) sizes[loop->num]++; - for (i = 0; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, LI_INCLUDE_ROOT) { - if (!current_loops->parray[i]) - continue; + i = loop->num; - if (current_loops->parray[i]->num_nodes != sizes[i]) + if (loop->num_nodes != sizes[i]) { error ("size of loop %d should be %d, not %d", - i, sizes[i], current_loops->parray[i]->num_nodes); + i, sizes[i], loop->num_nodes); err = 1; } } /* Check get_loop_body. */ - for (i = 1; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, 0) { - loop = current_loops->parray[i]; - if (!loop) - continue; bbs = get_loop_body (loop); for (j = 0; j < loop->num_nodes; j++) if (!flow_bb_inside_loop_p (loop, bbs[j])) { error ("bb %d do not belong to loop %d", - bbs[j]->index, i); + bbs[j]->index, loop->num); err = 1; } free (bbs); } /* Check headers and latches. */ - for (i = 1; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, 0) { - loop = current_loops->parray[i]; - if (!loop) - continue; + i = loop->num; if ((current_loops->state & LOOPS_HAVE_PREHEADERS) && EDGE_COUNT (loop->header->preds) != 2) @@ -1120,7 +1091,7 @@ verify_loop_structure (void) /* Check the single_exit. */ if (current_loops->state & LOOPS_HAVE_MARKED_SINGLE_EXITS) { - memset (sizes, 0, sizeof (unsigned) * current_loops->num); + memset (sizes, 0, sizeof (unsigned) * num); FOR_EACH_BB (bb) { edge_iterator ei; @@ -1154,11 +1125,9 @@ verify_loop_structure (void) } } - for (i = 1; i < current_loops->num; i++) + FOR_EACH_LOOP (li, loop, 0) { - loop = current_loops->parray[i]; - if (!loop) - continue; + i = loop->num; if (sizes[i] == 1 && !single_exit (loop)) |