cfg_hooks->flush_pending_stmts (e);
}
-/* Loop versioning uses the duplicate_loop_to_header_edge to create
+/* Loop versioning uses the duplicate_loop_body_to_header_edge to create
a new version of the loop basic-blocks, the parameters here are
- exactly the same as in duplicate_loop_to_header_edge or
- tree_duplicate_loop_to_header_edge; while in tree-ssa there is
+ exactly the same as in duplicate_loop_body_to_header_edge or
+ tree_duplicate_loop_body_to_header_edge; while in tree-ssa there is
additional work to maintain ssa information that's why there is
- a need to call the tree_duplicate_loop_to_header_edge rather
- than duplicate_loop_to_header_edge when we are in tree mode. */
+ a need to call the tree_duplicate_loop_body_to_header_edge rather
+ than duplicate_loop_body_to_header_edge when we are in tree mode. */
bool
-cfg_hook_duplicate_loop_to_header_edge (class loop *loop, edge e,
- unsigned int ndupl,
- sbitmap wont_exit, edge orig,
- vec<edge> *to_remove,
- int flags)
+cfg_hook_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)
{
- gcc_assert (cfg_hooks->cfg_hook_duplicate_loop_to_header_edge);
- return cfg_hooks->cfg_hook_duplicate_loop_to_header_edge (loop, e,
- ndupl, wont_exit,
- orig, to_remove,
- flags);
+ gcc_assert (cfg_hooks->cfg_hook_duplicate_loop_body_to_header_edge);
+ return cfg_hooks->cfg_hook_duplicate_loop_body_to_header_edge (
+ loop, e, ndupl, wont_exit, orig, to_remove, flags);
}
/* Conditional jumps are represented differently in trees and RTL,
/* A hook for duplicating loop in CFG, currently this is used
in loop versioning. */
- bool (*cfg_hook_duplicate_loop_to_header_edge) (class loop *, edge,
- unsigned, sbitmap,
- edge, vec<edge> *,
- int);
+ bool (*cfg_hook_duplicate_loop_body_to_header_edge) (class loop *, edge,
+ unsigned, sbitmap, edge,
+ vec<edge> *, int);
/* Add condition to new basic block and update CFG used in loop
versioning. */
extern int flow_call_edges_add (sbitmap);
extern void execute_on_growing_pred (edge);
extern void execute_on_shrinking_pred (edge);
-extern bool cfg_hook_duplicate_loop_to_header_edge (class loop *loop, edge,
- unsigned int ndupl,
- sbitmap wont_exit,
- edge orig,
- vec<edge> *to_remove,
- int flags);
+extern bool
+cfg_hook_duplicate_loop_body_to_header_edge (class loop *loop, edge,
+ unsigned int ndupl,
+ sbitmap wont_exit, edge orig,
+ vec<edge> *to_remove, int flags);
extern void lv_flush_pending_stmts (edge);
extern void extract_cond_bb_edges (basic_block, edge *, edge*);
impossible. */
bool
-duplicate_loop_to_header_edge (class loop *loop, edge e,
- unsigned int ndupl, sbitmap wont_exit,
- edge orig, vec<edge> *to_remove,
- int flags)
+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)
{
class loop *target, *aloop;
class loop **orig_loops;
first_head = entry->dest;
/* 1) Duplicate loop on the entry edge. */
- if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1,
- NULL, NULL, NULL, 0))
+ if (!cfg_hook_duplicate_loop_body_to_header_edge (loop, entry, 1, NULL, NULL,
+ NULL, 0))
{
entry->flags |= irred_flag;
return NULL;
class loop * = NULL);
extern void duplicate_subloops (class loop *, class loop *);
extern bool can_duplicate_loop_p (const class loop *loop);
-extern bool duplicate_loop_to_header_edge (class loop *, edge,
- unsigned, sbitmap, edge,
- vec<edge> *, int);
+extern bool
+duplicate_loop_body_to_header_edge (class loop *, edge, unsigned, sbitmap, edge,
+ vec<edge> *, int);
extern bool mfb_keep_just (edge);
basic_block create_preheader (class loop *, int);
extern void create_preheaders (int);
rtl_flow_call_edges_add,
NULL, /* execute_on_growing_pred */
NULL, /* execute_on_shrinking_pred */
- duplicate_loop_to_header_edge, /* duplicate loop for trees */
+ duplicate_loop_body_to_header_edge, /* duplicate loop for trees */
rtl_lv_add_condition_to_bb, /* lv_add_condition_to_bb */
NULL, /* lv_adjust_loop_header_phi*/
rtl_extract_cond_bb_edges, /* extract_cond_bb_edges */
@item @code{create_iv}: Creates a new induction variable. Only works on
GIMPLE@. @code{standard_iv_increment_position} can be used to find a
suitable place for the iv increment.
-@item @code{duplicate_loop_to_header_edge},
-@code{tree_duplicate_loop_to_header_edge}: These functions (on RTL and
+@item @code{duplicate_loop_body_to_header_edge},
+@code{tree_duplicate_loop_body_to_header_edge}: These functions (on RTL and
on GIMPLE) duplicate the body of the loop prescribed number of times on
one of the edges entering loop header, thus performing either loop
unrolling or loop peeling. @code{can_duplicate_loop_p}
if (exit_mod)
{
opt_info_start_duplication (opt_info);
- ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- exit_mod,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info && exit_mod > 1
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
+ ok = duplicate_loop_body_to_header_edge (
+ loop, loop_preheader_edge (loop), exit_mod, wont_exit,
+ desc->out_edge, &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ
+ | (opt_info && exit_mod > 1 ? DLTHE_RECORD_COPY_NUMBER : 0));
gcc_assert (ok);
if (opt_info && exit_mod > 1)
bitmap_clear_bit (wont_exit, 1);
opt_info_start_duplication (opt_info);
- ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- exit_mod + 1,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info && exit_mod > 0
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
+ ok = duplicate_loop_body_to_header_edge (
+ loop, loop_preheader_edge (loop), exit_mod + 1, wont_exit,
+ desc->out_edge, &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ
+ | (opt_info && exit_mod > 0 ? DLTHE_RECORD_COPY_NUMBER : 0));
gcc_assert (ok);
if (opt_info && exit_mod > 0)
/* Now unroll the loop. */
opt_info_start_duplication (opt_info);
- ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
- max_unroll,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
+ ok = duplicate_loop_body_to_header_edge (
+ loop, loop_latch_edge (loop), max_unroll, wont_exit, desc->out_edge,
+ &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ | (opt_info ? DLTHE_RECORD_COPY_NUMBER : 0));
gcc_assert (ok);
if (opt_info)
if (!desc->noloop_assumptions)
bitmap_set_bit (wont_exit, 1);
ezc_swtch = loop_preheader_edge (loop)->src;
- ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- 1, wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ);
+ ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
+ 1, wont_exit, desc->out_edge,
+ &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ);
gcc_assert (ok);
}
bitmap_clear (wont_exit);
if (i != n_peel - 1 || !last_may_exit)
bitmap_set_bit (wont_exit, 1);
- ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- 1, wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ);
+ ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
+ 1, wont_exit, desc->out_edge,
+ &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ);
gcc_assert (ok);
/* Create item for switch. */
bitmap_clear_bit (wont_exit, may_exit_copy);
opt_info_start_duplication (opt_info);
- ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
- max_unroll,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
+ ok = duplicate_loop_body_to_header_edge (
+ loop, loop_latch_edge (loop), max_unroll, wont_exit, desc->out_edge,
+ &remove_edges,
+ DLTHE_FLAG_UPDATE_FREQ | (opt_info ? DLTHE_RECORD_COPY_NUMBER : 0));
gcc_assert (ok);
if (opt_info)
bitmap_clear (wont_exit);
opt_info_start_duplication (opt_info);
- ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
- nunroll, wont_exit,
- NULL, NULL,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
+ ok = duplicate_loop_body_to_header_edge (
+ loop, loop_latch_edge (loop), nunroll, wont_exit, NULL, NULL,
+ DLTHE_FLAG_UPDATE_FREQ | (opt_info ? DLTHE_RECORD_COPY_NUMBER : 0));
gcc_assert (ok);
if (opt_info)
orig_bb = get_bb_original (bb);
/* bb->aux holds position in copy sequence initialized by
- duplicate_loop_to_header_edge. */
+ duplicate_loop_body_to_header_edge. */
delta = determine_split_iv_delta ((size_t)bb->aux, n_copies,
unrolling);
bb->aux = 0;
gimple_flow_call_edges_add, /* flow_call_edges_add */
gimple_execute_on_growing_pred, /* execute_on_growing_pred */
gimple_execute_on_shrinking_pred, /* execute_on_shrinking_pred */
- gimple_duplicate_loop_to_header_edge, /* duplicate loop for trees */
+ gimple_duplicate_loop_body_to_header_edge, /* duplicate loop for trees */
gimple_lv_add_condition_to_bb, /* lv_add_condition_to_bb */
gimple_lv_adjust_loop_header_phi, /* lv_adjust_loop_header_phi*/
extract_true_false_edges_from_block, /* extract_cond_bb_edges */
if (may_be_zero)
bitmap_clear_bit (wont_exit, 1);
- if (!gimple_duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- n_unroll, wont_exit,
- exit, &edges_to_remove,
- DLTHE_FLAG_UPDATE_FREQ
- | DLTHE_FLAG_COMPLETTE_PEEL))
+ if (!gimple_duplicate_loop_body_to_header_edge (
+ loop, loop_preheader_edge (loop), n_unroll, wont_exit, exit,
+ &edges_to_remove,
+ DLTHE_FLAG_UPDATE_FREQ | DLTHE_FLAG_COMPLETTE_PEEL))
{
free_original_copy_tables ();
if (dump_file && (dump_flags & TDF_DETAILS))
}
if (may_be_zero)
bitmap_clear_bit (wont_exit, 1);
- if (!gimple_duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
- npeel, wont_exit,
- exit, &edges_to_remove,
- DLTHE_FLAG_UPDATE_FREQ))
+ if (!gimple_duplicate_loop_body_to_header_edge (
+ loop, loop_preheader_edge (loop), npeel, wont_exit, exit,
+ &edges_to_remove, DLTHE_FLAG_UPDATE_FREQ))
{
free_original_copy_tables ();
return false;
}
-/* The same as cfgloopmanip.c:duplicate_loop_to_header_edge, but also
+/* The same as cfgloopmanip.c: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.
after the loop has been duplicated. */
bool
-gimple_duplicate_loop_to_header_edge (class loop *loop, edge e,
- unsigned int ndupl, sbitmap wont_exit,
- edge orig, vec<edge> *to_remove,
- int flags)
+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)
{
unsigned first_new_block;
return false;
first_new_block = last_basic_block_for_fn (cfun);
- if (!duplicate_loop_to_header_edge (loop, e, ndupl, wont_exit,
- orig, to_remove, flags))
+ if (!duplicate_loop_body_to_header_edge (loop, e, ndupl, wont_exit, orig,
+ to_remove, flags))
return false;
/* Readd the removed phi args for e. */
bitmap_clear_bit (wont_exit, factor - 1);
auto_vec<edge> to_remove;
- bool ok = gimple_duplicate_loop_to_header_edge
- (loop, loop_latch_edge (loop), factor - 1,
- wont_exit, new_exit, &to_remove, DLTHE_FLAG_UPDATE_FREQ);
+ bool ok
+ = gimple_duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
+ factor - 1, wont_exit,
+ new_exit, &to_remove,
+ DLTHE_FLAG_UPDATE_FREQ);
gcc_assert (ok);
for (edge e : to_remove)
extern basic_block ip_normal_pos (class loop *);
extern void standard_iv_increment_position (class loop *,
gimple_stmt_iterator *, bool *);
-extern bool gimple_duplicate_loop_to_header_edge (class loop *, edge,
- unsigned int, sbitmap,
- edge, vec<edge> *,
- int);
+extern bool
+gimple_duplicate_loop_body_to_header_edge (class loop *, edge, unsigned int,
+ sbitmap, edge, vec<edge> *, int);
extern bool can_unroll_loop_p (class loop *loop, unsigned factor,
class tree_niter_desc *niter);
extern gcov_type niter_for_unrolled_loop (class loop *, unsigned);