aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-08-28 13:13:45 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-08-28 13:13:45 +0000
commitb1aef01e16b01f3b07a14c5c7cac92d98553517f (patch)
treeb4e458d2703a45df4467d10ef7a50acef78d5b09 /gcc
parentf22ae1ecbd724ed01423a2132b5631a5d7c0ee10 (diff)
downloadgcc-b1aef01e16b01f3b07a14c5c7cac92d98553517f.zip
gcc-b1aef01e16b01f3b07a14c5c7cac92d98553517f.tar.gz
gcc-b1aef01e16b01f3b07a14c5c7cac92d98553517f.tar.bz2
re PR fortran/62283 (basic-block vectorization fails)
2014-08-28 Richard Biener <rguenther@suse.de> PR tree-optimization/62283 * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Do not peel loops for alignment where the vector loop likely doesn't run at least VF times. * gfortran.dg/vect/pr62283.f: New testcase. * gcc.dg/tree-ssa/cunroll-5.c: Adjust. * gcc.dg/vect/costmodel/i386/costmodel-vect-31.c: Likewise. * gcc.dg/vect/costmodel/i386/costmodel-vect-33.c: Likewise. * gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c: Likewise. * gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c: Likewise. * gcc.dg/vect/vect-33.c: Likewise. From-SVN: r214678
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/cunroll-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c2
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-33.c6
-rw-r--r--gcc/testsuite/gfortran.dg/vect/pr62283.f17
-rw-r--r--gcc/tree-vect-data-refs.c22
10 files changed, 63 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 28a3219..347075d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2014-08-28 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/62283
+ * tree-vect-data-refs.c (vect_enhance_data_refs_alignment):
+ Do not peel loops for alignment where the vector loop likely
+ doesn't run at least VF times.
+
2014-08-28 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (iv_ca_add_use): Delete parameter
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index acacc53..91a98e8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2014-08-28 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/62283
+ * gfortran.dg/vect/pr62283.f: New testcase.
+ * gcc.dg/tree-ssa/cunroll-5.c: Adjust.
+ * gcc.dg/vect/costmodel/i386/costmodel-vect-31.c: Likewise.
+ * gcc.dg/vect/costmodel/i386/costmodel-vect-33.c: Likewise.
+ * gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c: Likewise.
+ * gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c: Likewise.
+ * gcc.dg/vect/vect-33.c: Likewise.
+
2014-08-28 Yury Gribov <y.gribov@samsung.com>
* c-c++-common/asan/pr62089.c: Fix test on 32-bit platforms.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-5.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-5.c
index 1e9b8bf..2739c29 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-5.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-5.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O3 -fdump-tree-cunroll-details" } */
+/* { dg-options "-O3 -fdump-tree-cunroll-details -fno-tree-vectorize" } */
int *a;
test(int c)
{
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c
index 1372676..3c9bfda 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c
@@ -86,6 +86,5 @@ int main (void)
return main1 ();
}
-/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c
index 5676b24..86bfb58 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c
@@ -36,5 +36,5 @@ int main (void)
return main1 ();
}
-/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c
index 1372676..3c9bfda 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c
@@ -86,6 +86,5 @@ int main (void)
return main1 ();
}
-/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c
index 5676b24..86bfb58 100644
--- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c
@@ -36,5 +36,5 @@ int main (void)
return main1 ();
}
-/* { dg-final { scan-tree-dump-times "vectorization not profitable" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-33.c b/gcc/testsuite/gcc.dg/vect/vect-33.c
index 43daaa8..8542904 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-33.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-33.c
@@ -38,7 +38,7 @@ int main (void)
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
-/* { dg-final { scan-tree-dump "Alignment of access forced using peeling" "vect" { target vector_alignment_reachable } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */
+/* { dg-final { scan-tree-dump "Vectorizing an unaligned access" "vect" { target { vect_hw_misalign && { ! vect64 } } } } } */
+/* { dg-final { scan-tree-dump "Alignment of access forced using peeling" "vect" { target { vector_alignment_reachable && vect64 } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { { {! vector_alignment_reachable} || {! vect64} } && {! vect_hw_misalign} } } } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gfortran.dg/vect/pr62283.f b/gcc/testsuite/gfortran.dg/vect/pr62283.f
new file mode 100644
index 0000000..038a998
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/pr62283.f
@@ -0,0 +1,17 @@
+C { dg-do compile }
+C { dg-additional-options "-fvect-cost-model=dynamic" }
+ subroutine test2(x,y)
+ real x(4),y(4)
+ beta=3.141593
+ do i=1,4
+ y(i)=y(i)+beta*x(i)
+ end do
+ end
+
+ subroutine test3(x,y)
+ real x(4),y(4)
+ beta=3.141593
+ y=y+beta*x
+ end
+C { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_hw_misalign } } } }
+C { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 893ad5a..8785d10 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1515,10 +1515,20 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
|| !slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
do_peeling = false;
- if (do_peeling && all_misalignments_unknown
+ /* If we don't know how many times the peeling loop will run
+ assume it will run VF-1 times and disable peeling if the remaining
+ iters are less than the vectorization factor. */
+ if (do_peeling
+ && all_misalignments_unknown
+ && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ && (LOOP_VINFO_INT_NITERS (loop_vinfo)
+ < 2 * (unsigned) LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 1))
+ do_peeling = false;
+
+ if (do_peeling
+ && all_misalignments_unknown
&& vect_supportable_dr_alignment (dr0, false))
{
-
/* Check if the target requires to prefer stores over loads, i.e., if
misaligned stores are more expensive than misaligned loads (taking
drs with same alignment into account). */
@@ -1605,6 +1615,14 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
&body_cost_vec);
if (!dr0 || !npeel)
do_peeling = false;
+
+ /* If peeling by npeel will result in a remaining loop not iterating
+ enough to be vectorized then do not peel. */
+ if (do_peeling
+ && LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ && (LOOP_VINFO_INT_NITERS (loop_vinfo)
+ < LOOP_VINFO_VECT_FACTOR (loop_vinfo) + npeel))
+ do_peeling = false;
}
if (do_peeling)