diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -1003,11 +1003,11 @@ CurLoop, ICmpInst::ICMP_NE, BECount, SE->getMinusOne(BECount->getType()))) { TripCountS = SE->getZeroExtendExpr( - SE->getAddExpr(BECount, SE->getOne(BECount->getType()), SCEV::FlagNUW), + SE->getAddExpr(BECount, SE->getOne(BECount->getType())), IntPtr); } else { TripCountS = SE->getAddExpr(SE->getTruncateOrZeroExtend(BECount, IntPtr), - SE->getOne(IntPtr), SCEV::FlagNUW); + SE->getOne(IntPtr)); } return TripCountS; diff --git a/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll b/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll --- a/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll +++ b/llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll @@ -196,9 +196,9 @@ ; CHECK-NEXT: [[I:%.*]] = icmp sgt i32 [[ARG2:%.*]], -1 ; CHECK-NEXT: br i1 [[I]], label [[BB3:%.*]], label [[BB5:%.*]] ; CHECK: bb3: -; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[ARG2]] to i64 -; CHECK-NEXT: [[TMP1:%.*]] = mul nuw nsw i64 [[TMP0]], 12 -; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 12 +; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[ARG2]], 1 +; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[TMP0]] to i64 +; CHECK-NEXT: [[TMP2:%.*]] = mul nuw nsw i64 [[TMP1]], 12 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[ARG:%.*]], ptr align 4 [[ARG1:%.*]], i64 [[TMP2]], i1 false) ; CHECK-NEXT: br label [[BB6:%.*]] ; CHECK: bb4: