]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: Relax vect_recog_vector_vector_shift_pattern STMT def type [PR121949]
authorTamar Christina <tamar.christina@arm.com>
Tue, 14 Oct 2025 09:24:13 +0000 (10:24 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 14 Oct 2025 09:24:20 +0000 (10:24 +0100)
commitc078309cda304ffa18d2bd322512530e6feffdfb
treed1b260918e11552f546987699a6fa1ac09e0051d
parentc3e0fb3cd8b9af33cd3445bc500a558b818b43e5
middle-end: Relax vect_recog_vector_vector_shift_pattern STMT def type [PR121949]

The example

void f(long long* acc)
{
    for (int row = 0; row < 64; ++row)
      acc[row] = acc[row] << row;
}

fails to vectorize because the size of row is different than the size of the
being shifted value.

The vectorizer has a pattern that should deal with such shifts in
vect_recog_vector_vector_shift_pattern however this pattern is using
vect_get_internal_def to get the definition of the shift operand.

This needlessly restricts the pattern to only internal_defs.  The vectorizer
can deal with casts on any operand type so this restriction isn't needed and
this is dropped.

gcc/ChangeLog:

PR tree-optimization/121949
* tree-vect-patterns.cc (vect_recog_vector_vector_shift_pattern): Remove
restriction on internal_def.

gcc/testsuite/ChangeLog:

PR tree-optimization/121949
* gcc.dg/vect/pr121949_1.c: New test.
* gcc.dg/vect/pr121949_2.c: New test.
* gcc.dg/vect/pr121949_3.c: New test.
gcc/testsuite/gcc.dg/vect/pr121949_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr121949_2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr121949_3.c [new file with mode: 0644]
gcc/tree-vect-patterns.cc