3 ms·
> 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 mean
by astrange 3y ago
> 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 duplicate setup code making it worse than nothing.
- dzaima 3y agoThe checks are done outside of the loop though (unless you mean ≥two nested loops, with a small-ish inner one, at which point things indeed get less nice, but also this is less common). 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".