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

            Bug ID: 81948
           Summary: vectorize exp2 using exp
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
  Target Milestone: ---

Using -Ofast -mavx2 and a recent glibc, g++ vectorizes

#include <cmath>
void f(double*d){
  d=(double*)__builtin_assume_aligned(d,256);
  for(int i=0;i<1024;++i)
    d[i]=std::exp(d[i]*std::log(2));
}

However, if I write d[i]=std::exp2(d[i]) instead, it fails to vectorize
(libmvec does not provide a vector version of exp2). It would be good, when
checking if a standard function like exp2 has a vector version, to also check
related, more canonical functions (exp in this case).

(this could also be vaguely related to PR 81706)

Reply via email to