public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] vect: Fix offset calculation for -ve strides [PR93767]
@ 2020-09-17 16:45 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 16:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2c9d8125580ab40c25b2cda98a56d38880327b09

commit 2c9d8125580ab40c25b2cda98a56d38880327b09
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Feb 18 18:06:32 2020 +0000

    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-25  Richard Sandiford  <richard.sandiford@arm.com>
    
    gcc/
            Backport from mainline
            2020-02-19  Richard Sandiford  <richard.sandiford@arm.com>
    
            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/
            Backport from mainline
            2020-02-19  Richard Sandiford  <richard.sandiford@arm.com>
    
            PR tree-optimization/93767
            * gcc.dg/vect/pr93767.c: New test.

Diff:
---
 gcc/ChangeLog                       |  9 +++++++++
 gcc/testsuite/ChangeLog             |  8 ++++++++
 gcc/testsuite/gcc.dg/vect/pr93767.c | 13 +++++++++++++
 gcc/tree-vect-data-refs.c           |  4 ++--
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3cc921e655f..6a4938c8544 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2020-02-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backport from mainline
+	2020-02-19  Richard Sandiford  <richard.sandiford@arm.com>
+
+	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.
+
 2020-02-25  Richard Sandiford  <richard.sandiford@arm.com>
 
 	Backport from mainline
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2c698b20389..eb1cdf420ff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-02-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backport from mainline
+	2020-02-19  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR tree-optimization/93767
+	* gcc.dg/vect/pr93767.c: New test.
+
 2020-02-25  Richard Sandiford  <richard.sandiford@arm.com>
 
 	PR tree-optimization/93434
diff --git a/gcc/testsuite/gcc.dg/vect/pr93767.c b/gcc/testsuite/gcc.dg/vect/pr93767.c
new file mode 100644
index 00000000000..5f95d7bd35b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr93767.c
@@ -0,0 +1,13 @@
+int
+main ()
+{
+  int a[10], b;
+  for (b = 6; b >= 3; b--)
+    {
+      a[b] = 1;
+      a[b + 2] = a[3];
+    }
+  if (a[5] != 1)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index b7a82986a45..81c86d73b26 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -3245,14 +3245,14 @@ vect_compile_time_alias (struct data_reference *a, struct data_reference *b,
   if (tree_int_cst_compare (DR_STEP (a), size_zero_node) < 0)
     {
       const_length_a = (-wi::to_poly_wide (segment_length_a)).force_uhwi ();
-      offset_a = (offset_a + access_size_a) - const_length_a;
+      offset_a -= const_length_a;
     }
   else
     const_length_a = tree_to_poly_uint64 (segment_length_a);
   if (tree_int_cst_compare (DR_STEP (b), size_zero_node) < 0)
     {
       const_length_b = (-wi::to_poly_wide (segment_length_b)).force_uhwi ();
-      offset_b = (offset_b + access_size_b) - const_length_b;
+      offset_b -= const_length_b;
     }
   else
     const_length_b = tree_to_poly_uint64 (segment_length_b);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-17 16:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 16:45 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] vect: Fix offset calculation for -ve strides [PR93767] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).