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

            Bug ID: 120732
           Summary: Compiler doesn't generate a call to a vector function
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ibogosavljevic at gmail dot com
  Target Milestone: ---

Created attachment 61671
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61671&action=edit
Test example

The compiler doesn't generate a call to a vector function. The example is
attached.

I declared a function 
__attribute__ ((__simd__ ("notinbranch"))) 
double square(double x);

However, the loop which is lower


    for (size_t i = 0; i < s; i++) {
        d[i] = square(d[i]);
    }


doesn't call vectorized version of sqaure, but just a plain old scalar version.
If I put #pragma omp simd before the loop, the compiler generates a call to
vector version of square.

Compilation line:
 g++ -c -O3 -fopenmp-simd -ffast-math -mavx2 test.cpp -S -o test.asm

Why doesn't the compiler generate a call to vectorized version of square, since
all prerequisites are met?
  • [Bug c++/120732] New: Compile... ibogosavljevic at gmail dot com via Gcc-bugs

Reply via email to