[LoopIdiomRecognize] Remove NUW flag from SCEV in getTripCount.
authorCraig Topper <craig.topper@sifive.com>
Thu, 13 Apr 2023 18:53:43 +0000 (11:53 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 13 Apr 2023 18:58:10 +0000 (11:58 -0700)
Based on the conversation in D147355.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148170

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/test/Transforms/LoopIdiom/memcpy-intrinsic.ll

index 3e7d33a..b4c2baf 100644 (file)
@@ -1003,11 +1003,11 @@ static const SCEV *getTripCount(const SCEV *BECount, Type *IntPtr,
           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;
index fb56e61..85561da 100644 (file)
@@ -196,9 +196,9 @@ define dso_local i32 @copy_noalias_negative_stride(ptr noalias nocapture %arg, p
 ; 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: