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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-03-09
                 CC|                            |law 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> ---
This is if-conversion at work making the code vectorizable.  You can disable it
with -fno-tree-loop-if-convert.

It's not easy to assess profitablility here (well, locally it should use
bb frequencies), as computing a*a*a*a*a always could be a win if vectorizing
the rest of the loop compensates for the cost.

In this case the optimal thing to do is to turn the loop into a loop nest.
Not sure how you'd call this kind of loop transform - sth with unswitching
IV-based conditions (it's not exactly splitting in this case).  We want

    for (int j = 0; j < 10000/1000; j++){
       int i;
       for (i = j*1000; i < 999; ++i)
         buffer[i] = a;
       a = a * a * a * a * a;
       buffer[i] = a;
    }

so we can vectorize the inner loop and don't need to evaluate the conditional
there.

Reply via email to