https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104112
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- The following adds such verification diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 0fe3529b2d1..6ce33f3cef0 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -4979,9 +4979,20 @@ vect_find_reusable_accumulator (loop_vec_info loop_vinfo, /* Handle the case where we can reduce wider vectors to narrower ones. */ tree vectype = STMT_VINFO_VECTYPE (reduc_info); tree old_vectype = TREE_TYPE (accumulator->reduc_input); + unsigned HOST_WIDE_INT m; if (!constant_multiple_p (TYPE_VECTOR_SUBPARTS (old_vectype), - TYPE_VECTOR_SUBPARTS (vectype))) + TYPE_VECTOR_SUBPARTS (vectype), &m)) return false; + /* Check the intermediate vector types are available. */ + while (m > 2) + { + m /= 2; + tree intermediate_vectype = get_related_vectype_for_scalar_type + (TYPE_MODE (vectype), TREE_TYPE (vectype), + exact_div (TYPE_VECTOR_SUBPARTS (old_vectype), m)); + if (!intermediate_vectype) + return false; + } /* Non-SLP reductions might apply an adjustment after the reduction operation, in order to simplify the initialization of the accumulator.