GCC Middle and Back End API Reference
cfgloop.h File Reference
#include "cfgloopmanip.h"
Include dependency graph for cfgloop.h:

Go to the source code of this file.

Data Structures

struct  lpt_decision
 
class  nb_iter_bound
 
struct  loop_exit
 
struct  loop_exit_hasher
 
struct  control_iv
 
class  loop
 
struct  loops
 
class  rtx_iv
 
class  niter_desc
 
class  loops_list
 
class  loops_list::Iter< T >
 
struct  target_cfgloop
 

Macros

#define LOOP_C_INFINITE   (1 << 0)
 
#define LOOP_C_FINITE   (1 << 1)
 
#define LOOPS_NORMAL
 
#define AVOID_CFG_MODIFICATIONS   (LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
 
#define this_target_cfgloop   (&default_target_cfgloop)
 
#define target_avail_regs    (this_target_cfgloop->x_target_avail_regs)
 
#define target_clobbered_regs    (this_target_cfgloop->x_target_clobbered_regs)
 
#define target_res_regs    (this_target_cfgloop->x_target_res_regs)
 
#define target_reg_cost    (this_target_cfgloop->x_target_reg_cost)
 
#define target_spill_cost    (this_target_cfgloop->x_target_spill_cost)
 

Typedefs

typedef generic_wide_int< fixed_wide_int_storage< WIDE_INT_MAX_INL_PRECISION > > bound_wide_int
 
typedef class looploop_p
 

Enumerations

enum  lpt_dec { LPT_NONE , LPT_UNROLL_CONSTANT , LPT_UNROLL_RUNTIME , LPT_UNROLL_STUPID }
 
enum  iv_extend_code { IV_SIGN_EXTEND , IV_ZERO_EXTEND , IV_UNKNOWN_EXTEND }
 
enum  loop_estimation { EST_NOT_COMPUTED , EST_AVAILABLE , EST_LAST }
 
enum  {
  LOOPS_HAVE_PREHEADERS = 1 , LOOPS_HAVE_SIMPLE_LATCHES = 2 , LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS = 4 , LOOPS_HAVE_RECORDED_EXITS = 8 ,
  LOOPS_MAY_HAVE_MULTIPLE_LATCHES = 16 , LOOP_CLOSED_SSA = 32 , LOOPS_NEED_FIXUP = 64 , LOOPS_HAVE_FALLTHRU_PREHEADERS = 128
}
 
enum  li_flags { LI_INCLUDE_ROOT = 1 , LI_FROM_INNERMOST = 2 , LI_ONLY_INNERMOST = 4 }
 
enum  { UAP_UNROLL = 1 , UAP_UNROLL_ALL = 2 }
 

Functions

void loop_constraint_set (class loop *loop, unsigned c)
 
void loop_constraint_clear (class loop *loop, unsigned c)
 
bool loop_constraint_set_p (class loop *loop, unsigned c)
 
bool bb_loop_header_p (basic_block)
 
void init_loops_structure (struct function *, struct loops *, unsigned)
 
struct loopsflow_loops_find (struct loops *)
 
void disambiguate_loops_with_multiple_latches (void)
 
void flow_loops_free (struct loops *)
 
void flow_loops_dump (FILE *, void(*)(const class loop *, FILE *, int), int)
 
void flow_loop_dump (const class loop *, FILE *, void(*)(const class loop *, FILE *, int), int)
 
class loopalloc_loop (void)
 
void flow_loop_free (class loop *)
 
int flow_loop_nodes_find (basic_block, class loop *)
 
unsigned fix_loop_structure (bitmap changed_bbs)
 
bool mark_irreducible_loops (void)
 
void release_recorded_exits (function *)
 
void record_loop_exits (void)
 
void rescan_loop_exit (edge, bool, bool)
 
void sort_sibling_loops (function *)
 
void flow_loop_tree_node_add (class loop *, class loop *, class loop *=NULL)
 
void flow_loop_tree_node_remove (class loop *)
 
bool flow_loop_nested_p (const class loop *, const class loop *)
 
bool flow_bb_inside_loop_p (const class loop *, const_basic_block)
 
class loopfind_common_loop (class loop *, class loop *)
 
class loopsuperloop_at_depth (class loop *, unsigned)
 
int num_loop_insns (const class loop *)
 
int average_num_loop_insns (const class loop *)
 
unsigned get_loop_level (const class loop *)
 
bool loop_exit_edge_p (const class loop *, const_edge)
 
bool loop_exits_to_bb_p (class loop *, basic_block)
 
bool loop_exits_from_bb_p (class loop *, basic_block)
 
void mark_loop_exit_edges (void)
 
dump_user_location_t get_loop_location (class loop *loop)
 
basic_blockget_loop_body (const class loop *)
 
unsigned get_loop_body_with_size (const class loop *, basic_block *, unsigned)
 
basic_blockget_loop_body_in_dom_order (const class loop *)
 
basic_blockget_loop_body_in_bfs_order (const class loop *)
 
basic_blockget_loop_body_in_custom_order (const class loop *, int(*)(const void *, const void *))
 
basic_blockget_loop_body_in_custom_order (const class loop *, void *, int(*)(const void *, const void *, void *))
 
auto_vec< edgeget_loop_exit_edges (const class loop *, basic_block *=NULL)
 
edge single_exit (const class loop *)
 
edge single_likely_exit (class loop *loop, const vec< edge > &)
 
unsigned num_loop_branches (const class loop *)
 
edge loop_preheader_edge (const class loop *)
 
edge loop_latch_edge (const class loop *)
 
void add_bb_to_loop (basic_block, class loop *)
 
void remove_bb_from_loops (basic_block)
 
void cancel_loop_tree (class loop *)
 
void delete_loop (class loop *)
 
void verify_loop_structure (void)
 
bool just_once_each_iteration_p (const class loop *, const_basic_block)
 
gcov_type expected_loop_iterations_unbounded (const class loop *, bool *read_profile_p=NULL)
 
bool expected_loop_iterations_by_profile (const class loop *loop, sreal *ret, bool *reliable=NULL)
 
bool maybe_flat_loop_profile (const class loop *)
 
unsigned expected_loop_iterations (class loop *)
 
rtx doloop_condition_get (rtx_insn *)
 
void mark_loop_for_removal (loop_p)
 
void print_loop_info (FILE *file, const class loop *loop, const char *)
 
void iv_analysis_loop_init (class loop *)
 
bool iv_analyze (rtx_insn *, scalar_int_mode, rtx, class rtx_iv *)
 
bool iv_analyze_result (rtx_insn *, rtx, class rtx_iv *)
 
bool iv_analyze_expr (rtx_insn *, scalar_int_mode, rtx, class rtx_iv *)
 
rtx get_iv_value (class rtx_iv *, rtx)
 
bool biv_p (rtx_insn *, scalar_int_mode, rtx)
 
void iv_analysis_done (void)
 
class niter_descget_simple_loop_desc (class loop *loop)
 
