@@ -3768,9 +3768,8 @@ 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.
@@ -3786,20 +3785,18 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
37863785 NW = GEPNoWrapFlags::none();
37873786 }
37883787
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) {
37893794 SCEV::NoWrapFlags OffsetWrap = SCEV::FlagAnyWrap;
37903795 if (NW.hasNoUnsignedSignedWrap())
37913796 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNSW);
37923797 if (NW.hasNoUnsignedWrap())
37933798 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNUW);
37943799
3795- return getGEPExpr(BaseExpr, IndexExprs, GEP->getSourceElementType(),
3796- OffsetWrap);
3797- }
3798-
3799- const SCEV *
3800- ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
3801- const SmallVectorImpl<const SCEV *> &IndexExprs,
3802- Type *SrcElementTy, SCEV::NoWrapFlags OffsetWrap) {
38033800 Type *CurTy = BaseExpr->getType();
38043801 Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
38053802 bool FirstIter = true;
@@ -3845,9 +3842,8 @@ ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
38453842 // Add the base address and the offset. We cannot use the nsw flag, as the
38463843 // base address is unsigned. However, if we know that the offset is
38473844 // non-negative, we can use nuw.
3848- bool NUW =
3849- hasFlags(OffsetWrap, SCEV::FlagNUW) ||
3850- (hasFlags(OffsetWrap, SCEV::FlagNSW) && isKnownNonNegative(Offset));
3845+ bool NUW = NW.hasNoUnsignedWrap() ||
3846+ (NW.hasNoUnsignedSignedWrap() && isKnownNonNegative(Offset));
38513847 SCEV::NoWrapFlags BaseWrap = NUW ? SCEV::FlagNUW : SCEV::FlagAnyWrap;
38523848 auto *GEPExpr = getAddExpr(BaseExpr, Offset, BaseWrap);
38533849 assert(BaseExpr->getType() == GEPExpr->getType() &&
0 commit comments