void m(int *p, int *p2, int q) {
int *a = p;
int i, j, r;
i = 0;
for (; i < 63; i++) {
r = j = 0;
for (; j < 63; j++)
r -= p2[j];
a[i] = r;
}
}For the code above, expandBounds that works for LoopVectorize can
generate incorrect runtime checks that the range generated for the p2
group is [p2+62, p2+63) rather than [p2, p2+63).
I think we should use the same code as in the else part to compute ScEnd. Perhaps we can just keep ScStart = ScEnd = Sc and move the increment code out of the else.
// Add the size of the pointed element to ScEnd. auto &DL = Lp->getHeader()->getModule()->getDataLayout(); Type *IdxTy = DL.getIndexType(Ptr->getType()); const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr(IdxTy, Ptr->getType()->getPointerElementType()); ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);