This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[41/46] Add vec_info::remove_stmt


This patch adds a new helper function for permanently removing a
statement and its associated stmt_vec_info.


2018-07-24  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.

Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	2018-07-24 10:24:16.552366384 +0100
+++ gcc/tree-vectorizer.h	2018-07-24 10:24:19.544339803 +0100
@@ -241,6 +241,7 @@ struct vec_info {
   stmt_vec_info lookup_def (tree);
   stmt_vec_info lookup_single_use (tree);
   stmt_vec_info lookup_dr (data_reference *);
+  void remove_stmt (stmt_vec_info);
 
   /* The type of vectorization.  */
   vec_kind kind;
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	2018-07-24 10:24:16.552366384 +0100
+++ gcc/tree-vectorizer.c	2018-07-24 10:24:19.544339803 +0100
@@ -577,6 +577,20 @@ vec_info::lookup_dr (data_reference *dr)
   return 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: gcc/tree-vect-loop-manip.c
===================================================================
--- gcc/tree-vect-loop-manip.c	2018-07-24 10:24:16.552366384 +0100
+++ gcc/tree-vect-loop-manip.c	2018-07-24 10:24:19.540339838 +0100
@@ -935,8 +935,12 @@ vect_set_loop_condition (struct loop *lo
 						  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: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c	2018-07-24 10:24:12.252404574 +0100
+++ gcc/tree-vect-loop.c	2018-07-24 10:24:19.540339838 +0100
@@ -8487,28 +8487,18 @@ vect_transform_loop (loop_vec_info loop_
 		  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: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	2018-07-24 10:24:02.360492422 +0100
+++ gcc/tree-vect-slp.c	2018-07-24 10:24:19.540339838 +0100
@@ -4087,7 +4087,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.
@@ -4108,11 +4107,7 @@ vect_schedule_slp (vec_info *vinfo)
 	  if (store_info->pattern_stmt_p)
 	    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: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2018-07-24 10:24:08.924434128 +0100
+++ gcc/tree-vect-stmts.c	2018-07-24 10:24:19.544339803 +0100
@@ -9842,8 +9842,8 @@ vect_transform_stmt (stmt_vec_info stmt_
 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)
     {
@@ -9851,11 +9851,7 @@ vect_remove_stores (stmt_vec_info first_
       if (next_stmt_info->pattern_stmt_p)
 	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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]