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

            Bug ID: 98774
           Summary: gcc -O3 does not vectorize multiplication
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vanyacpp at gmail dot com
  Target Milestone: ---

Created attachment 50014
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50014&action=edit
nbody-update-velocity.cpp

In the following sample GCC (-O3 -ffast-math) fails to vectorize operations.
The results is that GCC 10.2 does 8 mulsd, while clang 11.0 does 4 mulpd.

struct vec3 { double x, y, z; };

void update_velocities(vec3* __restrict velocity,
                       double const* __restrict mass,
                       vec3 const* __restrict dpos,
                       double const* __restrict mag)
{
    velocity[0] -= dpos[0] * (mass[1] * mag[0]);
    velocity[1] += dpos[0] * (mass[0] * mag[0]);
}

See an attachment for the complete sample.

Reply via email to