From: Xionghu Luo Date: Mon, 1 Nov 2021 05:14:01 +0000 (-0500) Subject: Rename duplicate_loop_to_header_edge to duplicate_loop_body_to_header_edge X-Git-Tag: basepoints/gcc-13~3494 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4851c80ce8de18896dc5c4b1b023afa8456736ba;p=thirdparty%2Fgcc.git Rename duplicate_loop_to_header_edge to duplicate_loop_body_to_header_edge gcc/ChangeLog: 2021-11-01 Xionghu Luo * cfghooks.c (cfg_hook_duplicate_loop_to_header_edge): Rename duplicate_loop_to_header_edge to duplicate_loop_body_to_header_edge. (cfg_hook_duplicate_loop_body_to_header_edge): Likewise. * cfghooks.h (struct cfg_hooks): Likewise. (cfg_hook_duplicate_loop_body_to_header_edge): Likewise. * cfgloopmanip.c (duplicate_loop_body_to_header_edge): Likewise. (clone_loop_to_header_edge): Likewise. * cfgloopmanip.h (duplicate_loop_body_to_header_edge): Likewise. * cfgrtl.c (struct cfg_hooks): Likewise. * doc/loop.texi: Likewise. * loop-unroll.c (unroll_loop_constant_iterations): Likewise. (unroll_loop_runtime_iterations): Likewise. (unroll_loop_stupid): Likewise. (apply_opt_in_copies): Likewise. * tree-cfg.c (struct cfg_hooks): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. * tree-ssa-loop-manip.c (copy_phi_node_args): Likewise. (gimple_duplicate_loop_body_to_header_edge): Likewise. (tree_transform_and_unroll_loop): Likewise. * tree-ssa-loop-manip.h (gimple_duplicate_loop_body_to_header_edge): Likewise. --- diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c index 6446e16ca8c0..fa2dae21a039 100644 --- a/gcc/cfghooks.c +++ b/gcc/cfghooks.c @@ -1239,25 +1239,22 @@ lv_flush_pending_stmts (edge e) 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 *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 *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, diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h index 8645fe5b9e72..6df651f128e6 100644 --- a/gcc/cfghooks.h +++ b/gcc/cfghooks.h @@ -166,10 +166,9 @@ struct cfg_hooks /* 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 *, - int); + bool (*cfg_hook_duplicate_loop_body_to_header_edge) (class loop *, edge, + unsigned, sbitmap, edge, + vec *, int); /* Add condition to new basic block and update CFG used in loop versioning. */ @@ -250,12 +249,11 @@ extern bool block_ends_with_condjump_p (const_basic_block bb); 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 *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 *to_remove, int flags); extern void lv_flush_pending_stmts (edge); extern void extract_cond_bb_edges (basic_block, edge *, edge*); diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index a30ebe1cdb47..aa538a221e1f 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -1059,10 +1059,9 @@ can_duplicate_loop_p (const class loop *loop) impossible. */ bool -duplicate_loop_to_header_edge (class loop *loop, edge e, - unsigned int ndupl, sbitmap wont_exit, - edge orig, vec *to_remove, - int flags) +duplicate_loop_body_to_header_edge (class loop *loop, edge e, + unsigned int ndupl, sbitmap wont_exit, + edge orig, vec *to_remove, int flags) { class loop *target, *aloop; class loop **orig_loops; @@ -1630,8 +1629,8 @@ loop_version (class loop *loop, 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; diff --git a/gcc/cfgloopmanip.h b/gcc/cfgloopmanip.h index 312a3b48d05f..8dc5de909e47 100644 --- a/gcc/cfgloopmanip.h +++ b/gcc/cfgloopmanip.h @@ -48,9 +48,9 @@ extern class loop * duplicate_loop (class loop *, class loop *, 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 *, int); +extern bool +duplicate_loop_body_to_header_edge (class loop *, edge, unsigned, sbitmap, edge, + vec *, int); extern bool mfb_keep_just (edge); basic_block create_preheader (class loop *, int); extern void create_preheaders (int); diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 4f3b1e8f3dc6..e3a724bddb45 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -5344,7 +5344,7 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = { 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 */ diff --git a/gcc/doc/loop.texi b/gcc/doc/loop.texi index 94eed6720b1e..29a580066d60 100644 --- a/gcc/doc/loop.texi +++ b/gcc/doc/loop.texi @@ -249,8 +249,8 @@ are only reliable for the innermost loops: @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} diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index 2b31fafa3a38..a06bdfb9dacb 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -520,14 +520,11 @@ unroll_loop_constant_iterations (class loop *loop) 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) @@ -569,14 +566,11 @@ unroll_loop_constant_iterations (class loop *loop) 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) @@ -606,14 +600,10 @@ unroll_loop_constant_iterations (class loop *loop) /* 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) @@ -975,10 +965,10 @@ unroll_loop_runtime_iterations (class loop *loop) 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); } @@ -997,10 +987,10 @@ unroll_loop_runtime_iterations (class loop *loop) 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. */ @@ -1061,14 +1051,10 @@ unroll_loop_runtime_iterations (class loop *loop) 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) @@ -1255,13 +1241,9 @@ unroll_loop_stupid (class loop *loop) 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) @@ -2019,7 +2001,7 @@ apply_opt_in_copies (struct opt_info *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; diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index b3a27bcd17ce..8ed8c69b5b1f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9126,7 +9126,7 @@ struct cfg_hooks gimple_cfg_hooks = { 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 */ diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 8d8791f837ec..be533b03a85b 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -903,11 +903,10 @@ try_unroll_loop_completely (class loop *loop, 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)) @@ -1094,10 +1093,9 @@ try_peel_loop (class loop *loop, } 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; diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index 2d576bfa3913..1fb2450b41fb 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -911,7 +911,7 @@ copy_phi_node_args (unsigned first_new_block) } -/* 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. @@ -921,10 +921,10 @@ copy_phi_node_args (unsigned first_new_block) 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 *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 *to_remove, int flags) { unsigned first_new_block; @@ -934,8 +934,8 @@ gimple_duplicate_loop_to_header_edge (class loop *loop, edge e, 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. */ @@ -1388,9 +1388,11 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor, bitmap_clear_bit (wont_exit, factor - 1); auto_vec 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) diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h index 5e2d7fa11a42..4f604e1bd24a 100644 --- a/gcc/tree-ssa-loop-manip.h +++ b/gcc/tree-ssa-loop-manip.h @@ -42,10 +42,9 @@ extern basic_block ip_end_pos (class loop *); 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 *, - int); +extern bool +gimple_duplicate_loop_body_to_header_edge (class loop *, edge, unsigned int, + sbitmap, edge, vec *, 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);