tree-vect-data-refs.c (vect_enhance_data_refs_alignment): When all DRs have unknown...
authorRichard Biener <rguenther@suse.de>
Wed, 3 May 2017 11:01:06 +0000 (11:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 3 May 2017 11:01:06 +0000 (11:01 +0000)
2017-05-03  Richard Biener  <rguenther@suse.de>

* tree-vect-data-refs.c (vect_enhance_data_refs_alignment):
When all DRs have unknown misaligned do not always peel
when there is a store but apply the same costing model as if
there were only loads.

* gcc.dg/vect/costmodel/x86_64/costmodel-alignpeel.c: New testcase.

From-SVN: r247544

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-alignpeel.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c

index 8dee382d10a5a5de2deba26ca41692ce1d57be0c..0c54109a5f28e6ff33f772b786b8cbcf114f3e09 100644 (file)
@@ -1,3 +1,10 @@
+2017-05-03  Richard Biener  <rguenther@suse.de>
+
+       * tree-vect-data-refs.c (vect_enhance_data_refs_alignment):
+       When all DRs have unknown misaligned do not always peel
+       when there is a store but apply the same costing model as if
+       there were only loads.
+
 2017-05-03  Richard Biener  <rguenther@suse.de>
 
        Revert
index 3f6190bd0747527d02910c2b5e9f10e0fecb72bc..2d4d8e0de582b815a8575cd6f25d4a5b20c931c4 100644 (file)
@@ -1,3 +1,7 @@
+2017-05-03  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/vect/costmodel/x86_64/costmodel-alignpeel.c: New testcase.
+
 2017-05-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/79472
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-alignpeel.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-alignpeel.c
new file mode 100644 (file)
index 0000000..9e20b4a
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+void func(double * __restrict__ v1, double * v2, unsigned n)
+{
+  for (unsigned i = 0; i < n; ++i)
+    v1[i] = v2[i];
+}
+
+/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */
index aa504b6a1c694f7d8a1ac5e767d04504a67f8725..c97426882e82ffa11abdb900fe2c26f45373a3bf 100644 (file)
@@ -1715,18 +1715,18 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
             dr0 = first_store;
         }
 
-      /* In case there are only loads with different unknown misalignments, use
-         peeling only if it may help to align other accesses in the loop or
+      /* Use peeling only if it may help to align other accesses in the loop or
         if it may help improving load bandwith when we'd end up using
         unaligned loads.  */
       tree dr0_vt = STMT_VINFO_VECTYPE (vinfo_for_stmt (DR_STMT (dr0)));
-      if (!first_store
-         && !STMT_VINFO_SAME_ALIGN_REFS (
-                 vinfo_for_stmt (DR_STMT (dr0))).length ()
+      if (STMT_VINFO_SAME_ALIGN_REFS
+           (vinfo_for_stmt (DR_STMT (dr0))).length () == 0
          && (vect_supportable_dr_alignment (dr0, false)
              != dr_unaligned_supported
-             || (builtin_vectorization_cost (vector_load, dr0_vt, 0)
-                 == builtin_vectorization_cost (unaligned_load, dr0_vt, -1))))
+             || (DR_IS_READ (dr0)
+                 && (builtin_vectorization_cost (vector_load, dr0_vt, 0)
+                     == builtin_vectorization_cost (unaligned_load,
+                                                    dr0_vt, -1)))))
         do_peeling = false;
     }