public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/105226 - avoid splitting abnormal edges
@ 2022-04-12  8:53 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-04-12  8:53 UTC (permalink / raw)
  To: gcc-patches

Vectorizer loop versioning tries to version outer loops if possible
but fails to check whether it can actually split the single exit
edge as it will do.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2022-04-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105226
	* tree-vect-loop-manip.cc (vect_loop_versioning): Verify
	we can split the exit of an outer loop we choose to version.

	* gcc.dg/pr105226.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr105226.c | 23 +++++++++++++++++++++++
 gcc/tree-vect-loop-manip.cc     |  3 ++-
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr105226.c

diff --git a/gcc/testsuite/gcc.dg/pr105226.c b/gcc/testsuite/gcc.dg/pr105226.c
new file mode 100644
index 00000000000..9c4941dc6fc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105226.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+/* { dg-require-effective-target indirect_jumps } */
+
+#include <setjmp.h>
+struct longjmp_buf {
+  jmp_buf buf;
+};
+void g ();
+void f ()
+{
+  int i, n;
+  long *a;
+  long *args;
+  struct longjmp_buf b;
+  setjmp (b.buf);
+  for (;;)
+    {
+      for (i = 0; i < n; i++)
+        a[i] = args[i];
+      g ();
+    }
+}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 5c8bb9b5728..e4381eb7079 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -3545,7 +3545,8 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
 	outermost = superloop_at_depth (loop, 1);
       /* And avoid applying versioning on non-perfect nests.  */
       while (loop_to_version != outermost
-	     && single_exit (loop_outer (loop_to_version))
+	     && (e = single_exit (loop_outer (loop_to_version)))
+	     && !(e->flags & EDGE_COMPLEX)
 	     && (!loop_outer (loop_to_version)->inner->next
 		 || vect_loop_vectorized_call (loop_to_version))
 	     && (!loop_outer (loop_to_version)->inner->next
-- 
2.34.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-12  8:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  8:53 [PATCH] tree-optimization/105226 - avoid splitting abnormal edges Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).