- const SCEV *ElementSizeExpr = SE->getSizeOfExpr(IntPtrTy, *GTI);
- const SCEV *ArrayIdxExpr = SE->getSCEV(ArrayIdx);
- ArrayIdxExpr = SE->getTruncateOrSignExtend(ArrayIdxExpr, IntPtrTy);
- const SCEV *LocalOffset =
- SE->getMulExpr(ArrayIdxExpr, ElementSizeExpr, SCEV::FlagNSW);
- // The base of this candidate equals GEPExpr less the byte offset of this
- // index.
- const SCEV *Base = SE->getMinusSCEV(GEPExpr, LocalOffset);
- factorArrayIndex(ArrayIdx, Base, ElementSize, GEP);
+ factorArrayIndex(ArrayIdx, BaseExpr, ElementSize, GEP);