From: Richard Biener Date: Tue, 12 Apr 2022 07:40:15 +0000 (+0200) Subject: tree-optimization/105226 - avoid splitting abnormal edges X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62d5bb0f35fb6ec373eaac942755585a633528a0;p=test_jj.git 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 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. --- diff --git a/gcc/testsuite/gcc.dg/pr105226.c b/gcc/testsuite/gcc.dg/pr105226.c new file mode 100644 index 0000000..9c4941d --- /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 +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 a7bbc91..63fb6f6 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -3524,7 +3524,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