While working on autovectorizing for the RISCV port I encountered an issue where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode), where GET_MODE_NUNITS is equal to one.
Tested on RISCV and x86_64-linux-gnu. Okay? 2023-03-09 Michael Collison <colli...@rivosinc.com> * tree-vect-slp.cc (can_duplicate_and_interleave_p): Check that GET_MODE_NUNITS is greater than one. --- gcc/tree-vect-slp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 9a4e000925e..add58113fa8 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -426,7 +426,8 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, if (vector_type && VECTOR_MODE_P (TYPE_MODE (vector_type)) && known_eq (GET_MODE_SIZE (TYPE_MODE (vector_type)), - GET_MODE_SIZE (base_vector_mode))) + GET_MODE_SIZE (base_vector_mode)) + && known_gt (GET_MODE_NUNITS (TYPE_MODE (vector_type)), 1)) { /* Try fusing consecutive sequences of COUNT / NVECTORS elements together into elements of type INT_TYPE and using the result -- 2.34.1