@@ -3786,20 +3786,18 @@ ScalarEvolution::getGEPExpr(GEPOperator *GEP,
37863786 NW = GEPNoWrapFlags::none();
37873787 }
37883788
3789+ return getGEPExpr(BaseExpr, IndexExprs, GEP->getSourceElementType(), NW);
3790+ }
3791+
3792+ const SCEV *ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
3793+ ArrayRef<const SCEV *> IndexExprs,
3794+ Type *SrcElementTy, GEPNoWrapFlags NW) {
37893795 SCEV::NoWrapFlags OffsetWrap = SCEV::FlagAnyWrap;
37903796 if (NW.hasNoUnsignedSignedWrap())
37913797 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNSW);
37923798 if (NW.hasNoUnsignedWrap())
37933799 OffsetWrap = setFlags(OffsetWrap, SCEV::FlagNUW);
37943800
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) {
38033801 Type *CurTy = BaseExpr->getType();
38043802 Type *IntIdxTy = getEffectiveSCEVType(BaseExpr->getType());
38053803 bool FirstIter = true;
@@ -3845,9 +3843,8 @@ ScalarEvolution::getGEPExpr(const SCEV *BaseExpr,
38453843 // Add the base address and the offset. We cannot use the nsw flag, as the
38463844 // base address is unsigned. However, if we know that the offset is
38473845 // non-negative, we can use nuw.
3848- bool NUW =
3849- hasFlags(OffsetWrap, SCEV::FlagNUW) ||
3850- (hasFlags(OffsetWrap, SCEV::FlagNSW) && isKnownNonNegative(Offset));
3846+ bool NUW = NW.hasNoUnsignedWrap() ||
3847+ (NW.hasNoUnsignedSignedWrap() && isKnownNonNegative(Offset));
38513848 SCEV::NoWrapFlags BaseWrap = NUW ? SCEV::FlagNUW : SCEV::FlagAnyWrap;
38523849 auto *GEPExpr = getAddExpr(BaseExpr, Offset, BaseWrap);
38533850 assert(BaseExpr->getType() == GEPExpr->getType() &&
0 commit comments