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

--- Comment #3 from Suvarchal Cheedela (AWI) <suvarchal.cheedela at awi dot de> 
---
As far as I can see neither unswitching path catches it on trunk:

  - find_loop_guard considers the guard but only brings it when nothing
    outside the skipped region has side effects; here c[i] = s is stored on
    both paths ("Block 6 has side effects").

  - tree_ssa_unswitch_loops only collects predicates from the innermost
    loop; m > 0 is in the outer loop body, so it is possibly not a candidate.

Would it be acceptable to fall back to versioning the outer loop on the guard
condition when find_loop_guard fails only for that reason, limited by
max-unswitch-insns on the duplicated outer body?  If so I would like  to try a
patch.

A correction: gfortran emits DO loops test-at-top like C for loops; the guard
comes from loop header copying, so this may not be necessarily Fortran
specific.

The testcases (outer.c, outer_dowhile.c, outer_unswitched.c, drivers and the
Fortran version) are in the attached tarball.

Reply via email to