void free_simple_loop_desc (class loop *loop)
 
class niter_descsimple_loop_desc (class loop *loop)
 
class loopget_loop (struct function *fn, unsigned num)
 
unsigned loop_depth (const class loop *loop)
 
class looploop_outer (const class loop *loop)
 
bool loop_has_exit_edges (const class loop *loop)
 
vec< loop_p, va_gc > * get_loops (struct function *fn)
 
unsigned number_of_loops (struct function *fn)
 
bool loops_state_satisfies_p (function *fn, unsigned flags)
 
bool loops_state_satisfies_p (unsigned flags)
 
void loops_state_set (function *fn, unsigned flags)
 
void loops_state_set (unsigned flags)
 
void loops_state_clear (function *fn, unsigned flags)
 
void loops_state_clear (unsigned flags)
 
void checking_verify_loop_structure (void)
 
template<typename T >
constexpr const Tas_const (T &t)
 
unsigned estimate_reg_pressure_cost (unsigned, unsigned, bool, bool)
 
void init_set_costs (void)
 
void loop_optimizer_init (unsigned)
 
void loop_optimizer_finalize (function *, bool=false)
 
void loop_optimizer_finalize ()
 
void doloop_optimize_loops (void)
 
void move_loop_invariants (void)
 
auto_vec< basic_blockget_loop_hot_path (const class loop *loop)
 
class looploop_outermost (class loop *loop)
 
void record_niter_bound (class loop *, const widest_int &, bool, bool)
 
HOST_WIDE_INT get_estimated_loop_iterations_int (class loop *)
 
HOST_WIDE_INT get_max_loop_iterations_int (const class loop *)
 
HOST_WIDE_INT get_likely_max_loop_iterations_int (class loop *)
 
bool get_estimated_loop_iterations (class loop *loop, widest_int *nit)
 
bool get_max_loop_iterations (const class loop *loop, widest_int *nit)
 
bool get_likely_max_loop_iterations (class loop *loop, widest_int *nit)
 
int bb_loop_depth (const_basic_block)
 
edge single_dom_exit (class loop *)
 
profile_count loop_count_in (const class loop *loop)
 
widest_int gcov_type_to_wide_int (gcov_type val)
 

Variables

struct target_cfgloop default_target_cfgloop
 

Macro Definition Documentation

◆ AVOID_CFG_MODIFICATIONS

◆ LOOP_C_FINITE

#define LOOP_C_FINITE   (1 << 1)
Set if the loop is known to be finite without any assumptions.   

Referenced by number_of_iterations_exit_assumptions(), try_vectorize_loop_1(), vect_analyze_loop(), vect_free_loop_info_assumptions(), and vect_loop_versioning().

◆ LOOP_C_INFINITE

#define LOOP_C_INFINITE   (1 << 0)
Set if the loop is known to be infinite.   

Referenced by number_of_iterations_exit_assumptions(), and vect_do_peeling().

◆ LOOPS_NORMAL

#define LOOPS_NORMAL
Value:
@ LOOPS_HAVE_PREHEADERS
Definition cfgloop.h:309
@ LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS
Definition cfgloop.h:311
@ LOOPS_HAVE_SIMPLE_LATCHES
Definition cfgloop.h:310

Referenced by analyze_function_body(), execute_ranger_vrp(), perform_tree_ssa_dce(), report_predictor_hitrates(), rtl_loop_init(), scev_initialize(), and split_paths().

◆ target_avail_regs

#define target_avail_regs    (this_target_cfgloop->x_target_avail_regs)

◆ target_clobbered_regs

#define target_clobbered_regs    (this_target_cfgloop->x_target_clobbered_regs)

◆ target_reg_cost

#define target_reg_cost    (this_target_cfgloop->x_target_reg_cost)

◆ target_res_regs

#define target_res_regs    (this_target_cfgloop->x_target_res_regs)

◆ target_spill_cost

◆ this_target_cfgloop

#define this_target_cfgloop   (&default_target_cfgloop)

Typedef Documentation

◆ bound_wide_int

◆ loop_p

typedef class loop* loop_p

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Flags for state of loop structure.   
Enumerator
LOOPS_HAVE_PREHEADERS 
LOOPS_HAVE_SIMPLE_LATCHES 
LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS 
LOOPS_HAVE_RECORDED_EXITS 
LOOPS_MAY_HAVE_MULTIPLE_LATCHES 
LOOP_CLOSED_SSA 
LOOPS_NEED_FIXUP 
LOOPS_HAVE_FALLTHRU_PREHEADERS 

◆ anonymous enum

anonymous enum
Optimization passes.   
Enumerator
UAP_UNROLL 
UAP_UNROLL_ALL 

◆ iv_extend_code

The type of extend applied to an IV.   
Enumerator
IV_SIGN_EXTEND 
IV_ZERO_EXTEND 
IV_UNKNOWN_EXTEND 

◆ li_flags

enum li_flags
Loop iterators.   
Flags for loop iteration.   
Enumerator
LI_INCLUDE_ROOT 
LI_FROM_INNERMOST 
LI_ONLY_INNERMOST 

◆ loop_estimation

An integer estimation of the number of iterations.  Estimate_state
describes what is the state of the estimation.   
Enumerator
EST_NOT_COMPUTED 
EST_AVAILABLE 
EST_LAST 

◆ lpt_dec

enum lpt_dec
Natural loop functions
   Copyright (C) 1987-2024 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/>.   
Structure to hold decision about unrolling/peeling.   
Enumerator
LPT_NONE 
LPT_UNROLL_CONSTANT 
LPT_UNROLL_RUNTIME 
LPT_UNROLL_STUPID 

Function Documentation

◆ add_bb_to_loop()

◆ alloc_loop()

◆ as_const()

template<typename T >
const T & as_const ( T & t)
constexpr
Provide the functionality of std::as_const to support range-based for
to use const iterator.  (We can't use std::as_const itself because it's
a C++17 feature.)   

◆ average_num_loop_insns()

int average_num_loop_insns ( const class loop * loop)
extern
Counts number of insns executed on average per iteration LOOP.   

References basic_block_def::count, FOR_BB_INSNS, free(), get_loop_body(), loop::header, i, loop::ninsns, NONDEBUG_INSN_P, loop::num_nodes, and profile_count::to_sreal_scale().

Referenced by decide_unrolling().

◆ bb_loop_depth()

◆ bb_loop_header_p()

◆ biv_p()

bool biv_p ( rtx_insn * insn,
scalar_int_mode mode,
rtx reg )
extern
Checks whether definition of register REG in INSN is a basic induction
variable.  MODE is the mode of REG.

IV analysis must have been initialized (via a call to
iv_analysis_loop_init) for this function to produce a result.   

References const0_rtx, df_find_def(), gcc_assert, iv_analyze_biv(), latch_dominating_def(), rtx_iv::mode, NULL, simple_reg_p(), and iv::step.

Referenced by analyze_iv_to_split_insn().

