@@ -3768,13 +3768,11 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
37683768 return getOrCreateAddRecExpr(Operands, L, Flags);
37693769}
37703770
3771- const SCEV *
3772- ScalarEvolution::getGEPExpr(GEPOperator *GEP,
3773- const SmallVectorImpl<const SCEV *> &IndexExprs) {
3771+ const SCEV *ScalarEvolution::getGEPExpr(GEPOperator *GEP,
3772+ ArrayRef<const SCEV *> IndexExprs) {
37743773 const SCEV *BaseExpr = getSCEV(GEP->getPointerOperand());
37753774 // getSCEV(Base)->getType() has the same address space as Base->getType()
37763775 // because SCEV::getType() preserves the address space.
3777- Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
37783776 GEPNoWrapFlags NW = GEP->getNoWrapFlags();
37793777 if (NW != GEPNoWrapFlags::none()) {
37803778 // We'd like to propagate flags from the IR to the corresponding SCEV nodes,
@@ -3787,13 +3785,20 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
37873785 NW = GEPNoWrapFlags::none();
37883786 }
37893787
3788+ return getGEPExpr(BaseExpr, IndexExprs, GEP->getSourceElementType(), NW);
3789+ }
3790+
3791+ const SCEV *ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
3792+ ArrayRef<const SCEV *> IndexExprs,
3793+ Type *SrcElementTy, GEPNoWrapFlags NW) {
37903794 SCEV::NoWrapFlags OffsetWrap = SCEV::FlagAnyWrap;
37913795 if (NW.hasNoUnsignedSignedWrap())
37923796 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNSW);
37933797 if (NW.hasNoUnsignedWrap())
37943798 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNUW);
37953799
3796- Type *CurTy = GEP->getType();
3800+ Type *CurTy = BaseExpr->getType();
3801+ Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
37973802 bool FirstIter = true;
37983803 SmallVector<const SCEV *, 4> Offsets;
37993804 for (const SCEV *IndexExpr : IndexExprs) {
@@ -3812,7 +3817,7 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
38123817 if (FirstIter) {
38133818 assert(isa<PointerType>(CurTy) &&
38143819 "The first index of a GEP indexes a pointer");
3815- CurTy = GEP->getSourceElementType() ;
3820+ CurTy = SrcElementTy ;
38163821 FirstIter = false;
38173822 } else {
38183823 CurTy = GetElementPtrInst::getTypeAtIndex(CurTy, (uint64_t)0);
0 commit comments