GCC Middle and Back End API Reference
tree-ssa-loop-niter.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

tree expand_simple_operations (tree, tree=NULL)
 
tree simplify_using_initial_conditions (class loop *, tree)
 
bool loop_only_exit_p (const class loop *, basic_block *body, const_edge)
 
bool number_of_iterations_exit (class loop *, edge, class tree_niter_desc *niter, bool, bool every_iteration=true, basic_block *=NULL)
 
bool number_of_iterations_exit_assumptions (class loop *, edge, class tree_niter_desc *, gcond **, bool=true, basic_block *=NULL)
 
tree find_loop_niter (class loop *, edge *)
 
bool finite_loop_p (class loop *)
 
tree loop_niter_by_eval (class loop *, edge)
 
tree find_loop_niter_by_eval (class loop *, edge *)
 
bool estimated_loop_iterations (class loop *, widest_int *)
 
HOST_WIDE_INT estimated_loop_iterations_int (class loop *)
 
bool max_loop_iterations (class loop *, widest_int *)
 
HOST_WIDE_INT max_loop_iterations_int (class loop *)
 
bool likely_max_loop_iterations (class loop *, widest_int *)
 
HOST_WIDE_INT likely_max_loop_iterations_int (class loop *)
 
HOST_WIDE_INT max_stmt_executions_int (class loop *)
 
HOST_WIDE_INT likely_max_stmt_executions_int (class loop *)
 
HOST_WIDE_INT estimated_stmt_executions_int (class loop *)
 
bool max_stmt_executions (class loop *, widest_int *)
 
bool likely_max_stmt_executions (class loop *, widest_int *)
 
bool estimated_stmt_executions (class loop *, widest_int *)
 
void estimate_numbers_of_iterations (function *)
 
void estimate_numbers_of_iterations (class loop *)
 
bool stmt_dominates_stmt_p (gimple *, gimple *)
 
bool nowrap_type_p (tree)
 
bool scev_probably_wraps_p (tree, tree, tree, gimple *, class loop *, bool)
 
void free_numbers_of_iterations_estimates (class loop *)
 
void free_numbers_of_iterations_estimates (function *)
 
tree simplify_replace_tree (tree, tree, tree, tree(*)(tree, void *)=NULL, void *=NULL, bool do_fold=true)
 
void substitute_in_loop_info (class loop *, tree, tree)
 

Function Documentation

◆ estimate_numbers_of_iterations() [1/2]

◆ estimate_numbers_of_iterations() [2/2]

void estimate_numbers_of_iterations ( function * fn)
extern
Records estimates on numbers of iterations of loops.   

References estimate_numbers_of_iterations(), fold_defer_overflow_warnings(), and fold_undefer_and_ignore_overflow_warnings().

◆ estimated_loop_iterations()

bool 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 CONSERVATIVE is true, we must be sure that NIT is at least as
large as the number of iterations.  If we have no reliable estimate,
the function returns false, otherwise returns true.   

References estimate_numbers_of_iterations(), get_estimated_loop_iterations(), ggc_alloc(), and scev_initialized_p().

Referenced by estimated_loop_iterations_int(), and estimated_stmt_executions().

◆ estimated_loop_iterations_int()

HOST_WIDE_INT estimated_loop_iterations_int ( class loop * loop)
extern
Similar to 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 estimated_loop_iterations(), wi::fits_shwi_p(), and ggc_alloc().

Referenced by estimated_stmt_executions_int(), loop_distribution::execute(), parallelize_loops(), tree_ssa_unswitch_loops(), tree_unswitch_outer_loop(), and try_peel_loop().

◆ estimated_stmt_executions()

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

References estimated_loop_iterations(), ggc_alloc(), and wi::gtu_p().

Referenced by predict_loops(), and vect_create_loop_vinfo().

◆ estimated_stmt_executions_int()

HOST_WIDE_INT estimated_stmt_executions_int ( class loop * loop)
extern
Returns an estimate for the number of executions of statements
in the LOOP.  For statements before the loop exit, this exceeds
the number of execution of the latch by one.   

References estimated_loop_iterations_int(), and ggc_alloc().

Referenced by avg_loop_niter(), determine_loop_nest_reuse(), loop_prefetch_arrays(), and vect_analyze_loop_costing().

◆ expand_simple_operations()

tree expand_simple_operations ( tree expr,
tree stop = NULL )
extern
Header file for loop interation estimates.
   Copyright (C) 2013-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/>.   

References cache, and expand_simple_operations().

◆ find_loop_niter()

tree find_loop_niter ( class loop * loop,
edge * exit )
extern
Try to determine the number of iterations of LOOP.  If we succeed,
expression giving number of iterations is returned and *EXIT is
set to the edge from that the information is obtained.  Otherwise
chrec_dont_know is returned.   

References build_int_cst(), chrec_dont_know, FOR_EACH_VEC_ELT, get_loop_exit_edges(), ggc_alloc(), i, integer_nonzerop(), integer_zerop(), tree_niter_desc::may_be_zero, tree_niter_desc::niter, NULL, NULL_TREE, number_of_iterations_exit(), TREE_CODE, tree_int_cst_lt(), and unsigned_type_node.

