GCC Middle and Back End API Reference
cfgloop.c File Reference

Functions

static void flow_loops_cfg_dump (FILE *)
static void flow_loops_cfg_dump ()
bool flow_loop_nested_p ()
struct loopsuperloop_at_depth ()
static vec< edgeget_loop_latch_edges ()
void flow_loop_dump (const struct loop *loop, FILE *file, void(*loop_dump_aux)(const struct loop *, FILE *, int), int verbose)
void flow_loops_dump (FILE *file, void(*loop_dump_aux)(const struct loop *, FILE *, int), int verbose)
void flow_loop_free ()
void flow_loops_free ()
int flow_loop_nodes_find ()
static void establish_preds ()
void flow_loop_tree_node_add ()
void flow_loop_tree_node_remove ()
struct loopalloc_loop ()
void init_loops_structure (struct function *fn, struct loops *loops, unsigned num_loops)
bool bb_loop_header_p ()
struct loopsflow_loops_find ()
static edge find_subloop_latch_edge_by_profile ()
static edge find_subloop_latch_edge_by_ivs ()
static edge find_subloop_latch_edge ()
static bool mfb_redirect_edges_in_set ()
static void form_subloop ()
static void merge_latch_edges ()
static void disambiguate_multiple_latches ()
void disambiguate_loops_with_multiple_latches ()
bool flow_bb_inside_loop_p ()
static bool glb_enum_p ()
unsigned get_loop_body_with_size (const struct loop *loop, basic_block *body, unsigned max_size)
basic_blockget_loop_body ()
static void fill_sons_in_loop (const struct loop *loop, basic_block bb, basic_block *tovisit, int *tv)
basic_blockget_loop_body_in_dom_order ()
basic_blockget_loop_body_in_custom_order (const struct loop *loop, int(*bb_comparator)(const void *, const void *))
basic_blockget_loop_body_in_bfs_order ()
static hashval_t loop_exit_hash ()
static int loop_exit_eq ()
static void loop_exit_free ()
static struct loop_exitget_exit_descriptions ()
void rescan_loop_exit ()
void record_loop_exits ()
static int dump_recorded_exit ()
void dump_recorded_exits (FILE *)
void dump_recorded_exits ()
void release_recorded_exits ()
vec< edgeget_loop_exit_edges ()
unsigned num_loop_branches ()
void add_bb_to_loop ()
void remove_bb_from_loops ()
struct loopfind_common_loop ()
void delete_loop ()
static void cancel_loop ()
void cancel_loop_tree ()
DEBUG_FUNCTION void verify_loop_structure ()
edge loop_latch_edge ()
edge loop_preheader_edge ()
bool loop_exit_edge_p ()
edge single_exit ()
bool loop_exits_to_bb_p ()
bool loop_exits_from_bb_p ()
location_t get_loop_location ()

Variables

static struct pointer_set_tmfb_reis_set

Function Documentation

bool bb_loop_header_p ( )
static void cancel_loop ( )
static
Cancels the LOOP; it must be innermost one.   

References delete_loop(), free(), get_loop_body(), loop::inner, loop_outer(), and loop::num_nodes.

Referenced by cancel_loop_tree().

void cancel_loop_tree ( )
Cancels LOOP and all its subloops.   

References cancel_loop(), and loop::inner.

Referenced by destroy_loop(), gen_parallel_loop(), and remove_path().

void delete_loop ( )
Removes LOOP from structures and frees its data.   

References flow_loop_free(), flow_loop_tree_node_remove(), and loop::num.

Referenced by cancel_loop(), and unloop().

void disambiguate_loops_with_multiple_latches ( void  )
Split loops with multiple latch edges.   

References disambiguate_multiple_latches(), and loop::latch.

Referenced by apply_loop_flags().

static void disambiguate_multiple_latches ( )
static
LOOP may have several latch edges.  Transform it into (possibly several)
   loops with single latch edge.   

References dump_file, find_edge(), find_subloop_latch_edge(), form_subloop(), loop::header, merge_latch_edges(), loop::num, and split_edge().

Referenced by disambiguate_loops_with_multiple_latches().

static int dump_recorded_exit ( )
static
Dumps information about the exit in *SLOT to FILE.
   Callback for htab_traverse.   

References edge_def::dest, loop_exit::e, basic_block_def::index, loop_exit::next_e, and edge_def::src.

Referenced by dump_recorded_exits().

void dump_recorded_exits ( FILE *  )
Dumps the recorded exits of loops to FILE.   
void dump_recorded_exits ( )

References dump_recorded_exit().

