https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113137

--- Comment #10 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Ok, so this bug is simply fixed by:

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index f51ae3e719e..e7a5917bc4c 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -976,7 +976,8 @@ vec_init_loop_exit_info (class loop *loop)
       if (number_of_iterations_exit_assumptions (loop, exit, &niter_desc,
NULL)
          && !chrec_contains_undetermined (niter_desc.niter))
        {
-         if (!niter_desc.may_be_zero || !candidate)
+         tree may_be_zero = niter_desc.may_be_zero;
+         if ((may_be_zero && integer_zerop (may_be_zero)) || !candidate)
            candidate = exit;
        }
     }

because niter_desc.may_be_zero is not a boolean but instead a tree that encodes
a boolean.

Due to this we were forcing much more complicated loops than required.  However
we *should* be able to handle these complicated loops since we don't know when
they'll occur.. so I'll post a companion patch to fix those too.

Reply via email to