The SCEVAddRecExpr nest describing a Subscript may contain loops in which the corresponding memory access is not contained in. This causes errors in DependenceAnalysis. An example is this (see PR31848 for details):
void foo(int *A, int n) {
for (int j = 0; j < n; ++j) { for (int i = 0; i < n; ++i) { for (int di = -1; di <= 1; ++di) { for (int dj = -1; dj <= 1; ++dj) { int x = i + di; int y = j + dj; while (x < 0) x += n; while (y < 0) y += n; A[y * n + x] = 7; } } } }
}
This patch detects that, and classifies the subscripts as NonLinear. This solution is possibly a bit over-pessimistic. For instance, subscripts might well be legal, if its extraneous loops are loop invariant wrt. the lowest common ancestor in the loop nest. I haven't been able to produce this situation however, so I'm not sure whether that can actually happen, or whether it triggers entirely different paths of DA.
Nit: Loop instead of AddRec->getLoop(), same as Dst