GCC Middle and Back End API Reference
cfgloopmanip.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "cfganal.h"
#include "cfgloop.h"
#include "gimple-iterator.h"
#include "gimplify-me.h"
#include "tree-ssa-loop-manip.h"
#include "dumpfile.h"
#include "sreal.h"
Include dependency graph for cfgloopmanip.cc:

Functions

static void copy_loops_to (class loop **, int, class loop *)
 
static void loop_redirect_edge (edge, basic_block)
 
static void remove_bbs (basic_block *, int)
 
static bool rpe_enum_p (const_basic_block, const void *)
 
static int find_path (edge, basic_block **)
 
static void fix_loop_placements (class loop *, bool *, bitmap)
 
static bool fix_bb_placement (basic_block)
 
static void fix_bb_placements (basic_block, bool *, bitmap)
 
static bool fix_loop_placement (class loop *loop, bool *irred_invalidated)
 
bool remove_path (edge e, bool *irred_invalidated, bitmap loop_closed_ssa_invalidated)
 
void place_new_loop (struct function *fn, class loop *loop)
 
void add_loop (class loop *loop, class loop *outer)
 
void scale_loop_frequencies (class loop *loop, profile_probability p)
 
void scale_dominated_blocks_in_loop (class loop *loop, basic_block bb, profile_count num, profile_count den)
 
static edge loop_exit_for_scaling (class loop *loop)
 
edge update_loop_exit_probability_scale_dom_bbs (class loop *loop, edge exit_edge, profile_count desired_count)
 
void scale_loop_profile (class loop *loop, profile_probability p, gcov_type iteration_bound)
 
static void update_dominators_in_loop (class loop *loop)
 
edge create_empty_if_region_on_edge (edge entry_edge, tree condition)
 
class loopcreate_empty_loop_on_edge (edge entry_edge, tree initial_value, tree stride, tree upper_bound, tree iv, tree *iv_before, tree *iv_after, class loop *outer)
 
void unloop (class loop *loop, bool *irred_invalidated, bitmap loop_closed_ssa_invalidated)
 
void copy_loop_info (class loop *loop, class loop *target)
 
class loopduplicate_loop (class loop *loop, class loop *target, class loop *after)
 
void duplicate_subloops (class loop *loop, class loop *target)
 
bool can_duplicate_loop_p (const class loop *loop)
 
bool 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)
 
bool mfb_keep_just (edge e)
 
static bool has_preds_from_loop (basic_block block, class loop *loop)
 
basic_block create_preheader (class loop *loop, int flags)
 
void create_preheaders (int flags)
 
void force_single_succ_latches (void)
 
static basic_block lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head, edge e, void *cond_expr, profile_probability then_prob, profile_probability else_prob)
 
class looploop_version (class loop *loop, void *cond_expr, basic_block *condition_bb, profile_probability then_prob, profile_probability else_prob, profile_probability then_scale, profile_probability else_scale, bool place_after)
 

Variables

edge mfb_kj_edge
 

Function Documentation

◆ add_loop()

◆ can_duplicate_loop_p()

bool can_duplicate_loop_p ( const class loop * loop)
Check whether LOOP's body can be duplicated.   

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

Referenced by can_unroll_loop_p(), decide_unrolling(), and parallelize_loops().

◆ copy_loop_info()

◆ copy_loops_to()

static void copy_loops_to ( class loop ** copied_loops,
int n,
class loop * target )
static
Loop manipulation 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/>.   
Copies structure of subloops of N loops, stored in array COPIED_LOOPS,
into TARGET loop, placing newly created loops into loop tree adding
them to TARGETs sibling list at the end in order.   

References duplicate_loop(), duplicate_subloops(), gcc_assert, i, loop::inner, and loop::next.

Referenced by duplicate_loop_body_to_header_edge().

◆ create_empty_if_region_on_edge()

