Although the S/390 backend states that the machine supports unaligned
vector accesses the loop vectorizer still tries to peel loop
iterations to get higher alignments.  Setting
vect_max_peeling_for_alignment to 0 prevents this.

gcc/ChangeLog:

2016-11-29  Andreas Krebbel  <kreb...@linux.vnet.ibm.com>

        * config/s390/s390.c (s390_option_override_internal): Set
        vect_max_peeling_for_alignment to 0.

gcc/testsuite/ChangeLog:

2016-11-29  Andreas Krebbel  <kreb...@linux.vnet.ibm.com>

        * gcc.dg/tree-ssa/gen-vect-26.c: Disable peeling check for s390.
        * gcc.dg/tree-ssa/gen-vect-28.c: Likewise.
---
 gcc/config/s390/s390.c                      | 13 +++++++++++++
 gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c |  5 ++---
 gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c |  4 ++--
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index dab4f43..2e71745 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -14586,6 +14586,19 @@ s390_option_override_internal (bool main_args_p,
                          opts->x_param_values,
                          opts_set->x_param_values);
 
+  /* S/390 can deal with unaligned accesses without a performance
+     penalty (as long as we do not cross a cache line boundary).  This
+     setting prevents the vectorizer from generating expensive extra
+     code emitted to reach a better alignment.
+     Don't do this when vectorize_support_vector_misalignment falls
+     back to the default path in order to avoid effects on software
+     vectorization.  */
+  if (TARGET_VX)
+    maybe_set_param_value (PARAM_VECT_MAX_PEELING_FOR_ALIGNMENT,
+                          0,
+                          opts->x_param_values,
+                          opts_set->x_param_values);
+
   /* Call target specific restore function to do post-init work.  At the 
moment,
      this just sets opts->x_s390_cost_pointer.  */
   s390_function_specific_restore (opts, NULL);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c 
b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c
index 8e5f141..461a952 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c
@@ -28,7 +28,6 @@ int main ()
   return 0;
 }
 
-
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { 
! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 
"vect" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using 
peeling" 1 "vect" { target { ! avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 
"vect" { target { ! { avr-*-* s390*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using 
peeling" 1 "vect" { target { ! { avr-*-* s390*-*-* } } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c 
b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c
index ce97e09..fe44e85 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c
@@ -38,5 +38,5 @@ int main (void)
 
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { 
! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 
"vect" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using 
peeling" 1 "vect" { target { ! avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 
"vect" { target { ! { avr-*-* s390*-*-* } } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using 
peeling" 1 "vect" { target { ! { avr-*-* s390*-*-* } } } } } */
-- 
2.9.1

Reply via email to