This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81706] New: std::sin vectorization bug


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

            Bug ID: 81706
           Summary: std::sin vectorization bug
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: diegoandres91b at hotmail dot com
  Target Milestone: ---

The next code (with -O3 -ffast-math):

#include <cmath>

float a[4];

void sin1() {
    for(unsigned i = 0; i < 4; i++) a[i] = sinf(a[i]);
}

Compiles vectorized version of sinf (_ZGVbN4v_sinf):

sin1():
        sub     rsp, 8
        movaps  xmm0, XMMWORD PTR a[rip]
        call    _ZGVbN4v_sinf
        movaps  XMMWORD PTR a[rip], xmm0
        add     rsp, 8
        ret

But when i use c++ version of sinf (std::sin) no vectorization occurrs:

void sin2() {
    for(unsigned i = 0; i < 4; i++) a[i] = std::sin(a[i]);
}

sin2():
        sub     rsp, 8
        movss   xmm0, DWORD PTR a[rip]
        call    sinf
        movss   DWORD PTR a[rip], xmm0
        movss   xmm0, DWORD PTR a[rip+4]
        call    sinf
        movss   DWORD PTR a[rip+4], xmm0
        movss   xmm0, DWORD PTR a[rip+8]
        call    sinf
        movss   DWORD PTR a[rip+8], xmm0
        movss   xmm0, DWORD PTR a[rip+12]
        call    sinf
        movss   DWORD PTR a[rip+12], xmm0
        add     rsp, 8
        ret

Compiler Explorer Code: https://godbolt.org/g/zSrJrK

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]