vect: Fix offset calculation for -ve strides [PR93767]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Feb 2020 18:06:32 +0000 (18:06 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 19 Feb 2020 13:12:22 +0000 (13:12 +0000)
commitf91aa3e6cb808f8dfc6b45fa135f7583a7549161
treedf517321d86e31f94c6bb925803180716b53634c
parentaca60ecff35837a1af9383cf67ee7d1c0a718b28
vect: Fix offset calculation for -ve strides [PR93767]

This PR is a regression caused by r256644, which added support for alias
checks involving variable strides.  One of the changes in that commit
was to split the access size out of the segment length.  The PR shows
that I hadn't done that correctly for the handling of negative strides
in vect_compile_time_alias.  The old code was:

      const_length_a = (-wi::to_poly_wide (segment_length_a)).force_uhwi ();
      offset_a = (offset_a + vect_get_scalar_dr_size (a)) - const_length_a;

where vect_get_scalar_dr_size (a) was cancelling out the subtraction
of the access size inherent in "- const_length_a".  Taking the access
size out of the segment length meant that the addition was no longer
needed/correct.

2020-02-19  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/93767
* tree-vect-data-refs.c (vect_compile_time_alias): Remove the
access-size bias from the offset calculations for negative strides.

gcc/testsuite/
PR tree-optimization/93767
* gcc.dg/vect/pr93767.c: New test.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr93767.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c