[41/46] Add vec_info::remove_stmt
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 31 Jul 2018 14:26:18 +0000 (14:26 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 31 Jul 2018 14:26:18 +0000 (14:26 +0000)
This patch adds a new helper function for permanently removing a
statement and its associated stmt_vec_info.

2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-vectorizer.h (vec_info::remove_stmt): Declare.
* tree-vectorizer.c (vec_info::remove_stmt): New function.
* tree-vect-loop-manip.c (vect_set_loop_condition): Use it.
* tree-vect-loop.c (vect_transform_loop): Likewise.
* tree-vect-slp.c (vect_schedule_slp): Likewise.
* tree-vect-stmts.c (vect_remove_stores): Likewise.

From-SVN: r263156

gcc/ChangeLog
gcc/tree-vect-loop-manip.c
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.c
gcc/tree-vectorizer.h

index d17ac3b..396898e 100644 (file)
@@ -1,5 +1,14 @@
 2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>
 
+       * tree-vectorizer.h (vec_info::remove_stmt): Declare.
+       * tree-vectorizer.c (vec_info::remove_stmt): New function.
+       * tree-vect-loop-manip.c (vect_set_loop_condition): Use it.
+       * tree-vect-loop.c (vect_transform_loop): Likewise.
+       * tree-vect-slp.c (vect_schedule_slp): Likewise.
+       * tree-vect-stmts.c (vect_remove_stores): Likewise.
+
+2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>
+
        * tree-vectorizer.h (vec_info::lookup_dr): New member function.
        (vect_dr_stmt): Delete.
        * tree-vectorizer.c (vec_info::lookup_dr): New function.
index 504e4e3..dd7463a 100644 (file)
@@ -935,8 +935,12 @@ vect_set_loop_condition (struct loop *loop, loop_vec_info loop_vinfo,
                                                  loop_cond_gsi);
 
   /* Remove old loop exit test.  */
-  gsi_remove (&loop_cond_gsi, true);
-  free_stmt_vec_info (orig_cond);
+  stmt_vec_info orig_cond_info;
+  if (loop_vinfo
+      && (orig_cond_info = loop_vinfo->lookup_stmt (orig_cond)))
+    loop_vinfo->remove_stmt (orig_cond_info);
+  else
+    gsi_remove (&loop_cond_gsi, true);
 
   if (dump_enabled_p ())
     {
index 32643d3..6a00695 100644 (file)
@@ -8487,28 +8487,18 @@ vect_transform_loop (loop_vec_info loop_vinfo)
                  vect_transform_loop_stmt (loop_vinfo, stmt_info, &si,
                                            &seen_store, &slp_scheduled);
                }
+             gsi_next (&si);
              if (seen_store)
                {
                  if (STMT_VINFO_GROUPED_ACCESS (seen_store))
-                   {
-                     /* Interleaving.  If IS_STORE is TRUE, the
-                        vectorization of the interleaving chain was
-                        completed - free all the stores in the chain.  */
-                     gsi_next (&si);
-                     vect_remove_stores (DR_GROUP_FIRST_ELEMENT (seen_store));
-                   }
+                   /* Interleaving.  If IS_STORE is TRUE, the
+                      vectorization of the interleaving chain was
+                      completed - free all the stores in the chain.  */
+                   vect_remove_stores (DR_GROUP_FIRST_ELEMENT (seen_store));
                  else
-                   {
-                     /* Free the attached stmt_vec_info and remove the
-                        stmt.  */
-                     free_stmt_vec_info (stmt);
-                     unlink_stmt_vdef (stmt);
-                     gsi_remove (&si, true);
-                     release_defs (stmt);
-                   }
+                   /* Free the attached stmt_vec_info and remove the stmt.  */
+                   loop_vinfo->remove_stmt (stmt_info);
                }
-             else
-               gsi_next (&si);
            }
        }
 
index 07f10c0..fe123bf 100644 (file)
@@ -4088,7 +4088,6 @@ vect_schedule_slp (vec_info *vinfo)
       slp_tree root = SLP_INSTANCE_TREE (instance);
       stmt_vec_info store_info;
       unsigned int j;
-      gimple_stmt_iterator gsi;
 
       /* Remove scalar call stmts.  Do not do this for basic-block
         vectorization as not all uses may be vectorized.
@@ -4109,11 +4108,7 @@ vect_schedule_slp (vec_info *vinfo)
          if (is_pattern_stmt_p (store_info))
            store_info = STMT_VINFO_RELATED_STMT (store_info);
          /* Free the attached stmt_vec_info and remove the stmt.  */
-         gsi = gsi_for_stmt (store_info);
-         unlink_stmt_vdef (store_info);
-         gsi_remove (&gsi, true);
-         release_defs (store_info);
-         free_stmt_vec_info (store_info);
+         vinfo->remove_stmt (store_info);
         }
     }
 
index 46ef3bb..1bf9dd8 100644 (file)
@@ -9845,8 +9845,8 @@ vect_transform_stmt (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
 void
 vect_remove_stores (stmt_vec_info first_stmt_info)
 {
+  vec_info *vinfo = first_stmt_info->vinfo;
   stmt_vec_info next_stmt_info = first_stmt_info;
-  gimple_stmt_iterator next_si;
 
   while (next_stmt_info)
     {
@@ -9854,11 +9854,7 @@ vect_remove_stores (stmt_vec_info first_stmt_info)
       if (is_pattern_stmt_p (next_stmt_info))
        next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info);
       /* Free the attached stmt_vec_info and remove the stmt.  */
-      next_si = gsi_for_stmt (next_stmt_info->stmt);
-      unlink_stmt_vdef (next_stmt_info->stmt);
-      gsi_remove (&next_si, true);
-      release_defs (next_stmt_info->stmt);
-      free_stmt_vec_info (next_stmt_info);
+      vinfo->remove_stmt (next_stmt_info);
       next_stmt_info = tmp;
     }
 }
index cece978..abdc6cd 100644 (file)
@@ -588,6 +588,20 @@ vec_info::move_dr (stmt_vec_info new_stmt_info, stmt_vec_info old_stmt_info)
     = STMT_VINFO_GATHER_SCATTER_P (old_stmt_info);
 }
 
+/* Permanently remove the statement described by STMT_INFO from the
+   function.  */
+
+void
+vec_info::remove_stmt (stmt_vec_info stmt_info)
+{
+  gcc_assert (!stmt_info->pattern_stmt_p);
+  gimple_stmt_iterator si = gsi_for_stmt (stmt_info->stmt);
+  unlink_stmt_vdef (stmt_info->stmt);
+  gsi_remove (&si, true);
+  release_defs (stmt_info->stmt);
+  free_stmt_vec_info (stmt_info);
+}
+
 /* A helper function to free scev and LOOP niter information, as well as
    clear loop constraint LOOP_C_FINITE.  */
 
index 61d89ac..8aa485e 100644 (file)
@@ -242,6 +242,7 @@ struct vec_info {
   stmt_vec_info lookup_single_use (tree);
   struct dr_vec_info *lookup_dr (data_reference *);
   void move_dr (stmt_vec_info, stmt_vec_info);
+  void remove_stmt (stmt_vec_info);
 
   /* The type of vectorization.  */
   vec_kind kind;