Loop dependence analysis


I'm currently trying to implement [1] basic loop-dependence analysis
for LLVM (since most of the symbol handling code is already there in
SCEV) and I'm facing the following issues:

Let's say we have a loop

void test(int *array, unsigned long length) {
  for (unsigned long i = 0; i < length; i++)
    array[3 * length - i] = array[i];

For there to be a loop carried dependency, we'd have to have (3 *
length / 2) < length which we know doesn't hold, since length is
always positive. Unfortunately, the LLVM IR tell us nothing about the
unsignedness of length, and SCEV ends up making a useless conservative
estimate. Is there some way around this?

Secondly, I'm currently comparing A and B by creating an SCEV for (A -
B) and then checking isZero, isKnownNonPositive etc. Is this a good


[1] https://github.com/sanjoy/llvm/tree/lda