Hi gcc-patches mailing list, Christopher Bazley via Sourceware Forge <[email protected]> has requested that the following forgejo pull request be published on the mailing list.
Created on: 2026-06-16 16:07:08+00:00 Latest update: 2026-06-16 16:11:12+00:00 Changes: 2 changed files, 19 additions, 7 deletions Head revision: chris.bazley/gcc ref store_constructor commit b697ef4dcff931628e34501230d318c3fcc7b5a9 Base revision: gcc/gcc-TEST ref trunk commit c6133f911ea5ae4a4df59079c6299593fdec8afc r17-1517-gc6133f911ea5ae Merge base: c6133f911ea5ae4a4df59079c6299593fdec8afc Full diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/177.diff Discussion: https://forge.sourceware.org/gcc/gcc-TEST/pulls/177 Requested Reviewers: When given a constructor of variable-length vector type, the store_constructor function now builds a vector with the lower bound of the number of subparts in the vector type and uses it to emit the body of the kind of insn chosen by the convert_optab_handler function. Previously, this function used a fallback path of calling store_constructor_field upon discovering that the number of subparts in the vector type was not a constant multiple of the number of subparts in the element type. For example, this allows GCC to generate the following AArch64 assembly language output for the tail of a reduction in the slp_6 test: uaddv d31, p6, z31.b uaddv d27, p6, z27.b uaddv d26, p6, z26.b movi d30, #0 insr z30.b, b26 insr z30.b, b27 insr z30.b, b31 add z25.b, z25.b, z30.b instead of the following output (with predicated tails for basic block SLP vectorization but without this change): addvl x0, sp, #2 movi d0, #0 st1b z0.b, p6, [sp, #2, mul vl] uaddv d27, p6, z27.b uaddv d26, p6, z26.b uaddv d25, p6, z25.b str b27, [x0] addvl x0, sp, #1 add x0, x0, 1 ptrue p7.b, vl3 ld1b z0.b, p6/z, [sp, #2, mul vl] st1b z0.b, p6, [sp, #1, mul vl] str b26, [x0] ld1b z0.b, p6/z, [sp, #1, mul vl] st1b z0.b, p6, [sp] str b25, [sp, 2] ld1b z0.b, p6/z, [sp] add z28.b, z28.b, z0.b st1b z28.b, p7, [x1] addvl sp, sp, #3 or the original assembly language output (with neither predicated tails for basic block SLP vectorization nor this change): uaddv d31, p6, z31.b fmov x0, d31 uaddv d31, p6, z26.b add w6, w6, w0 fmov x0, d31 uaddv d31, p6, z27.b add w5, w5, w0 fmov x0, d31 add w4, w4, w0 The behavior of vec_init for scalable vector modes was not previously documented, so rectify that. Any elements beyond the minimum number of elements implied by the vector mode are implicitly zero. gcc/ChangeLog: * expr.cc (store_constructor): Add an else block to handle cases of TREE_CODE (TREE_TYPE (exp)) == VECTOR_TYPE in which exact_div (n_elts, GET_MODE_NUNITS (eltmode)).is_constant (&const_n_elts) is false similar to the existing "element type is not a vector type" case except that const_n_elts is taken from the lower bound of the subparts of the vector type. * doc/md.texi: Update description of vec_init. Changed files: - M: gcc/doc/md.texi - M: gcc/expr.cc Christopher Bazley (1): Handle variable-length vector types in store_constructor gcc/doc/md.texi | 4 +++- gcc/expr.cc | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) -- 2.54.0