edge create_empty_if_region_on_edge ( edge entry_edge,
tree condition )
Creates an if region as shown above. CONDITION is used to create
 the test for the if.

 |
 |     -------------                 -------------
 |     |  pred_bb  |                 |  pred_bb  |
 |     -------------                 -------------
 |           |                             |
 |           |                             | ENTRY_EDGE
 |           | ENTRY_EDGE                  V
 |           |             ====>     -------------
 |           |                       |  cond_bb  |
 |           |                       | CONDITION |
 |           |                       -------------
 |           V                        /         \
 |     -------------         e_false /           \ e_true
 |     |  succ_bb  |                V             V
 |     -------------         -----------       -----------
 |                           | false_bb |      | true_bb |
 |                           -----------       -----------
 |                                   \           /
 |                                    \         /
 |                                     V       V
 |                                   -------------
 |                                   |  join_bb  |
 |                                   -------------
 |                                         | exit_edge (result)
 |                                         V
 |                                    -----------
 |                                    | succ_bb |
 |                                    -----------
 |

References CDI_DOMINATORS, force_gimple_operand_gsi(), gimple_build_cond_from_tree(), gsi_insert_after(), gsi_last_bb(), GSI_NEW_STMT, make_edge(), NULL, NULL_TREE, set_immediate_dominator(), single_pred_p(), single_succ_edge(), and split_edge().

◆ create_empty_loop_on_edge()

class loop * create_empty_loop_on_edge ( edge entry_edge,
tree initial_value,
tree stride,
tree upper_bound,
tree iv,
tree * iv_before,
tree * iv_after,
class loop * outer )
create_empty_loop_on_edge
|
|    - pred_bb -                   ------ pred_bb ------
|   |           |                 | iv0 = initial_value |
|    -----|-----                   ---------|-----------
|         |                       ______    | entry_edge
|         | entry_edge           /      |   |
|         |             ====>   |      -V---V- loop_header -------------
|         V                     |     | iv_before = phi (iv0, iv_after) |
|    - succ_bb -                |      ---|-----------------------------
|   |           |               |         |
|    -----------                |      ---V--- loop_body ---------------
|                               |     | iv_after = iv_before + stride   |
|                               |     | if (iv_before < upper_bound)    |
|                               |      ---|--------------\--------------
|                               |         |               \ exit_e
|                               |         V                \
|                               |       - loop_latch -      V- succ_bb -
|                               |      |              |     |           |
|                               |       /-------------       -----------
|                                \ ___ /

Creates an empty loop as shown above, the IV_BEFORE is the SSA_NAME
that is used before the increment of IV. IV_BEFORE should be used for
adding code to the body that uses the IV.  OUTER is the outer loop in
which the new loop should be inserted.

Both INITIAL_VALUE and UPPER_BOUND expressions are gimplified and
inserted on the loop entry edge.  This implies that this function
should be used only when the UPPER_BOUND expression is a loop
invariant.   

References add_loop(), alloc_loop(), CDI_DOMINATORS, create_iv(), profile_probability::even(), force_gimple_operand(), force_gimple_operand_gsi(), gcc_assert, gimple_build_cond(), gimple_cond_lhs(), gimple_cond_set_lhs(), gsi_commit_edge_inserts(), gsi_insert_after(), gsi_insert_seq_on_edge(), gsi_last_bb(), GSI_NEW_STMT, loop::header, loop::latch, loop_preheader_edge(), make_edge(), NULL, NULL_TREE, redirect_edge_succ_nodup(), scale_loop_frequencies(), set_immediate_dominator(), single_exit(), single_pred_edge(), single_succ(), single_succ_edge(), split_block_after_labels(), split_edge(), and update_dominators_in_loop().

◆ create_preheader()

basic_block create_preheader ( class loop * loop,
int flags )
Creates a pre-header for a LOOP.  Returns newly created block.  Unless
CP_SIMPLE_PREHEADERS is set in FLAGS, we only force LOOP to have single
entry; otherwise we also force preheader block to have only one successor.
When CP_FALLTHRU_PREHEADERS is set in FLAGS, we force the preheader block
to be a fallthru predecessor to the loop header and to have only
predecessors from outside of the loop.
The function also updates dominators.   

References BB_END, cfun, CP_FALLTHRU_PREHEADERS, CP_SIMPLE_PREHEADERS, dump_file, EDGE_COMPLEX, EDGE_PRED, ENTRY_BLOCK_PTR_FOR_FN, basic_block_def::flags, FOR_EACH_EDGE, gcc_assert, has_preds_from_loop(), loop::header, JUMP_P, loop::latch, loop_latch_edge(), make_forwarder_block(), mfb_keep_just(), mfb_kj_edge, move_block_after(), NULL, loop::num, basic_block_def::preds, single_succ_edge(), single_succ_p(), and split_edge().

