std::array<int, 4> a = {1, 1, 1, 1};
std::array<int, 4> b = { 1, 2, 3, 4 };
std::array<int, 4> c;
bool res = false;
for (int i = 0; i < a.size(); i++) {
a[i] = rand() % 10;
}
for (int i = 0; i < 4; i++) {
c[i] = a[i] + b[i];
}
Smart compiler can compile above to SIMD well. But how to write the compare one like below can compile to SIMD well too;
res = a[0] <= b[0] && a[1] <= b[1] && a[2] <= b[2] && a[3] <= b[3]; // not compile to SIMD