]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr: Use constant_lower_bound classifying constructor els [PR116595].
authorRobin Dapp <rdapp@ventanamicro.com>
Thu, 3 Apr 2025 14:46:05 +0000 (16:46 +0200)
committerRobin Dapp <rdapp@ventanamicro.com>
Wed, 9 Apr 2025 09:45:13 +0000 (11:45 +0200)
In categorize_ctor_elements_1 we do
  VECTOR_CST_NELTS (value).to_constant ()
but VALUE's type can be a VLA vector (since r15-5780-g17b520a10cdaab).

This patch uses constant_lower_bound instead.

PR middle-end/116595

gcc/ChangeLog:

* expr.cc (categorize_ctor_elements_1): Use
constant_lower_bound.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/autovec/pr116595.C: New test.

gcc/expr.cc
gcc/testsuite/g++.target/riscv/rvv/autovec/pr116595.C [new file with mode: 0644]

index 2147eedad7bea1d02606a16f5a15428570497b5e..3815c565e2d8239670e7e77b499a37d3a35a1ec9 100644 (file)
@@ -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 (file)
index 0000000..6d509d2
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv" } */
+
+#include <riscv_vector.h>
+
+void
+vsseg (float *a, vfloat32mf2_t b, vfloat32mf2_t c, unsigned long vl)
+{
+  vfloat32mf2x2_t foo = vfloat32mf2x2_t ();
+}