Referenced by create_preheaders(), generate_loops_for_partition(), and fwd_jt_path_registry::thread_through_loop_header().

◆ create_preheaders()

void create_preheaders ( int flags)
Create preheaders for each loop; for meaning of FLAGS see create_preheader.   

References cfun, create_preheader(), current_loops, LOOPS_HAVE_PREHEADERS, and loops_state_set().

Referenced by apply_loop_flags(), and tree_estimate_probability().

◆ duplicate_loop()

class loop * duplicate_loop ( class loop * loop,
class loop * target,
class loop * after )
Copies copy of LOOP as subloop of TARGET loop, placing newly
created loop into loops structure.  If AFTER is non-null
the new loop is added at AFTER->next, otherwise in front of TARGETs
sibling list.   

References alloc_loop(), cfun, copy_loop_info(), flow_loop_tree_node_add(), place_new_loop(), and set_loop_copy().

Referenced by copy_loops_to(), duplicate_subloops(), gimple_duplicate_sese_tail(), and slpeel_tree_duplicate_loop_to_edge_cfg().

◆ duplicate_loop_body_to_header_edge()

bool 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 )
Duplicates body of LOOP to given edge E NDUPL times.  Takes care of updating
loop structure and dominators (order of inner subloops is retained).
E's destination must be LOOP header for this to work, i.e. it must be entry
or latch edge of this loop; these are unique, as the loops must have
preheaders for this function to work correctly (in case E is latch, the
function unrolls the loop, if E is entry edge, it peels the loop).  Store
edges created by copying ORIG edge from copies corresponding to set bits in
WONT_EXIT bitmap (bit 0 corresponds to original LOOP body, the other copies
are numbered in order given by control flow through them) into TO_REMOVE
array.  Returns false if duplication is
impossible.   

References profile_probability::always(), profile_count::apply_probability(), profile_count::apply_scale(), profile_probability::apply_scale(), basic_block_def::aux, loop::aux, BITMAP_ALLOC, bitmap_bit_p, BITMAP_FREE, bitmap_set_bit, can_copy_bbs_p(), CDI_DOMINATORS, copy_bbs(), copy_loops_to(), DLTHE_FLAG_COMPLETTE_PEEL, DLTHE_FLAG_FLAT_PROFILE, DLTHE_FLAG_UPDATE_FREQ, DLTHE_RECORD_COPY_NUMBER, dominated_by_p(), EXECUTE_IF_SET_IN_BITMAP, loop::exits, basic_block_def::flags, flow_bb_inside_loop_p(), FOR_EACH_EDGE, FOR_EACH_VEC_ELT, force_edge_cold(), free(), gcc_assert, get_dominated_by(), get_loop_body_in_dom_order(), get_loop_exit_edges(), header, loop::header, i, loop::inner, loop::latch, basic_block_def::loop_father, loop_latch_edge(), nearest_common_dominator(), loop::next, profile_count::nonzero_p(), NULL, loop::num_nodes, profile_count::probability_in(), redirect_edge_and_branch_force(), scale_bbs_frequencies(), scale_bbs_frequencies_profile_count(), set_immediate_dominator(), set_loop_copy(), basic_block_def::succs, and profile_count::zero().

Referenced by gimple_duplicate_loop_body_to_header_edge(), unroll_loop_constant_iterations(), unroll_loop_runtime_iterations(), and unroll_loop_stupid().

◆ duplicate_subloops()

void duplicate_subloops ( class loop * loop,
class loop * target )
Copies structure of subloops of LOOP into TARGET loop, placing
newly created loops into loop tree at the end of TARGETs sibling
list in the original order.   

References duplicate_loop(), duplicate_subloops(), gcc_assert, loop::inner, and loop::next.

Referenced by copy_loops_to(), duplicate_subloops(), gimple_duplicate_sese_tail(), and slpeel_tree_duplicate_loop_to_edge_cfg().

◆ find_path()

static int find_path ( edge e,
basic_block ** bbs )
static
Find path -- i.e. the basic blocks dominated by edge E and put them
into array BBS, that will be allocated large enough to contain them.
E->dest must have exactly one predecessor for this to work (it is
easy to achieve and we do not put it here because we do not want to
alter anything by this function).  The number of basic blocks in the
path is returned.   

References cfun, dfs_enumerate_from(), EDGE_COUNT, gcc_assert, n_basic_blocks_for_fn, and rpe_enum_p().