static void establish_preds ( )
static
Records the vector of superloops of the loop LOOP, whose immediate
   superloop is FATHER.   

References loop::inner, loop_depth(), loop::next, loop::superloops, and vec_alloc().

Referenced by flow_loop_tree_node_add().

static void fill_sons_in_loop ( const struct loop loop,
basic_block  bb,
basic_block tovisit,
int *  tv 
)
static
Fills dominance descendants inside LOOP of the basic block BB into
   array TOVISIT from index *TV.   

References CDI_DOMINATORS, dominated_by_p(), first_dom_son(), flow_bb_inside_loop_p(), loop::latch, and next_dom_son().

Referenced by get_loop_body_in_dom_order().

static edge find_subloop_latch_edge ( )
static
If we can determine that one of the several latch edges of LOOP behaves
   as a latch edge of a separate subloop, returns this edge.  Otherwise
   returns NULL.   

References current_ir_type(), find_subloop_latch_edge_by_ivs(), find_subloop_latch_edge_by_profile(), get_loop_latch_edges(), IR_GIMPLE, and loop::latch.

Referenced by disambiguate_multiple_latches().

static edge find_subloop_latch_edge_by_ivs ( )
static
Among LATCHES, guesses a latch edge of LOOP corresponding to subloop, based
   on the structure of induction variables.  Returns this edge, or NULL if we
   do not find any.

   We are quite conservative, and look just for an obvious simple innermost
   loop (which is the case where we would lose the most performance by not
   disambiguating the loop).  More precisely, we look for the following
   situation: The source of the chosen latch edge dominates sources of all
   the other latch edges.  Additionally, the header does not contain a phi node
   such that the argument from the chosen edge is equal to the argument from
   another edge.   

References CDI_DOMINATORS, edge_def::dest, dominated_by_p(), dump_file, flow_bb_inside_loop_p(), gimple_bb(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), loop::header, basic_block_def::index, loop::latch, and edge_def::src.

Referenced by find_subloop_latch_edge().

static edge find_subloop_latch_edge_by_profile ( )
static
If the profile info is available, finds an edge in LATCHES that much more
   frequent than the remaining edges.  Returns such an edge, or NULL if we do
   not find one.

   We do not use guessed profile here, only the measured one.  The guessed
   profile is usually too flat and unreliable for this (and it is mostly based
   on the loop structure of the program, so it does not make much sense to
   derive the loop structure from it).   

References edge_def::count, edge_def::dest, dump_file, basic_block_def::index, and edge_def::src.

Referenced by find_subloop_latch_edge().

bool flow_bb_inside_loop_p ( )
Return nonzero if basic block BB belongs to LOOP.   

References flow_loop_nested_p(), and basic_block_def::loop_father.

Referenced by add_exit_phi(), add_to_dst_predicate_list(), analyze_evolution_in_loop(), analyze_initial_condition(), analyze_scalar_evolution_1(), base_names_in_chain_on(), bb_in_loop_p(), chain_of_csts_start(), check_loop_closed_ssa_use(), classify_partition(), copy_loop_headers(), duplicate_loop_to_header_edge(), expr_invariant_in_loop_p(), fill_always_executed_in_1(), fill_sons_in_loop(), final_range_test_p(), find_exits(), find_interesting_uses(), find_simple_exit(), find_subloop_latch_edge_by_ivs(), find_uses_to_rename_use(), flow_loops_find(), follow_ssa_edge_inner_loop_phi(), get_initial_def_for_induction(), get_initial_def_for_reduction(), get_iv(), get_loop_body_in_bfs_order(), get_loop_exit_edges(), inhibit_phi_insertion(), inner_loop_header_p(), insert_into_preds_of_block(), ip_normal_pos(), is_reassociable_op(), iv_elimination_compare(), loop_exit_edge_p(), loop_to_lst(), mark_irreducible_loops(), may_eliminate_iv(), may_unswitch_on(), outermost_invariant_loop_for_expr(), phi_arg_in_outermost_loop(), predict_loops(), process_use(), record_invariant(), rename_variables_in_bb(), rescan_loop_exit(), scale_dominated_blocks_in_loop(), should_duplicate_loop_header_p(), tree_may_unswitch_on(), tree_unswitch_loop(), try_create_reduction_list(), unroll_loop_runtime_iterations(), unswitch_loop(), used_outside_reduction(), vect_analyze_loop_operations(), vect_create_epilog_for_reduction(), vect_detect_hybrid_slp_stmts(), vect_get_and_check_slp_defs(), vect_is_simple_iv_evolution(), vect_is_simple_reduction_1(), vect_is_simple_use(), vect_is_slp_reduction(), vect_loop_kill_debug_uses(), vect_mark_relevant(), vect_recog_dot_prod_pattern(), vect_same_loop_or_bb_p(), vect_stmt_relevant_p(), vect_transform_stmt(), vectorizable_induction(), vectorizable_reduction(), and verify_loop_structure().

