Function exploreDirections() in DependenceAnalysis implements a recursive algorithm for refining direction vectors. This algorithm has worst-case complexity of O(3^(n+1)) where n is the number of common loop levels. It essentially performs a search over a complete ternary tree of dependence directions. The algorithm tries to prune the search space by checking testBounds before recursing for each direction, but since the delta usually falls within the sum of lower and upper bounds the search space ends up being the full tree most of the time.
The problem can be illustrated with a deeply nested loop. For exampley DA takes more than a minute to analyze a 12 level deep loop nest containing a single load and a store (see example below and the attached IR) on a 3.1 GHz P8 machine with 600 GB of RAM.
for (int i1 = 0; i1 < n; i1++) for (int i2 = 0; i2 < n; i2++) ... for (int i12 = 0; i12 < n; i12++) A[i1 + i2 + ... + i12] = B[i1 + i2 ... + i12];
The compile-time increases exponentially as the depth of the loop nest increases.
In this patch I'm adding a threshold to control the amount of time we spend in doing MIV tests (which most of the time end up resulting in over pessimistic direction vectors anyway).