I want to compare two arrays and write the result to bitmap. Therefore, I tried the following code:
void wtf(int *lhs, int *rhs, int len, std::vector<bool>& dst){
for (int i = 0; i < len; i++){
dst[i] = lhs[i] == rhs[i];
}
}
In the compiler explorer
, we can see that the above code is not vectorized. If we write the result to a boolean array, LLVM will vectorize it.
Why the above code can not be vectorized? What is the most efficient code to accomplish this task? I searched a lot and did not find the answer.