GCC Middle and Back End API Reference
|
#include "tree-scalar-evolution.h"
Variables | |
static bitmap_obstack | loop_renamer_obstack |
|
static |
Add a loop-closing PHI for VAR in basic block EXIT.
References add_phi_arg(), create_new_def_for(), create_phi_node(), edge_def::dest, dump_file, dump_flags, find_common_loop(), flow_bb_inside_loop_p(), gimple_bb(), gimple_phi_result_ptr(), basic_block_def::loop_father, basic_block_def::preds, print_gimple_stmt(), and edge_def::src.
Referenced by add_exit_phis_var().
|
static |
Add exit phis for the names marked in NAMES_TO_RENAME. Exits of the loops are stored in EXITS. Sets of blocks where the ssa names are used are stored in USE_BLOCKS.
References add_exit_phis_var().
Referenced by rewrite_into_loop_closed_ssa().
|
static |
Add exit phis for VAR that is used in LIVEIN. Exits of the loops are stored in LOOP_EXITS.
References add_exit_phi(), bitmap_bit_p(), compute_live_loop_exits(), gimple_bb(), and basic_block_def::index.
Referenced by add_exit_phis().
bool can_unroll_loop_p | ( | struct loop * | loop, |
unsigned | factor, | ||
struct tree_niter_desc * | niter | ||
) |
Returns true if we can unroll LOOP FACTOR times. Number of iterations of the loop is returned in NITER.
References affine_iv::base, tree_niter_desc::bound, can_duplicate_loop_p(), tree_niter_desc::cmp, contains_abnormal_ssa_name_p(), tree_niter_desc::control, eni_size_weights, tree_niter_desc::may_be_zero, number_of_iterations_exit(), single_dom_exit(), affine_iv::step, and tree_num_loop_insns().
Referenced by should_unroll_loop_p(), and tree_predictive_commoning_loop().
tree canonicalize_loop_ivs | ( | ) |
Bases all the induction variables in LOOP on a single induction variable (unsigned 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 build_int_cst(), build_int_cst_type(), build_nonstandard_integer_type(), create_iv(), extract_true_false_edges_from_block(), edge_def::flags, force_gimple_operand(), 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(), gsi_stmt(), loop::header, last_stmt(), loop::latch, loop_preheader_edge(), rewrite_all_phi_nodes_with_iv(), single_dom_exit(), smallest_mode_for_size(), edge_def::src, type(), update_stmt(), and virtual_operand_p().
|
static |
Checks invariants of loop closed ssa form in statement STMT in BB.
References check_loop_closed_ssa_use(), and is_gimple_debug().
Referenced by verify_loop_closed_ssa().
|
static |
Check invariants of the loop closed ssa form for the USE in BB.
References flow_bb_inside_loop_p(), gimple_bb(), basic_block_def::loop_father, and virtual_operand_p().
Referenced by check_loop_closed_ssa_stmt(), and verify_loop_closed_ssa().
|
static |
DEF_BB is a basic block containing a DEF that needs rewriting into loop-closed SSA form. USE_BLOCKS is the set of basic blocks containing uses of DEF that "escape" from the loop containing DEF_BB (i.e. blocks in USE_BLOCKS are dominated by DEF_BB but not in the loop father of DEF_B). ALL_EXITS[I] is the set of all basic blocks that exit loop I. Compute the subset of LOOP_EXITS that exit the loop containing DEF_BB or one of its loop fathers, in which DEF is live. This set is returned in the bitmap LIVE_EXITS. Instead of computing the complete livein set of the def, we use the loop nesting tree as a form of poor man's structure analysis. This greatly speeds up the analysis, which is important because this function may be called on all SSA names that need rewriting, one at a time.
References bitmap_and_into(), bitmap_ior_into(), bitmap_set_bit(), CDI_DOMINATORS, dominated_by_p(), find_sibling_superloop(), flow_loop_nested_p(), loop::header, basic_block_def::index, loop_depth(), basic_block_def::loop_father, loop_outer(), loop::num, basic_block_def::preds, edge_def::src, superloop_at_depth(), and worklist.
Referenced by add_exit_phis_var().
|
static |
Copies phi node arguments for duplicated blocks. The index of the first duplicated block is FIRST_NEW_BLOCK.
References add_phi_args_after_copy_bb().
Referenced by gimple_duplicate_loop_to_header_edge().
void create_iv | ( | tree | base, |
tree | step, | ||
tree | var, | ||
struct loop * | loop, | ||
gimple_stmt_iterator * | incr_pos, | ||
bool | after, | ||
tree * | var_before, | ||
tree * | var_after | ||
) |
Creates an induction variable with value BASE + STEP * iteration in LOOP. 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(), create_phi_node(), force_gimple_operand(), gimple_build_assign_with_ops(), gsi_insert_after(), gsi_insert_before(), gsi_insert_seq_on_edge_immediate(), GSI_NEW_STMT, loop::header, loop_latch_edge(), loop_preheader_edge(), make_ssa_name(), make_temp_ssa_name(), mark_addressable(), may_negate_without_overflow_p(), tree_expr_nonnegative_warnv_p(), and tree_int_cst_lt().
Referenced by canonicalize_loop_ivs(), create_canonical_iv(), create_empty_loop_on_edge(), create_new_iv(), slpeel_make_loop_iterate_ntimes(), tree_transform_and_unroll_loop(), vect_create_data_ref_ptr(), and vectorizable_load().
|
static |
Determines the conditions that control execution of LOOP unrolled FACTOR times. DESC is number of iterations of LOOP. ENTER_COND is set to condition that must be true if the main loop can be entered. EXIT_BASE, EXIT_STEP, EXIT_CMP and EXIT_BOUND are set to values describing how the exit from the unrolled loop should be controlled.
References affine_iv::base, tree_niter_desc::bound, build_int_cst_type(), tree_niter_desc::cmp, tree_niter_desc::control, force_gimple_operand(), gsi_insert_seq_on_edge_immediate(), integer_zerop(), is_gimple_condexpr(), loop_preheader_edge(), lower_bound_in_type(), tree_niter_desc::may_be_zero, affine_iv::step, tree_int_cst_sign_bit(), unshare_expr(), and upper_bound_in_type().
Referenced by tree_transform_and_unroll_loop().
|
staticread |
Return the innermost superloop LOOP of USE_LOOP that is a superloop of both DEF_LOOP and USE_LOOP.
References loop_depth(), loop_outer(), and superloop_at_depth().
Referenced by compute_live_loop_exits().
|
static |
Marks names that are used outside of the loop they are defined in for rewrite. Records the set of blocks in that the ssa names are defined to USE_BLOCKS. If CHANGED_BBS is not NULL, scan only blocks in this set.
References find_uses_to_rename_bb().
Referenced by rewrite_into_loop_closed_ssa().
|
static |
Marks names that are used in BB and outside of the loop they are defined in for rewrite. Records the set of blocks in that the ssa names are defined to USE_BLOCKS. Record the SSA names that will need exit PHIs in NEED_PHIS.
References edge_def::dest, find_uses_to_rename_stmt(), find_uses_to_rename_use(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::succs, and virtual_operand_p().
Referenced by find_uses_to_rename().
|
static |
For uses in STMT, mark names that are used outside of the loop they are defined to rewrite. Record the set of blocks in that the ssa names are defined to USE_BLOCKS and the ssa names themselves to NEED_PHIS.
References find_uses_to_rename_use(), gimple_bb(), and is_gimple_debug().
Referenced by find_uses_to_rename_bb().
|
static |
For USE in BB, if it is used outside of the loop it is defined in, mark it for rewrite. Record basic block BB where it is used to USE_BLOCKS. Record the ssa name index to NEED_PHIS bitmap.
References bitmap_set_bit(), flow_bb_inside_loop_p(), gimple_bb(), basic_block_def::index, basic_block_def::loop_father, and loop_outer().
Referenced by find_uses_to_rename_bb(), and find_uses_to_rename_stmt().
|
static |
Fill the array of bitmaps LOOP_EXITS with all loop exit edge targets.
References bitmap_set_bit(), edge_def::dest, get_loop_exit_edges(), basic_block_def::index, and loop::num.
Referenced by rewrite_into_loop_closed_ssa().
bool gimple_duplicate_loop_to_header_edge | ( | struct loop * | loop, |
edge | e, | ||
unsigned int | ndupl, | ||
sbitmap | wont_exit, | ||
edge | orig, | ||
vec< edge > * | to_remove, | ||
int | flags | ||
) |
The same as cfgloopmanip.c:duplicate_loop_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_to_header_edge(), flush_pending_stmts(), LOOP_CLOSED_SSA, LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_SIMPLE_LATCHES, loops_state_satisfies_p(), need_ssa_update_p(), scev_reset(), and verify_loop_closed_ssa().
Referenced by tree_transform_and_unroll_loop(), and try_unroll_loop_completely().
basic_block ip_end_pos | ( | ) |
Returns the basic block in that statements should be emitted for induction variables incremented at the end of the LOOP.
References loop::latch.
basic_block ip_normal_pos | ( | ) |
Returns the basic block in that statements should be emitted for induction variables incremented just before exit condition of a LOOP.
References edge_def::dest, flow_bb_inside_loop_p(), last, last_stmt(), loop::latch, single_pred(), and single_pred_p().
|
static |
Rewrite all the phi nodes of LOOP in function of the main induction variable MAIN_IV.
References free(), get_loop_body_in_dom_order(), gsi_after_labels(), gsi_end_p(), gsi_start_phis(), basic_block_def::loop_father, loop::num_nodes, and rewrite_phi_with_iv().
Referenced by canonicalize_loop_ivs().
void rewrite_into_loop_closed_ssa | ( | ) |
Rewrites the program into a loop closed ssa form -- i.e. inserts extra phi nodes to ensure that no variable is used outside the loop it is defined in. This strengthening of the basic ssa form has several advantages: 1) Updating it during unrolling/peeling/versioning is trivial, since we do not need to care about the uses outside of the loop. The same applies to virtual operands which are also rewritten into loop closed SSA form. Note that virtual operands are always live until function exit. 2) The behavior of all uses of an induction variable is the same. Without this, you need to distinguish the case when the variable is used outside of the loop it is defined in, for example for (i = 0; i < 100; i++) { for (j = 0; j < 100; j++) { k = i + j; use1 (k); } use2 (k); } Looking from the outer loop with the normal SSA form, the first use of k is not well-behaved, while the second one is an induction variable with base 99 and step 1. 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 add_exit_phis(), bitmap_empty_p(), bitmap_obstack_initialize(), bitmap_obstack_release(), cfun, find_uses_to_rename(), free(), get_loops_exits(), LOOP_CLOSED_SSA, loops_state_set(), number_of_loops(), and update_ssa().
|
static |
Rewrite the phi node at position PSI in function of the main induction variable MAIN_IV and insert the generated code at GSI.
References affine_iv::base, force_gimple_operand_gsi(), gsi_insert_before(), gsi_next(), GSI_SAME_STMT, gsi_stmt(), remove_phi_node(), simple_iv(), affine_iv::step, unshare_expr(), and virtual_operand_p().
Referenced by rewrite_all_phi_nodes_with_iv().
|
static |
Scales the frequencies of all basic blocks in LOOP that are strictly dominated by BB by NUM/DEN.
References CDI_DOMINATORS, first_dom_son(), flow_bb_inside_loop_p(), next_dom_son(), and scale_bbs_frequencies_int().
Referenced by tree_transform_and_unroll_loop().
basic_block split_loop_exit_edge | ( | ) |
Split loop exit edge EXIT. The things are a bit complicated by a need to preserve the loop closed ssa form. The newly created block is returned.
References add_phi_arg(), create_phi_node(), edge_def::dest, duplicate_ssa_name(), gimple_phi_arg_location_from_edge(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), single_succ_edge(), and split_edge().
void standard_iv_increment_position | ( | struct loop * | loop, |
gimple_stmt_iterator * | bsi, | ||
bool * | insert_after | ||
) |
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_stmt(), and loop::latch.
Referenced by slpeel_make_loop_iterate_ntimes(), vect_create_data_ref_ptr(), and vectorizable_load().
void tree_transform_and_unroll_loop | ( | struct loop * | loop, |
unsigned | factor, | ||
edge | exit, | ||
struct tree_niter_desc * | desc, | ||
transform_callback | transform, | ||
void * | data | ||
) |
References add_phi_arg(), bitmap_clear_bit(), bitmap_ones(), copy_ssa_name(), edge_def::count, basic_block_def::count, create_iv(), create_phi_node(), determine_exit_conditions(), expected_loop_iterations(), find_edge(), edge_def::flags, free(), basic_block_def::frequency, gimple_build_cond(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_duplicate_loop_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(), loop::header, integer_nonzerop(), loop::latch, loop_latch_edge(), loop_preheader_edge(), loop_version(), make_edge(), make_temp_ssa_name(), loop::next, operand_equal_for_phi_arg_p(), prob, edge_def::probability, remove_path(), rescan_loop_exit(), sbitmap_alloc(), scale_bbs_frequencies_int(), scale_dominated_blocks_in_loop(), scale_loop_frequencies(), single_pred(), single_pred_edge(), split_edge(), edge_def::src, update_ssa(), update_stmt(), useless_type_conversion_p(), verify_flow_info(), verify_loop_closed_ssa(), verify_loop_structure(), and vNULL.
Referenced by tree_predictive_commoning_loop(), and tree_unroll_loop().
void tree_unroll_loop | ( | struct loop * | loop, |
unsigned | factor, | ||
edge | exit, | ||
struct tree_niter_desc * | desc | ||
) |
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 tree_transform_and_unroll_loop().
Referenced by loop_prefetch_arrays().
DEBUG_FUNCTION void verify_loop_closed_ssa | ( | ) |
Checks that invariants of the loop closed ssa form are preserved. Call verify_ssa when VERIFY_SSA_P is true.
References cfun, check_loop_closed_ssa_stmt(), check_loop_closed_ssa_use(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), number_of_loops(), basic_block_def::preds, edge_def::src, timevar_pop(), timevar_push(), and verify_ssa().
|
static |
@verbatim High-level loop manipulation functions.
Copyright (C) 2004-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/.
All bitmaps for rewriting into loop-closed SSA go on this obstack, so that we can free them all at once.