Bug ID: 77689
           Summary: Missing vectorization lead to huge performance loss
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot
          Reporter: morandidodo at gmail dot com
  Target Milestone: ---

Created attachment 39673
Asm code of the main, generated by gcc and icc

I recently started using auto-vectorization as much as possible. Unfortunately,
I discovered that gcc is often unable to vectorize code.
I wrote a very simple MWE which (unfortunately, from my point of view) performs
around 11X faster if compiled with icc instead of gcc.

Here is the code:

#include <vector>
#include <cmath>

constexpr unsigned s = 100000000;

int main()
    std::vector<float> a, b, c;

    for(unsigned i = 0; i < s; ++i)
        if(i == 0)
            a[i] = b[i] * c[i];
            a[i] = (b[i] + c[i]) * c[i-1] * std::log(i);

I attach the generated assembly with both compiler. I hope that it could help
someone try improving the vectorization procedures.

Reply via email to