]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Rename duplicate_loop_to_header_edge to duplicate_loop_body_to_header_edge
authorXionghu Luo <luoxhu@linux.ibm.com>
Mon, 1 Nov 2021 05:14:01 +0000 (00:14 -0500)
committerXionghu Luo <luoxhu@linux.ibm.com>
Mon, 1 Nov 2021 05:14:01 +0000 (00:14 -0500)
gcc/ChangeLog:

2021-11-01  Xionghu Luo  <luoxhu@linux.ibm.com>

* 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
gcc/cfghooks.h
gcc/cfgloopmanip.c
gcc/cfgloopmanip.h
gcc/cfgrtl.c
gcc/doc/loop.texi
gcc/loop-unroll.c
gcc/tree-cfg.c
gcc/tree-ssa-loop-ivcanon.c
gcc/tree-ssa-loop-manip.c
gcc/tree-ssa-loop-manip.h

index 6446e16ca8c041390f3e3904d2b93480c48b2f90..fa2dae21a03925c83f5545e9d8c3e924a44b8cdf 100644 (file)
@@ -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<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,
index 8645fe5b9e7230a1dfc68dfaf2a7e8ab82bba3d1..6df651f128e6cfeb894cdf774d92d73010767169 100644 (file)
@@ -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<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.  */
@@ -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<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*);
index a30ebe1cdb4752f20b37a447effd64018f95aead..aa538a221e1f7efdd092a4d63c6489e72fb3a5d4 100644 (file)
@@ -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,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;
index 312a3b48d05fa7dda4ecec9c1046a84bf126c26e..8dc5de909e47d4db782f134a83ad1ca3aa734877 100644 (file)
@@ -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);
index 4f3b1e8f3dc6fdea3da38821c3b7918f86546303..e3a724bddb4547f93986a2a81ecc093037fca2af 100644 (file)
@@ -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 */
index 94eed6720b1eb60c125dad409e468eaead2d81be..29a580066d60fa21ee8f3d5ad6b0d9a1b85a628b 100644 (file)
@@ -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}
index 2b31fafa3a389dea3fb6de966a34b40509c5230a..a06bdfb9dacbe3530ee76cb3ac74f5ab43b83fbc 100644 (file)
@@ -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;
index b3a27bcd17ce437835b635cc58e329338a6c5354..8ed8c69b5b1f9626e5a13468ce1ae71a418e5532 100644 (file)
@@ -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 */
index 8d8791f837ec92d0554bb24a6fb74aef801db4d2..be533b03a85b9675f7d428b414931d31f5e4a1ef 100644 (file)
@@ -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;
index 2d576bfa3913e03c20be56bfd09192f05022dc0b..1fb2450b41fbf34dffb6c24dd3d7b6c85f967a16 100644 (file)
@@ -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.  */
@@ -1388,9 +1388,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)
index 5e2d7fa11a429afff4f3d8086862a9d2b725e93a..4f604e1bd24a3ee659082a140e463744a7ff46e7 100644 (file)
@@ -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);