Tentative change to Loop Vectorizer to avoid a case of interleaving that creates incorrect code.
This problem is described on bug https://bugs.llvm.org/show_bug.cgi?id=48546.
In short, there is a case of compiling the following code with -O2 which triggers the loop vectorizer bug with clang -O2 test.c
int printf(const char *, ...); int a, b, e; char c, d; int main() { d = 19; printf("%d\n", c); for (; d < 161; d++) { char *f = &c; *f &= 1; e = b== 0 ?:a%b; (*f)--; } printf("%d\n", c); }
The output compilation produces incorrect code. The value printed is 254 instead of 0.
This is because we determine that we can interleave this loop, when instead it should not be allowed.
There are cases without interleaving that would make it legal to vectorize this code, so the condition is placed only if we can interleave.
Could you elaborate why the type width would matter here? Is it possible that this only exposed a problem somewhere else, e.g. lowering operations on vectors of i1?
(I tried to reproduce the problem with current trunk on macOS, but failed)