3 ms·
You can quite often write C code that compilers will autovectorize into what you want.. if the thing in question is a simple case, or you put in effort into doi
by dzaima 2y ago
You can quite often write C code that compilers will autovectorize into what you want.. if the thing in question is a simple case, or you put in effort into doing the non-trivial aspects yourself.
e.g. for the loop reordering example [1] in C you could just, well, manually reorder the loops; and the simple loop would autovectorize to AVX2 just fine.
The things that are messy-to-impossible to achieve in current traditional compilers are things where the compiler thinks it does a smart transformation, but it ends up making things worse.
[1]: https://github.com/exo-lang/exo/tree/main/examples/avx2_matmul https://github.com/exo-lang/exo/tree/main/examples/avx2_matm...