Referenced by canonicalize_loop_induction_variables().

◆ find_loop_niter_by_eval()

tree find_loop_niter_by_eval ( class loop * loop,
edge * exit )
extern
Finds the exit of the LOOP by that the loop exits after a constant
number of iterations and stores the exit edge to *EXIT.  The constant
giving the number of iterations of LOOP is returned.  The number of
iterations is determined using loop_niter_by_eval (i.e. by brute force
evaluation).  If we are unable to find the exit for that loop_niter_by_eval
determines the number of iterations, chrec_dont_know is returned.   

References chrec_contains_undetermined(), chrec_dont_know, FOR_EACH_VEC_ELT, get_loop_exit_edges(), ggc_alloc(), i, just_once_each_iteration_p(), loop_niter_by_eval(), tree_niter_desc::niter, NULL, NULL_TREE, and tree_int_cst_lt().

Referenced by canonicalize_loop_induction_variables().

◆ finite_loop_p()

◆ free_numbers_of_iterations_estimates() [1/2]

◆ free_numbers_of_iterations_estimates() [2/2]

void free_numbers_of_iterations_estimates ( function * fn)
extern
Frees the information on upper bounds on numbers of iterations of loops.   

References free_numbers_of_iterations_estimates().

◆ likely_max_loop_iterations()

bool likely_max_loop_iterations ( class loop * loop,
widest_int * nit )
extern
Sets NIT to an likely 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 estimate_numbers_of_iterations(), get_likely_max_loop_iterations(), ggc_alloc(), and scev_initialized_p().

Referenced by likely_max_loop_iterations_int(), and likely_max_stmt_executions().

◆ likely_max_loop_iterations_int()

HOST_WIDE_INT likely_max_loop_iterations_int ( class loop * loop)
extern
Similar to 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(), ggc_alloc(), and likely_max_loop_iterations().

Referenced by canonicalize_loop_induction_variables(), loop_distribution::execute(), predict_loops(), tree_ssa_unswitch_loops(), tree_unswitch_outer_loop(), and try_peel_loop().

◆ likely_max_stmt_executions()

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

References ggc_alloc(), wi::gtu_p(), and likely_max_loop_iterations().

Referenced by predict_loops().

◆ likely_max_stmt_executions_int()

HOST_WIDE_INT likely_max_stmt_executions_int ( class loop * loop)
extern
Returns an likely upper bound on the number of executions of statements
in the LOOP.  For statements before the loop exit, this exceeds
the number of execution of the latch by one.   

References get_likely_max_loop_iterations_int(), and ggc_alloc().

Referenced by avg_loop_niter(), vector_costs::compare_inside_loop_cost(), loop_prefetch_arrays(), vect_analyze_loop_costing(), and vect_need_peeling_or_partial_vectors_p().

◆ loop_niter_by_eval()

tree loop_niter_by_eval ( class loop * loop,
edge exit )
extern
Tries to count the number of iterations of LOOP till it exits by EXIT
by brute force -- i.e. by determining the value of the operands of the
condition at EXIT in first few iterations of the loop (assuming that
these values are constant) and determining the first one in that the
condition is not satisfied.  Returns the constant giving the number
of the iterations of LOOP if successful, chrec_dont_know otherwise.   

