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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What -O3 is doing is removing the loop header at:

              for (short o = 0; o < 19; o += 2)
              {
                g[n] &= i;
                f = (f < 0 ? f : 0);
              }


Because it is not needed.

So -O2 is vectorizing:

              for (short o = 0; o < 19; o += 2)
              {
                g[n] &= i;
                f = (f < 0 ? f : 0);
              }

While -O3 sees:
            for (int n = q; n; n += 3)
           //   for (short o = 0; o < 19; o += 2) 
              {
                g[n] &= i;
                f = (f < 0 ? f : 0);
              }

And there is nothing there to vectorize.

Note it is unrolling the inner most loop rather than anything else. Plus the
load/store can be moved out of the loop.

So what GCC is doing is correct but just that -O2 does not see that `g[n] &=
i;` and `f = (f < 0 ? f : 0);` could be moved out of the inner most loop and
remove it at -O2 which is a different missed optimization.

Part of which is recorded as PR 112104. The other one I will file soon.

Reply via email to