--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org>
Date: Mon Mar 12 13:50:52 2018
New Revision: 258450
Don't vectorise zero-step rmw operations (PR 84485)
GCC 6 and 7 would vectorise:
f (unsigned long incx, unsigned long incy,
float *restrict dx, float *restrict dy)
unsigned long ix = 0, iy = 0;
for (unsigned long i = 0; i < 512; ++i)
dy[iy] += dx[ix];
ix += incx;
iy += incy;
without first proving that incy is nonzero. This is a regression from
GCC 5. It was fixed on trunk in r256644, which versioned the loop based
on whether incy is zero, but that's obviously too invasive to backport.
This patch instead bails out for possibly-zero steps in the place that
trunk would try a check for zeroness.
Also, the patch makes vect_analyze_data_ref_access check safelen
as well as force_vectorize.
2018-03-12 Richard Sandiford <richard.sandif...@linaro.org>
* tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Return
true for zero dependence distances if the step might be zero,
and if there is no metadata that guarantees correctness.
(vect_analyze_data_ref_access): Check safelen as well as
* gcc.dg/vect/pr84485.c: New test.