Referenced by remove_path().

◆ fix_bb_placement()

static bool fix_bb_placement ( basic_block bb)
static
Fix placement of basic block BB inside loop hierarchy --
Let L be a loop to that BB belongs.  Then every successor of BB must either
  1) belong to some superloop of loop L, or
  2) be a header of loop K such that K->outer is superloop of L
Returns true if we had to move BB into other loop to enforce this condition,
false if the placement of BB was already correct (provided that placements
of its successors are correct).   

References add_bb_to_loop(), cfun, current_loops, EXIT_BLOCK_PTR_FOR_FN, flow_loop_nested_p(), FOR_EACH_EDGE, basic_block_def::loop_father, loop_outer(), remove_bb_from_loops(), and basic_block_def::succs.

Referenced by fix_bb_placements().

◆ fix_bb_placements()

static void fix_bb_placements ( basic_block from,
bool * irred_invalidated,
bitmap loop_closed_ssa_invalidated )
static
Fix placements of basic blocks inside loop hierarchy stored in loops; i.e.
enforce condition stated in description of fix_bb_placement. We
start from basic block FROM that had some of its successors removed, so that
his placement no longer has to be correct, and iteratively fix placement of
its predecessors that may change if placement of FROM changed.  Also fix
placement of subloops of FROM->loop_father, that might also be altered due
to this change; the condition for them is similar, except that instead of
successors we consider edges coming out of the loops.

If the changes may invalidate the information about irreducible regions,
IRRED_INVALIDATED is set to true.

If LOOP_CLOSED_SSA_INVLIDATED is non-zero then all basic blocks with
changed loop_father are collected there.  

References bitmap_bit_p, bitmap_clear(), bitmap_clear_bit(), bitmap_set_bit, cfun, current_loops, find_common_loop(), fix_bb_placement(), fix_loop_placement(), flow_loop_nested_p(), FOR_EACH_EDGE, free(), get_loop_body(), loop::header, i, basic_block_def::index, last_basic_block_for_fn, basic_block_def::loop_father, loop_outer(), loop::num_nodes, basic_block_def::preds, queue, and basic_block_def::succs.

Referenced by fix_loop_placements(), remove_path(), and unloop().

◆ fix_loop_placement()

static bool fix_loop_placement ( class loop * loop,
bool * irred_invalidated )
static
Fix placement of LOOP inside loop tree, i.e. find the innermost superloop
of LOOP to that leads at least one exit edge of LOOP, and set it
as the immediate superloop of LOOP.  Return true if the immediate superloop
of LOOP changed.

IRRED_INVALIDATED is set to true if a change in the loop structures might
invalidate the information about irreducible regions.   

References current_loops, loop::exits, find_common_loop(), flow_loop_nested_p(), flow_loop_tree_node_add(), flow_loop_tree_node_remove(), FOR_EACH_VEC_ELT, get_loop_exit_edges(), i, loop_outer(), loop::num_nodes, and rescan_loop_exit().

Referenced by fix_bb_placements(), and fix_loop_placements().

◆ fix_loop_placements()

static void fix_loop_placements ( class loop * loop,
bool * irred_invalidated,
bitmap loop_closed_ssa_invalidated )
static
Fix placement of superloops of LOOP inside loop tree, i.e. ensure that
condition stated in description of fix_loop_placement holds for them.
It is used in case when we removed some edges coming out of LOOP, which
may cause the right placement of LOOP inside loop tree to change.

IRRED_INVALIDATED is set to true if a change in the loop structures might
invalidate the information about irreducible regions.   

References fix_bb_placements(), fix_loop_placement(), loop_outer(), and loop_preheader_edge().

Referenced by remove_path().

◆ force_single_succ_latches()

void force_single_succ_latches ( void )
Forces all loop latches to have only single successor.   

References cfun, find_edge(), gcc_checking_assert, loop::header, loop::latch, LOOPS_HAVE_SIMPLE_LATCHES, loops_state_set(), NULL, single_succ_p(), and split_edge().

Referenced by apply_loop_flags().

◆ has_preds_from_loop()

static bool has_preds_from_loop ( basic_block block,
class loop * loop )
static
True when a candidate preheader BLOCK has predecessors from LOOP.   

References FOR_EACH_EDGE, and basic_block_def::preds.

