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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2018-12-18
          Component|fortran                     |tree-optimization
                 CC|                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
   Target Milestone|---                         |9.0

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so the issue is starting with GCC 9 we have one more conditional branch
inside the loop checking the outer loop induction variable against some
ubound.  In previous GCC loop-header copying essentially peeled off
an entire iteration exposing the invariant condition as redundant.

GCC 9 does not perform any copying because doing so doesn't make the
loop any more "do-while".  I have added

          /* Make sure to stop copying after we copied the first exit test.
             Without further heuristics we do not want to rotate the loop
             any further.  */
          if (loop_exits_from_bb_p (loop, exit->src))
            break;

which stops header-copying after copying the first check.  This was done
in r259754 to not de-optimize some cases.

I guess we could amend the heuristics so that we only ever copy blocks
with IV tests.  It's not that simple though since for example invariant
motion did not yet take place so it's difficult to identify the case
we wanted to avoid with r259754.

Reply via email to