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

            Bug ID: 61171
           Summary: vectorization fails for a reduction in presence of
                    subtraction
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch

give this code
cat bug.cc
float px[1024];
float xx, vv;
unsigned int N=1024;

void ok() {
  for (auto j=0U; j<N; ++j) {
    auto ax = px[j]-xx;
    vv-=ax;
  }
}

void noOk() {
  for (auto j=0U; j<N; ++j) {
    auto ax = xx-px[j];
    vv+=ax;
  }
}
 c++ -std=c++11 -Ofast  -S bug.cc -march=haswell -fopt-info-vec-missed; cat
bug.s
ok vectorize, noOk does not because
bug.cc:13:3: note: reduction: not commutative/associative: vv.6_9 = _2 - _6;

even if the code is clearly identical (at least with Ofast)

Reply via email to