4 ms·
> Major compilers (LLVM, GCC, Intel) are able to vectorize real world code to a useful extent. Try compiling this with recent gcc: uint8_t dumb_checksum(u
by tmyklebu 9y ago
> Major compilers (LLVM, GCC, Intel) are able to vectorize real world code to a useful extent.
Try compiling this with recent gcc:
uint8_t dumb_checksum(uint8_t *ar) {
uint8_t ans = 0;
for (int i = 0; i < 320; i++) ans += ar[i];
return ans;
}
You don't get satisfactory results. I, at least, don't have a clear mental model of when gcc will do something reasonable and when it will generate a large amount of bad code.
- marmaduke 9y agoSure there are bugs. There are also compiler flags which elucidate the model of loops it has and how it makes its decisions.