https://gcc.gnu.org/g:591d8f3b273627cc42171e778014b84370091e44
commit r16-2129-g591d8f3b273627cc42171e778014b84370091e44 Author: Richard Biener <rguent...@suse.de> Date: Wed Jul 9 11:23:30 2025 +0200 Avoid accessing STMT_VINFO_VECTYPE 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. Diff: --- gcc/tree-vect-loop.cc | 2 +- gcc/tree-vect-stmts.cc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index d5044d5fe227..42e00159ff82 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -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; diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 5767a351fdf9..da201274c786 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -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)