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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that x[i] may alias *ret and that PRE did half of the store-motion
job only so we can't recognize the reduction pattern.  I'm not sure whether
#pragma omp simd guarantees there's no forward dependence between x[]
and ret but I guess it's at least valid that x == ret, no?

The vectorizer relies on reductions being "scalar" so something would need to
do the store-motion for us.

I doubt the call is the issue btw.  The following fails the same way:

#include <cmath>

void foo(float *x, float tx, float *ret, int n)
{

#pragma omp simd
    for (int i = 0; i < n; i++)
    {
        float s,c;

        s = c = x[i] * tx;

        *ret += s * c;
    }
}

Reply via email to