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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
      Known to work|                            |13.1.0

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like SCEV can figure out the bounds more correctly in GCC 13+ which fixes
the warning and the missed optimization.

GCC 12.3.0:
```
Estimating # of iterations of loop 1
Matching expression match.pd:2119, generic-match.cc:693
Matching expression match.pd:2122, generic-match.cc:753
Matching expression match.pd:2129, generic-match.cc:776
Analyzing # of iterations of loop 1
  exit condition [prephitmp_30, + , -1] != 0
  bounds on difference of bases: -5 ... 1
Applying pattern match.pd:182, generic-match.cc:30997
Applying pattern match.pd:5698, generic-match.cc:11425
Matching expression match.pd:2119, generic-match.cc:693
Matching expression match.pd:2122, generic-match.cc:753
Matching expression match.pd:2129, generic-match.cc:776
Applying pattern match.pd:354, generic-match.cc:5780
  result:
    # of iterations (unsigned int) prephitmp_30, bounded by 4294967295
Statement (exit)if (nb_24 != 0)
 is executed at most (unsigned int) prephitmp_30 (bounded by 4294967295) + 1
times in loop 1.
```

While GCC 13+:
```
Estimating # of iterations of loop 1
Matching expression match.pd:2404, generic-match.cc:727
Matching expression match.pd:2407, generic-match.cc:787
Matching expression match.pd:2414, generic-match.cc:810
Analyzing # of iterations of loop 1
  exit condition [prephitmp_30, + , -1] != 0
  bounds on difference of bases: -5 ... 0
Applying pattern match.pd:182, generic-match.cc:33250
Applying pattern match.pd:6155, generic-match.cc:21253
Matching expression match.pd:2404, generic-match.cc:727
Matching expression match.pd:2407, generic-match.cc:787
Matching expression match.pd:2414, generic-match.cc:810
Applying pattern match.pd:365, generic-match.cc:21998
  result:
    # of iterations (unsigned int) prephitmp_30, bounded by 5
Statement (exit)if (nb_24 != 0)
 is executed at most (unsigned int) prephitmp_30 (bounded by 5) + 1 times in
loop 1.
```

Reply via email to