https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113576
--- Comment #7 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 1fd957288d4..33a8d539b4d 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -8032,7 +8032,7 @@ native_encode_vector_part (const_tree expr, unsigned char *ptr, int len, unsigned int elts_per_byte = BITS_PER_UNIT / elt_bits; unsigned int first_elt = off * elts_per_byte; - unsigned int extract_elts = extract_bytes * elts_per_byte; + unsigned int extract_elts = count; for (unsigned int i = 0; i < extract_elts; ++i) { tree elt = VECTOR_CST_ELT (expr, first_elt + i); Shouldn't we use count here?(it also fixed the hanged issue). Also even vector_boolean_type has only 4 elements, VECTOR_CST_ELT (expr, 5) still return -1, not sure if it's reasonable.