@@ -3778,13 +3778,11 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
37783778 return getOrCreateAddRecExpr(Operands, L, Flags);
37793779}
37803780
3781- const SCEV *
3782- ScalarEvolution::getGEPExpr(GEPOperator *GEP,
3783- const SmallVectorImpl<const SCEV *> &IndexExprs) {
3781+ const SCEV *ScalarEvolution::getGEPExpr(GEPOperator *GEP,
3782+ ArrayRef<const SCEV *> IndexExprs) {
37843783 const SCEV *BaseExpr = getSCEV(GEP->getPointerOperand());
37853784 // getSCEV(Base)->getType() has the same address space as Base->getType()
37863785 // because SCEV::getType() preserves the address space.
3787- Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
37883786 GEPNoWrapFlags NW = GEP->getNoWrapFlags();
37893787 if (NW != GEPNoWrapFlags::none()) {
37903788 // We'd like to propagate flags from the IR to the corresponding SCEV nodes,
@@ -3797,13 +3795,20 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
37973795 NW = GEPNoWrapFlags::none();
37983796 }
37993797
3798+ return getGEPExpr(BaseExpr, IndexExprs, GEP->getSourceElementType(), NW);
3799+ }
3800+
3801+ const SCEV *ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
3802+ ArrayRef<const SCEV *> IndexExprs,
3803+ Type *SrcElementTy, GEPNoWrapFlags NW) {
38003804 SCEV::NoWrapFlags OffsetWrap = SCEV::FlagAnyWrap;
38013805 if (NW.hasNoUnsignedSignedWrap())
38023806 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNSW);
38033807 if (NW.hasNoUnsignedWrap())
38043808 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNUW);
38053809
3806- Type *CurTy = GEP->getType();
3810+ Type *CurTy = BaseExpr->getType();
3811+ Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
38073812 bool FirstIter = true;
38083813 SmallVector<const SCEV *, 4> Offsets;
38093814 for (const SCEV *IndexExpr : IndexExprs) {
@@ -3822,7 +3827,7 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
38223827 if (FirstIter) {
38233828 assert(isa<PointerType>(CurTy) &&
38243829 "The first index of a GEP indexes a pointer");
3825- CurTy = GEP->getSourceElementType() ;
3830+ CurTy = SrcElementTy ;
38263831 FirstIter = false;
38273832 } else {
38283833 CurTy = GetElementPtrInst::getTypeAtIndex(CurTy, (uint64_t)0);
0 commit comments