[vect] PR 92351: When peeling for alignment make alignment of epilogues unknown
authorAndre Vieira <andre.simoesdiasvieira@arm.com>
Fri, 8 Nov 2019 13:52:56 +0000 (13:52 +0000)
committerAndre Vieira <avieira@gcc.gnu.org>
Fri, 8 Nov 2019 13:52:56 +0000 (13:52 +0000)
gcc/ChangeLog:
2019-11-08  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR tree-optimization/92351
* tree-vect-data-refs.c (vect_compute_data_ref_alignment): When we are
peeling the main loop for alignment, make sure to set the misalignment
of the epilogue's data references to DR_MISALIGNMENT_UNKNOWN.

gcc/testsuite/ChangeLog:
2019-11-08  Andre Vieira  <andre.simoesdiasvieira@arm.com>

PR tree-optimization/92351
* gcc.dg/vect/vect-peel-2.c: Disable epilogue vectorization and
split the source of this test to...
* gcc.dg/vect/vect-peel-2-src.c: ... This.
* gcc.dg/vect/vect-peel-2-epilogues.c: New test.

From-SVN: r277974

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-peel-2-epilogues.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-peel-2-src.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-peel-2.c
gcc/tree-vect-data-refs.c

index b00e473..b61665d 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-08  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+
+       PR tree-optimization/92351
+       * tree-vect-data-refs.c (vect_compute_data_ref_alignment): When we are
+       peeling the main loop for alignment, make sure to set the misalignment
+       of the epilogue's data references to DR_MISALIGNMENT_UNKNOWN.
+
 2019-11-08  Richard Biener  <rguenther@suse.de>
 
        * dbgcnt.def (ivopts_loop): Add.
index 45306ae..55b0c5a 100644 (file)
@@ -1,3 +1,11 @@
+2019-11-08  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+
+       PR tree-optimization/92351
+       * gcc.dg/vect/vect-peel-2.c: Disable epilogue vectorization and
+       split the source of this test to...
+       * gcc.dg/vect/vect-peel-2-src.c: ... This.
+       * gcc.dg/vect/vect-peel-2-epilogues.c: New test.
+
 2019-11-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/compile/20191108-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/vect-peel-2-epilogues.c b/gcc/testsuite/gcc.dg/vect/vect-peel-2-epilogues.c
new file mode 100644 (file)
index 0000000..c06fa44
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "vect-peel-2-src.c"
diff --git a/gcc/testsuite/gcc.dg/vect/vect-peel-2-src.c b/gcc/testsuite/gcc.dg/vect/vect-peel-2-src.c
new file mode 100644 (file)
index 0000000..f6fc134
--- /dev/null
@@ -0,0 +1,48 @@
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 128
+
+/* unaligned store.  */
+
+int ib[N+7];
+
+__attribute__ ((noinline))
+int main1 ()
+{
+  int i;
+  int ia[N+1];
+
+  /* The store is aligned and the loads are misaligned with the same 
+     misalignment. Cost model is disabled. If misaligned stores are supported,
+     we peel according to the loads to align them.  */
+  for (i = 0; i <= N; i++)
+    {
+      ia[i] = ib[i+2] + ib[i+6];
+    }
+
+  /* check results:  */
+  for (i = 1; i <= N; i++)
+    {
+      if (ia[i] != ib[i+2] + ib[i+6])
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  for (i = 0; i <= N+6; i++)
+    {
+      asm volatile ("" : "+r" (i));
+      ib[i] = i;
+    }
+
+  return main1 ();
+}
+
index b6061c3..65e70bd 100644 (file)
@@ -1,52 +1,8 @@
 /* { dg-require-effective-target vect_int } */
+/* Disabling epilogues until we find a better way to deal with scans.  */
+/* { dg-additional-options "--param vect-epilogues-nomask=0" } */
 
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 128
-
-/* unaligned store.  */
-
-int ib[N+7];
-
-__attribute__ ((noinline))
-int main1 ()
-{
-  int i;
-  int ia[N+1];
-
-  /* The store is aligned and the loads are misaligned with the same 
-     misalignment. Cost model is disabled. If misaligned stores are supported,
-     we peel according to the loads to align them.  */
-  for (i = 0; i <= N; i++)
-    {
-      ia[i] = ib[i+2] + ib[i+6];
-    }
-
-  /* check results:  */
-  for (i = 1; i <= N; i++)
-    {
-      if (ia[i] != ib[i+2] + ib[i+6])
-        abort ();
-    }
-
-  return 0;
-}
-
-int main (void)
-{ 
-  int i;
-
-  check_vect ();
-
-  for (i = 0; i <= N+6; i++)
-    {
-      asm volatile ("" : "+r" (i));
-      ib[i] = i;
-    }
-
-  return main1 ();
-}
+#include "vect-peel-2-src.c"
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */
index 36639b6..88f14e7 100644 (file)
@@ -938,6 +938,18 @@ vect_compute_data_ref_alignment (dr_vec_info *dr_info)
     = exact_div (vect_calculate_target_alignment (dr_info), BITS_PER_UNIT);
   DR_TARGET_ALIGNMENT (dr_info) = vector_alignment;
 
+  /* If the main loop has peeled for alignment we have no way of knowing
+     whether the data accesses in the epilogues are aligned.  We can't at
+     compile time answer the question whether we have entered the main loop or
+     not.  Fixes PR 92351.  */
+  if (loop_vinfo)
+    {
+      loop_vec_info orig_loop_vinfo = LOOP_VINFO_ORIG_LOOP_INFO (loop_vinfo);
+      if (orig_loop_vinfo
+         && LOOP_VINFO_PEELING_FOR_ALIGNMENT (orig_loop_vinfo) != 0)
+       return;
+    }
+
   unsigned HOST_WIDE_INT vect_align_c;
   if (!vector_alignment.is_constant (&vect_align_c))
     return;