https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116081
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #5) > I think I found it: > while (k > 0 && elts[k - 1] == neutral_op) > > > I think that should be since both elts[k - 1] and neutral_op are trees: > while (k > 0 && operand_equal_p (elts[k - 1], neutral_op)) Yes this patch fixes the code difference: ``` diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index d7d628efa60..856ce491c3e 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -5652,7 +5652,7 @@ get_initial_defs_for_reduction (loop_vec_info loop_vinfo, init = gimple_build_vector_from_val (&ctor_seq, vector_type, neutral_op); int k = nunits; - while (k > 0 && elts[k - 1] == neutral_op) + while (k > 0 && operand_equal_p (elts[k - 1], neutral_op)) k -= 1; while (k > 0) { ```