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

https://gcc.gnu.org/g:813b14ede7207555e65e6ce976ff0c04ab2b7875

commit r10-10543-g813b14ede7207555e65e6ce976ff0c04ab2b7875
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 12 09:40:15 2022 +0200

    tree-optimization/105226 - avoid splitting abnormal edges
    
    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.
    
    2022-04-12  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105226
            * tree-vect-loop-manip.c (vect_loop_versioning): Verify
            we can split the exit of an outer loop we choose to version.
    
            * gcc.dg/pr105226.c: New testcase.
    
    (cherry picked from commit 62d5bb0f35fb6ec373eaac942755585a633528a0)

Diff:
---
 gcc/testsuite/gcc.dg/pr105226.c | 23 +++++++++++++++++++++++
 gcc/tree-vect-loop-manip.c      |  3 ++-
 2 files changed, 25 insertions(+), 1 deletion(-)

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.c b/gcc/tree-vect-loop-manip.c
index 639d8ceabf0..046e131e837 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -3384,7 +3384,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


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 12:51 [gcc r10-10543] 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).