Referenced by create_preheader().

◆ loop_exit_for_scaling()

static edge loop_exit_for_scaling ( class loop * loop)
static
Return exit that suitable for update when loop iterations
changed.   

References loop::exits, get_loop_exit_edges(), single_exit(), and single_likely_exit().

Referenced by scale_loop_profile(), and update_loop_exit_probability_scale_dom_bbs().

◆ loop_redirect_edge()

static void loop_redirect_edge ( edge e,
basic_block dest )
static
Redirects edge E to basic block DEST.   

References redirect_edge_and_branch_force().

Referenced by loop_version().

◆ loop_version()

class loop * loop_version ( class loop * loop,
void * cond_expr,
basic_block * condition_bb,
profile_probability then_prob,
profile_probability else_prob,
profile_probability then_scale,
profile_probability else_scale,
bool place_after )
Main entry point for Loop Versioning transformation.

This transformation given a condition and a loop, creates
-if (condition) { loop_copy1 } else { loop_copy2 },
where loop_copy1 is the loop transformed in one way, and loop_copy2
is the loop transformed in another way (or unchanged). COND_EXPR
may be a run time test for things that were not resolved by static
analysis (overlapping ranges (anti-aliasing), alignment, etc.).

If non-NULL, CONDITION_BB is set to the basic block containing the
condition.

THEN_PROB is the probability of the then edge of the if.  THEN_SCALE
is the ratio by that the frequencies in the original loop should
be scaled.  ELSE_SCALE is the ratio by that the frequencies in the
new loop should be scaled.

If PLACE_AFTER is true, we place the new loop after LOOP in the
instruction stream, otherwise it is placed before LOOP.   

References add_bb_to_loop(), add_loop(), alloc_loop(), cfg_hook_duplicate_loop_body_to_header_edge(), copy_loop_info(), basic_block_def::flags, free(), get_bb_copy(), get_loop_body_in_dom_order(), loop::header, i, loop::latch, basic_block_def::loop_father, loop_outer(), loop_preheader_edge(), loop_redirect_edge(), lv_adjust_loop_entry_edge(), lv_flush_pending_stmts(), move_block_after(), NULL, loop::num_nodes, remove_bb_from_loops(), scale_loop_frequencies(), set_loop_copy(), single_pred_edge(), single_succ_edge(), split_edge(), and update_dominators_in_loop().

Referenced by do_split_loop_on_cond(), gen_parallel_loop(), split_loop(), tree_transform_and_unroll_loop(), tree_unswitch_loop(), vect_loop_versioning(), version_loop_by_alias_check(), and version_loop_for_if_conversion().

◆ lv_adjust_loop_entry_edge()

static basic_block lv_adjust_loop_entry_edge ( basic_block first_head,
basic_block second_head,
edge e,
void * cond_expr,
profile_probability then_prob,
profile_probability else_prob )
static
This function is called from loop_version.  It splits the entry edge
 of the loop we want to version, adds the versioning condition, and
 adjust the edges to the two versions of the loop appropriately.
 e is an incoming edge. Returns the basic block containing the
 condition.

 --- edge e ---- > [second_head]

 Split it and insert new conditional expression and adjust edges.

  --- edge e ---> [cond expr] ---> [first_head]
                |
                +---------> [second_head]

THEN_PROB is the probability of then branch of the condition.
ELSE_PROB is the probability of else branch. Note that they may be both
REG_BR_PROB_BASE when condition is IFN_LOOP_VECTORIZED or
IFN_LOOP_DIST_ALIAS.   

References CDI_DOMINATORS, current_ir_type(), gcc_assert, IR_GIMPLE, lv_add_condition_to_bb(), lv_adjust_loop_header_phi(), make_edge(), NULL, set_immediate_dominator(), single_succ_edge(), and split_edge().

Referenced by loop_version().

◆ mfb_keep_just()

◆ place_new_loop()

void place_new_loop ( struct function * fn,
class loop * loop )
Creates place for a new LOOP in loops structure of FN.   

References loops_for_fn(), loop::num, number_of_loops(), and vec_safe_push().

Referenced by add_loop(), copy_loops(), duplicate_loop(), and input_cfg().

◆ remove_bbs()

static void remove_bbs ( basic_block * bbs,
int nbbs )
static
Remove basic blocks BBS.  NBBS is the number of the basic blocks.   

