[v2,4/4] Rename duplicate_loop_to_header_edge to duplicate_loop_body_to_header_edge

Message ID 20211027063448.1844771-5-luoxhu@linux.ibm.com
State New
Headers
Series loop split fix and functions renaming |

Commit Message

Xionghu Luo Oct. 27, 2021, 6:34 a.m. UTC
  gcc/ChangeLog:

	* 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.
---
 gcc/cfghooks.c              | 27 ++++++++++++---------------
 gcc/cfghooks.h              | 13 ++++++-------
 gcc/cfgloopmanip.c          |  9 ++++-----
 gcc/cfgloopmanip.h          |  6 +++---
 gcc/cfgrtl.c                |  2 +-
 gcc/doc/loop.texi           |  4 ++--
 gcc/loop-unroll.c           | 27 ++++++++++++---------------
 gcc/tree-cfg.c              |  2 +-
 gcc/tree-ssa-loop-ivcanon.c |  4 ++--
 gcc/tree-ssa-loop-manip.c   | 22 ++++++++++++----------
 gcc/tree-ssa-loop-manip.h   |  7 +++----
 11 files changed, 58 insertions(+), 65 deletions(-)
  

Comments

Richard Biener Oct. 29, 2021, 11:50 a.m. UTC | #1
On Wed, 27 Oct 2021, Xionghu Luo wrote:

> gcc/ChangeLog:
> 
> 	* 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.

This renaming is OK (you can commit it independently).

Thanks,
Richard.

> ---
>  gcc/cfghooks.c              | 27 ++++++++++++---------------
>  gcc/cfghooks.h              | 13 ++++++-------
>  gcc/cfgloopmanip.c          |  9 ++++-----
>  gcc/cfgloopmanip.h          |  6 +++---
>  gcc/cfgrtl.c                |  2 +-
>  gcc/doc/loop.texi           |  4 ++--
>  gcc/loop-unroll.c           | 27 ++++++++++++---------------
>  gcc/tree-cfg.c              |  2 +-
>  gcc/tree-ssa-loop-ivcanon.c |  4 ++--
>  gcc/tree-ssa-loop-manip.c   | 22 ++++++++++++----------
>  gcc/tree-ssa-loop-manip.h   |  7 +++----
>  11 files changed, 58 insertions(+), 65 deletions(-)
> 
> diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
> index 50b9b177639..23eb364bee6 100644
> --- a/gcc/cfghooks.c
> +++ b/gcc/cfghooks.c
> @@ -1226,25 +1226,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<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,
> diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
> index 8645fe5b9e7..29aa2bf0636 100644
> --- a/gcc/cfghooks.h
> +++ b/gcc/cfghooks.h
> @@ -166,7 +166,7 @@ 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,
> +  bool (*cfg_hook_duplicate_loop_body_to_header_edge) (class loop *, edge,
>  						  unsigned, sbitmap,
>  						  edge, vec<edge> *,
>  						  int);
> @@ -250,12 +250,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<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*);
> diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
> index 066fbddbcfe..455c3ef8db9 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<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;
> @@ -1630,7 +1629,7 @@ clone_loop_to_header_edge (class loop *loop, void *cond_expr,
>    first_head = entry->dest;
>  
>    /* 1) Duplicate loop on the entry edge.  */
> -  if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1,
> +  if (!cfg_hook_duplicate_loop_body_to_header_edge (loop, entry, 1,
>  					       NULL, NULL, NULL, 0))
>      {
>        entry->flags |= irred_flag;
> diff --git a/gcc/cfgloopmanip.h b/gcc/cfgloopmanip.h
> index eac09518702..42ba0689825 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<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);
> diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
> index 4f3b1e8f3dc..e3a724bddb4 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 94eed6720b1..29a580066d6 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 2b31fafa3a3..f554ebb8450 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,7 +566,7 @@ 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),
> +	  ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
>  					      exit_mod + 1,
>  					      wont_exit, desc->out_edge,
>  					      &remove_edges,
> @@ -606,7 +603,7 @@ 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),
> +  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
>  				      max_unroll,
>  				      wont_exit, desc->out_edge,
>  				      &remove_edges,
> @@ -975,7 +972,7 @@ 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),
> +      ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
>  					  1, wont_exit, desc->out_edge,
>  					  &remove_edges,
>  					  DLTHE_FLAG_UPDATE_FREQ);
> @@ -997,7 +994,7 @@ 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),
> +      ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
>  					  1, wont_exit, desc->out_edge,
>  					  &remove_edges,
>  					  DLTHE_FLAG_UPDATE_FREQ);
> @@ -1061,7 +1058,7 @@ 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),
> +  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
>  				      max_unroll,
>  				      wont_exit, desc->out_edge,
>  				      &remove_edges,
> @@ -1255,7 +1252,7 @@ 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),
> +  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
>  				      nunroll, wont_exit,
>  				      NULL, NULL,
>  				      DLTHE_FLAG_UPDATE_FREQ
> @@ -2019,7 +2016,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 9883eaaa9bf..d0177cb1c07 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -9072,7 +9072,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 8d8791f837e..a9107ef5ffb 100644
> --- a/gcc/tree-ssa-loop-ivcanon.c
> +++ b/gcc/tree-ssa-loop-ivcanon.c
> @@ -903,7 +903,7 @@ 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),
> +      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
> @@ -1094,7 +1094,7 @@ 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),
> +  if (!gimple_duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
>  					     npeel, wont_exit,
>  					     exit, &edges_to_remove,
>  					     DLTHE_FLAG_UPDATE_FREQ))
> diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
> index 350e25bb8d2..b60da4fb084 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<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;
>  
> @@ -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.  */
> @@ -1390,9 +1390,11 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
>    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)
> diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
> index 86fc118b6be..792c366701b 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<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);
>
  

