On 10/9/26 10:49 AM, Dominic P wrote:
expand_constructor passed int_expr_size to store_constructor, which is
-1 for a type whose size is a POLY_INT_CST. The RECORD_TYPE case then
skipped clear_storage, so an empty CONSTRUCTOR of an SVE or RVV tuple
type stored nothing: a register target got only a clobber and a memory
target was left unchanged. Pass the poly size instead; only types with
a POLY_INT_CST size are affected.
store_constructor now asserts that SIZE is nonnegative, so an unknown
size from any caller ICEs instead of leaving the object uninitialized.
Bootstrapped and regression tested on x86_64-pc-linux-gnu, including Ada. On
aarch64-linux-gnu (qemu), regression tested dg.exp, aarch64.exp and
the SVE tests at SVE VL128, and the SVE tests at VL2048. On
riscv64, compiling gcc.target/riscv/rvv/base changes the asm of the new
test only.
Assisted-by: Claude Opus 5 (Anthropic)
PR middle-end/121105
gcc/ChangeLog:
* expr.cc (store_constructor): Assert that SIZE is nonnegative.
Drop the then-redundant known_size_p check.
(expand_constructor): Pass the poly_int64 size of the type to
store_constructor.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/pr121105_1.c: New test.
* gcc.target/aarch64/sve/pr121105_2.c: New test.
* g++.target/aarch64/sve/pr121105.C: New test.
* gcc.target/riscv/rvv/base/pr121105.c: New test.
Signed-off-by: Dominic P <[email protected]>
---
v2: as Jeff Law suggested, store_constructor now asserts on entry that
SIZE is nonnegative, which covers all of its callers, and drops the
known_size_p test that the assert makes redundant. expand_constructor
uses tree_to_poly_int64 instead of falling back to -1. The gimplifier
lowers variable-sized CONSTRUCTORs (element stores, or memset when
empty), so no valid caller trips the assert. Patch 1/2 is unchanged.
OK for trunk?
OK. Thanks!
jeff