void flow_loop_dump ( const struct loop loop,
FILE *  file,
void(*)(const struct loop *, FILE *, int)  loop_dump_aux,
int  verbose 
)
Dump the loop information specified by LOOP to the stream FILE
   using auxiliary dump callback function LOOP_DUMP_AUX if non null.   

References free(), get_loop_body(), get_loop_latch_edges(), loop::header, basic_block_def::index, loop::latch, loop_depth(), loop_outer(), loop::num, loop::num_nodes, and edge_def::src.

Referenced by flow_loops_dump(), and tree_ssa_iv_optimize().

void flow_loop_free ( )
int flow_loop_nodes_find ( )
Find the nodes contained within the LOOP with header HEADER.
   Return the number of nodes within the loop.   

References CDI_DOMINATORS, dominated_by_p(), loop_exit::e, loop::header, basic_block_def::loop_father, basic_block_def::preds, edge_def::src, stack, and vNULL.

Referenced by flow_loops_find().

void flow_loop_tree_node_add ( )
Add LOOP to the loop hierarchy tree where FATHER is father of the
   added loop.  If LOOP has some children, take care of that their
   pred field will be initialized correctly.   

References establish_preds(), loop::inner, and loop::next.

Referenced by add_loop(), copy_loops(), duplicate_loop(), fix_loop_placement(), fix_loop_structure(), flow_loops_find(), input_cfg(), move_sese_region_to_fn(), and unloop().

void flow_loop_tree_node_remove ( )
static void flow_loops_cfg_dump ( FILE *  )
static
@verbatim Natural loop discovery code for GNU compiler.

Copyright (C) 2000-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

Referenced by flow_loops_dump().

static void flow_loops_cfg_dump ( )
static
Dump loop related CFG information.   

References edge_def::dest, basic_block_def::index, and basic_block_def::succs.

void flow_loops_dump ( FILE *  file,
void(*)(const struct loop *, FILE *, int)  loop_dump_aux,
int  verbose 
)
Dump the loop information about loops to the stream FILE,
   using auxiliary dump callback function LOOP_DUMP_AUX if non null.   

References cfun, flow_loop_dump(), flow_loops_cfg_dump(), LI_INCLUDE_ROOT, and number_of_loops().

Referenced by analyze_function(), compute_alignments(), estimate_function_body_sizes(), loop_optimizer_init(), and tree_estimate_probability_driver().

struct loops* flow_loops_find ( )
read
Find all the natural loops in the function and save in LOOPS structure and
   recalculate loop_father information in basic block structures.
   If LOOPS is non-NULL then the loop structures for already recorded loops
   will be re-used and their number will not change.  We assume that no
   stale loops exist in LOOPS.
   When LOOPS is NULL it is allocated and re-built from scratch.
   Return the built LOOPS structure.   

References alloc_loop(), bb_loop_header_p(), calculate_dominance_info(), CDI_DOMINATORS, cfun, dump_file, dump_flags, loops::exits, flow_bb_inside_loop_p(), flow_loop_nodes_find(), flow_loop_tree_node_add(), flow_loop_tree_node_remove(), free(), loop::header, basic_block_def::index, init_loops_structure(), loops::larray, loop::latch, basic_block_def::loop_father, loop::num, loop::num_nodes, pre_and_rev_post_order_compute(), basic_block_def::preds, edge_def::src, loops::tree_root, and vec_safe_push().

Referenced by fix_loop_structure(), input_cfg(), and loop_optimizer_init().

void flow_loops_free ( )
Free all the memory allocated for LOOPS.   

References flow_loop_free(), loops::larray, and vec_free().

Referenced by loop_optimizer_finalize().

static struct loop_exit* get_exit_descriptions ( )
staticread
Returns the list of records for E as an exit of a loop.   

Referenced by verify_loop_structure().

basic_block* get_loop_body_in_custom_order ( const struct loop loop,
int(*)(const void *, const void *)  bb_comparator 
)
Gets body of a LOOP sorted via provided BB_COMPARATOR.   

References get_loop_body(), and loop::num_nodes.

unsigned get_loop_body_with_size ( const struct loop loop,
basic_block body,
unsigned  max_size 
)
Gets basic blocks of a LOOP.  Header is the 0-th block, rest is in dfs
   order against direction of edges from latch.  Specially, if
   header != latch, latch is the 1-st block.  LOOP cannot be the fake
   loop tree root, and its size must be at most MAX_SIZE.  The blocks
   in the LOOP body are stored to BODY, and the size of the LOOP is
   returned.   

