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

Go to the source code of this file.

Typedefs

typedef void(* transform_callback) (class loop *, void *)
 

Functions

void create_iv (tree, tree_code, tree, tree, class loop *, gimple_stmt_iterator *, bool, tree *, tree *)
 
void rewrite_into_loop_closed_ssa (bitmap, unsigned)
 
void verify_loop_closed_ssa (bool, class loop *=NULL)
 
void checking_verify_loop_closed_ssa (bool verify_ssa_p, class loop *loop=NULL)
 
basic_block split_loop_exit_edge (edge, bool=false)
 
basic_block ip_end_pos (class loop *)
 
basic_block ip_normal_pos (class loop *)
 
void standard_iv_increment_position (class loop *, gimple_stmt_iterator *, bool *)
 
bool gimple_duplicate_loop_body_to_header_edge (class loop *, edge, unsigned int, sbitmap, edge, vec< edge > *, int)
 
bool can_unroll_loop_p (class loop *loop, unsigned factor, class tree_niter_desc *niter)
 
gcov_type niter_for_unrolled_loop (class loop *, unsigned)
 
void tree_transform_and_unroll_loop (class loop *, unsigned, tree_niter_desc *, transform_callback, void *)
 
void tree_unroll_loop (class loop *, unsigned, tree_niter_desc *)
 
tree canonicalize_loop_ivs (class loop *, tree *, bool)
 
unsigned int loop_invariant_motion_in_fun (function *, bool)
 

Typedef Documentation

◆ transform_callback

typedef void(* transform_callback) (class loop *, void *)
Header file for High-level loop manipulation functions. Copyright (C) 2013-2025 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/>.

Function Documentation

◆ can_unroll_loop_p()

◆ canonicalize_loop_ivs()

tree canonicalize_loop_ivs ( class loop * loop,
tree * nit,
bool bump_in_latch )
extern
Bases all the induction variables in LOOP on a single induction variable (with base 0 and step 1), whose final value is compared with *NIT. When the IV type precision has to be larger than *NIT type precision, *NIT is converted to the larger type, the conversion code is inserted before the loop, and *NIT is updated to the new definition. When BUMP_IN_LATCH is true, the induction variable is incremented in the loop latch, otherwise it is incremented in the loop header. Return the induction variable that was created.

