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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
expand_omp_for_generic like other ompexp functions has the notion of
broken_loop for
loops where the body doesn't fall through to the artificial #pragma omp
continue.
This works fine even for doacross loops if they have ordered equals collapse or
all the loops between ordered (inclusive) and collapse (exclusive) have compile
time constant non-zero number of iterations.
The problem is when they could have zero iterations (as in the testcase) or do
have those provably - say if l < a above is replaced with l < -2, in that case
while the ultimate body is a broken loop, either conditionally or always that
ultimate body will not be encountered at runtime at all, and the loop will do
nothing at all.  In that case
the loop is no longer a non-loop (broken_loop) because in some cases or all it
can actually loop.
We can I think detect that after the expand_omp_for_init_counts call in
expand_omp_for_generic.  The question is if we at that point can add an
artificial cont_bb somewhere, set broken_loop to false and do whatever is
needed to make the rest of the function work as if it wasn't a broken loop.

Reply via email to