Hi! As mentioned in the PR, if a VECTOR_CST is not VECTOR_CST_STEPPED_P, it is sufficient to recurse just on all the encoded elt, because if the vector has more elts than encoded, all the remaining ones are equal to the last one. But, if it is stepped, there is the possibility that while the penultimate and last encoded elt could be zero or one, the first non-encoded one could be two or minus one.
The patch as committed is doing: unsigned HOST_WIDE_INT nelts = vector_cst_encoded_nelts (expr); if (VECTOR_CST_STEPPED_P (expr) && !TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr)).is_constant (&nelts)) return false; so if it is stepped, it updates nelts to the subparts count and thus attempts to verify all elts rather than just the encoded ones. But that fails because VECTOR_CST_ENCODED_ELT can't really access the non-encoded ones. The following patch fixes it by using vector_cst_elt there instead, for the encoded elt it just returns VECTOR_CST_ENCODED_ELT immediately and for the next value it will likely fail the predicate. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-01-08 Jelinek <ja...@redhat.com> PR middle-end/88758 * tree.c (initializer_each_zero_or_onep) <case VECTOR_CST>: Use vector_cst_elt instead of VECTOR_CST_ENCODED_ELT. --- gcc/tree.c.jj 2019-01-07 17:59:22.883951743 +0100 +++ gcc/tree.c 2019-01-08 18:15:01.956087119 +0100 @@ -11255,7 +11255,7 @@ initializer_each_zero_or_onep (const_tre for (unsigned int i = 0; i < nelts; ++i) { - tree elt = VECTOR_CST_ENCODED_ELT (expr, i); + tree elt = vector_cst_elt (expr, i); if (!initializer_each_zero_or_onep (elt)) return false; } Jakub