[llvm] r374016 - [ConstantRange] [NFC] replace addWithNoSignedWrap with addWithNoWrap.
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 20:00:31 PDT 2019
Author: shchenz
Date: Mon Oct 7 20:00:31 2019
New Revision: 374016
URL: http://llvm.org/viewvc/llvm-project?rev=374016&view=rev
Log:
[ConstantRange] [NFC] replace addWithNoSignedWrap with addWithNoWrap.
Modified:
llvm/trunk/include/llvm/IR/ConstantRange.h
llvm/trunk/lib/IR/ConstantRange.cpp
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/trunk/unittests/IR/ConstantRangeTest.cpp
Modified: llvm/trunk/include/llvm/IR/ConstantRange.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ConstantRange.h?rev=374016&r1=374015&r2=374016&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ConstantRange.h (original)
+++ llvm/trunk/include/llvm/IR/ConstantRange.h Mon Oct 7 20:00:31 2019
@@ -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;
Modified: llvm/trunk/lib/IR/ConstantRange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantRange.cpp?rev=374016&r1=374015&r2=374016&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantRange.cpp (original)
+++ llvm/trunk/lib/IR/ConstantRange.cpp Mon Oct 7 20:00:31 2019
@@ -866,16 +866,6 @@ ConstantRange ConstantRange::addWithNoWr
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())
Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=374016&r1=374015&r2=374016&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Oct 7 20:00:31 2019
@@ -1839,8 +1839,8 @@ void WidenIV::calculatePostIncRange(Inst
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);
};
Modified: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/ConstantRangeTest.cpp?rev=374016&r1=374015&r2=374016&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp (original)
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp Mon Oct 7 20:00:31 2019
@@ -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;
More information about the llvm-commits
mailing list