mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[ConstantRange] Handle wrapping range in binaryNot()
We don't need any special handling for wrapping ranges (or empty ranges for that matter). The sub() call will already compute a correct and precise range. We only need to adjust the test expectation: We're now computing an optimal result, rather than an unsigned envelope.
This commit is contained in:
parent
8328dce0c0
commit
ca3345ac4e
@ -1256,12 +1256,6 @@ ConstantRange ConstantRange::srem(const ConstantRange &RHS) const {
|
||||
}
|
||||
|
||||
ConstantRange ConstantRange::binaryNot() const {
|
||||
if (isEmptySet())
|
||||
return getEmpty();
|
||||
|
||||
if (isWrappedSet())
|
||||
return getFull();
|
||||
|
||||
return ConstantRange(APInt::getAllOnesValue(getBitWidth())).sub(*this);
|
||||
}
|
||||
|
||||
|
@ -2388,26 +2388,24 @@ TEST_F(ConstantRangeTest, binaryXor) {
|
||||
}
|
||||
|
||||
TEST_F(ConstantRangeTest, binaryNot) {
|
||||
// TODO: Improve binaryNot() implementation to remove the need for
|
||||
// PreferSmallestUnsigned.
|
||||
TestUnaryOpExhaustive(
|
||||
[](const ConstantRange &CR) { return CR.binaryNot(); },
|
||||
[](const APInt &N) { return ~N; },
|
||||
PreferSmallestUnsigned);
|
||||
PreferSmallest);
|
||||
TestUnaryOpExhaustive(
|
||||
[](const ConstantRange &CR) {
|
||||
return CR.binaryXor(
|
||||
ConstantRange(APInt::getAllOnesValue(CR.getBitWidth())));
|
||||
},
|
||||
[](const APInt &N) { return ~N; },
|
||||
PreferSmallestUnsigned);
|
||||
PreferSmallest);
|
||||
TestUnaryOpExhaustive(
|
||||
[](const ConstantRange &CR) {
|
||||
return ConstantRange(APInt::getAllOnesValue(CR.getBitWidth()))
|
||||
.binaryXor(CR);
|
||||
},
|
||||
[](const APInt &N) { return ~N; },
|
||||
PreferSmallestUnsigned);
|
||||
PreferSmallest);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user