]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid accessing STMT_VINFO_VECTYPE
authorRichard Biener <rguenther@suse.de>
Wed, 9 Jul 2025 09:23:30 +0000 (11:23 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 9 Jul 2025 11:11:39 +0000 (13:11 +0200)
The following fixes up two places we access STMT_VINFO_VECTYPE that's
not covered by the fixup in vect_analyze/transform_stmt to set that
from SLP_TREE_VECTYPE.

* tree-vect-loop.cc (vectorizable_reduction): Get the
output vector type from slp_for_stmt_info.
* tree-vect-stmts.cc (vect_analyze_stmt): Bail out earlier
for PURE_SLP_STMT when doing loop stmt analysis.

gcc/tree-vect-loop.cc
gcc/tree-vect-stmts.cc

index d5044d5fe227295ef9a0b6880248020291bfc0b6..42e00159ff8247117e63abe73b6df614e55d3b2b 100644 (file)
@@ -7822,7 +7822,7 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
         inside the loop body. The last operand is the reduction variable,
         which is defined by the loop-header-phi.  */
 
-  tree vectype_out = STMT_VINFO_VECTYPE (stmt_info);
+  tree vectype_out = SLP_TREE_VECTYPE (slp_for_stmt_info);
   STMT_VINFO_REDUC_VECTYPE (reduc_info) = vectype_out;
   STMT_VINFO_REDUC_VECTYPE_IN (reduc_info) = vectype_in;
 
index 5767a351fdf9c30ed134042740fbb41e3245ceaa..da201274c786030003ef84134521d2e594aa556a 100644 (file)
@@ -13368,6 +13368,14 @@ vect_analyze_stmt (vec_info *vinfo,
         gcc_unreachable ();
     }
 
+  if (PURE_SLP_STMT (stmt_info) && !node)
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "handled only by SLP analysis\n");
+      return opt_result::success ();
+    }
+
   tree saved_vectype = STMT_VINFO_VECTYPE (stmt_info);
   if (node)
     STMT_VINFO_VECTYPE (stmt_info) = SLP_TREE_VECTYPE (node);
@@ -13381,14 +13389,6 @@ vect_analyze_stmt (vec_info *vinfo,
       *need_to_vectorize = true;
     }
 
-  if (PURE_SLP_STMT (stmt_info) && !node)
-    {
-      if (dump_enabled_p ())
-       dump_printf_loc (MSG_NOTE, vect_location,
-                        "handled only by SLP analysis\n");
-      return opt_result::success ();
-    }
-
   /* When we arrive here with a non-SLP statement and we are supposed
      to use SLP for everything fail vectorization.  */
   if (!node)