Hi! I’m trying to understand why do I get loop unrolling instead of vectorization in this code (Compiler Explorer)? I definitely know that this C code will be vectorized:
void sqr(const int* restrict src, int* restrict dest, unsigned int len) {
for(int i = 0; i < len; i++){
dest[i] = src[i] * src[i];
}
}
Could somebody explain where am I wrong, please?
1 Like
Note that the issue has been fixed on master with the upgrade to LLVM 22
As noted in the linked release notes, that is incorrect:
This has been reported and fixed upstream, however at time of writing the fix has not been cherry-picked into LLVM’s 22.x release branch, therefore we expect this performance regression to affect not only Zig 0.16.x but also 0.17.x, finally resolved in 0.18.x.
1 Like
Oops my bad, I should have double checked.
Got confused cause I’m using a patched version of LLVM.