]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Simplify intereaved store vectorization processing
authorRichard Biener <rguenther@suse.de>
Tue, 22 Aug 2023 12:28:00 +0000 (14:28 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 22 Aug 2023 12:28:00 +0000 (14:28 +0200)
When doing interleaving we perform code generation when visiting the
last store of a chain.  We keep track of this via DR_GROUP_STORE_COUNT,
the following localizes this to the caller of vectorizable_store,
also avoing redundant non-processing of the other stores.

* tree-vect-stmts.cc (vectorizable_store): Do not bump
DR_GROUP_STORE_COUNT here.  Remove early out.
(vect_transform_stmt): Only call vectorizable_store on
the last element of an interleaving chain.

gcc/tree-vect-stmts.cc

index 33f62b77710c7c6bbc77334e1c30104879a6f74b..43502dc169fc361ad71c14032e0d7f174cd4347e 100644 (file)
@@ -8429,24 +8429,11 @@ vectorizable_store (vec_info *vinfo,
   else if (STMT_VINFO_SIMD_LANE_ACCESS_P (stmt_info) >= 3)
     return vectorizable_scan_store (vinfo, stmt_info, gsi, vec_stmt, ncopies);
 
-  if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
-    DR_GROUP_STORE_COUNT (DR_GROUP_FIRST_ELEMENT (stmt_info))++;
-
   if (grouped_store)
     {
       /* FORNOW */
       gcc_assert (!loop || !nested_in_vect_loop_p (loop, stmt_info));
 
-      /* We vectorize all the stmts of the interleaving group when we
-        reach the last stmt in the group.  */
-      if (DR_GROUP_STORE_COUNT (first_stmt_info)
-         < DR_GROUP_SIZE (first_stmt_info)
-         && !slp)
-       {
-         *vec_stmt = NULL;
-         return true;
-       }
-
       if (slp)
         {
           grouped_store = false;
@@ -12487,21 +12474,22 @@ vect_transform_stmt (vec_info *vinfo,
       break;
 
     case store_vec_info_type:
-      done = vectorizable_store (vinfo, stmt_info,
-                                gsi, &vec_stmt, slp_node, NULL);
-      gcc_assert (done);
-      if (STMT_VINFO_GROUPED_ACCESS (stmt_info) && !slp_node)
+      if (STMT_VINFO_GROUPED_ACCESS (stmt_info)
+         && !slp_node
+         && (++DR_GROUP_STORE_COUNT (DR_GROUP_FIRST_ELEMENT (stmt_info))
+             < DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info))))
+       /* In case of interleaving, the whole chain is vectorized when the
+          last store in the chain is reached.  Store stmts before the last
+          one are skipped, and there vec_stmt_info shouldn't be freed
+          meanwhile.  */
+       ;
+      else
        {
-         /* In case of interleaving, the whole chain is vectorized when the
-            last store in the chain is reached.  Store stmts before the last
-            one are skipped, and there vec_stmt_info shouldn't be freed
-            meanwhile.  */
-         stmt_vec_info group_info = DR_GROUP_FIRST_ELEMENT (stmt_info);
-         if (DR_GROUP_STORE_COUNT (group_info) == DR_GROUP_SIZE (group_info))
-           is_store = true;
+         done = vectorizable_store (vinfo, stmt_info,
+                                    gsi, &vec_stmt, slp_node, NULL);
+         gcc_assert (done);
+         is_store = true;
        }
-      else
-       is_store = true;
       break;
 
     case condition_vec_info_type: