This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][vect]PR92347: Don't overwrite safelen for epilogues
- From: "Andre Vieira (lists)" <andre dot simoesdiasvieira at arm dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Biener <rguenther at suse dot de>
- Date: Mon, 11 Nov 2019 17:59:00 +0000
- Subject: [PATCH][vect]PR92347: Don't overwrite safelen for epilogues
Hi,
After during my investigation into the first testcase in PR92347 I
noticed that the ICE was arising because the vectorizer was under the
assumption it knew how to vectorize the zp call for both the main and
epilogues. By the time it got to transform the epilogue
vectorizable_simd_clone_call would fail, leading to the eventual ICE.
The reason was because the main loop's safelen was set to MAX_INT at
time of analysis, but 0 for the epilogue at the time of its
transformation. This was because we were copying the loop's safelen to
the epilogue after vectorizing the main loop and we set safelen to 0
when we are done vectorizing. This resulted in the epilogue always
having safelen set to 0 at transformation time.
I believe its safe to assume that if the main loop can assume that it is
safe to vectorize between 0 and safelen then so is the epilogue in this
context.
Bootstrapped x86_64 and aarch64 and ran libgomp.
Is this OK for trunk? (If approved can someone commit on my behalf as
I'll be away for two weeks?)
Cheers,
Andre
gcc/ChangeLog:
2019-11-11 Andre Vieira <andre.simoesdiasvieira@arm.com>
* tree-vect-loop.c (vect_transform_loop): Don't overwrite epilogues
safelen with 0.
gcc/testsuite/ChangeLog:
2019-11-11 Andre Vieira <andre.simoesdiasvieira@arm.com>
* gcc.dg/vect/pr92347.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/pr92347.c b/gcc/testsuite/gcc.dg/vect/pr92347.c
new file mode 100644
index 0000000000000000000000000000000000000000..f7e6b490c837f209e9a574d6f10e1e2e34e4729e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr92347.c
@@ -0,0 +1,18 @@
+/* Copied from PR 92347. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fopenmp" } */
+/* { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } } */
+
+int by;
+
+#pragma omp declare simd
+int
+zp (int);
+
+void
+qh (int oh)
+{
+#pragma omp simd
+ for (by = 0; by < oh; ++by)
+ by = zp (by);
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 78fe6290ee6bf069f7cfaabba466f119e41f39ac..b600d3157457c3180d0456c4f66cbc57012e3c71 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -8587,7 +8587,6 @@ vect_transform_loop (loop_vec_info loop_vinfo)
epilogue->simduid = loop->simduid;
epilogue->force_vectorize = loop->force_vectorize;
- epilogue->safelen = loop->safelen;
epilogue->dont_vectorize = false;
}