mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-27 13:40:43 +00:00
Revert "[ConstantRange] Rename make{Guaranteed -> Exact}NoWrapRegion() NFC"
This reverts commit 7bf4d7c07f2fac862ef34c82ad0fef6513452445. After thinking about this more, this isn't right, the range is not exact in the same sense as makeExactICmpRegion(). This needs a separate function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
09d24ddb89
commit
4872512fe9
@ -131,16 +131,16 @@ public:
|
||||
///
|
||||
/// Examples:
|
||||
/// typedef OverflowingBinaryOperator OBO;
|
||||
/// #define MENR makeExactNoWrapRegion
|
||||
/// MENR(Add, [i8 1, 2), OBO::NoSignedWrap) == [-128, 127)
|
||||
/// MENR(Add, [i8 1, 2), OBO::NoUnsignedWrap) == [0, -1)
|
||||
/// MENR(Add, [i8 0, 1), OBO::NoUnsignedWrap) == Full Set
|
||||
/// MENR(Add, [i8 -1, 6), OBO::NoSignedWrap) == [INT_MIN+1, INT_MAX-4)
|
||||
/// MENR(Sub, [i8 1, 2), OBO::NoSignedWrap) == [-127, 128)
|
||||
/// MENR(Sub, [i8 1, 2), OBO::NoUnsignedWrap) == [1, 0)
|
||||
static ConstantRange makeExactNoWrapRegion(Instruction::BinaryOps BinOp,
|
||||
const ConstantRange &Other,
|
||||
unsigned NoWrapKind);
|
||||
/// #define MGNR makeGuaranteedNoWrapRegion
|
||||
/// MGNR(Add, [i8 1, 2), OBO::NoSignedWrap) == [-128, 127)
|
||||
/// MGNR(Add, [i8 1, 2), OBO::NoUnsignedWrap) == [0, -1)
|
||||
/// MGNR(Add, [i8 0, 1), OBO::NoUnsignedWrap) == Full Set
|
||||
/// MGNR(Add, [i8 -1, 6), OBO::NoSignedWrap) == [INT_MIN+1, INT_MAX-4)
|
||||
/// MGNR(Sub, [i8 1, 2), OBO::NoSignedWrap) == [-127, 128)
|
||||
/// MGNR(Sub, [i8 1, 2), OBO::NoUnsignedWrap) == [1, 0)
|
||||
static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
|
||||
const ConstantRange &Other,
|
||||
unsigned NoWrapKind);
|
||||
|
||||
/// Set up \p Pred and \p RHS such that
|
||||
/// ConstantRange::makeExactICmpRegion(Pred, RHS) == *this. Return true if
|
||||
|
@ -1146,7 +1146,7 @@ static ValueLatticeElement getValueFromOverflowCondition(
|
||||
return ValueLatticeElement::getOverdefined();
|
||||
|
||||
// Calculate the possible values of %x for which no overflow occurs.
|
||||
ConstantRange NWR = ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange NWR = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
WO->getBinaryOp(), ConstantRange(*C), WO->getNoWrapKind());
|
||||
|
||||
// If overflow is false, %x is constrained to NWR. If overflow is true, %x is
|
||||
|
@ -2363,7 +2363,7 @@ StrengthenNoWrapFlags(ScalarEvolution *SE, SCEVTypes Type,
|
||||
|
||||
// (A <opcode> C) --> (A <opcode> C)<nsw> if the op doesn't sign overflow.
|
||||
if (!(SignOrUnsignWrap & SCEV::FlagNSW)) {
|
||||
auto NSWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Opcode, C, OBO::NoSignedWrap);
|
||||
if (NSWRegion.contains(SE->getSignedRange(Ops[1])))
|
||||
Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNSW);
|
||||
@ -2371,7 +2371,7 @@ StrengthenNoWrapFlags(ScalarEvolution *SE, SCEVTypes Type,
|
||||
|
||||
// (A <opcode> C) --> (A <opcode> C)<nuw> if the op doesn't unsign overflow.
|
||||
if (!(SignOrUnsignWrap & SCEV::FlagNUW)) {
|
||||
auto NUWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Opcode, C, OBO::NoUnsignedWrap);
|
||||
if (NUWRegion.contains(SE->getUnsignedRange(Ops[1])))
|
||||
Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNUW);
|
||||
@ -4471,7 +4471,7 @@ ScalarEvolution::proveNoWrapViaConstantRanges(const SCEVAddRecExpr *AR) {
|
||||
ConstantRange AddRecRange = getSignedRange(AR);
|
||||
ConstantRange IncRange = getSignedRange(AR->getStepRecurrence(*this));
|
||||
|
||||
auto NSWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, IncRange, OBO::NoSignedWrap);
|
||||
if (NSWRegion.contains(AddRecRange))
|
||||
Result = ScalarEvolution::setFlags(Result, SCEV::FlagNSW);
|
||||
@ -4481,7 +4481,7 @@ ScalarEvolution::proveNoWrapViaConstantRanges(const SCEVAddRecExpr *AR) {
|
||||
ConstantRange AddRecRange = getUnsignedRange(AR);
|
||||
ConstantRange IncRange = getUnsignedRange(AR->getStepRecurrence(*this));
|
||||
|
||||
auto NUWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, IncRange, OBO::NoUnsignedWrap);
|
||||
if (NUWRegion.contains(AddRecRange))
|
||||
Result = ScalarEvolution::setFlags(Result, SCEV::FlagNUW);
|
||||
|
@ -181,9 +181,9 @@ bool ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred,
|
||||
}
|
||||
|
||||
ConstantRange
|
||||
ConstantRange::makeExactNoWrapRegion(Instruction::BinaryOps BinOp,
|
||||
const ConstantRange &Other,
|
||||
unsigned NoWrapKind) {
|
||||
ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
|
||||
const ConstantRange &Other,
|
||||
unsigned NoWrapKind) {
|
||||
using OBO = OverflowingBinaryOperator;
|
||||
|
||||
// Computes the intersection of CR0 and CR1. It is different from
|
||||
@ -262,7 +262,7 @@ ConstantRange::makeExactNoWrapRegion(Instruction::BinaryOps BinOp,
|
||||
return Result;
|
||||
|
||||
case Instruction::Mul: {
|
||||
// Equivalent to calling makeExactNoWrapRegion() on [V, V+1).
|
||||
// Equivalent to calling makeGuaranteedNoWrapRegion() on [V, V+1).
|
||||
const bool Unsigned = NoWrapKind == OBO::NoUnsignedWrap;
|
||||
const auto makeSingleValueRegion = [Unsigned,
|
||||
BitWidth](APInt V) -> ConstantRange {
|
||||
@ -841,9 +841,10 @@ ConstantRange::add(const ConstantRange &Other) const {
|
||||
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, ConstantRange(Other),
|
||||
OverflowingBinaryOperator::NoSignedWrap);
|
||||
// makeGuaranteedNoWrapRegion will produce an exact NSW range.
|
||||
auto NSWRange = ConstantRange::makeGuaranteedNoWrapRegion(BinaryOperator::Add,
|
||||
ConstantRange(Other),
|
||||
OverflowingBinaryOperator::NoSignedWrap);
|
||||
auto NSWConstrainedRange = intersectWith(NSWRange);
|
||||
|
||||
return NSWConstrainedRange.add(ConstantRange(Other));
|
||||
|
@ -402,7 +402,7 @@ static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI,
|
||||
static bool willNotOverflow(WithOverflowInst *WO, LazyValueInfo *LVI) {
|
||||
Value *RHS = WO->getRHS();
|
||||
ConstantRange RRange = LVI->getConstantRange(RHS, WO->getParent(), WO);
|
||||
ConstantRange NWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange NWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
WO->getBinaryOp(), RRange, WO->getNoWrapKind());
|
||||
// As an optimization, do not compute LRange if we do not need it.
|
||||
if (NWRegion.isEmptySet())
|
||||
@ -640,7 +640,7 @@ static bool processBinOp(BinaryOperator *BinOp, LazyValueInfo *LVI) {
|
||||
|
||||
bool Changed = false;
|
||||
if (!NUW) {
|
||||
ConstantRange NUWRange = ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange NUWRange = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
BinOp->getOpcode(), RRange, OBO::NoUnsignedWrap);
|
||||
if (!NUWRange.isEmptySet()) {
|
||||
bool NewNUW = NUWRange.contains(LazyLRange());
|
||||
@ -649,7 +649,7 @@ static bool processBinOp(BinaryOperator *BinOp, LazyValueInfo *LVI) {
|
||||
}
|
||||
}
|
||||
if (!NSW) {
|
||||
ConstantRange NSWRange = ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange NSWRange = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
BinOp->getOpcode(), RRange, OBO::NoSignedWrap);
|
||||
if (!NSWRange.isEmptySet()) {
|
||||
bool NewNSW = NSWRange.contains(LazyLRange());
|
||||
|
@ -891,7 +891,7 @@ TEST(ConstantRange, MakeSatisfyingICmpRegion) {
|
||||
ConstantRange(APInt(8, 4), APInt(8, -128)));
|
||||
}
|
||||
|
||||
TEST(ConstantRange, MakeExactNoWrapRegion) {
|
||||
TEST(ConstantRange, MakeGuaranteedNoWrapRegion) {
|
||||
const int IntMin4Bits = 8;
|
||||
const int IntMax4Bits = 7;
|
||||
typedef OverflowingBinaryOperator OBO;
|
||||
@ -899,12 +899,12 @@ TEST(ConstantRange, MakeExactNoWrapRegion) {
|
||||
for (int Const : {0, -1, -2, 1, 2, IntMin4Bits, IntMax4Bits}) {
|
||||
APInt C(4, Const, true /* = isSigned */);
|
||||
|
||||
auto NUWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, C, OBO::NoUnsignedWrap);
|
||||
|
||||
EXPECT_FALSE(NUWRegion.isEmptySet());
|
||||
|
||||
auto NSWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, C, OBO::NoSignedWrap);
|
||||
|
||||
EXPECT_FALSE(NSWRegion.isEmptySet());
|
||||
@ -927,12 +927,12 @@ TEST(ConstantRange, MakeExactNoWrapRegion) {
|
||||
for (int Const : {0, -1, -2, 1, 2, IntMin4Bits, IntMax4Bits}) {
|
||||
APInt C(4, Const, true /* = isSigned */);
|
||||
|
||||
auto NUWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, C, OBO::NoUnsignedWrap);
|
||||
|
||||
EXPECT_FALSE(NUWRegion.isEmptySet());
|
||||
|
||||
auto NSWRegion = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, C, OBO::NoSignedWrap);
|
||||
|
||||
EXPECT_FALSE(NSWRegion.isEmptySet());
|
||||
@ -952,102 +952,102 @@ TEST(ConstantRange, MakeExactNoWrapRegion) {
|
||||
}
|
||||
}
|
||||
|
||||
auto NSWForAllValues = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NSWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, ConstantRange(32, /* isFullSet = */ true),
|
||||
OBO::NoSignedWrap);
|
||||
EXPECT_TRUE(NSWForAllValues.isSingleElement() &&
|
||||
NSWForAllValues.getSingleElement()->isMinValue());
|
||||
|
||||
NSWForAllValues = ConstantRange::makeExactNoWrapRegion(
|
||||
NSWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, ConstantRange(32, /* isFullSet = */ true),
|
||||
OBO::NoSignedWrap);
|
||||
EXPECT_TRUE(NSWForAllValues.isSingleElement() &&
|
||||
NSWForAllValues.getSingleElement()->isMaxValue());
|
||||
|
||||
auto NUWForAllValues = ConstantRange::makeExactNoWrapRegion(
|
||||
auto NUWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, ConstantRange(32, /* isFullSet = */ true),
|
||||
OBO::NoUnsignedWrap);
|
||||
EXPECT_TRUE(NUWForAllValues.isSingleElement() &&
|
||||
NUWForAllValues.getSingleElement()->isMinValue());
|
||||
|
||||
NUWForAllValues = ConstantRange::makeExactNoWrapRegion(
|
||||
NUWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, ConstantRange(32, /* isFullSet = */ true),
|
||||
OBO::NoUnsignedWrap);
|
||||
EXPECT_TRUE(NUWForAllValues.isSingleElement() &&
|
||||
NUWForAllValues.getSingleElement()->isMaxValue());
|
||||
|
||||
EXPECT_TRUE(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_TRUE(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, APInt(32, 0), OBO::NoUnsignedWrap).isFullSet());
|
||||
EXPECT_TRUE(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_TRUE(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, APInt(32, 0), OBO::NoSignedWrap).isFullSet());
|
||||
EXPECT_TRUE(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_TRUE(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, APInt(32, 0), OBO::NoUnsignedWrap).isFullSet());
|
||||
EXPECT_TRUE(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_TRUE(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, APInt(32, 0), OBO::NoSignedWrap).isFullSet());
|
||||
|
||||
ConstantRange OneToFive(APInt(32, 1), APInt(32, 6));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, OneToFive, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32),
|
||||
APInt::getSignedMaxValue(32) - 4));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, OneToFive, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMinValue(32), APInt::getMinValue(32) - 5));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, OneToFive, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32) + 5,
|
||||
APInt::getSignedMinValue(32)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, OneToFive, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMinValue(32) + 5, APInt::getMinValue(32)));
|
||||
|
||||
ConstantRange MinusFiveToMinusTwo(APInt(32, -5), APInt(32, -1));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, MinusFiveToMinusTwo, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32) + 5,
|
||||
APInt::getSignedMinValue(32)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, MinusFiveToMinusTwo, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt(32, 0), APInt(32, 2)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, MinusFiveToMinusTwo, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32),
|
||||
APInt::getSignedMaxValue(32) - 4));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, MinusFiveToMinusTwo, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMaxValue(32) - 1,
|
||||
APInt::getMinValue(32)));
|
||||
|
||||
ConstantRange MinusOneToOne(APInt(32, -1), APInt(32, 2));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, MinusOneToOne, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32) + 1,
|
||||
APInt::getSignedMinValue(32) - 1));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, MinusOneToOne, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt(32, 0), APInt(32, 1)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, MinusOneToOne, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32) + 1,
|
||||
APInt::getSignedMinValue(32) - 1));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, MinusOneToOne, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMaxValue(32),
|
||||
APInt::getMinValue(32)));
|
||||
|
||||
ConstantRange One(APInt(32, 1), APInt(32, 2));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, One, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32),
|
||||
APInt::getSignedMaxValue(32)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Add, One, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMinValue(32), APInt::getMaxValue(32)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, One, OBO::NoSignedWrap),
|
||||
ConstantRange(APInt::getSignedMinValue(32) + 1,
|
||||
APInt::getSignedMinValue(32)));
|
||||
EXPECT_EQ(ConstantRange::makeExactNoWrapRegion(
|
||||
EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Sub, One, OBO::NoUnsignedWrap),
|
||||
ConstantRange(APInt::getMinValue(32) + 1, APInt::getMinValue(32)));
|
||||
}
|
||||
@ -1063,7 +1063,7 @@ void TestNoWrapRegionExhaustive(Instruction::BinaryOps BinOp,
|
||||
return;
|
||||
|
||||
ConstantRange NoWrap =
|
||||
ConstantRange::makeExactNoWrapRegion(BinOp, CR2, NoWrapKind);
|
||||
ConstantRange::makeGuaranteedNoWrapRegion(BinOp, CR2, NoWrapKind);
|
||||
ForeachNumInConstantRange(CR1, [&](const APInt &N1) {
|
||||
bool NoOverflow = true;
|
||||
ForeachNumInConstantRange(CR2, [&](const APInt &N2) {
|
||||
@ -1075,7 +1075,7 @@ void TestNoWrapRegionExhaustive(Instruction::BinaryOps BinOp,
|
||||
});
|
||||
}
|
||||
|
||||
// Show that makeExactNoWrapRegion is precise if only one of
|
||||
// Show that makeGuaranteedNoWrapRegion is precise if only one of
|
||||
// NoUnsignedWrap or NoSignedWrap is used.
|
||||
TEST(ConstantRange, NoWrapRegionExhaustive) {
|
||||
TestNoWrapRegionExhaustive(
|
||||
@ -1204,12 +1204,12 @@ TEST(ConstantRange, GetEquivalentICmp) {
|
||||
EXPECT_EQ(RHS, APInt(32, -1));
|
||||
}
|
||||
|
||||
TEST(ConstantRange, MakeExactNoWrapRegionMulUnsignedSingleValue) {
|
||||
TEST(ConstantRange, MakeGuaranteedNoWrapRegionMulUnsignedSingleValue) {
|
||||
typedef OverflowingBinaryOperator OBO;
|
||||
|
||||
for (uint64_t I = std::numeric_limits<uint8_t>::min();
|
||||
I <= std::numeric_limits<uint8_t>::max(); I++) {
|
||||
auto Range = ConstantRange::makeExactNoWrapRegion(
|
||||
auto Range = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Mul, ConstantRange(APInt(8, I), APInt(8, I + 1)),
|
||||
OBO::NoUnsignedWrap);
|
||||
|
||||
@ -1222,12 +1222,12 @@ TEST(ConstantRange, MakeExactNoWrapRegionMulUnsignedSingleValue) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ConstantRange, MakeExactNoWrapRegionMulSignedSingleValue) {
|
||||
TEST(ConstantRange, MakeGuaranteedNoWrapRegionMulSignedSingleValue) {
|
||||
typedef OverflowingBinaryOperator OBO;
|
||||
|
||||
for (int64_t I = std::numeric_limits<int8_t>::min();
|
||||
I <= std::numeric_limits<int8_t>::max(); I++) {
|
||||
auto Range = ConstantRange::makeExactNoWrapRegion(
|
||||
auto Range = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Mul,
|
||||
ConstantRange(APInt(8, I, /*isSigned=*/true),
|
||||
APInt(8, I + 1, /*isSigned=*/true)),
|
||||
@ -1243,28 +1243,28 @@ TEST(ConstantRange, MakeExactNoWrapRegionMulSignedSingleValue) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ConstantRange, MakeExactNoWrapRegionMulUnsignedRange) {
|
||||
TEST(ConstantRange, MakeGuaranteedNoWrapRegionMulUnsignedRange) {
|
||||
typedef OverflowingBinaryOperator OBO;
|
||||
|
||||
for (uint64_t Lo = std::numeric_limits<uint8_t>::min();
|
||||
Lo <= std::numeric_limits<uint8_t>::max(); Lo++) {
|
||||
for (uint64_t Hi = Lo; Hi <= std::numeric_limits<uint8_t>::max(); Hi++) {
|
||||
EXPECT_EQ(
|
||||
ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Mul, ConstantRange(APInt(8, Lo), APInt(8, Hi + 1)),
|
||||
OBO::NoUnsignedWrap),
|
||||
ConstantRange::makeExactNoWrapRegion(
|
||||
ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Mul, ConstantRange(APInt(8, Hi), APInt(8, Hi + 1)),
|
||||
OBO::NoUnsignedWrap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ConstantRange, MakeExactNoWrapRegionMulSignedRange) {
|
||||
TEST(ConstantRange, MakeGuaranteedNoWrapRegionMulSignedRange) {
|
||||
typedef OverflowingBinaryOperator OBO;
|
||||
|
||||
int Lo = -12, Hi = 16;
|
||||
auto Range = ConstantRange::makeExactNoWrapRegion(
|
||||
auto Range = ConstantRange::makeGuaranteedNoWrapRegion(
|
||||
Instruction::Mul,
|
||||
ConstantRange(APInt(8, Lo, /*isSigned=*/true),
|
||||
APInt(8, Hi + 1, /*isSigned=*/true)),
|
||||
|
Loading…
Reference in New Issue
Block a user