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

            Bug ID: 84261
           Summary: gcc fails to call a simd-vectorized function
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marcin.krotkiewski at gmail dot com
  Target Milestone: ---

Consider the following vectorized functions (omp declare simd):

#include <math.h>

#pragma omp declare simd simdlen(4)
double test1(double v1)
{
    for(int i=0; i<4; i++){
        v1 = exp(v1);
    }
    return v1;
}

#pragma omp declare simd simdlen(4)
double test2(double v1)
{
    v1 = exp(v1);
    v1 = exp(v1);
    v1 = exp(v1);
    v1 = exp(v1);
    return v1;
}

I used GCC versions up to 7.3. Code compiled with -fopenmp -O3  -ffast-math
-march=haswell.

In the test1 case GCC generates scalar calls to exp, while in the second case
(test2) calls to exp are vectorized, as expected. 

Is there a reason for such behaviour? Because it sure looks like something is
wrong. Would some flag convince gcc to vectorize?

Reply via email to