forwprop: allow subvectors in simplify_vector_constructor ()
This is an attempt to fix
https://gcc.gnu.org/pipermail/gcc-patches/2025-October/697879.html in the
middle-end; the motivation in that patch was to teach gcc to compile:
foo:
dup d31, v0.d[1]
uzp1 v0.2d, v31.2d, v0.2d
ret
Instead of adding a define_insn in the backend, this patch relaxes the
precondition of tree-ssa-forwprop.cc:simplify_vector_constructor () to
accept subvectors as constructor elements. During initial argument
processing (ll. 3817-3916), subvectors are decomposed into individual
elements before populating the ELTS array; this allows the rest of the
function to remain unchanged. Special handling is also implemented for
constant and splat subvector elements of a constructor (the latter with
the use of ssa_uniform_vector_p () from tree-vect-generic.cc, which this
patch moves to tree.cc).
Add GIMPLE tests to gcc.dg/tree-ssa demonstrating the intended behavior
with various combinations of subvectors as constructor arguments,
including constant and splat subvectors; also add some aarch64-specific
tests to show that the change leads to us picking the "ext" instruction
for the resulting VEC_PERM_EXPR.
Bootstrapped and regtested on aarch64 and x86_64, regtested on aarch64_be.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (simplify_vector_constructor): Support
vector constructor elements.
* tree-vect-generic.cc (ssa_uniform_vector_p): Make non-static and
move ...
* tree.cc (ssa_uniform_vector_p): ... here.
* tree.h (ssa_uniform_vector_p): Declare it.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/forwprop-43.c: New test.
* gcc.target/aarch64/simd/combine_ext.c: New test.