Extended Description
As reported in https://bugs.freebsd.org/225345, building the FreeBSD games/scummvm port for AArch64 with clang 6.0.0 results in an assertion:
Assertion failed: (ExitCount != SE.getCouldNotCompute() && "Invalid loop count"), function generateOverflowCheck, file /usr/local/poudriere/jails/head-arm64/usr/src/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp, line 2152.
This assertion still occurs with trunk r322755, and bisection shows it has regressed with https://reviews.llvm.org/rL313012 ("[LAA] Allow more run-time alias checks by coercing pointer expressions to AddRecExprs") by Silviu Baranga.
Minimized test case:
// clang -cc1 -triple aarch64-- -S -O1 -vectorize-loops graphics-minimized.cpp
struct {
void *a();
} b;
char c[6];
void d() {
unsigned char *e = (unsigned char *)b.a();
unsigned short f;
for (;;) {
for (unsigned g; g < 4; g++)
e[g] = c[g + f];
f += 4;
}
}
Note that -vectorize-loops is essential for reproducing the assertion.