◆ cancel_loop_tree()

void cancel_loop_tree ( class loop * loop)
extern
Cancels LOOP and all its subloops.   

References cancel_loop(), cancel_loop_tree(), and loop::inner.

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

◆ checking_verify_loop_structure()

void checking_verify_loop_structure ( void )
inline

◆ delete_loop()

void delete_loop ( class loop * loop)
extern
Removes LOOP from structures and frees its data.   

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

Referenced by cancel_loop(), fuse_loops(), and unloop().

◆ disambiguate_loops_with_multiple_latches()

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

References cfun, disambiguate_multiple_latches(), and loop::latch.

Referenced by apply_loop_flags().

◆ doloop_condition_get()

rtx doloop_condition_get ( rtx_insn * doloop_pat)
extern
Perform doloop optimizations
   Copyright (C) 2004-2024 Free Software Foundation, Inc.
   Based on code by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)

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/>.   
This module is used to modify loops with a determinable number of
iterations to use special low-overhead looping instructions.

It first validates whether the loop is well behaved and has a
determinable number of iterations (either at compile or run-time).
It then modifies the loop to use a low-overhead looping pattern as
follows:

1. A pseudo register is allocated as the loop iteration counter.

2. The number of loop iterations is calculated and is stored
   in the loop counter.

3. At the end of the loop, the jump insn is replaced by the
   doloop_end pattern.  The compare must remain because it might be
   used elsewhere.  If the loop-variable or condition register are
   used elsewhere, they will be eliminated by flow.

4. An optional doloop_begin pattern is inserted at the top of the
   loop.

TODO The optimization should only performed when either the biv used for exit
condition is unused at all except for the exit test, or if we do not have to
change its value, since otherwise we have to add a new induction variable,
which usually will not pay up (unless the cost of the doloop pattern is
somehow extremely lower than the cost of compare & jump, or unless the bct
register cannot be used for anything else but doloop -- ??? detect these
cases).   
Return the loop termination condition for PATTERN or zero
if it is not a decrement and branch jump insn.   

References const0_rtx, const1_rtx, CONST_INT_P, GEN_INT, GET_CODE, INSN_P, INTVAL, NULL, NULL_RTX, PATTERN(), pc_rtx, prev_nondebug_insn(), REG_P, rtx_equal_p(), SET, SET_DEST, SET_SRC, XEXP, and XVECEXP.

Referenced by doloop_optimize().

◆ doloop_optimize_loops()

void doloop_optimize_loops ( void )
extern

◆ estimate_reg_pressure_cost()

unsigned estimate_reg_pressure_cost ( unsigned n_new,
unsigned n_old,
bool speed,
bool call_p )
extern
Register pressure estimation for induction variable optimizations & loop
invariant motion.   
Estimates cost of increased register pressure caused by making N_NEW new
registers live around the loop.  N_OLD is the number of registers live
around the loop.  If CALL_P is true, also take into account that
call-used registers may be clobbered in the loop body, reducing the
number of available registers before we spill.   

References cfun, IRA_REGION_ALL, IRA_REGION_MIXED, number_of_loops(), target_avail_regs, target_clobbered_regs, target_reg_cost, target_res_regs, and target_spill_cost.

Referenced by gain_for_invariant().

◆ expected_loop_iterations()

unsigned expected_loop_iterations ( class loop * loop)
extern
Returns expected number of LOOP iterations.  The returned value is bounded
by REG_BR_PROB_BASE.   

References expected_loop_iterations_unbounded(), and REG_BR_PROB_BASE.

Referenced by determine_loop_nest_reuse().

◆ expected_loop_iterations_by_profile()

