diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 18:19:33 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 18:19:33 +0000 |
commit | 6d855ea024186d7dba21b1c178e7a0afd0f13eb0 (patch) | |
tree | f00b6d28611be2583556d7365d885c41b5053095 /llvm/lib/IR/ConstantRange.cpp | |
parent | beda859a15ae064c5ace8c230709fdf79dc7a602 (diff) | |
download | bcm5719-llvm-6d855ea024186d7dba21b1c178e7a0afd0f13eb0.tar.gz bcm5719-llvm-6d855ea024186d7dba21b1c178e7a0afd0f13eb0.zip |
[ConstantRange] Rename isWrappedSet() to isUpperWrapped()
Split out from D59749. The current implementation of isWrappedSet()
doesn't do what it says on the tin, and treats ranges like
[X, Max] as wrapping, because they are represented as [X, 0) when
using half-inclusive ranges. This also makes it inconsistent with
the semantics of isSignWrappedSet().
This patch renames isWrappedSet() to isUpperWrapped(), in preparation
for the introduction of a new isWrappedSet() method with corrected
behavior.
llvm-svn: 357107
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantRange.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index 0c2a3a86597..896a870bf90 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -344,7 +344,7 @@ bool ConstantRange::isEmptySet() const { return Lower == Upper && Lower.isMinValue(); } -bool ConstantRange::isWrappedSet() const { +bool ConstantRange::isUpperWrapped() const { return Lower.ugt(Upper); } @@ -382,13 +382,13 @@ ConstantRange::isSizeLargerThan(uint64_t MaxSize) const { } APInt ConstantRange::getUnsignedMax() const { - if (isFullSet() || isWrappedSet()) + if (isFullSet() || isUpperWrapped()) return APInt::getMaxValue(getBitWidth()); return getUpper() - 1; } APInt ConstantRange::getUnsignedMin() const { - if (isFullSet() || (isWrappedSet() && !getUpper().isNullValue())) + if (isFullSet() || (isUpperWrapped() && !getUpper().isNullValue())) return APInt::getMinValue(getBitWidth()); return getLower(); } @@ -409,7 +409,7 @@ bool ConstantRange::contains(const APInt &V) const { if (Lower == Upper) return isFullSet(); - if (!isWrappedSet()) + if (!isUpperWrapped()) return Lower.ule(V) && V.ult(Upper); return Lower.ule(V) || V.ult(Upper); } @@ -418,14 +418,14 @@ bool ConstantRange::contains(const ConstantRange &Other) const { if (isFullSet() || Other.isEmptySet()) return true; if (isEmptySet() || Other.isFullSet()) return false; - if (!isWrappedSet()) { - if (Other.isWrappedSet()) + if (!isUpperWrapped()) { + if (Other.isUpperWrapped()) return false; return Lower.ule(Other.getLower()) && Other.getUpper().ule(Upper); } - if (!Other.isWrappedSet()) + if (!Other.isUpperWrapped()) return Other.getUpper().ule(Upper) || Lower.ule(Other.getLower()); @@ -452,10 +452,10 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR) const { if ( isEmptySet() || CR.isFullSet()) return *this; if (CR.isEmptySet() || isFullSet()) return CR; - if (!isWrappedSet() && CR.isWrappedSet()) + if (!isUpperWrapped() && CR.isUpperWrapped()) return CR.intersectWith(*this); - if (!isWrappedSet() && !CR.isWrappedSet()) { + if (!isUpperWrapped() && !CR.isUpperWrapped()) { if (Lower.ult(CR.Lower)) { if (Upper.ule(CR.Lower)) return getEmpty(); @@ -474,7 +474,7 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR) const { return getEmpty(); } - if (isWrappedSet() && !CR.isWrappedSet()) { + if (isUpperWrapped() && !CR.isUpperWrapped()) { if (CR.Lower.ult(Upper)) { if (CR.Upper.ult(Upper)) return CR; @@ -525,9 +525,9 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const { if ( isFullSet() || CR.isEmptySet()) return *this; if (CR.isFullSet() || isEmptySet()) return CR; - if (!isWrappedSet() && CR.isWrappedSet()) return CR.unionWith(*this); + if (!isUpperWrapped() && CR.isUpperWrapped()) return CR.unionWith(*this); - if (!isWrappedSet() && !CR.isWrappedSet()) { + if (!isUpperWrapped() && !CR.isUpperWrapped()) { if (CR.Upper.ult(Lower) || Upper.ult(CR.Lower)) { // If the two ranges are disjoint, find the smaller gap and bridge it. APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper; @@ -545,7 +545,7 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const { return ConstantRange(std::move(L), std::move(U)); } - if (!CR.isWrappedSet()) { + if (!CR.isUpperWrapped()) { // ------U L----- and ------U L----- : this // L--U L--U : CR if (CR.Upper.ule(Upper) || CR.Lower.uge(Lower)) @@ -637,7 +637,7 @@ ConstantRange ConstantRange::zeroExtend(uint32_t DstTySize) const { unsigned SrcTySize = getBitWidth(); assert(SrcTySize < DstTySize && "Not a value extension"); - if (isFullSet() || isWrappedSet()) { + if (isFullSet() || isUpperWrapped()) { // Change into [0, 1 << src bit width) APInt LowerExt(DstTySize, 0); if (!Upper) // special case: [X, 0) -- not really wrapping around @@ -680,7 +680,7 @@ ConstantRange ConstantRange::truncate(uint32_t DstTySize) const { // Analyze wrapped sets in their two parts: [0, Upper) \/ [Lower, MaxValue] // We use the non-wrapped set code to analyze the [Lower, MaxValue) part, and // then we do the union with [MaxValue, Upper) - if (isWrappedSet()) { + if (isUpperWrapped()) { // If Upper is greater than or equal to MaxValue(DstTy), it covers the whole // truncated range. if (Upper.getActiveBits() > DstTySize || @@ -859,7 +859,7 @@ ConstantRange::multiply(const ConstantRange &Other) const { // from one positive number to another which is as good as we can generate. // In this case, skip the extra work of generating signed ranges which aren't // going to be better than this range. - if (!UR.isWrappedSet() && + if (!UR.isUpperWrapped() && (UR.getUpper().isNonNegative() || UR.getUpper().isMinSignedValue())) return UR; |