I\'ve problems getting my g++ 5.4 use vectorization for comparison. Basically I want to compare 4 unsigned ints using vectorization. My first approach was straight forward:<
Okay, apparently the compiler does not like "unrolled loops". This works for me:
bool compare(signed int const pX[8]) {
signed int const w[] __attribute__((aligned(32))) = {1,2,3,4,5,6,7,8};
signed int out[8] __attribute__((aligned(32)));
for (unsigned int i = 0; i < 8; ++i) {
out[i] = (pX[i] <= w[i]);
}
bool temp = true;
for (unsigned int i = 0; i < 8; ++i) {
temp = temp && out[i];
if (!temp) {
return false;
}
}
return true;
}
Please note, that out
is also a signed int
.
Now I'll just need a fast way to combine the result saved in out