bool expected_loop_iterations_by_profile ( const class loop * loop,
sreal * ret,
bool * reliable )
extern
Return true if BB profile can be used to determine the expected number of
iterations (that is number of executions of latch edge(s) for each
entry of the loop.  If this is the case initialize RET with the number
of iterations.

RELIABLE is set if profile indiates that the returned value should be
realistic estimate.  (This is the case if we read profile and did not
messed it up yet and not the case of guessed profiles.)

This function uses only CFG profile.  We track more reliable info in
loop_info structure and for loop optimization heuristics more relevant
is get_estimated_loop_iterations API.   

References basic_block_def::count, profile_count::differs_from_p(), dump_file, dump_flags, loop::header, profile_count::initialized_p(), loop_count_in(), profile_count::nonzero_p(), loop::num, profile_count::reliable_p(), and TDF_DETAILS.

Referenced by branch_prob(), estimate_numbers_of_iterations(), expected_loop_iterations_unbounded(), get_estimated_loop_iterations(), maybe_flat_loop_profile(), print_loop_info(), and scale_loop_profile().

◆ expected_loop_iterations_unbounded()

gcov_type expected_loop_iterations_unbounded ( const class loop * loop,
bool * read_profile_p )
Returns expected number of iterations of LOOP, according to
measured or guessed profile.

This functions attempts to return "sane" value even if profile
information is not good enough to derive osmething.   

References expected_loop_iterations_by_profile(), get_max_loop_iterations_int(), and sreal::to_nearest_int().

Referenced by expected_loop_iterations().

◆ find_common_loop()

◆ fix_loop_structure()

unsigned fix_loop_structure ( bitmap changed_bbs)
The structure of loops might have changed.  Some loops might get removed
(and their headers and latches were set to NULL), loop exists might get
removed (thus the loop nesting may be wrong), and some blocks and edges
were changed (so the information about bb --> loop mapping does not have
to be correct).  But still for the remaining loops the header dominates
the latch, and loops did not get new subloops (new loops might possibly
get created, but we are not interested in them).  Fix up the mess.

If CHANGED_BBS is not NULL, basic blocks whose loop depth has changed are
marked in it.

Returns the number of new discovered plus the number of removed loops.   

References apply_loop_flags(), basic_block_def::aux, BASIC_BLOCK_FOR_FN, basic_block_info_for_fn, bb_loop_header_p(), bitmap_set_bit, CDI_DOMINATORS, cfun, checking_verify_loop_structure(), current_loops, dom_info_state(), DOM_OK, dump_file, dump_flags, flow_loop_free(), flow_loop_tree_node_add(), flow_loop_tree_node_remove(), flow_loops_find(), FOR_EACH_BB_FN, FOR_EACH_VEC_ELT, loop::former_header, gcc_assert, get_loops(), loop::header, i, basic_block_def::index, loop::inner, LI_FROM_INNERMOST, loop_depth(), basic_block_def::loop_father, loop_outer(), LOOPS_HAVE_RECORDED_EXITS, LOOPS_NEED_FIXUP, loops_state_clear(), loops_state_satisfies_p(), NULL, loop::num, number_of_loops(), release_recorded_exits(), scev_initialized_p(), scev_reset_htab(), TDF_DETAILS, timevar_pop(), and timevar_push().

Referenced by cleanup_cfg(), loop_optimizer_init(), repair_loop_structures(), tree_function_versioning(), and unroll_loops().

◆ flow_bb_inside_loop_p()

bool flow_bb_inside_loop_p ( const class loop * loop,
const_basic_block bb )
extern
Return nonzero if basic block BB belongs to LOOP.   

References cfun, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, flow_loop_nested_p(), and basic_block_def::loop_father.

Referenced by add_exit_phi(), add_to_dst_predicate_list(), add_to_predicate_list(), analyze_evolution_in_loop(), loop_cand::analyze_iloop_reduction_var(), analyze_initial_condition(), loop_cand::analyze_oloop_reduction_var(), analyze_scalar_evolution_1(), base_names_in_chain_on(), bb_in_loop_p(), can_move_invariant_reg(), chain_of_csts_start(), check_exit_phi(), check_loop_closed_ssa_def(), check_reduction_path(), classify_builtin_st(), compute_access_stride(), compute_added_num_insns(), create_rdg_cd_edges(), duplicate_loop_body_to_header_edge(), rpo_elim::eliminate_avail(), eliminate_dom_walker::eliminate_stmt(), evaluate_bbs(), crc_symbolic_execution::execute_crc_loop(), expr_invariant_in_loop_p(), fill_always_executed_in_1(), fill_sons_in_loop(), final_range_test_p(), find_exits(), find_interesting_uses(), find_inv_vars_cb(), find_loop_guard(), crc_optimization::find_shift_after_xor(), find_simple_exit(), find_subloop_latch_edge_by_ivs(), find_unswitching_predicates_for_bb(), find_uses_to_rename_use(), find_vdef_in_loop(), flow_loops_find(), scev_dfs::follow_ssa_edge_inner_loop_phi(), for_all_locs_in_loop(), get_cond_invariant_branch(), get_control_equiv_head_block(), get_iv(), get_loop_body_in_bfs_order(), get_loop_exit_edges(), hoist_defs_of_uses(), hoist_guard(), init_loop_unswitch_info(), inner_loop_header_p(), insert_into_preds_of_block(), ip_normal_pos(), is_cond_scalar_reduction(), is_inv_store_elimination_chain(), is_reassociable_op(), crc_symbolic_execution::is_used_outside_the_loop(), iv_elimination_compare(), loop_combined_static_and_iv_p(), loop_count_in(), loop_exit_edge_p(), loop_invariant_op_p(), loop_inverted_rev_post_order_compute(), loop_iter_phi_semi_invariant_p(), loop_rev_post_order_compute(), loop_static_op_p(), mark_irreducible_loops(), may_eliminate_iv(), tree_loop_interchange::move_code_to_inner_loop(), outermost_invariant_loop_for_expr(), parloops_is_simple_reduction(), parloops_is_slp_reduction(), crc_optimization::passes_checks_for_def_chain(), predict_loops(), predict_paths_for_bb(), record_invariant(), rename_variables_in_bb(), rescan_loop_exit(), scale_dominated_blocks_in_loop(), should_duplicate_loop_header_p(), single_use_in_loop(), slpeel_tree_duplicate_loop_to_edge_cfg(), ssa_name_has_uses_outside_loop_p(), ssa_semi_invariant_p(), crc_symbolic_execution::symb_execute_crc_loop(), tree_unswitch_loop(), try_create_reduction_list(), unroll_jam_possible_p(), unroll_loop_runtime_iterations(), used_outside_loop_p(), vect_create_epilog_for_reduction(), vect_do_peeling(), vect_is_simple_iv_evolution(), vect_is_simple_reduction(), vect_loop_dist_alias_call(), vect_loop_kill_debug_uses(), vect_loop_versioning(), vect_phi_first_order_recurrence_p(), vect_stmt_relevant_p(), vectorizable_early_exit(), vectorizable_induction(), vectorizable_live_operation(), and verify_loop_structure().

◆ flow_loop_dump()

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

References FOR_EACH_VEC_ELT, free(), get_loop_body(), get_loop_latch_edges(), loop::header, i, basic_block_def::index, loop::latch, loop_depth(), loop_outer(), loop::num, loop::num_nodes, print_loop_info(), and verbose.

Referenced by analyze_and_mark_doloop_use(), flow_loops_dump(), and tree_ssa_iv_optimize().

◆ flow_loop_free()

void flow_loop_free ( class loop * loop)
extern

◆ flow_loop_nested_p()

◆ flow_loop_nodes_find()

int flow_loop_nodes_find ( basic_block header,
class loop * loop )
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, FOR_EACH_EDGE, header, loop::header, basic_block_def::loop_father, basic_block_def::preds, and vNULL.

Referenced by flow_loops_find().

◆ flow_loop_tree_node_add()

void flow_loop_tree_node_add ( class loop * father,
class loop * loop,
class loop * after )
extern
Loop data structure manipulation/querying.   
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.  If AFTER is non-null
then it's expected it's a pointer into FATHERs inner sibling
list and LOOP is added behind AFTER, otherwise it's added in front
of FATHERs siblings.   

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(), merge_loop_tree(), move_sese_region_to_fn(), and unloop().

◆ flow_loop_tree_node_remove()

void flow_loop_tree_node_remove ( class loop * loop)
extern

◆ flow_loops_dump()

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

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

Referenced by analyze_function_body(), compute_alignments(), finite_function_p(), loop_optimizer_init(), and report_predictor_hitrates().

◆ flow_loops_find()

struct loops * flow_loops_find ( struct loops * loops)
extern
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(), b, BASIC_BLOCK_FOR_FN, 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(), FOR_EACH_EDGE, free(), gcc_assert, ggc_cleared_alloc(), header, loop::header, i, init_loops_structure(), loops::larray, loop::latch, n_basic_blocks_for_fn, NULL, loop::num, NUM_FIXED_BLOCKS, loop::num_nodes, pre_and_rev_post_order_compute(), TDF_DETAILS, loops::tree_root, and vec_safe_push().

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

◆ flow_loops_free()

void flow_loops_free ( struct loops * loops)
extern
Free all the memory allocated for LOOPS.   

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

Referenced by loop_optimizer_finalize().

◆ free_simple_loop_desc()

void free_simple_loop_desc ( class loop * loop)
extern
Releases simple loop description for LOOP.   

References ggc_free(), NULL, loop::simple_loop_desc, and simple_loop_desc().

Referenced by loop_optimizer_finalize().

◆ gcov_type_to_wide_int()

widest_int gcov_type_to_wide_int ( gcov_type val)
inline
Converts VAL to widest_int.   

References a, and HOST_BITS_PER_WIDE_INT.

◆ get_estimated_loop_iterations()

bool get_estimated_loop_iterations ( class loop * loop,
widest_int * nit )
extern
Sets NIT to the estimated number of executions of the latch of the
LOOP.  If we have no reliable estimate, the function returns false, otherwise
returns true.   

References loop::any_estimate, expected_loop_iterations_by_profile(), loop::nb_iterations_estimate, SIGNED, and sreal::to_nearest_int().

Referenced by decide_unroll_constant_iterations(), decide_unroll_runtime_iterations(), decide_unroll_stupid(), estimated_loop_iterations(), and get_estimated_loop_iterations_int().

◆ get_estimated_loop_iterations_int()

HOST_WIDE_INT get_estimated_loop_iterations_int ( class loop * loop)
extern
Similar to get_estimated_loop_iterations, but returns the estimate only
if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate
on the number of iterations of LOOP could not be derived, returns -1.   

References wi::fits_shwi_p(), get_estimated_loop_iterations(), and generic_wide_int< storage >::to_shwi().

Referenced by doloop_optimize(), find_simple_exit(), and generic_predict_doloop_p().

◆ get_iv_value()

rtx get_iv_value ( class rtx_iv * iv,
rtx iteration )
extern
Calculates value of IV at ITERATION-th iteration.   

References iv::base, const0_rtx, gcc_assert, iv_extend_to_rtx_code(), IV_UNKNOWN_EXTEND, lowpart_subreg(), simplify_gen_binary(), simplify_gen_unary(), and iv::step.

Referenced by iv_extend(), and iv_subreg().

◆ get_likely_max_loop_iterations()

bool get_likely_max_loop_iterations ( class loop * loop,
widest_int * nit )
extern
Sets NIT to an upper bound for the maximum number of executions of the
latch of the LOOP.  If we have no reliable estimate, the function returns
false, otherwise returns true.   

References loop::any_likely_upper_bound, loop::nb_iterations_likely_upper_bound, and SIGNED.

Referenced by decide_unroll_constant_iterations(), decide_unroll_runtime_iterations(), decide_unroll_stupid(), get_likely_max_loop_iterations_int(), and likely_max_loop_iterations().

◆ get_likely_max_loop_iterations_int()

HOST_WIDE_INT get_likely_max_loop_iterations_int ( class loop * loop)
extern
Similar to get_max_loop_iterations, but returns the estimate only
if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate
on the number of iterations of LOOP could not be derived, returns -1.   

References wi::fits_shwi_p(), get_likely_max_loop_iterations(), and generic_wide_int< storage >::to_shwi().

Referenced by doloop_optimize(), find_simple_exit(), generic_predict_doloop_p(), likely_max_stmt_executions_int(), parallelize_loops(), and scale_profile_for_vect_loop().

◆ get_loop()

◆ get_loop_body()

basic_block * get_loop_body ( const class loop * loop)
extern
Loops & cfg manipulation.   
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.   

References cfun, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_BB_FN, gcc_assert, get_loop_body_with_size(), loop::header, loop::latch, n_basic_blocks_for_fn, and loop::num_nodes.

Referenced by analyze_function_body(), analyze_insns_in_loop(), average_num_loop_insns(), can_duplicate_loop_p(), cancel_loop(), determine_reduction_stmt(), doloop_valid_p(), draw_cfg_nodes_for_loop(), estimate_loops_at_level(), estimate_numbers_of_iterations(), find_loop_guard(), find_simple_exit(), fix_bb_placements(), fix_loop_bb_probability(), flow_loop_dump(), free_rdg(), get_loop_body_in_custom_order(), get_loop_body_in_custom_order(), get_loop_exit_edges(), hoist_guard(), ifcvt_split_critical_edges(), init_loop_unswitch_info(), loop_has_phi_with_address_arg(), loop_nest_has_data_refs(), num_loop_branches(), num_loop_insns(), number_of_iterations_exit_assumptions(), optimize_mask_stores(), predict_loops(), referenced_in_one_insn_in_loop_p(), reset_debug_uses_in_loop(), scale_loop_frequencies(), set_uid_loop_bbs(), simplify_loop_version(), split_loop(), split_loop_on_cond(), tree_estimate_loop_size(), tree_num_loop_insns(), tree_ssa_iv_optimize_loop(), tree_unswitch_single_loop(), unloop(), unroll_loop_runtime_iterations(), update_dominators_in_loop(), update_epilogue_loop_vinfo(), vect_analyze_loop_form(), vect_do_peeling(), and verify_loop_closed_ssa().

◆ get_loop_body_in_bfs_order()

basic_block * get_loop_body_in_bfs_order ( const class loop * loop)
extern

◆ get_loop_body_in_custom_order() [1/2]

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

References get_loop_body(), loop::num_nodes, and qsort.

Referenced by loop_distribution::stmts_from_loop().

◆ get_loop_body_in_custom_order() [2/2]

basic_block * get_loop_body_in_custom_order ( const class loop * loop,
void * data,
int(* bb_comparator )(const void *, const void *, void *) )
extern
Same as above, but use gcc_sort_r instead of qsort.   

References gcc_sort_r(), get_loop_body(), and loop::num_nodes.

◆ get_loop_body_in_dom_order()

◆ get_loop_body_with_size()

unsigned get_loop_body_with_size ( const class loop * loop,
basic_block * body,
unsigned max_size )
extern
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(), merge_loop_tree(), slpeel_can_duplicate_loop_p(), slpeel_tree_duplicate_loop_to_edge_cfg(), unroll_jam_possible_p(), and verify_loop_structure().

◆ get_loop_exit_edges()

◆ get_loop_hot_path()

auto_vec< basic_block > get_loop_hot_path ( const class loop * loop)
extern
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.   

References BITMAP_ALLOC, bitmap_bit_p, BITMAP_FREE, bitmap_set_bit, FOR_EACH_EDGE, loop::header, basic_block_def::index, loop_exit_edge_p(), NULL, path, basic_block_def::succs, and visited.

Referenced by tree_estimate_loop_size().

◆ get_loop_level()

unsigned get_loop_level ( const class loop * loop)
extern
Returns the maximum level of nesting of subloops of LOOP.   

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

Referenced by doloop_optimize(), and get_loop_level().

◆ get_loop_location()

dump_user_location_t get_loop_location ( class loop * loop)
extern

◆ get_loops()

◆ get_max_loop_iterations()

bool get_max_loop_iterations ( const class loop * loop,
widest_int * nit )
extern
Sets NIT to an upper bound for the maximum number of executions of the
latch of the LOOP.  If we have no reliable estimate, the function returns
false, otherwise returns true.   

References loop::any_upper_bound, loop::nb_iterations_upper_bound, and SIGNED.

Referenced by doloop_modify(), doloop_optimize(), doloop_simplify_count(), get_max_loop_iterations_int(), iv_can_overflow_p(), loop_niters_no_overflow(), and max_loop_iterations().

◆ get_max_loop_iterations_int()

HOST_WIDE_INT get_max_loop_iterations_int ( const class loop * loop)
extern
Similar to get_max_loop_iterations, but returns the estimate only
if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate
on the number of iterations of LOOP could not be derived, returns -1.   

References wi::fits_shwi_p(), get_max_loop_iterations(), and generic_wide_int< storage >::to_shwi().

Referenced by expected_loop_iterations_unbounded(), find_simple_exit(), max_stmt_executions_int(), and pcom_worker::tree_predictive_commoning_loop().

◆ get_simple_loop_desc()

◆ init_loops_structure()

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(), ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, loop::header, loops::larray, loop::latch, n_basic_blocks_for_fn, 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().

◆ init_set_costs()

◆ iv_analysis_done()

void iv_analysis_done ( void )
extern
Free the data for an induction variable analysis.   

References bivs, clean_slate, clear_iv_info(), df_finish_pass(), free(), iv_ref_table, iv_ref_table_size, and NULL.

Referenced by doloop_optimize_loops(), and unroll_loops().

◆ iv_analysis_loop_init()

◆ iv_analyze()

bool iv_analyze ( rtx_insn * insn,
scalar_int_mode mode,
rtx val,
class rtx_iv * iv )
extern
Analyzes value VAL at INSN and stores the result to *IV.  MODE is the
mode of VAL.   

References df_find_use(), GET_CODE, iv_analyze_op(), rtx_iv::mode, NEXT_INSN(), simple_reg_p(), and SUBREG_REG.

Referenced by iv_number_of_iterations().

◆ iv_analyze_expr()

bool iv_analyze_expr ( rtx_insn * insn,
scalar_int_mode mode,
rtx rhs,
class rtx_iv * iv )
extern
Analyzes expression RHS used at INSN and stores the result to *IV.
The mode of the induction variable is MODE.   

References iv::base, CONSTANT_P, gcc_assert, GET_CODE, GET_MODE, is_a(), iv_add(), iv_analyze_expr(), iv_analyze_op(), iv_extend(), iv_mult(), iv_neg(), iv_shift(), IV_SIGN_EXTEND, IV_ZERO_EXTEND, rtx_iv::mode, NULL_RTX, REG_P, iv::step, and XEXP.

Referenced by iv_analyze_def(), and iv_analyze_expr().

◆ iv_analyze_result()

bool iv_analyze_result ( rtx_insn * insn,
rtx def,
class rtx_iv * iv )
extern
Analyzes definition of DEF in INSN and stores the result to IV.   

References df_find_def(), and iv_analyze_def().

Referenced by analyze_iv_to_split_insn().

◆ just_once_each_iteration_p()

◆ loop_constraint_clear()

void loop_constraint_clear ( class loop * loop,
unsigned c )
inline
Clear C from the LOOP constraint.   

References loop::constraints.

Referenced by vect_do_peeling(), and vect_free_loop_info_assumptions().

◆ loop_constraint_set()

void loop_constraint_set ( class loop * loop,
unsigned c )
inline
Set C to the LOOP constraint.   

References loop::constraints.

Referenced by vect_analyze_loop().

◆ loop_constraint_set_p()

bool loop_constraint_set_p ( class loop * loop,
unsigned c )
inline
Check if C is set in the LOOP constraint.   

References loop::constraints.

Referenced by number_of_iterations_exit_assumptions(), try_vectorize_loop_1(), and vect_loop_versioning().

◆ loop_count_in()

◆ loop_depth()

◆ loop_exit_edge_p()

◆ loop_exits_from_bb_p()

bool loop_exits_from_bb_p ( class loop * loop,
basic_block bb )
extern

◆ loop_exits_to_bb_p()

bool loop_exits_to_bb_p ( class loop * loop,
basic_block bb )
extern
Returns true when BB has an incoming edge exiting LOOP.   

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

◆ loop_has_exit_edges()

bool loop_has_exit_edges ( const class loop * loop)
inline
Returns true if LOOP has at least one exit edge.   

References loop_exit::e, loop::exits, loop_exit::next, and NULL.

◆ loop_latch_edge()

edge loop_latch_edge ( const class loop * loop)
extern
Returns latch edge of LOOP.   

References find_edge(), loop::header, and loop::latch.

Referenced by add_iv_candidate_for_biv(), analyze_and_compute_bitop_with_inv_effect(), analyze_and_compute_bitwise_induction_effect(), loop_cand::analyze_iloop_reduction_var(), loop_cand::analyze_oloop_reduction_var(), assign_calc_vals_to_header_phis(), connect_loop_phis(), constant_after_peeling(), create_iv(), create_parallel_loop(), create_preheader(), discover_iteration_bound_by_body_walk(), do_split_loop_on_cond(), duplicate_loop_body_to_header_edge(), easy_exit_values(), eliminate_temp_copies(), estimate_loops_at_level(), crc_optimization::execute(), pcom_worker::find_looparound_phi(), find_vdef_in_loop(), fuse_loops(), get_base_for(), ifcvt_local_dce(), initialize_root_vars(), initialize_root_vars_lm(), initialize_root_vars_store_elim_2(), is_cond_scalar_reduction(), crc_optimization::is_output_crc(), loop_iter_phi_semi_invariant_p(), loop_niter_by_eval(), mark_bivs(), maybe_lower_iteration_bound(), maybe_set_vectorized_backedge_value(), number_of_iterations_cltz(), number_of_iterations_cltz_complement(), number_of_iterations_popcount(), parloops_is_simple_reduction(), process_use(), slpeel_tree_duplicate_loop_to_edge_cfg(), split_loop(), crc_optimization::swap_crc_and_data_if_needed(), fwd_jt_path_registry::thread_through_loop_header(), tree_transform_and_unroll_loop(), unloop_loops(), unroll_loop_constant_iterations(), unroll_loop_runtime_iterations(), unroll_loop_stupid(), vect_analyze_slp(), vect_build_slp_instance(), vect_build_slp_tree_2(), vect_create_epilog_for_reduction(), vect_is_nonlinear_iv_evolution(), vect_is_simple_reduction(), vect_phi_first_order_recurrence_p(), vect_set_loop_control(), vectorizable_induction(), vectorizable_load(), vectorizable_nonlinear_induction(), vectorizable_recurr(), vectorizable_reduction(), and vectorizable_simd_clone_call().

◆ loop_optimizer_finalize() [1/2]

◆ loop_optimizer_finalize() [2/2]

◆ loop_optimizer_init()

◆ loop_outer()

class loop * loop_outer ( const class loop * loop)
inline
Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost
loop.   

References NULL, loop::superloops, and vec_safe_length().

Referenced by add_exit_phis(), add_loop(), add_loop_to_tree(), analyze_memory_references(), analyze_scalar_evolution_in_loop(), calculate_loop_reg_pressure(), cancel_loop(), compute_access_range(), compute_access_stride(), compute_invariantness(), create_loop_tree_nodes(), determine_loop_nest_reuse(), dfs_find_deadend(), do_not_sink(), duplicate_block(), dw2_build_landing_pads(), eliminate_dom_walker::eliminate_stmt(), fill_coldest_and_hotter_out_loop(), find_common_loop(), find_loop_location(), find_sibling_superloop(), find_uses_to_rename_use(), fix_bb_placement(), fix_bb_placements(), fix_loop_placement(), fix_loop_placements(), fix_loop_structure(), flow_loop_dump(), flow_loop_tree_node_remove(), form_loop_tree(), fwprop_insn(), gbb_loop_at_index(), get_all_loop_exits(), gimple_duplicate_seme_region(), init_loop_unswitch_info(), tree_loop_interchange::interchange_loops(), loop_preheader_edge(), loop_version(), make_forwarder_block(), mark_loop_exit_edges(), mark_loops_in_oacc_kernels_region(), mark_ref_loaded(), mark_ref_regs(), mark_ref_stored(), mark_regno_live(), merge_loop_tree(), move_computations_worker(), move_sese_region_to_fn(), optimize_loop_nest_for_size_p(), optimize_loop_nest_for_speed_p(), outermost_invariant_loop(), outermost_loop_in_sese_1(), predict_loops(), prepare_perfect_loop_nest(), fold_using_range::range_of_phi(), remove_ctrl_stmt_and_useless_edges(), remove_edge_and_dominated_blocks(), remove_path(), rename_variables_in_bb(), rescan_loop_exit(), sese_loop_depth(), set_level(), sjlj_emit_dispatch_table(), slpeel_can_duplicate_loop_p(), slpeel_tree_duplicate_loop_to_edge_cfg(), fwd_jt_path_registry::thread_block_1(), fwd_jt_path_registry::thread_through_loop_header(), tree_forwarder_block_p(), tree_if_conversion(), tree_loop_unroll_and_jam(), tree_ssa_split_loops(), tree_unroll_loops_completely(), tree_unroll_loops_completely_1(), unloop(), vect_analyze_early_break_dependences(), vect_analyze_loop(), vect_loop_versioning(), verify_loop_structure(), versionable_outer_loop_p(), and loops_list::walk_loop_tree().

◆ loop_outermost()

class loop * loop_outermost ( class loop * loop)
inline
Returns the outermost loop of the loop nest that contains LOOP. 

References loop::superloops, and vec_safe_length().

Referenced by gather_memory_references_ref().

◆ loop_preheader_edge()

edge loop_preheader_edge ( const class loop * loop)
extern
Returns preheader edge of LOOP.   

References cfun, loop_exit::e, ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, gcc_assert, loop::header, loop::latch, loop_outer(), LOOPS_HAVE_PREHEADERS, LOOPS_MAY_HAVE_MULTIPLE_LATCHES, loops_state_satisfies_p(), basic_block_def::preds, and single_succ_edge().

Referenced by add_preheader_seq(), analyze_and_compute_bitop_with_inv_effect(), analyze_and_compute_bitwise_induction_effect(), loop_cand::analyze_carried_vars(), analyze_function_body(), loop_cand::analyze_iloop_reduction_var(), loop_cand::analyze_induction_var(), analyze_insns_in_loop(), loop_cand::analyze_oloop_reduction_var(), assign_calc_vals_to_header_phis(), assign_known_vals_to_header_phis(), assign_vals_to_header_phis(), bb_colder_than_loop_preheader(), block_before_loop(), build_region(), canonicalize_loop_ivs(), check_exit_phi(), compute_access_stride(), connect_loop_phis(), connect_loops(), constant_after_peeling(), copy_loop_before(), create_empty_loop_on_edge(), create_iv(), create_parallel_loop(), cse_and_gimplify_to_preheader(), destroy_loop(), determine_exit_conditions(), determine_loop_nest_reuse(), determine_value_range(), do_split_loop_on_cond(), doloop_modify(), execute_sm(), execute_sm_exit(), fill_coldest_and_hotter_out_loop(), find_bivs(), find_data_references_in_stmt(), find_invariants_bb(), pcom_worker::find_looparound_phi(), find_reduc_addr(), fix_loop_placements(), gen_parallel_loop(), generate_memcpy_builtin(), generate_memset_builtin(), generate_reduction_builtin_1(), get_base_for(), get_range_query(), get_vop_from_header(), hoist_guard(), hoist_memory_references(), ifcvt_can_hoist(), initialize_data_dependence_relation(), initialize_reductions(), initialize_root_vars(), initialize_root_vars_lm(), initialize_root_vars_store_elim_2(), insert_init_seqs(), vec_info::insert_seq_on_entry(), instantiate_parameters(), tree_loop_interchange::interchange_loops(), loop_niter_by_eval(), loop_rev_post_order_compute(), loop_version(), move_computations_worker(), move_invariant_reg(), number_of_iterations_cltz(), number_of_iterations_cltz_complement(), number_of_iterations_popcount(), parallelize_loops(), predict_loops(), pcom_worker::prepare_initializers_chain(), resolve_mixers(), rewrite_use_compare(), scale_profile_for_vect_loop(), simplify_using_initial_values(), slpeel_can_duplicate_loop_p(), slpeel_tree_duplicate_loop_to_edge_cfg(), slpeel_update_phi_nodes_for_guard1(), split_loop(), stmt_semi_invariant_p_1(), transform_to_exit_first_loop_alt(), tree_if_conversion(), tree_loop_unroll_and_jam(), tree_transform_and_unroll_loop(), tree_unroll_loops_completely(), try_peel_loop(), try_transform_to_exit_first_loop_alt(), try_unroll_loop_completely(), unloop(), unroll_loop_constant_iterations(), unroll_loop_runtime_iterations(), crc_optimization::validate_crc_and_data(), vect_analyze_loop_form(), vect_build_loop_niters(), vect_build_slp_tree_2(), vect_create_data_ref_ptr(), vect_create_epilog_for_reduction(), vect_do_peeling(), vect_emit_reduction_init_stmts(), vect_enhance_data_refs_alignment(), vect_gen_vector_loop_niters(), vect_get_external_def_edge(), vect_get_gather_scatter_ops(), vect_is_nonlinear_iv_evolution(), vect_loop_dist_alias_call(), vect_loop_vectorized_call(), vect_loop_versioning(), vect_phi_initial_value(), vect_prepare_for_masked_peels(), vect_set_loop_condition_normal(), vect_set_loop_control(), vect_setup_realignment(), vect_transform_cycle_phi(), vect_transform_loop(), vect_update_ivs_after_vectorizer(), vectorizable_induction(), vectorizable_load(), vectorizable_nonlinear_induction(), vectorizable_recurr(), and vectorizable_simd_clone_call().

◆ loops_state_clear() [1/2]

void loops_state_clear ( function * fn,
unsigned flags )
inline

◆ loops_state_clear() [2/2]

void loops_state_clear ( unsigned flags)
inline

◆ loops_state_satisfies_p() [1/2]

◆ loops_state_satisfies_p() [2/2]

bool loops_state_satisfies_p ( unsigned flags)
inline

References cfun, and loops_state_satisfies_p().

◆ loops_state_set() [1/2]

◆ loops_state_set() [2/2]

void loops_state_set ( unsigned flags)
inline

References cfun, and loops_state_set().

◆ mark_irreducible_loops()

◆ mark_loop_exit_edges()

void mark_loop_exit_edges ( void )
extern

◆ mark_loop_for_removal()

◆ maybe_flat_loop_profile()

bool maybe_flat_loop_profile ( const class loop * loop)
extern
Return true if loop CFG profile may be unrealistically flat.
This is a common case, since average loops iterate only about 5 times.
In the case we do not have profile feedback or do not know real number of
iterations during profile estimation, we are likely going to predict it with
similar low iteration count.  For static loop profiles we also artificially
cap profile of loops with known large iteration count so they do not appear
significantly more hot than other loops with unknown iteration counts.

For loop optimization heuristics we ignore CFG profile and instead
use get_estimated_loop_iterations API which returns estimate
only when it is realistic.  For unknown counts some optimizations,
like vectorizer or unroller make guess that iteration count will
be large.  In this case we need to avoid scaling down the profile
after the loop transform.   

References loop::any_estimate, loop::any_likely_upper_bound, loop::any_upper_bound, dump_file, dump_flags, expected_loop_iterations_by_profile(), wi::geu_p(), wi::gtu_p(), wi::ltu_p(), loop::nb_iterations_estimate, loop::nb_iterations_likely_upper_bound, loop::nb_iterations_upper_bound, loop::num, TDF_DETAILS, sreal::to_double(), sreal::to_nearest_int(), and generic_wide_int< storage >::to_shwi().

Referenced by print_loop_info(), tree_transform_and_unroll_loop(), unroll_loop_constant_iterations(), and vect_transform_loop().

◆ move_loop_invariants()

◆ num_loop_branches()

unsigned num_loop_branches ( const class loop * loop)
extern
Counts the number of conditional branches inside LOOP.   

References cfun, EDGE_COUNT, EXIT_BLOCK_PTR_FOR_FN, free(), gcc_assert, get_loop_body(), i, loop::latch, and loop::num_nodes.

Referenced by decide_unroll_stupid().

◆ num_loop_insns()

int num_loop_insns ( const class loop * loop)
extern

◆ number_of_loops()

◆ print_loop_info()

◆ record_loop_exits()

◆ record_niter_bound()

void record_niter_bound ( class loop * loop,
const widest_int & i_bound,
bool realistic,
bool upper )
extern
Records that every statement in LOOP is executed I_BOUND times.
REALISTIC is true if I_BOUND is expected to be close to the real number
of iterations.  UPPER is true if we are sure the loop iterates at most
I_BOUND times.   

References loop::any_estimate, loop::any_likely_upper_bound, loop::any_upper_bound, wi::ltu_p(), wi::min_precision(), loop::nb_iterations_estimate, loop::nb_iterations_likely_upper_bound, loop::nb_iterations_upper_bound, and SIGNED.

Referenced by branch_prob(), canonicalize_loop_induction_variables(), discover_iteration_bound_by_body_walk(), estimate_numbers_of_iterations(), iv_number_of_iterations(), maybe_lower_iteration_bound(), record_estimate(), and vect_do_peeling().

◆ release_recorded_exits()

◆ remove_bb_from_loops()

◆ rescan_loop_exit()

◆ simple_loop_desc()

class niter_desc * simple_loop_desc ( class loop * loop)
inline

◆ single_dom_exit()

◆ single_exit()

edge single_exit ( const class loop * loop)
extern
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(), loop_exit::next, and NULL.

Referenced by canonicalize_loop_induction_variables(), check_exit_phi(), combine_blocks(), compute_access_range(), connect_loops(), copy_loop_before(), create_bb_after_loop(), create_empty_loop_on_edge(), destroy_loop(), do_warn_aggressive_loop_optimizations(), easy_exit_values(), empty_bb_without_guard_p(), loop_distribution::execute(), final_value_replacement_loop(), finalize_eliminated_stores(), find_simple_exit(), find_single_drs(), gen_parallel_loop(), generate_loops_for_partition(), get_loop_exit_condition(), get_loop_location(), crc_optimization::get_output_phi(), hoist_guard(), crc_optimization::is_output_crc(), latch_dominated_by_data_ref(), crc_optimization::loop_calculates_crc(), loop_closed_phi_def(), loop_exit_for_scaling(), loop_only_exit_p(), tree_loop_interchange::move_code_to_inner_loop(), number_of_latch_executions(), patch_loop_exit(), prepare_perfect_loop_nest(), single_dom_exit(), single_likely_exit(), pcom_worker::split_data_refs_to_components(), split_loop(), crc_optimization::swap_crc_and_data_if_needed(), loop_distribution::transform_reduction_loop(), tree_if_conversion(), tree_loop_unroll_and_jam(), tree_unswitch_outer_loop(), unroll_jam_possible_p(), vect_analyze_loop_form(), vect_loop_versioning(), and versionable_outer_loop_p().

◆ single_likely_exit()

edge single_likely_exit ( class loop * loop,
const vec< edge > & exits )
extern
Return exit edge if loop has only one exit that is likely
to be executed on runtime (i.e. it is not EH or leading
to noreturn call.   

References cfun, loop::exits, FOR_EACH_VEC_ELT, i, NULL, probably_never_executed_edge_p(), single_exit(), and profile_probability::very_unlikely().

Referenced by canonicalize_loop_induction_variables(), estimate_numbers_of_iterations(), and loop_exit_for_scaling().

◆ sort_sibling_loops()

◆ superloop_at_depth()

◆ verify_loop_structure()

void verify_loop_structure ( void )
extern
Disable warnings about missing quoting in GCC diagnostics for
the verification errors.  Their format strings don't follow GCC
diagnostic conventions and the calls are ultimately followed by
a deliberate ICE triggered by a failed assertion.   
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_set_bit, calculate_dominance_info(), CDI_DOMINATORS, cfun, current_loops, dom_info_available_p(), dominated_by_p(), loop_exit::e, EDGE_COUNT, ENTRY_BLOCK_PTR_FOR_FN, error(), EXIT_BLOCK_PTR_FOR_FN, loop::exits, find_edge(), find_released_ssa_name(), basic_block_def::flags, flow_bb_inside_loop_p(), FOR_EACH_BB_FN, FOR_EACH_EDGE, free(), free_dominance_info(), gcc_assert, get_exit_descriptions(), get_loop_body_with_size(), loop::header, i, basic_block_def::index, last_basic_block_for_fn, loop::latch, LI_FROM_INNERMOST, basic_block_def::loop_father, 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(), n_basic_blocks_for_fn, loop::nb_iterations, loop_exit::next, loop_exit::next_e, NULL, loop::num, loop::num_nodes, number_of_loops(), basic_block_def::preds, single_succ(), single_succ_p(), basic_block_def::succs, verify_dominators(), visited, and walk_tree.

Referenced by checking_verify_loop_structure(), execute_function_todo(), expand_omp_target(), and expand_omp_taskreg().

Variable Documentation

◆ default_target_cfgloop

struct target_cfgloop default_target_cfgloop
extern
Natural loop analysis code for GNU compiler.
   Copyright (C) 2002-2024 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/>.