diff --git a/gcc/expr.cc b/gcc/expr.cc index 2147eedad7b..3815c565e2d 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -7193,9 +7193,9 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts, case VECTOR_CST: { - /* We can only construct constant-length vectors using - CONSTRUCTOR. */ - unsigned int nunits = VECTOR_CST_NELTS (value).to_constant (); + unsigned int nunits + = constant_lower_bound + (TYPE_VECTOR_SUBPARTS (TREE_TYPE (value))); for (unsigned int i = 0; i < nunits; ++i) { tree v = VECTOR_CST_ELT (value, i); diff --git a/gcc/testsuite/g++.target/riscv/rvv/autovec/pr116595.C b/gcc/testsuite/g++.target/riscv/rvv/autovec/pr116595.C new file mode 100644 index 00000000000..6d509d2cf74 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/rvv/autovec/pr116595.C @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv" } */ + +#include + +void +vsseg (float *a, vfloat32mf2_t b, vfloat32mf2_t c, unsigned long vl) +{ + vfloat32mf2x2_t foo = vfloat32mf2x2_t (); +}