Patch

diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 50b9b177639..23eb364bee6 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -1226,25 +1226,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<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,
diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h
index 8645fe5b9e7..29aa2bf0636 100644
--- a/gcc/cfghooks.h
+++ b/gcc/cfghooks.h
@@ -166,7 +166,7 @@  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,
+  bool (*cfg_hook_duplicate_loop_body_to_header_edge) (class loop *, edge,
 						  unsigned, sbitmap,
 						  edge, vec<edge> *,
 						  int);
@@ -250,12 +250,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<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*);
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 066fbddbcfe..455c3ef8db9 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<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;
@@ -1630,7 +1629,7 @@  clone_loop_to_header_edge (class loop *loop, void *cond_expr,
   first_head = entry->dest;
 
   /* 1) Duplicate loop on the entry edge.  */
-  if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1,
+  if (!cfg_hook_duplicate_loop_body_to_header_edge (loop, entry, 1,
 					       NULL, NULL, NULL, 0))
     {
       entry->flags |= irred_flag;
diff --git a/gcc/cfgloopmanip.h b/gcc/cfgloopmanip.h
index eac09518702..42ba0689825 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<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);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 4f3b1e8f3dc..e3a724bddb4 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 94eed6720b1..29a580066d6 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 2b31fafa3a3..f554ebb8450 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,7 +566,7 @@  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),
+	  ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
 					      exit_mod + 1,
 					      wont_exit, desc->out_edge,
 					      &remove_edges,
@@ -606,7 +603,7 @@  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),
+  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
 				      max_unroll,
 				      wont_exit, desc->out_edge,
 				      &remove_edges,
@@ -975,7 +972,7 @@  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),
+      ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
 					  1, wont_exit, desc->out_edge,
 					  &remove_edges,
 					  DLTHE_FLAG_UPDATE_FREQ);
@@ -997,7 +994,7 @@  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),
+      ok = duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
 					  1, wont_exit, desc->out_edge,
 					  &remove_edges,
 					  DLTHE_FLAG_UPDATE_FREQ);
@@ -1061,7 +1058,7 @@  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),
+  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
 				      max_unroll,
 				      wont_exit, desc->out_edge,
 				      &remove_edges,
@@ -1255,7 +1252,7 @@  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),
+  ok = duplicate_loop_body_to_header_edge (loop, loop_latch_edge (loop),
 				      nunroll, wont_exit,
 				      NULL, NULL,
 				      DLTHE_FLAG_UPDATE_FREQ
@@ -2019,7 +2016,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 9883eaaa9bf..d0177cb1c07 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -9072,7 +9072,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 8d8791f837e..a9107ef5ffb 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -903,7 +903,7 @@  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),
+      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
@@ -1094,7 +1094,7 @@  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),
+  if (!gimple_duplicate_loop_body_to_header_edge (loop, loop_preheader_edge (loop),
 					     npeel, wont_exit,
 					     exit, &edges_to_remove,
 					     DLTHE_FLAG_UPDATE_FREQ))
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 350e25bb8d2..b60da4fb084 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<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;
 
@@ -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.  */
@@ -1390,9 +1390,11 @@  tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
   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)
diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h
index 86fc118b6be..792c366701b 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<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);