This is a summary of discussions relative to the merge request created by
Christopher Bazley (chris.bazley) <[email protected]> titled
Handle variable-length vector types in store_constructor
since its creation.
Description: 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.
Bootstrapped and tested on aarch64. Test results compared
with 107d2ad166d09883b43ec1a5cf1e37c68b134a93.
CC: [email protected], [email protected],
[email protected]
The full and up to date discussion can be found at
https://forge.sourceware.org/gcc/gcc/pulls/177
The merge request has been closed without being merged directly on the forge
repository.
On 2026-06-16 16:08:01+00:00, Christopher Bazley (chris.bazley)
<[email protected]> commented on the code:
Split from the patch series '[PATCH v11 00/12] Extend BB SLP vectorization to
use predicated tails' as requested by a maintainer in this email:
https://inbox.sourceware.org/gcc-patches/cafiyyc210cha8jaywrtwg__9w4uhaatvaicbuaskox7daq7...@mail.gmail.com/
> +++ gcc/expr.cc
> @@ -8082,3 +8089,1 @@
> - for (unsigned int k = 0; k < const_n_elts; k++)
> - RTVEC_ELT (vector, k) = CONST0_RTX (eltmode);
> - }
> + if (const_n_elts && icode != CODE_FOR_nothing)
I don't like mixing whitespace and functional changes but this was confusing
and closely related.
On 2026-06-16 16:12:51+00:00, Christopher Bazley (chris.bazley)
<[email protected]> commented on the code:
> +++ gcc/expr.cc
> @@ -8078,0 +8082,4 @@
> + else
> + {
> + /* Handle variable-length vector types. */
> + icode = convert_optab_handler (vec_init_optab, mode, eltmode);
The requested assertion that icode != CODE_FOR_nothing cannot be added.
See
https://inbox.sourceware.org/gcc-patches/[email protected]/
On 2026-07-28 13:16:10+00:00, Christopher Bazley (chris.bazley) wrote:
Reworked by Tamar