]> granicus.if.org Git - llvm/commitdiff
[ConstantRange] [NFC] replace addWithNoSignedWrap with addWithNoWrap.
authorChen Zheng <czhengsz@cn.ibm.com>
Tue, 8 Oct 2019 03:00:31 +0000 (03:00 +0000)
committerChen Zheng <czhengsz@cn.ibm.com>
Tue, 8 Oct 2019 03:00:31 +0000 (03:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374016 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/ConstantRange.h
lib/IR/ConstantRange.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
unittests/IR/ConstantRangeTest.cpp

index ce4b851cb45725bd20768efd47fdba234d07f17b..964f9e8e9bc9c2edc708ea9c90a683dfd16a8c9e 100644 (file)
@@ -338,10 +338,6 @@ public:
   ConstantRange addWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind,
                               PreferredRangeType RangeType = Smallest) const;
 
-  /// Return a new range representing the possible values resulting from a
-  /// known NSW addition of a value in this range and \p Other constant.
-  ConstantRange addWithNoSignedWrap(const APInt &Other) const;
-
   /// Return a new range representing the possible values resulting
   /// from a subtraction of a value in this range and a value in \p Other.
   ConstantRange sub(const ConstantRange &Other) const;
index 8ea688ff1f07e2ad99cf1a33e8824bbfe5aafec6..592042bc0c7884aabe770f8e00fbf0435ec4ecc4 100644 (file)
@@ -866,16 +866,6 @@ ConstantRange ConstantRange::addWithNoWrap(const ConstantRange &Other,
   return Result;
 }
 
-ConstantRange ConstantRange::addWithNoSignedWrap(const APInt &Other) const {
-  // Calculate the subset of this range such that "X + Other" is
-  // guaranteed not to wrap (overflow) for all X in this subset.
-  auto NSWRange = ConstantRange::makeExactNoWrapRegion(
-      BinaryOperator::Add, Other, OverflowingBinaryOperator::NoSignedWrap);
-  auto NSWConstrainedRange = intersectWith(NSWRange);
-
-  return NSWConstrainedRange.add(ConstantRange(Other));
-}
-
 ConstantRange
 ConstantRange::sub(const ConstantRange &Other) const {
   if (isEmptySet() || Other.isEmptySet())
index 1aaa0265bade63b7ff87bb49d778c9e323bbcfc4..c55783ac2154fa7d74d937a784e2af687802a9e6 100644 (file)
@@ -1839,8 +1839,8 @@ void WidenIV::calculatePostIncRange(Instruction *NarrowDef,
     auto CmpRHSRange = SE->getSignedRange(SE->getSCEV(CmpRHS));
     auto CmpConstrainedLHSRange =
             ConstantRange::makeAllowedICmpRegion(P, CmpRHSRange);
-    auto NarrowDefRange =
-            CmpConstrainedLHSRange.addWithNoSignedWrap(*NarrowDefRHS);
+    auto NarrowDefRange = CmpConstrainedLHSRange.addWithNoWrap(
+        *NarrowDefRHS, OverflowingBinaryOperator::NoSignedWrap);
 
     updatePostIncRangeInfo(NarrowDef, NarrowUser, NarrowDefRange);
   };
index 7c43d2fb09cc9d7ca1acf5cb649ece64e960a5e0..58a25166d83dcfc8a5fc3ce5f580bfeba3b54fb5 100644 (file)
@@ -643,32 +643,6 @@ TEST_F(ConstantRangeTest, Add) {
             ConstantRange(APInt(16, 0xe)));
 }
 
-TEST_F(ConstantRangeTest, AddWithNoSignedWrap) {
-  EXPECT_EQ(Empty.addWithNoSignedWrap(APInt(16, 1)), Empty);
-  EXPECT_EQ(Full.addWithNoSignedWrap(APInt(16, 1)),
-            ConstantRange(APInt(16, INT16_MIN+1), APInt(16, INT16_MIN)));
-  EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 50)).addWithNoSignedWrap(APInt(8, 10)),
-            ConstantRange(APInt(8, -40), APInt(8, 60)));
-  EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 120)).addWithNoSignedWrap(APInt(8, 10)),
-            ConstantRange(APInt(8, -40), APInt(8, INT8_MIN)));
-  EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -10)).addWithNoSignedWrap(APInt(8, 5)),
-            ConstantRange(APInt(8, 125), APInt(8, -5)));
-  EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, 10)),
-            ConstantRange(APInt(8, INT8_MIN+10), APInt(8, -110)));
-
-  EXPECT_EQ(Empty.addWithNoSignedWrap(APInt(16, -1)), Empty);
-  EXPECT_EQ(Full.addWithNoSignedWrap(APInt(16, -1)),
-            ConstantRange(APInt(16, INT16_MIN), APInt(16, INT16_MAX)));
-  EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 50)).addWithNoSignedWrap(APInt(8, -10)),
-            ConstantRange(APInt(8, -60), APInt(8, 40)));
-  EXPECT_EQ(ConstantRange(APInt(8, -120), APInt(8, 50)).addWithNoSignedWrap(APInt(8, -10)),
-            ConstantRange(APInt(8, INT8_MIN), APInt(8, 40)));
-  EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, -5)),
-            ConstantRange(APInt(8, 115), APInt(8, -125)));
-  EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, -10)),
-            ConstantRange(APInt(8, 110), APInt(8, INT8_MIN-10)));
-}
-
 template <typename Fn1, typename Fn2>
 static void TestAddWithNoSignedWrapExhaustive(Fn1 RangeFn, Fn2 IntFn) {
   unsigned Bits = 4;