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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-03-01
            Version|unknown                     |8.0.1
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The issue seems to be that we prematurely optimize the compare to
(signed int) i < 0 and number of iteration analysis fails to handle
that.

The FE emits:

        unsigned int i = 0;
    goto <D.1960>;
    <D.1959>:;
     ++i;
    <D.1960>:;
    if ((signed int) i >= 0) goto <D.1959>; else goto <D.1961>;
    <D.1961>:;

(set_scalar_evolution
  instantiated_below = 2
  (scalar = i.0_1)
  (scalar_evolution = (signed int) {0, +, 1}_1))
)
(analyze_scalar_evolution
  (loop_nb = 1)
  (scalar = 0)
(get_scalar_evolution
  (scalar = 0)
  (scalar_evolution = 0))
)
  (set_nb_iterations_in_loop = scev_not_known))


we need to teach niter analysis this kind of trick.

Let me have a closer look.

Reply via email to