Earlier quoted context omitted.
Both gcc and clang check for aliasing at runtime if not provable statically for autovectorization (granted, that can fail if you have reverse/strided/gather addresses, but those are less common; and yeah it does lead to some constant overhead, though likely not significant often). Of minor note is that you can add "#pragma clang loop vectorize(assume_safety)" or "#pragma GCC ivdep" on the respective compilers to a lo…
> Both gcc and clang check for aliasing at runtime if not provable statically for autovectorization This is often enough to make it unworkable, because it means you're inserting checks into hot loops. Also, if you partially vectorize something yourself you have to write similar setup code, which might involve scalar versions of the loop, but then autovectorization can come by and vectorize those, so now you have dupl…
Yeah, autovectorization of a manual tail loop can be annoying, but there is "#pragma clang loop unroll(disable)" and "#pragma clang loop vectorize(disable)" for clang, and for gcc "#pragma GCC unroll 1" and, from gcc 14, "#pragma GCC novector".