https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61194
Bug ID: 61194
Summary: vectorization failed with "bit-precision arithmetic
not supported" even if conversion to int is requested
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
z[i] = ( (x[i]>0) & (w[i]<0)) ? z[i] : y[i];
produces
bit-precision arithmetic not supported.
note: not vectorized: relevant stmt not supported: _6 = _5 > 0.0;
while integer bitwise operators are vectorized at will
z[i] = ( k[i] & j[i] ) ? z[i] : y[i];
I tried to force conversion to int in many ways (see below) such as
z[i] = ( int(x[i]>0) & int(w[i]<0)) ? z[i] : y[i];
succeeding only with the quite expensive
z[i] = (2==(int(x[i]>0) + int(w[i]<0))) ? z[i] : y[i];
is there a way to force gcc to use integer w/o using arithmetic operators?
c++ -Ofast -Wall -fno-tree-slp-vectorize -ftree-loop-if-convert-stores -S
cond.cc -msse4.2 -fopt-info-vec -fno-tree-slp-vectorize -fopenmp
cat cond.cc
float x[1024];
float y[1024];
float z[1024];
float w[1024];
int k[1024];
int j[1024];
void bar() {
for (int i=0; i<1024; ++i)
z[i] = ( (x[i]>0) & (w[i]<0)) ? z[i] : y[i];
}
void barMP() {
#pragma omp simd
for (int i=0; i<1024; ++i)
z[i] = ( int(x[i]>0) & int(w[i]<0)) ? z[i] : y[i];
}
void barInt() {
for (int i=0; i<1024; ++i)
z[i] = ( int(x[i]>0) & int(w[i]<0)) ? z[i] : y[i];
}
void barInt0() {
for (int i=0; i<1024; ++i)
z[i] = ( (0+int(x[i]>0)) & (0+int(w[i]<0)) ) ? z[i] : y[i];
}
void barPlus() {
for (int i=0; i<1024; ++i)
z[i] = (2==(int(x[i]>0) + int(w[i]<0))) ? z[i] : y[i];
}
void foo() {
for (int i=0; i<1024; ++i)
z[i] = ( k[i] & j[i] ) ? z[i] : y[i];
}
void foo2() {
for (int i=0; i<1024; ++i) {
k[i] = x[i]>0; j[i] = w[i]<0;
}
}
void bar2() {
for (int i=0; i<1024; ++i) {
k[i] = x[i]>0; j[i] = w[i]<0;
z[i] = ( k[i] & j[i]) ? z[i] : y[i];
}
}