References as_a(), build_int_cst(), build_int_cst_type(), build_nonstandard_integer_type(), create_iv(), extract_true_false_edges_from_block(), fold_convert, force_gimple_operand(), GET_MODE_PRECISION(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gsi_end_p(), gsi_insert_seq_on_edge_immediate(), gsi_last_bb(), gsi_last_nondebug_bb(), gsi_next(), gsi_start_phis(), loop::header, INTEGRAL_TYPE_P, loop::latch, loop_preheader_edge(), NULL, NULL_TREE, gphi_iterator::phi(), PHI_RESULT, POINTER_TYPE_P, opt_mode< T >::require(), rewrite_all_phi_nodes_with_iv(), single_dom_exit(), smallest_int_mode_for_size(), TREE_TYPE, type(), TYPE_PRECISION, TYPE_UNSIGNED, update_stmt(), and virtual_operand_p().

Referenced by gen_parallel_loop().

◆ checking_verify_loop_closed_ssa()

void checking_verify_loop_closed_ssa ( bool verify_ssa_p,
class loop * loop = NULL )
inline

◆ create_iv()

void create_iv ( tree base,
tree_code incr_op,
tree step,
tree var,
class loop * loop,
gimple_stmt_iterator * incr_pos,
bool after,
tree * var_before,
tree * var_after )
extern
Creates an induction variable with value BASE (+/-) STEP * iteration in LOOP. If INCR_OP is PLUS_EXPR, the induction variable is BASE + STEP * iteration. If INCR_OP is MINUS_EXPR, the induction variable is BASE - STEP * iteration. It is expected that neither BASE nor STEP are shared with other expressions (unless the sharing rules allow this). Use VAR as a base var_decl for it (if NULL, a new temporary will be created). The increment will occur at INCR_POS (after it if AFTER is true, before it otherwise). INCR_POS and AFTER can be computed using standard_iv_increment_position. The ssa versions of the variable before and after increment will be stored in VAR_BEFORE and VAR_AFTER (unless they are NULL).

References add_phi_arg(), convert_to_ptrofftype, create_phi_node(), fold_build1, force_gimple_operand(), gcc_assert, gimple_build_assign(), gimple_location(), gimple_set_location(), gsi_bb(), gsi_end_p(), gsi_insert_after(), gsi_insert_before(), gsi_insert_seq_on_edge_immediate(), GSI_NEW_STMT, gsi_next_nondebug(), gsi_stmt(), loop::header, is_gimple_debug(), loop_latch_edge(), loop_preheader_edge(), make_ssa_name(), make_temp_ssa_name(), mark_addressable(), may_negate_without_overflow_p(), NULL, NULL_TREE, POINTER_TYPE_P, single_succ_edge(), TREE_CODE, tree_expr_nonnegative_warnv_p, tree_int_cst_lt(), TREE_OPERAND, TREE_TYPE, TYPE_UNSIGNED, and UNKNOWN_LOCATION.

Referenced by canonicalize_loop_induction_variables(), canonicalize_loop_ivs(), create_canonical_iv(), create_empty_loop_on_edge(), create_new_iv(), tree_loop_interchange::map_inductions_to_loop(), tree_transform_and_unroll_loop(), vect_create_data_ref_ptr(), vect_create_epilog_for_reduction(), vect_set_loop_condition_normal(), vect_set_loop_condition_partial_vectors_avx512(), vect_set_loop_controls_directly(), vectorizable_load(), and vectorizable_store().

◆ gimple_duplicate_loop_body_to_header_edge()

bool gimple_duplicate_loop_body_to_header_edge ( class loop * loop,
edge e,
unsigned int ndupl,
sbitmap wont_exit,
edge orig,
vec< edge > * to_remove,
int flags )
extern
The same as cfgloopmanip.cc:duplicate_loop_body_to_header_edge, but also updates the PHI nodes at start of the copied region. In order to achieve this, only loops whose exits all lead to the same location are handled. Notice that we do not completely update the SSA web after duplication. The caller is responsible for calling update_ssa after the loop has been duplicated.

References cfun, copy_phi_node_args(), duplicate_loop_body_to_header_edge(), flush_pending_stmts(), last_basic_block_for_fn, LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_SIMPLE_LATCHES, loops_state_satisfies_p(), and scev_reset().

Referenced by tree_transform_and_unroll_loop(), try_peel_loop(), and try_unroll_loop_completely().

◆ ip_end_pos()

basic_block ip_end_pos ( class loop * loop)
extern
Returns the basic block in that statements should be emitted for induction variables incremented at the end of the LOOP.

References loop::latch.

Referenced by add_candidate(), add_iv_candidate_derived_from_uses(), allow_ip_end_pos_p(), create_new_iv(), determine_iv_cost(), and standard_iv_increment_position().

◆ ip_normal_pos()

basic_block ip_normal_pos ( class loop * loop)
extern
Returns the basic block in that statements should be emitted for induction variables incremented just before exit condition of a LOOP.

References EDGE_SUCC, flow_bb_inside_loop_p(), gsi_last_bb(), loop::latch, NULL, safe_is_a(), single_pred(), and single_pred_p().

Referenced by add_candidate(), add_iv_candidate_derived_from_uses(), allow_ip_end_pos_p(), create_new_iv(), standard_iv_increment_position(), and stmt_after_ip_normal_pos().

◆ loop_invariant_motion_in_fun()

unsigned int loop_invariant_motion_in_fun ( function * fun,
bool store_motion )
extern

◆ niter_for_unrolled_loop()

gcov_type niter_for_unrolled_loop ( class loop * ,
unsigned  )
extern

◆ rewrite_into_loop_closed_ssa()

void rewrite_into_loop_closed_ssa ( bitmap changed_bbs,
unsigned update_flag )
extern
Rewrites the defs and uses into a loop closed ssa form. If CHANGED_BBS is not NULL, we look for uses outside loops only in the basic blocks in this set. UPDATE_FLAG is used in the call to update_ssa. See TODO_update_ssa* for documentation.

References rewrite_into_loop_closed_ssa_1(), and SSA_OP_ALL_USES.

Referenced by canonicalize_induction_variables(), loop_distribution::execute(), execute_ranger_vrp(), execute_update_addresses_taken(), loop_invariant_motion_in_fun(), repair_loop_structures(), tree_loop_unroll_and_jam(), tree_predictive_commoning(), tree_ssa_prefetch_arrays(), tree_ssa_split_loops(), and tree_unroll_loops_completely().

◆ split_loop_exit_edge()

basic_block split_loop_exit_edge ( edge exit,
bool copy_constants_p )
extern
Split loop exit edge EXIT. The things are a bit complicated by a need to preserve the loop closed ssa form. If COPY_CONSTANTS_P is true then forwarder PHIs are also created for constant arguments. The newly created block is returned.

References add_phi_arg(), create_phi_node(), duplicate_ssa_name(), gimple_phi_arg_location_from_edge(), gsi_end_p(), gsi_next(), gsi_start_phis(), NULL, gphi_iterator::phi(), PHI_ARG_DEF_PTR_FROM_EDGE, PHI_RESULT, SET_USE, single_succ_edge(), split_edge(), TREE_CODE, and USE_FROM_PTR.

Referenced by create_parallel_loop(), emit_mfence_after_loop(), final_value_replacement_loop(), and vect_transform_loop().

◆ standard_iv_increment_position()

void standard_iv_increment_position ( class loop * loop,
gimple_stmt_iterator * bsi,
bool * insert_after )
extern
Stores the standard position for induction variable increment in LOOP (just before the exit condition if it is available and latch block is empty, end of the latch block otherwise) to BSI. INSERT_AFTER is set to true if the increment should be inserted after *BSI.

References gsi_last_bb(), ip_end_pos(), ip_normal_pos(), last, last_nondebug_stmt(), and loop::latch.

Referenced by vect_create_data_ref_ptr(), vectorizable_load(), and vectorizable_store().

◆ tree_transform_and_unroll_loop()

void tree_transform_and_unroll_loop ( class loop * loop,
unsigned factor,
tree_niter_desc * desc,
transform_callback transform,
void * data )
extern

References add_phi_arg(), profile_probability::always(), loop::any_estimate, loop::any_likely_upper_bound, loop::any_upper_bound, profile_probability::apply_scale(), as_a(), bitmap_clear_bit(), bitmap_ones(), checking_verify_flow_info(), checking_verify_loop_closed_ssa(), checking_verify_loop_structure(), copy_ssa_name(), basic_block_def::count, create_iv(), create_phi_node(), determine_exit_conditions(), DLTHE_FLAG_FLAT_PROFILE, DLTHE_FLAG_UPDATE_FREQ, gcc_assert, gimple_build_cond(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_duplicate_loop_body_to_header_edge(), gsi_end_p(), gsi_insert_after(), gsi_last_bb(), gsi_last_nondebug_bb(), GSI_NEW_STMT, gsi_next(), gsi_start_phis(), gsi_stmt(), profile_probability::guessed_always(), loop::header, integer_nonzerop(), integer_zero_node, profile_probability::invert(), loop::latch, loop_latch_edge(), loop_preheader_edge(), loop_version(), make_edge(), make_temp_ssa_name(), maybe_flat_loop_profile(), loop::nb_iterations_estimate, loop::nb_iterations_likely_upper_bound, loop::nb_iterations_upper_bound, profile_probability::never(), loop::next, NULL, NULL_TREE, operand_equal_for_phi_arg_p(), PHI_ARG_DEF_FROM_EDGE, PHI_ARG_DEF_PTR_FROM_EDGE, PROB_UNROLLED_LOOP_ENTERED, remove_path(), rescan_loop_exit(), scale_dominated_blocks_in_loop(), scale_loop_profile(), set_edge_probability_and_rescale_others(), SET_USE, single_dom_exit(), single_pred(), single_pred_edge(), split_edge(), TODO_update_ssa, TODO_update_ssa_no_phi, TREE_CODE, TREE_TYPE, wi::udiv_floor(), UNKNOWN_LOCATION, update_loop_exit_probability_scale_dom_bbs(), update_ssa(), update_stmt(), USE_FROM_PTR, and useless_type_conversion_p().

Referenced by pcom_worker::tree_predictive_commoning_loop(), and tree_unroll_loop().

◆ tree_unroll_loop()

void tree_unroll_loop ( class loop * loop,
unsigned factor,
class tree_niter_desc * desc )
extern
Wrapper over tree_transform_and_unroll_loop for case we do not want to transform the loop before unrolling. The meaning of the arguments is the same as for tree_transform_and_unroll_loop.

References NULL, and tree_transform_and_unroll_loop().

Referenced by loop_prefetch_arrays(), and tree_loop_unroll_and_jam().

◆ verify_loop_closed_ssa()

void verify_loop_closed_ssa ( bool verify_ssa_p,
class loop * loop )
extern
Checks that invariants of the loop closed ssa form are preserved. Call verify_ssa when VERIFY_SSA_P is true. Note all loops are checked if LOOP is NULL, otherwise, only LOOP is checked.

References cfun, check_loop_closed_ssa_bb(), FOR_EACH_BB_FN, free(), gcc_assert, get_loop_body(), i, basic_block_def::loop_father, need_ssa_update_p(), NULL, loop::num, loop::num_nodes, number_of_loops(), timevar_pop(), timevar_push(), and verify_ssa().

Referenced by checking_verify_loop_closed_ssa(), execute_function_todo(), and tree_unroll_loops_completely().