References dfs_enumerate_from(), glb_enum_p(), and loop::header.

Referenced by add_loop(), get_loop_body(), slpeel_tree_duplicate_loop_to_edge_cfg(), and verify_loop_structure().

static vec<edge> get_loop_latch_edges ( )
static
Returns the list of the latch edges of LOOP.   

References CDI_DOMINATORS, dominated_by_p(), loop::header, basic_block_def::preds, edge_def::src, and vNULL.

Referenced by find_subloop_latch_edge(), flow_loop_dump(), and merge_latch_edges().

location_t get_loop_location ( )
Return location corresponding to the loop control condition if possible.   

References current_function_decl, get_simple_loop_desc(), loop::header, niter_desc::in_edge, loop::latch, single_exit(), and edge_def::src.

Referenced by decide_unrolling_and_peeling(), and peel_loops_completely().

static bool glb_enum_p ( )
static
Enumeration predicate for get_loop_body_with_size.   

References CDI_DOMINATORS, dominated_by_p(), and loop::header.

Referenced by get_loop_body_with_size().

void init_loops_structure ( struct function fn,
struct loops loops,
unsigned  num_loops 
)
Initializes loops structure LOOPS, reserving place for NUM_LOOPS loops
   (including the root of the loop tree).   

References alloc_loop(), loop::header, loops::larray, loop::latch, memset(), loop::num_nodes, loops::tree_root, and vec_alloc().

Referenced by flow_loops_find(), init_lowered_empty_function(), input_cfg(), and move_sese_region_to_fn().

static int loop_exit_eq ( )
static
Equality function for struct loop_exit.  Compares with edge.   

References loop_exit::e.

Referenced by record_loop_exits().

static void loop_exit_free ( )
static
Frees the list of loop exit descriptions EX.   

References ggc_free(), loop_exit::next, loop_exit::next_e, and loop_exit::prev.

Referenced by record_loop_exits(), and rescan_loop_exit().

static hashval_t loop_exit_hash ( )
static
Hash function for struct loop_exit.   

References loop_exit::e.

Referenced by record_loop_exits().

bool loop_exits_from_bb_p ( )
Returns true when BB has an outgoing edge exiting LOOP.   

References loop_exit::e, loop_exit_edge_p(), and basic_block_def::succs.

bool loop_exits_to_bb_p ( )
Returns true when BB has an incoming edge exiting LOOP.   

References loop_exit::e, loop_exit_edge_p(), and basic_block_def::preds.

Referenced by scopdet_basic_block_info().

edge loop_preheader_edge ( )
Returns preheader edge of LOOP.   

References loop_exit::e, loop::header, loop::latch, LOOPS_HAVE_PREHEADERS, loops_state_satisfies_p(), basic_block_def::preds, and edge_def::src.

Referenced by analyze_insns_in_loop(), block_before_loop(), canonicalize_loop_ivs(), copy_loop_before(), copy_loop_headers(), create_empty_loop_on_edge(), create_iv(), create_parallel_loop(), destroy_loop(), determine_exit_conditions(), doloop_modify(), execute_sm(), find_bivs(), find_looparound_phi(), fix_loop_placements(), gen_parallel_loop(), generate_memcpy_builtin(), generate_memset_builtin(), generate_prolog_epilog(), get_base_for(), get_initial_def_for_induction(), initialize_reductions(), initialize_root_vars(), initialize_root_vars_lm(), loop_niter_by_eval(), loop_version(), move_computations_stmt(), move_invariant_reg(), parallelize_loops(), peel_loop_completely(), peel_loop_simple(), prepare_initializers_chain(), rewrite_use_compare(), simplify_using_entry_checks(), simplify_using_initial_values(), slpeel_can_duplicate_loop_p(), slpeel_tree_duplicate_loop_to_edge_cfg(), slpeel_tree_peel_loop_to_edge(), slpeel_update_phi_nodes_for_guard1(), slpeel_verify_cfg_after_peeling(), sms_schedule(), tree_transform_and_unroll_loop(), try_unroll_loop_completely(), unloop(), unroll_loop_constant_iterations(), unroll_loop_runtime_iterations(), unswitch_loop(), vect_build_loop_niters(), vect_create_data_ref_ptr(), vect_create_epilog_for_reduction(), vect_do_peeling_for_alignment(), vect_do_peeling_for_loop_bound(), vect_gen_niters_for_prolog_loop(), vect_generate_tmps_on_preheader(), vect_get_constant_vectors(), vect_get_vec_def_for_operand(), vect_init_vector_1(), vect_recog_rotate_pattern(), vect_setup_realignment(), vect_transform_loop(), vect_update_ivs_after_vectorizer(), vectorizable_load(), and vectorizable_reduction().

