aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorRobin Dapp <rdapp@ventanamicro.com>2025-04-03 16:46:05 +0200
committerRobin Dapp <rdapp@ventanamicro.com>2025-04-09 11:45:13 +0200
commitf183ae0ae891a471764876eb1e69239904598bb4 (patch)
tree9b60884a0b308c07d58f4ca19cac0637a1e1db20 /gcc/expr.cc
parentee65440cbd8042a5e5885e18bde70f8d530e4404 (diff)
downloadgcc-f183ae0ae891a471764876eb1e69239904598bb4.zip
gcc-f183ae0ae891a471764876eb1e69239904598bb4.tar.gz
gcc-f183ae0ae891a471764876eb1e69239904598bb4.tar.bz2
expr: Use constant_lower_bound classifying constructor els [PR116595].
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.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r--gcc/expr.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 2147eed..3815c56 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);