vect: Fix missed gather load opportunity
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 20 Sep 2022 14:27:46 +0000 (15:27 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 20 Sep 2022 14:27:46 +0000 (15:27 +0100)
commit4a773bf2f08656a39ac75cf6b4871c8cec8b5007
treec87f504a225db1aad3622c3d85caefeb29609843
parent3e41e69ab2d85f6756d5217a3d87ada559691e0d
vect: Fix missed gather load opportunity

While writing a testcase for PR106794, I noticed that we failed
to vectorise the testcase in the patch for SVE.  The code that
recognises gather loads tries to optimise the point at which
the offset is calculated, to avoid unnecessary extensions or
truncations:

  /* Don't include the conversion if the target is happy with
     the current offset type.  */

But breaking only makes sense if we're at an SSA_NAME (which could
then be vectorised).  We shouldn't break on a conversion embedded
in a generic expression.

gcc/
* tree-vect-data-refs.cc (vect_check_gather_scatter): Restrict
early-out optimisation to SSA_NAMEs.

gcc/testsuite/
* gcc.dg/vect/vect-gather-5.c: New test.
gcc/testsuite/gcc.dg/vect/vect-gather-5.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc