Follow-up of D38677. This patch supports the vector type of both current and previous index when factoring out the current one into the previous one.
You should be able to just use !isa<Constant>(Idxs) for these kinds of checks I think. All GEP indices are required to be integers or integer vectors.
This should be an else instead of an else if. Idxs[i] should be a vector here, so just cast it without checking.
This is confusing; I would get rid of it. The zero value is never used either. I would just use PrevIdx->getType->getNumVectorElements() or the equivalent for CurrIdx whenever you need IdxNumElements (see below for an example).
CurrIdx = ConstantDataVector::getSplat(PrevIdx->getType()->getNumVectorElements(), CurrIdx);
PrevIdx = ConstantDataVector::getSplat(CurrIdx->getType()->getNumVectorElements(), PrevIdx);
I think Unknown is set to true if we don't know the indices are inbound or not. Since we only check the bound for ConstantInt and ConstantDataVector, I just white list these two. It is true that the constant index can only be constant integer and constant integer vector, but wild constant expression (e.g. ptrtoint) is also allowed. If I change the code to !isa<Constant>, many test cases fail.