References delete_basic_block(), and i.

Referenced by remove_path().

◆ remove_path()

◆ rpe_enum_p()

static bool rpe_enum_p ( const_basic_block bb,
const void * data )
static
Checks whether basic block BB is dominated by DATA.   

References CDI_DOMINATORS, and dominated_by_p().

Referenced by find_path().

◆ scale_dominated_blocks_in_loop()

void scale_dominated_blocks_in_loop ( class loop * loop,
basic_block bb,
profile_count num,
profile_count den )

◆ scale_loop_frequencies()

void scale_loop_frequencies ( class loop * loop,
profile_probability p )

◆ scale_loop_profile()

void scale_loop_profile ( class loop * loop,
profile_probability p,
gcov_type iteration_bound )
Scale profile in LOOP by P.
If ITERATION_BOUND is not -1, scale even further if loop is predicted
to iterate too many times.
Before caling this function, preheader block profile should be already
scaled to final count.  This is necessary because loop iterations are
determined by comparing header edge count to latch ege count and thus
they need to be scaled synchronously.   

References profile_probability::always(), basic_block_def::count, profile_probability::dump(), dump_file, dump_flags, expected_loop_iterations_by_profile(), loop::header, loop_count_in(), loop_exit_for_scaling(), loop::num, scale_loop_frequencies(), TDF_DETAILS, sreal::to_double(), profile_count::uninitialized(), and update_loop_exit_probability_scale_dom_bbs().

Referenced by scale_profile_for_vect_loop(), tree_transform_and_unroll_loop(), try_unroll_loop_completely(), and vect_do_peeling().

◆ unloop()

void unloop ( class loop * loop,
bool * irred_invalidated,
bitmap loop_closed_ssa_invalidated )
Remove the latch edge of a LOOP and update loops to indicate that
the LOOP was removed.  After this function, original loop latch will
have no successor, which caller is expected to fix somehow.

If this may cause the information about irreducible regions to become
invalid, IRRED_INVALIDATED is set to true.

LOOP_CLOSED_SSA_INVALIDATED, if non-NULL, is a bitmap where we store
basic blocks that had non-trivial update on their loop_father. 

References add_bb_to_loop(), delete_loop(), fix_bb_placements(), flow_loop_tree_node_add(), flow_loop_tree_node_remove(), free(), get_loop_body(), i, loop::inner, loop::latch, loop_outer(), loop_preheader_edge(), loop::num_nodes, remove_bb_from_loops(), remove_edge(), and single_succ_edge().

Referenced by remove_path(), and unloop_loops().

◆ update_dominators_in_loop()

static void update_dominators_in_loop ( class loop * loop)
static

◆ update_loop_exit_probability_scale_dom_bbs()

edge update_loop_exit_probability_scale_dom_bbs ( class loop * loop,
edge exit_edge,
profile_count desired_count )
Assume that loop's entry count and profile up to a given EXIT_EDGE is
consistent. Update exit probability so loop exists with PROFILE_COUNT
and rescale profile of basic blocks inside loop dominated by EXIT_EDGE->src.

This is useful after number of iteraitons of loop has changed.
If EXIT_EDGE is NULL, the function will try to identify suitable exit.
If DESIRED_COUNT is NULL, loop entry count will be used.
In consistent profile usually loop exists as many times as it is entred.

Return updated exit if successfull and NULL otherwise.  

References cfun, basic_block_def::count, profile_count::differs_from_p(), profile_count::dump(), dump_file, dump_flags, FOR_EACH_EDGE, profile_count::initialized_p(), just_once_each_iteration_p(), loop::latch, loop_count_in(), loop_exit_edge_p(), loop_exit_for_scaling(), NULL, loop::num, profile_count::probability_in(), scale_dominated_blocks_in_loop(), set_edge_probability_and_rescale_others(), single_pred_p(), and TDF_DETAILS.

Referenced by scale_loop_profile(), split_loop(), tree_transform_and_unroll_loop(), and unroll_loop_constant_iterations().

Variable Documentation

◆ mfb_kj_edge

edge mfb_kj_edge
A callback for make_forwarder block, to redirect all edges except for
MFB_KJ_EDGE to the entry part.  E is the edge for that we should decide
whether to redirect it.   

Referenced by create_preheader(), mfb_keep_just(), and fwd_jt_path_registry::thread_through_loop_header().