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.cc (vect_loop_versioning): Verify
we can split the exit of an outer loop we choose to version.
* gcc.dg/pr105226.c: New testcase.
--- /dev/null
+/* { 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 ();
+ }
+}
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