]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not set STMT_VINFO_VECTYPE for non-dataref stmts
authorRichard Biener <rguenther@suse.de>
Mon, 11 Aug 2025 09:22:47 +0000 (11:22 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 12 Aug 2025 07:11:30 +0000 (09:11 +0200)
Now that all STMT_VINFO_VECTYPE uses from vectorizable_* have been
pruged there's no longer a need to have STMT_VINFO_VECTYPE set.
We still rely on it being present on data-ref stmts and there it
can differ between different SLP instances when doing BB vectorization.
The following removes the setting from vect_analyze_stmt and
vect_transform_stmt.

Note the following clears STMT_VINFO_VECTYPE from pattern stmts (the
vector type should have moved to the SLP tree by this time).

* tree-vect-stmts.cc (vect_analyze_stmt): Only set
STMT_VINFO_VECTYPE for dataref SLP representatives.
Clear it for others and do not restore the original value.
(vect_transform_stmt): Likewise.

gcc/tree-vect-stmts.cc

index 26d5be51892279aeb6354ac9cae6f5fc7b1c58da..b14680e0d7c38ec390a7935910ca1593e3712f40 100644 (file)
@@ -12515,13 +12515,15 @@ vect_analyze_stmt (vec_info *vinfo,
         gcc_unreachable ();
     }
 
-  tree saved_vectype = STMT_VINFO_VECTYPE (stmt_info);
-  STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (node);
+  if (! STMT_VINFO_DATA_REF (stmt_info))
+    STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
+  else
+    STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (node);
 
   if (STMT_VINFO_RELEVANT_P (stmt_info))
     {
       gcall *call = dyn_cast <gcall *> (stmt_info->stmt);
-      gcc_assert (STMT_VINFO_VECTYPE (stmt_info)
+      gcc_assert (SLP_TREE_VECTYPE (node)
                  || gimple_code (stmt_info->stmt) == GIMPLE_COND
                  || (call && gimple_call_lhs (call) == NULL_TREE));
     }
@@ -12589,8 +12591,6 @@ vect_analyze_stmt (vec_info *vinfo,
 
     }
 
-  STMT_VINFO_VECTYPE (stmt_info) = saved_vectype;
-
   if (!ok)
     return opt_result::failure_at (stmt_info->stmt,
                                   "not vectorized:"
@@ -12634,8 +12634,10 @@ vect_transform_stmt (vec_info *vinfo,
     dump_printf_loc (MSG_NOTE, vect_location,
                     "------>vectorizing statement: %G", stmt_info->stmt);
 
-  tree saved_vectype = STMT_VINFO_VECTYPE (stmt_info);
-  STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (slp_node);
+  if (! STMT_VINFO_DATA_REF (stmt_info))
+    STMT_VINFO_VECTYPE (stmt_info) = NULL_TREE;
+  else
+    STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (slp_node);
 
   switch (SLP_TREE_TYPE (slp_node))
     {
@@ -12765,8 +12767,6 @@ vect_transform_stmt (vec_info *vinfo,
       gcc_assert (done);
     }
 
-  STMT_VINFO_VECTYPE (stmt_info) = saved_vectype;
-
   return is_store;
 }