This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/84485] [6/7 Regression] Vectorising zero-stride rmw operation


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84485

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Mon Mar 12 13:50:52 2018
New Revision: 258450

URL: https://gcc.gnu.org/viewcvs?rev=258450&root=gcc&view=rev
Log:
Don't vectorise zero-step rmw operations (PR 84485)

GCC 6 and 7 would vectorise:

void
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.sandiford@linaro.org>

gcc/
        PR tree-optimization/84485
        * 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
        force_vectorize.

gcc/testsuite/
        PR tree-optimization/84485
        * gcc.dg/vect/pr84485.c: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/vect/pr84485.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/tree-vect-data-refs.c

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]