References boolean_type_node, build_int_cst(), chrec_dont_know, tree_niter_desc::cmp, dump_file, dump_flags, fold_binary, fold_defer_overflow_warnings(), fold_undefer_and_ignore_overflow_warnings(), get_base_for(), get_val_for(), ggc_alloc(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gsi_last_bb(), i, integer_zerop(), invert_tree_comparison(), is_gimple_min_invariant(), loop_latch_edge(), loop_preheader_edge(), MAX_ITERATIONS_TO_TRACK, NULL_TREE, loop::num, PHI_ARG_DEF_FROM_EDGE, TDF_DETAILS, and unsigned_type_node.

Referenced by find_loop_niter_by_eval(), and predict_loops().

◆ loop_only_exit_p()

bool loop_only_exit_p ( const class loop * loop,
basic_block * body,
const_edge exit )
extern

◆ max_loop_iterations()

bool max_loop_iterations ( class loop * loop,
widest_int * nit )
extern

◆ max_loop_iterations_int()

HOST_WIDE_INT max_loop_iterations_int ( class loop * loop)
extern
Similar to 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(), ggc_alloc(), and max_loop_iterations().

Referenced by canonicalize_loop_induction_variables(), and predict_loops().

◆ max_stmt_executions()

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

References ggc_alloc(), wi::gtu_p(), and max_loop_iterations().

Referenced by is_nonwrapping_integer_induction(), and max_stmt_executions_tree().

◆ max_stmt_executions_int()

HOST_WIDE_INT max_stmt_executions_int ( class loop * loop)
extern
Returns an upper bound on the number of executions of statements
in the LOOP.  For statements before the loop exit, this exceeds
the number of execution of the latch by one.   

References get_max_loop_iterations_int(), and ggc_alloc().

Referenced by analyze_siv_subscript_cst_affine(), analyze_subscript_affine_affine(), compute_overlap_steps_for_affine_1_2(), and vect_known_niters_smaller_than_vf().

◆ nowrap_type_p()

◆ number_of_iterations_exit()

◆ number_of_iterations_exit_assumptions()

bool number_of_iterations_exit_assumptions ( class loop * loop,
edge exit,
class tree_niter_desc * niter,
gcond ** at_stmt,
bool every_iteration,
basic_block * body )
extern
Stores description of number of iterations of LOOP derived from
EXIT (an exit edge of the LOOP) in NITER.  Returns true if some useful
information could be derived (and fields of NITER have meaning described
in comments at class tree_niter_desc declaration), false otherwise.
When EVERY_ITERATION is true, only tests that are known to be executed
every iteration are considered (i.e. only test that alone bounds the loop).
If AT_STMT is not NULL, this function stores LOOP's condition statement in
it when returning true.   

References tree_niter_desc::assumptions, affine_iv::base, boolean_false_node, boolean_true_node, boolean_type_node, CDI_DOMINATORS, tree_niter_desc::control, dominated_by_p(), expand_simple_operations(), fold_build2, fold_convert, fold_defer_overflow_warnings(), fold_undefer_and_ignore_overflow_warnings(), free(), get_loop_body(), ggc_alloc(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gsi_last_bb(), integer_nonzerop(), integer_zerop(), invert_tree_comparison(), loop::latch, LOOP_C_FINITE, LOOP_C_INFINITE, loop_constraint_set_p(), loop_containing_stmt(), loop_only_exit_p(), tree_niter_desc::max, tree_niter_desc::may_be_zero, tree_niter_desc::niter, affine_iv::no_overflow, NULL, NULL_TREE, number_of_iterations_bitcount(), number_of_iterations_cltz(), number_of_iterations_cond(), POINTER_TYPE_P, simple_iv_with_niters(), simplify_using_initial_conditions(), simplify_using_outer_evolutions(), affine_iv::step, wi::to_widest(), TREE_CODE, TREE_TYPE, and type().

Referenced by number_of_iterations_exit(), vec_init_loop_exit_info(), and vect_get_loop_niters().

◆ scev_probably_wraps_p()

bool scev_probably_wraps_p ( tree var,
tree base,
tree step,
gimple * at_stmt,
class loop * loop,
bool use_overflow_semantics )
extern
Return false only when the induction variable BASE + STEP * I is
known to not overflow: i.e. when the number of iterations is small
enough with respect to the step and initial condition in order to
keep the evolution confined in TYPEs bounds.  Return true when the
iv is known to overflow or when the property is not computable.

USE_OVERFLOW_SEMANTICS is true if this function should assume that
the rules for overflow of the given language apply (e.g., that signed
arithmetics in C does not overflow).

If VAR is a ssa variable, this function also returns false if VAR can
be proven not overflow with value range info.   

References analyze_scalar_evolution(), chrec_contains_undetermined(), ggc_alloc(), integer_zerop(), loop_exits_before_overflow(), nonwrapping_chrec_p(), nowrap_type_p(), scev_var_range_cant_overflow(), TREE_CODE, and TREE_TYPE.

Referenced by convert_affine_scev(), get_scev_info(), and idx_infer_loop_bounds().

◆ simplify_replace_tree()

tree simplify_replace_tree ( tree expr,
tree old,
tree new_tree,
tree(*)(tree, void *) valueize,
void * context,
bool do_fold )
extern
Substitute NEW_TREE for OLD in EXPR and fold the result.
If VALUEIZE is non-NULL then OLD and NEW_TREE are ignored and instead
all SSA names are replaced with the result of calling the VALUEIZE
function with the SSA name as argument.   

References CONSTANT_CLASS_P, copy_node(), expr, EXPR_P, fold(), ggc_alloc(), i, NULL_TREE, operand_equal_p(), simplify_replace_tree(), TREE_CODE, TREE_OPERAND, TREE_OPERAND_LENGTH, and unshare_expr().

Referenced by process_bb(), simplify_replace_tree(), substitute_in_loop_info(), tree_simplify_using_condition_1(), and update_epilogue_loop_vinfo().

◆ simplify_using_initial_conditions()

◆ stmt_dominates_stmt_p()

bool stmt_dominates_stmt_p ( gimple * s1,
gimple * s2 )
extern
Returns true if statement S1 dominates statement S2.   

References CDI_DOMINATORS, dominated_by_p(), ggc_alloc(), gimple_bb(), gsi_next(), gsi_start_bb(), and gsi_stmt().

Referenced by n_of_executions_at_most().

◆ substitute_in_loop_info()

void substitute_in_loop_info ( class loop * loop,
tree name,
tree val )
extern
Substitute value VAL for ssa name NAME inside expressions held
at LOOP.   

References loop::nb_iterations, and simplify_replace_tree().

Referenced by replace_uses_by().