static void merge_latch_edges ( )
static
static bool mfb_redirect_edges_in_set ( )
static
unsigned num_loop_branches ( )
Counts the number of conditional branches inside LOOP.   

References free(), get_loop_body(), loop::latch, and loop::num_nodes.

Referenced by decide_peel_simple(), and decide_unroll_stupid().

void record_loop_exits ( void  )
void release_recorded_exits ( void  )
edge single_exit ( )
Returns the single exit edge of LOOP, or NULL if LOOP has either no exit
   or more than one exit.  If loops do not have the exits recorded, NULL
   is returned always.   

References loop_exit::e, loop::exits, LOOPS_HAVE_RECORDED_EXITS, loops_state_satisfies_p(), and loop_exit::next.

Referenced by canonicalize_loop_closed_ssa(), canonicalize_loop_induction_variables(), create_bb_after_loop(), create_empty_loop_on_edge(), destroy_loop(), do_warn_aggressive_loop_optimizations(), gen_parallel_loop(), generate_prolog_epilog(), get_bb_type(), get_loop_exit_condition(), get_loop_location(), graphite_can_represent_loop(), if_convertible_loop_p(), limit_scops(), loop_canon_p(), loop_closed_phi_def(), loop_only_exit_p(), number_of_iterations_exit(), number_of_latch_executions(), rewrite_commutative_reductions_out_of_ssa_loop(), scale_loop_profile(), scev_const_prop(), scopdet_basic_block_info(), single_dom_exit(), single_likely_exit(), slpeel_can_duplicate_loop_p(), slpeel_make_loop_iterate_ntimes(), slpeel_tree_duplicate_loop_to_edge_cfg(), slpeel_tree_peel_loop_to_edge(), slpeel_update_phi_nodes_for_guard1(), slpeel_update_phi_nodes_for_guard2(), slpeel_verify_cfg_after_peeling(), sms_schedule(), translate_clast_for_loop(), tree_loop_distribution(), vect_analyze_loop_form(), vect_analyze_loop_operations(), vect_create_epilog_for_reduction(), vect_do_peeling_for_loop_bound(), vect_enhance_data_refs_alignment(), vect_loop_versioning(), vect_stmt_relevant_p(), vect_update_ivs_after_vectorizer(), and vectorizable_live_operation().

DEBUG_FUNCTION void verify_loop_structure ( void  )
Checks that information about loops is correct
     -- sizes of loops are all right
     -- results of get_loop_body really belong to the loop
     -- loop header have just single entry edge and single latch edge
     -- loop latches have only single successor that is header of their loop
     -- irreducible loops are correctly marked
     -- the cached loop depth and loop father of each bb is correct

References bb_loop_header_p(), bitmap_bit_p(), bitmap_clear(), bitmap_clear_bit(), bitmap_set_bit(), calculate_dominance_info(), CDI_DOMINATORS, cfun, edge_def::dest, dom_info_available_p(), dominated_by_p(), loop_exit::e, error(), loop::exits, find_edge(), edge_def::flags, basic_block_def::flags, flow_bb_inside_loop_p(), free(), free_dominance_info(), get_exit_descriptions(), get_loop_body_with_size(), loop::header, basic_block_def::index, loop::latch, LI_FROM_INNERMOST, basic_block_def::loop_father, loop_latch_edge(), loop_outer(), LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS, LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_RECORDED_EXITS, LOOPS_HAVE_SIMPLE_LATCHES, LOOPS_NEED_FIXUP, loops_state_satisfies_p(), mark_irreducible_loops(), memset(), loop_exit::next, loop_exit::next_e, loop::num, loop::num_nodes, number_of_loops(), basic_block_def::preds, sbitmap_alloc(), sbitmap_free(), single_succ(), single_succ_p(), edge_def::src, basic_block_def::succs, verify_dominators(), and visited.

Referenced by create_sese_edges(), doloop_optimize_loops(), fix_loop_structure(), graphite_verify(), loop_optimizer_init(), repair_loop_structures(), tree_loop_distribution(), and tree_transform_and_unroll_loop().


Variable Documentation

struct pointer_set_t* mfb_reis_set
static
Callback for make_forwarder_block.  Returns true if the edge E is marked
   in the set MFB_REIS_SET.