patch for pointer-to-array conversion

The enlosed patch for IndVarSimplify.cpp works even when the pointer increment is deeply nested wrt pointer initialization, but note that it needs to have loop structures preserved, as in the following:

int A[3000000], B[20000], C[100], Z;
volatile int I, J, K;
int main()
{
         int i, j, k, *a, *b, *c;
         for ( a = &A[0], i = 0; i != 300; i++ )
         {
                 I++;
                 for ( b = &B[0], j = 0; j != 200; j++ )
                 {
                         J++;
                         for ( c = &C[0], k = 0; k != 100; k++ )
                         {
                                 K++;
                                 Z += *a++ * *b++ * *c++;
                         }
                 }
         }
}

but unlike the collapsing which would happen in, e.g., the following:

int A[3000000], B[20000], C[100], Z;
int main()
{
         int i, j, k, *a, *b, *c;
         for ( a = &A[0], i = 0; i != 300; i++ )
                 for ( b = &B[0], j = 0; j != 200; j++ )
                         for ( c = &C[0], k = 0; k != 100; k++ )
                                 Z += *a++ * *b++ * *c++;
}

Here's the patch with diff -u, limited to 80 columns:
Does it look reasonable?

Thanks,
Naftali

Index: lib/Transforms/Scalar/IndVarSimplify.cpp