This is a very naive approach to conclude that both accesses to Arr1 in the
loop below access the same memory location.
void foo(unsigned **Arr1) { for (int i = 0; i < 1024; ++i) for(int j = 0; j < 1024; ++j) Arr1[j][i] = Arr1[j][i] 10; }
By using SCEV, we can conclude that both accesses to Arr1 access the
same location in each loop iteration. I am probably missing something,
but this seems to work for loop variant accesses in the same loop.
It would be great if you could have a look and let me know what I am
missing :)
For SPEC2006 and the test-suite with LTO, this triggers in around 1100
cases. It also helps LoopInterchange to interchange a few more loops.
Even I am facing a similar issue. What happens if the access is something like A[(i + j) * n] = A[(i + j) * n] + 10, where n can be 0. In this case, the dependence would be "*" and not "=" right? Maybe just checking if difference is zero wouldn't be enough but traversing the SCEV to see that it is simple/understandable would be necessary.