]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[42/46] Add vec_info::replace_stmt
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 31 Jul 2018 14:26:22 +0000 (14:26 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 31 Jul 2018 14:26:22 +0000 (14:26 +0000)
This patch adds a helper for replacing a stmt_vec_info's statement with
a new statement.

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

gcc/
* tree-vectorizer.h (vec_info::replace_stmt): Declare.
* tree-vectorizer.c (vec_info::replace_stmt): New function.
* tree-vect-slp.c (vect_remove_slp_scalar_calls): Use it.
* tree-vect-stmts.c (vectorizable_call): Likewise.
(vectorizable_simd_clone_call): Likewise.

From-SVN: r263157

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

index 396898e1ffb34aab4481c2d96f5d6182786ef77b..bee475c5994310ad31555dfdfe3827d9722b7f27 100644 (file)
@@ -1,3 +1,11 @@
+2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * tree-vectorizer.h (vec_info::replace_stmt): Declare.
+       * tree-vectorizer.c (vec_info::replace_stmt): New function.
+       * tree-vect-slp.c (vect_remove_slp_scalar_calls): Use it.
+       * tree-vect-stmts.c (vectorizable_call): Likewise.
+       (vectorizable_simd_clone_call): Likewise.
+
 2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>
 
        * tree-vectorizer.h (vec_info::remove_stmt): Declare.
index fe123bf7b8341397998461680a720ef84595398d..abaddd7adf4cd44adab7e0c6b2e37ac94e70ae38 100644 (file)
@@ -4049,11 +4049,8 @@ vect_remove_slp_scalar_calls (slp_tree node)
        continue;
       lhs = gimple_call_lhs (stmt);
       new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
-      set_vinfo_for_stmt (new_stmt, stmt_info);
-      set_vinfo_for_stmt (stmt, NULL);
-      STMT_VINFO_STMT (stmt_info) = new_stmt;
       gsi = gsi_for_stmt (stmt);
-      gsi_replace (&gsi, new_stmt, false);
+      stmt_info->vinfo->replace_stmt (&gsi, stmt_info, new_stmt);
       SSA_NAME_DEF_STMT (gimple_assign_lhs (new_stmt)) = new_stmt;
     }
 }
index 1bf9dd8116f63b15e06495fcd42eb885b104bc00..05f9c5cee8c04ed88db4ad2ff938fc117e3e47bc 100644 (file)
@@ -3634,10 +3634,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
 
   gassign *new_stmt
     = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
-  set_vinfo_for_stmt (new_stmt, stmt_info);
-  set_vinfo_for_stmt (stmt_info->stmt, NULL);
-  STMT_VINFO_STMT (stmt_info) = new_stmt;
-  gsi_replace (gsi, new_stmt, false);
+  vinfo->replace_stmt (gsi, stmt_info, new_stmt);
 
   return true;
 }
@@ -4375,10 +4372,7 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info,
     }
   else
     new_stmt = gimple_build_nop ();
-  set_vinfo_for_stmt (new_stmt, stmt_info);
-  set_vinfo_for_stmt (stmt, NULL);
-  STMT_VINFO_STMT (stmt_info) = new_stmt;
-  gsi_replace (gsi, new_stmt, true);
+  vinfo->replace_stmt (gsi, stmt_info, new_stmt);
   unlink_stmt_vdef (stmt);
 
   return true;
index abdc6cd9a763668fe8981b60a58214f58fe5ddef..6e647abb69438d358f2bbeba05c89cdfe26b3440 100644 (file)
@@ -602,6 +602,22 @@ vec_info::remove_stmt (stmt_vec_info stmt_info)
   free_stmt_vec_info (stmt_info);
 }
 
+/* Replace the statement at GSI by NEW_STMT, both the vectorization
+   information and the function itself.  STMT_INFO describes the statement
+   at GSI.  */
+
+void
+vec_info::replace_stmt (gimple_stmt_iterator *gsi, stmt_vec_info stmt_info,
+                       gimple *new_stmt)
+{
+  gimple *old_stmt = stmt_info->stmt;
+  gcc_assert (!stmt_info->pattern_stmt_p && old_stmt == gsi_stmt (*gsi));
+  set_vinfo_for_stmt (old_stmt, NULL);
+  set_vinfo_for_stmt (new_stmt, stmt_info);
+  stmt_info->stmt = new_stmt;
+  gsi_replace (gsi, new_stmt, true);
+}
+
 /* A helper function to free scev and LOOP niter information, as well as
    clear loop constraint LOOP_C_FINITE.  */
 
index 8aa485eb9175247fb6c2641b059b9bef5b5993d7..c7b0515284ca9aa27ebb66734141826889a33fc8 100644 (file)
@@ -243,6 +243,7 @@ struct vec_info {
   struct dr_vec_info *lookup_dr (data_reference *);
   void move_dr (stmt_vec_info, stmt_vec_info);
   void remove_stmt (stmt_vec_info);
+  void replace_stmt (gimple_stmt_iterator *, stmt_vec_info, gimple *);
 
   /* The type of vectorization.  */
   vec_kind kind;