|
LLVM
10.0.0
|
This class represents a range of values. More...
#include "llvm/IR/ConstantRange.h"
Public Types | |
| enum | PreferredRangeType { Smallest, Unsigned, Signed } |
| If represented precisely, the result of some range operations may consist of multiple disjoint ranges. More... | |
| enum | OverflowResult { OverflowResult::AlwaysOverflowsLow, OverflowResult::AlwaysOverflowsHigh, OverflowResult::MayOverflow, OverflowResult::NeverOverflows } |
| Represents whether an operation on the given constant range is known to always or never overflow. More... | |
Public Member Functions | |
| ConstantRange (uint32_t BitWidth, bool isFullSet) | |
| Initialize a full or empty set for the specified bit width. More... | |
| ConstantRange (APInt Value) | |
| Initialize a range to hold the single specified value. More... | |
| ConstantRange (APInt Lower, APInt Upper) | |
| Initialize a range of values explicitly. More... | |
| bool | getEquivalentICmp (CmpInst::Predicate &Pred, APInt &RHS) const |
Set up Pred and RHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this. More... | |
| const APInt & | getLower () const |
| Return the lower value for this range. More... | |
| const APInt & | getUpper () const |
| Return the upper value for this range. More... | |
| uint32_t | getBitWidth () const |
| Get the bit width of this ConstantRange. More... | |
| bool | isFullSet () const |
| Return true if this set contains all of the elements possible for this data-type. More... | |
| bool | isEmptySet () const |
| Return true if this set contains no members. More... | |
| bool | isWrappedSet () const |
| Return true if this set wraps around the unsigned domain. More... | |
| bool | isUpperWrapped () const |
| Return true if the exclusive upper bound wraps around the unsigned domain. More... | |
| bool | isSignWrappedSet () const |
| Return true if this set wraps around the signed domain. More... | |
| bool | isUpperSignWrapped () const |
| Return true if the (exclusive) upper bound wraps around the signed domain. More... | |
| bool | contains (const APInt &Val) const |
| Return true if the specified value is in the set. More... | |
| bool | contains (const ConstantRange &CR) const |
| Return true if the other range is a subset of this one. More... | |
| const APInt * | getSingleElement () const |
| If this set contains a single element, return it, otherwise return null. More... | |
| const APInt * | getSingleMissingElement () const |
| If this set contains all but a single element, return it, otherwise return null. More... | |
| bool | isSingleElement () const |
| Return true if this set contains exactly one member. More... | |
| bool | isSizeStrictlySmallerThan (const ConstantRange &CR) const |
| Compare set size of this range with the range CR. More... | |
| bool | isSizeLargerThan (uint64_t MaxSize) const |
| Compare set size of this range with Value. More... | |
| bool | isAllNegative () const |
| Return true if all values in this range are negative. More... | |
| bool | isAllNonNegative () const |
| Return true if all values in this range are non-negative. More... | |
| APInt | getUnsignedMax () const |
| Return the largest unsigned value contained in the ConstantRange. More... | |
| APInt | getUnsignedMin () const |
| Return the smallest unsigned value contained in the ConstantRange. More... | |
| APInt | getSignedMax () const |
| Return the largest signed value contained in the ConstantRange. More... | |
| APInt | getSignedMin () const |
| Return the smallest signed value contained in the ConstantRange. More... | |
| bool | operator== (const ConstantRange &CR) const |
| Return true if this range is equal to another range. More... | |
| bool | operator!= (const ConstantRange &CR) const |
| ConstantRange | subtract (const APInt &CI) const |
| Subtract the specified constant from the endpoints of this constant range. More... | |
| ConstantRange | difference (const ConstantRange &CR) const |
| Subtract the specified range from this range (aka relative complement of the sets). More... | |
| ConstantRange | intersectWith (const ConstantRange &CR, PreferredRangeType Type=Smallest) const |
| Return the range that results from the intersection of this range with another range. More... | |
| ConstantRange | unionWith (const ConstantRange &CR, PreferredRangeType Type=Smallest) const |
| Return the range that results from the union of this range with another range. More... | |
| ConstantRange | castOp (Instruction::CastOps CastOp, uint32_t BitWidth) const |
| Return a new range representing the possible values resulting from an application of the specified cast operator to this range. More... | |
| ConstantRange | zeroExtend (uint32_t BitWidth) const |
| Return a new range in the specified integer type, which must be strictly larger than the current type. More... | |
| ConstantRange | signExtend (uint32_t BitWidth) const |
| Return a new range in the specified integer type, which must be strictly larger than the current type. More... | |
| ConstantRange | truncate (uint32_t BitWidth) const |
| Return a new range in the specified integer type, which must be strictly smaller than the current type. More... | |
| ConstantRange | zextOrTrunc (uint32_t BitWidth) const |
Make this range have the bit width given by BitWidth. More... | |
| ConstantRange | sextOrTrunc (uint32_t BitWidth) const |
Make this range have the bit width given by BitWidth. More... | |
| ConstantRange | binaryOp (Instruction::BinaryOps BinOp, const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an application of the specified binary operator to an left hand side of this range and a right hand side of Other. More... | |
| ConstantRange | overflowingBinaryOp (Instruction::BinaryOps BinOp, const ConstantRange &Other, unsigned NoWrapKind) const |
Return a new range representing the possible values resulting from an application of the specified overflowing binary operator to a left hand side of this range and a right hand side of Other given the provided knowledge about lack of wrapping NoWrapKind. More... | |
| ConstantRange | add (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an addition of a value in this range and a value in Other. More... | |
| ConstantRange | addWithNoWrap (const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const |
Return a new range representing the possible values resulting from an addition with wrap type NoWrapKind of a value in this range and a value in Other. More... | |
| ConstantRange | sub (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a subtraction of a value in this range and a value in Other. More... | |
| ConstantRange | subWithNoWrap (const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const |
Return a new range representing the possible values resulting from an subtraction with wrap type NoWrapKind of a value in this range and a value in Other. More... | |
| ConstantRange | multiply (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a multiplication of a value in this range and a value in Other, treating both this and Other as unsigned ranges. More... | |
| ConstantRange | smax (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a signed maximum of a value in this range and a value in Other. More... | |
| ConstantRange | umax (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an unsigned maximum of a value in this range and a value in Other. More... | |
| ConstantRange | smin (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a signed minimum of a value in this range and a value in Other. More... | |
| ConstantRange | umin (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an unsigned minimum of a value in this range and a value in Other. More... | |
| ConstantRange | udiv (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an unsigned division of a value in this range and a value in Other. More... | |
| ConstantRange | sdiv (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a signed division of a value in this range and a value in Other. More... | |
| ConstantRange | urem (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from an unsigned remainder operation of a value in this range and a value in Other. More... | |
| ConstantRange | srem (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a signed remainder operation of a value in this range and a value in Other. More... | |
| ConstantRange | binaryAnd (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a binary-and of a value in this range by a value in Other. More... | |
| ConstantRange | binaryOr (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a binary-or of a value in this range by a value in Other. More... | |
| ConstantRange | shl (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a left shift of a value in this range by a value in Other. More... | |
| ConstantRange | lshr (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a logical right shift of a value in this range and a value in Other. More... | |
| ConstantRange | ashr (const ConstantRange &Other) const |
Return a new range representing the possible values resulting from a arithmetic right shift of a value in this range and a value in Other. More... | |
| ConstantRange | uadd_sat (const ConstantRange &Other) const |
| Perform an unsigned saturating addition of two constant ranges. More... | |
| ConstantRange | sadd_sat (const ConstantRange &Other) const |
| Perform a signed saturating addition of two constant ranges. More... | |
| ConstantRange | usub_sat (const ConstantRange &Other) const |
| Perform an unsigned saturating subtraction of two constant ranges. More... | |
| ConstantRange | ssub_sat (const ConstantRange &Other) const |
| Perform a signed saturating subtraction of two constant ranges. More... | |
| ConstantRange | umul_sat (const ConstantRange &Other) const |
| Perform an unsigned saturating multiplication of two constant ranges. More... | |
| ConstantRange | smul_sat (const ConstantRange &Other) const |
| Perform a signed saturating multiplication of two constant ranges. More... | |
| ConstantRange | ushl_sat (const ConstantRange &Other) const |
Perform an unsigned saturating left shift of this constant range by a value in Other. More... | |
| ConstantRange | sshl_sat (const ConstantRange &Other) const |
Perform a signed saturating left shift of this constant range by a value in Other. More... | |
| ConstantRange | inverse () const |
| Return a new range that is the logical not of the current set. More... | |
| ConstantRange | abs () const |
| Calculate absolute value range. More... | |
| OverflowResult | unsignedAddMayOverflow (const ConstantRange &Other) const |
| Return whether unsigned add of the two ranges always/never overflows. More... | |
| OverflowResult | signedAddMayOverflow (const ConstantRange &Other) const |
| Return whether signed add of the two ranges always/never overflows. More... | |
| OverflowResult | unsignedSubMayOverflow (const ConstantRange &Other) const |
| Return whether unsigned sub of the two ranges always/never overflows. More... | |
| OverflowResult | signedSubMayOverflow (const ConstantRange &Other) const |
| Return whether signed sub of the two ranges always/never overflows. More... | |
| OverflowResult | unsignedMulMayOverflow (const ConstantRange &Other) const |
| Return whether unsigned mul of the two ranges always/never overflows. More... | |
| void | print (raw_ostream &OS) const |
| Print out the bounds to a stream. More... | |
| void | dump () const |
| Allow printing from a debugger easily. More... | |
Static Public Member Functions | |
| static ConstantRange | getEmpty (uint32_t BitWidth) |
| Create empty constant range with the given bit width. More... | |
| static ConstantRange | getFull (uint32_t BitWidth) |
| Create full constant range with the given bit width. More... | |
| static ConstantRange | getNonEmpty (APInt Lower, APInt Upper) |
| Create non-empty constant range with the given bounds. More... | |
| static ConstantRange | fromKnownBits (const KnownBits &Known, bool IsSigned) |
| Initialize a range based on a known bits constraint. More... | |
| static ConstantRange | makeAllowedICmpRegion (CmpInst::Predicate Pred, const ConstantRange &Other) |
| Produce the smallest range such that all values that may satisfy the given predicate with any value contained within Other is contained in the returned range. More... | |
| static ConstantRange | makeSatisfyingICmpRegion (CmpInst::Predicate Pred, const ConstantRange &Other) |
| Produce the largest range such that all values in the returned range satisfy the given predicate with all values contained within Other. More... | |
| static ConstantRange | makeExactICmpRegion (CmpInst::Predicate Pred, const APInt &Other) |
| Produce the exact range such that all values in the returned range satisfy the given predicate with any value contained within Other. More... | |
| static ConstantRange | makeGuaranteedNoWrapRegion (Instruction::BinaryOps BinOp, const ConstantRange &Other, unsigned NoWrapKind) |
| Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow) for all Y in Other. More... | |
| static ConstantRange | makeExactNoWrapRegion (Instruction::BinaryOps BinOp, const APInt &Other, unsigned NoWrapKind) |
| Produce the range that contains X if and only if "X BinOp Other" does not wrap. More... | |
This class represents a range of values.
Definition at line 47 of file ConstantRange.h.
|
strong |
Represents whether an operation on the given constant range is known to always or never overflow.
Definition at line 460 of file ConstantRange.h.
If represented precisely, the result of some range operations may consist of multiple disjoint ranges.
As only a single range may be returned, any range covering these disjoint ranges constitutes a valid result, but some may be more useful than others depending on context. The preferred range type specifies whether a range that is non-wrapping in the unsigned or signed domain, or has the smallest size, is preferred. If a signedness is preferred but all ranges are non-wrapping or all wrapping, then the smallest set size is preferred. If there are multiple smallest sets, any one of them may be returned.
| Enumerator | |
|---|---|
| Smallest | |
| Unsigned | |
| Signed | |
Definition at line 272 of file ConstantRange.h.
Initialize a full or empty set for the specified bit width.
Definition at line 42 of file ConstantRange.cpp.
References llvm::Upper.
Referenced by abs(), add(), castOp(), fromKnownBits(), llvm::getConstantRangeFromMetadata(), intersectWith(), inverse(), makeAllowedICmpRegion(), makeExactMulNSWRegion(), makeExactNoWrapRegion(), makeGuaranteedNoWrapRegion(), multiply(), sdiv(), shl(), signExtend(), srem(), sub(), subtract(), truncate(), unionWith(), and zeroExtend().
| ConstantRange::ConstantRange | ( | APInt | Value | ) |
Initialize a range to hold the single specified value.
Definition at line 46 of file ConstantRange.cpp.
Initialize a range of values explicitly.
This will assert out if Lower==Upper and Lower != Min or Max value for its type. It will also assert out if the two APInt's are not the same bit width.
Definition at line 49 of file ConstantRange.cpp.
References assert(), llvm::APInt::getBitWidth(), and llvm::LegalizeActions::Lower.
| ConstantRange ConstantRange::abs | ( | ) | const |
Calculate absolute value range.
If the original range contains signed min, then the resulting range will also contain signed min.
Definition at line 1399 of file ConstantRange.cpp.
References ConstantRange(), getBitWidth(), llvm::APInt::getNullValue(), getSignedMax(), getSignedMin(), llvm::APInt::getSignedMinValue(), isEmptySet(), llvm::APInt::isNonNegative(), isSignWrappedSet(), llvm::APInt::isStrictlyPositive(), llvm::MipsISD::Lo, llvm::LegalizeActions::Lower, llvm::APIntOps::umax(), and llvm::APIntOps::umin().
Referenced by srem().
| ConstantRange ConstantRange::add | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from an addition of a value in this range and a value in Other.
Definition at line 837 of file ConstantRange.cpp.
References ConstantRange(), getLower(), getUpper(), isEmptySet(), isFullSet(), isSizeStrictlySmallerThan(), and X.
Referenced by addWithNoWrap(), binaryOp(), llvm::JumpThreadingPass::ComputeValueKnownInPredecessorsImpl(), llvm::StackSafetyInfo::FunctionInfo::FunctionInfo(), and isKnownPredicateExtendIdiom().
| ConstantRange ConstantRange::addWithNoWrap | ( | const ConstantRange & | Other, |
| unsigned | NoWrapKind, | ||
| PreferredRangeType | RangeType = Smallest |
||
| ) | const |
Return a new range representing the possible values resulting from an addition with wrap type NoWrapKind of a value in this range and a value in Other.
If the result range is disjoint, the preferred range is determined by the PreferredRangeType.
Definition at line 856 of file ConstantRange.cpp.
References add(), intersectWith(), isEmptySet(), isFullSet(), sadd_sat(), and uadd_sat().
Referenced by GetRangeFromMetadata(), and overflowingBinaryOp().
| ConstantRange ConstantRange::ashr | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a arithmetic right shift of a value in this range and a value in Other.
Definition at line 1250 of file ConstantRange.cpp.
References llvm::APInt::ashr(), getNonEmpty(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), and llvm::max().
Referenced by binaryOp(), and makeGuaranteedNoWrapRegion().
| ConstantRange ConstantRange::binaryAnd | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a binary-and of a value in this range by a value in Other.
Definition at line 1193 of file ConstantRange.cpp.
References getBitWidth(), getNonEmpty(), llvm::APInt::getNullValue(), getUnsignedMax(), isEmptySet(), umin(), and llvm::APIntOps::umin().
Referenced by binaryOp().
| ConstantRange ConstantRange::binaryOp | ( | Instruction::BinaryOps | BinOp, |
| const ConstantRange & | Other | ||
| ) | const |
Return a new range representing the possible values resulting from an application of the specified binary operator to an left hand side of this range and a right hand side of Other.
Definition at line 776 of file ConstantRange.cpp.
References llvm::MCID::Add, add(), ashr(), assert(), binaryAnd(), binaryOr(), llvm::Instruction::isBinaryOp(), lshr(), multiply(), sdiv(), shl(), srem(), sub(), udiv(), and urem().
Referenced by overflowingBinaryOp().
| ConstantRange ConstantRange::binaryOr | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a binary-or of a value in this range by a value in Other.
Definition at line 1204 of file ConstantRange.cpp.
References getBitWidth(), getNonEmpty(), llvm::APInt::getNullValue(), getUnsignedMin(), isEmptySet(), umax(), and llvm::APIntOps::umax().
Referenced by binaryOp().
| ConstantRange ConstantRange::castOp | ( | Instruction::CastOps | CastOp, |
| uint32_t | BitWidth | ||
| ) | const |
Return a new range representing the possible values resulting from an application of the specified cast operator to this range.
BitWidth is the target bitwidth of the cast. For casts which don't change bitwidth, it must be the same as the source bitwidth. For casts which do change bitwidth, the bitwidth must be consistent with the requested cast and source bitwidth.
Definition at line 626 of file ConstantRange.cpp.
References ConstantRange(), getBitWidth(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm_unreachable, llvm::APInt::sextOrSelf(), signExtend(), truncate(), zeroExtend(), and llvm::APInt::zextOrSelf().
Return true if the specified value is in the set.
Definition at line 388 of file ConstantRange.cpp.
References isFullSet(), isUpperWrapped(), llvm::LegalizeActions::Lower, and llvm::APInt::ult().
Referenced by llvm::JumpThreadingPass::ComputeValueKnownInPredecessorsImpl(), llvm::copyRangeMetadata(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getPredicateResult(), getRangeForAffineARHelper(), llvm::ScalarEvolution::getSignExtendExpr(), llvm::ScalarEvolution::getZeroExtendExpr(), AAValueConstantRangeImpl::isBetterRange(), isKnownPredicateExtendIdiom(), llvm::ScalarEvolution::isLoopInvariantPredicate(), processBinOp(), sdiv(), simplifyICmpWithConstant(), SolveQuadraticAddRecRange(), and willNotOverflow().
| bool ConstantRange::contains | ( | const ConstantRange & | CR | ) | const |
Return true if the other range is a subset of this one.
Definition at line 397 of file ConstantRange.cpp.
References getLower(), getUpper(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::LegalizeActions::Lower, and llvm::APInt::ule().
| ConstantRange ConstantRange::difference | ( | const ConstantRange & | CR | ) | const |
Subtract the specified range from this range (aka relative complement of the sets).
Definition at line 423 of file ConstantRange.cpp.
References intersectWith(), and inverse().
Referenced by getEdgeValueLocal(), isImpliedCondMatchingImmOperands(), and processUGT_ADDCST_ADD().
| LLVM_DUMP_METHOD void ConstantRange::dump | ( | ) | const |
Allow printing from a debugger easily.
Definition at line 1552 of file ConstantRange.cpp.
References llvm::dbgs(), and print().
|
static |
Initialize a range based on a known bits constraint.
The IsSigned flag indicates whether the constant range should not wrap in the signed or unsigned domain.
Definition at line 57 of file ConstantRange.cpp.
References assert(), llvm::APInt::clearSignBit(), ConstantRange(), llvm::KnownBits::getBitWidth(), llvm::KnownBits::getMaxValue(), llvm::KnownBits::getMinValue(), llvm::KnownBits::hasConflict(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isUnknown(), llvm::LegalizeActions::Lower, and llvm::APInt::setSignBit().
Referenced by computeConstantRangeIncludingKnownBits(), and llvm::computeOverflowForUnsignedMul().
|
inline |
Get the bit width of this ConstantRange.
Definition at line 165 of file ConstantRange.h.
References contains(), and llvm::APInt::getBitWidth().
Referenced by abs(), binaryAnd(), binaryOr(), castOp(), computeOverflowForSignedAdd(), getEquivalentICmp(), getRangeForAffineARHelper(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), intersectWith(), isSizeLargerThan(), isSizeStrictlySmallerThan(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), mapBinOpcode(), multiply(), sdiv(), sextOrTrunc(), signedAddMayOverflow(), signedSubMayOverflow(), signExtend(), smul_sat(), srem(), subtract(), truncate(), unionWith(), urem(), zeroExtend(), and zextOrTrunc().
|
inlinestatic |
Create empty constant range with the given bit width.
Definition at line 73 of file ConstantRange.h.
| bool ConstantRange::getEquivalentICmp | ( | CmpInst::Predicate & | Pred, |
| APInt & | RHS | ||
| ) | const |
Set up Pred and RHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this.
Return true if successful.
Definition at line 149 of file ConstantRange.cpp.
References assert(), getBitWidth(), getLower(), getSingleElement(), getSingleMissingElement(), getUpper(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, isEmptySet(), isFullSet(), llvm::APInt::isMinSignedValue(), makeExactICmpRegion(), and Success.
Referenced by llvm::ScalarEvolution::SimplifyICmpOperands().
|
inlinestatic |
Create full constant range with the given bit width.
Definition at line 78 of file ConstantRange.h.
Return the lower value for this range.
Definition at line 159 of file ConstantRange.h.
References llvm::Lower.
Referenced by add(), contains(), getEquivalentICmp(), AAValueConstantRangeImpl::getMDNodeForConstantRange(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getRangeForAffineARHelper(), getSignedMin(), getUnsignedMin(), isContiguous(), makeAllowedICmpRegion(), mapBinOpcode(), llvm::operator<<(), SolveQuadraticAddRecRange(), sub(), tryMergeRange(), and udiv().
|
inlinestatic |
Create non-empty constant range with the given bounds.
If Lower and Upper are the same, a full range is returned.
Definition at line 84 of file ConstantRange.h.
References llvm::APInt::getBitWidth(), and llvm::Other.
Referenced by ashr(), binaryAnd(), binaryOr(), llvm::computeConstantRange(), getRangeForAffineARHelper(), GetRangeFromMetadata(), lshr(), makeAllowedICmpRegion(), makeExactMulNUWRegion(), makeGuaranteedNoWrapRegion(), sadd_sat(), smax(), smin(), smul_sat(), sshl_sat(), ssub_sat(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), urem(), ushl_sat(), and usub_sat().
| APInt ConstantRange::getSignedMax | ( | ) | const |
Return the largest signed value contained in the ConstantRange.
Definition at line 376 of file ConstantRange.cpp.
References getBitWidth(), llvm::APInt::getSignedMaxValue(), getUpper(), isFullSet(), and isUpperSignWrapped().
Referenced by abs(), ashr(), getRangeForAffineARHelper(), hasSingleUsesFromRoot(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), multiply(), sadd_sat(), signedAddMayOverflow(), signedSubMayOverflow(), smax(), smin(), smul_sat(), srem(), sshl_sat(), and ssub_sat().
| APInt ConstantRange::getSignedMin | ( | ) | const |
Return the smallest signed value contained in the ConstantRange.
Definition at line 382 of file ConstantRange.cpp.
References getBitWidth(), getLower(), llvm::APInt::getSignedMinValue(), isFullSet(), and isSignWrappedSet().
Referenced by abs(), ashr(), getRangeForAffineARHelper(), hasSingleUsesFromRoot(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), multiply(), sadd_sat(), signedAddMayOverflow(), signedSubMayOverflow(), smax(), smin(), smul_sat(), srem(), sshl_sat(), and ssub_sat().
If this set contains a single element, return it, otherwise return null.
Definition at line 207 of file ConstantRange.h.
References llvm::Lower.
Referenced by llvm::ValueLatticeElement::asConstantInteger(), llvm::AAValueConstantRange::getAssumedConstantInt(), llvm::LazyValueInfo::getConstant(), llvm::LazyValueInfo::getConstantOnEdge(), getEquivalentICmp(), and processUGT_ADDCST_ADD().
If this set contains all but a single element, return it, otherwise return null.
Definition at line 215 of file ConstantRange.h.
References llvm::Upper.
Referenced by getEquivalentICmp().
| APInt ConstantRange::getUnsignedMax | ( | ) | const |
Return the largest unsigned value contained in the ConstantRange.
Definition at line 364 of file ConstantRange.cpp.
References getBitWidth(), llvm::APInt::getMaxValue(), getUpper(), isFullSet(), and isUpperWrapped().
Referenced by llvm::SCEVAAResult::alias(), ashr(), binaryAnd(), hasSingleUsesFromRoot(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), lshr(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), multiply(), mustBeFiniteCountedLoop(), processAnd(), processUDivOrURem(), shl(), srem(), sshl_sat(), subWithNoWrap(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), and usub_sat().
| APInt ConstantRange::getUnsignedMin | ( | ) | const |
Return the smallest unsigned value contained in the ConstantRange.
Definition at line 370 of file ConstantRange.cpp.
References getBitWidth(), getLower(), llvm::APInt::getMinValue(), isFullSet(), and isWrappedSet().
Referenced by llvm::SCEVAAResult::alias(), ashr(), binaryOr(), GetLoopInvariantInsertPosition(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), lshr(), makeAllowedICmpRegion(), multiply(), shl(), srem(), sshl_sat(), subWithNoWrap(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), and usub_sat().
Return the upper value for this range.
Definition at line 162 of file ConstantRange.h.
References llvm::Upper.
Referenced by add(), contains(), getEquivalentICmp(), AAValueConstantRangeImpl::getMDNodeForConstantRange(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getRangeForAffineARHelper(), getSignedMax(), getUnsignedMax(), isContiguous(), makeAllowedICmpRegion(), mapBinOpcode(), multiply(), llvm::operator<<(), SolveQuadraticAddRecRange(), sub(), tryMergeRange(), and udiv().
| ConstantRange ConstantRange::intersectWith | ( | const ConstantRange & | CR, |
| PreferredRangeType | Type = Smallest |
||
| ) | const |
Return the range that results from the intersection of this range with another range.
If the intersection is disjoint, such that two results are possible, the preferred range is determined by the PreferredRangeType.
Definition at line 447 of file ConstantRange.cpp.
References assert(), ConstantRange(), getBitWidth(), getPreferredRange(), intersectWith(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::LegalizeActions::Lower, llvm::APInt::ule(), and llvm::APInt::ult().
Referenced by addWithNoWrap(), canBeMerged(), llvm::computeConstantRange(), computeConstantRangeIncludingKnownBits(), difference(), GetRangeFromMetadata(), intersect(), llvm::IntegerRangeState::intersectKnown(), intersectWith(), isContiguous(), isImpliedCondMatchingImmOperands(), isSupportedGuardInstruction(), makeGuaranteedNoWrapRegion(), processUGT_ADDCST_ADD(), sdiv(), subWithNoWrap(), llvm::IntegerRangeState::unionAssumed(), and visitIVCast().
| ConstantRange ConstantRange::inverse | ( | ) | const |
Return a new range that is the logical not of the current set.
Definition at line 1391 of file ConstantRange.cpp.
References ConstantRange(), isEmptySet(), isFullSet(), and llvm::LegalizeActions::Lower.
Referenced by llvm::JumpThreadingPass::ComputeValueKnownInPredecessorsImpl(), difference(), getPredicateResult(), getValueFromOverflowCondition(), isSupportedGuardInstruction(), makeSatisfyingICmpRegion(), and simplifyICmpWithConstant().
| bool ConstantRange::isAllNegative | ( | ) | const |
Return true if all values in this range are negative.
Definition at line 349 of file ConstantRange.cpp.
References isEmptySet(), isFullSet(), llvm::APInt::isStrictlyPositive(), and isUpperSignWrapped().
Referenced by computeOverflowForSignedAdd().
| bool ConstantRange::isAllNonNegative | ( | ) | const |
Return true if all values in this range are non-negative.
Definition at line 359 of file ConstantRange.cpp.
References isSignWrappedSet(), and llvm::LegalizeActions::Lower.
Referenced by computeOverflowForSignedAdd().
| bool ConstantRange::isEmptySet | ( | ) | const |
Return true if this set contains no members.
Definition at line 308 of file ConstantRange.cpp.
References llvm::LegalizeActions::Lower.
Referenced by abs(), add(), addWithNoWrap(), llvm::ValueLatticeElement::asConstantInteger(), ashr(), binaryAnd(), binaryOr(), canBeMerged(), contains(), llvm::StackSafetyInfo::FunctionInfo::FunctionInfo(), llvm::AAValueConstantRange::getAssumedConstantInt(), getEquivalentICmp(), intersectWith(), inverse(), isAllNegative(), isContiguous(), isImpliedCondMatchingImmOperands(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), lshr(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), AAValueConstantRangeImpl::manifest(), multiply(), print(), processUGT_ADDCST_ADD(), sadd_sat(), sdiv(), AAValueConstantRangeImpl::setRangeMetadataIfisBetterRange(), shl(), signedAddMayOverflow(), signedSubMayOverflow(), signExtend(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithConstant(), smax(), smin(), smul_sat(), srem(), sshl_sat(), ssub_sat(), sub(), subWithNoWrap(), truncate(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unionWith(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), usub_sat(), and zeroExtend().
| bool ConstantRange::isFullSet | ( | ) | const |
Return true if this set contains all of the elements possible for this data-type.
Definition at line 304 of file ConstantRange.cpp.
References llvm::LegalizeActions::Lower.
Referenced by add(), addWithNoWrap(), contains(), getEquivalentICmp(), llvm::MDNode::getMostGenericRange(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getRangeForAffineARHelper(), GetRangeFromMetadata(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), intersectWith(), inverse(), isAllNegative(), AAValueConstantRangeImpl::isBetterRange(), isContiguous(), isSizeLargerThan(), isSizeStrictlySmallerThan(), llvm::IntegerRangeState::isValidState(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), AAValueConstantRangeImpl::manifest(), mapBinOpcode(), llvm::ValueLatticeElement::mergeIn(), print(), signExtend(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithConstant(), sub(), subWithNoWrap(), truncate(), unionWith(), and zeroExtend().
| bool ConstantRange::isSignWrappedSet | ( | ) | const |
Return true if this set wraps around the signed domain.
Special cases:
Definition at line 320 of file ConstantRange.cpp.
References llvm::APInt::isMinSignedValue(), and llvm::LegalizeActions::Lower.
Referenced by abs(), getPreferredRange(), getSignedMin(), isAllNonNegative(), mapBinOpcode(), and signExtend().
|
inline |
Return true if this set contains exactly one member.
Definition at line 222 of file ConstantRange.h.
Referenced by getPredicateResult(), hasSingleValue(), makeAllowedICmpRegion(), and AAValueConstantRangeImpl::manifest().
| bool ConstantRange::isSizeLargerThan | ( | uint64_t | MaxSize | ) | const |
Compare set size of this range with Value.
Definition at line 339 of file ConstantRange.cpp.
References assert(), getBitWidth(), llvm::APInt::getMaxValue(), isFullSet(), llvm::LegalizeActions::Lower, and llvm::APInt::ugt().
| bool ConstantRange::isSizeStrictlySmallerThan | ( | const ConstantRange & | CR | ) | const |
Compare set size of this range with the range CR.
Definition at line 329 of file ConstantRange.cpp.
References assert(), getBitWidth(), isFullSet(), and llvm::LegalizeActions::Lower.
Referenced by add(), getPreferredRange(), multiply(), and sub().
| bool ConstantRange::isUpperSignWrapped | ( | ) | const |
Return true if the (exclusive) upper bound wraps around the signed domain.
Special cases:
Definition at line 324 of file ConstantRange.cpp.
References llvm::LegalizeActions::Lower.
Referenced by getSignedMax(), and isAllNegative().
| bool ConstantRange::isUpperWrapped | ( | ) | const |
Return true if the exclusive upper bound wraps around the unsigned domain.
Special cases:
Definition at line 316 of file ConstantRange.cpp.
References llvm::LegalizeActions::Lower.
Referenced by contains(), getUnsignedMax(), intersectWith(), llvm::SelectionDAGBuilder::lowerRangeToAssertZExt(), multiply(), truncate(), unionWith(), and zeroExtend().
| bool ConstantRange::isWrappedSet | ( | ) | const |
Return true if this set wraps around the unsigned domain.
Special cases:
Definition at line 312 of file ConstantRange.cpp.
References llvm::APInt::isNullValue(), and llvm::LegalizeActions::Lower.
Referenced by getPreferredRange(), and getUnsignedMin().
| ConstantRange ConstantRange::lshr | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a logical right shift of a value in this range and a value in Other.
Definition at line 1240 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::lshr(), and llvm::max().
Referenced by binaryOp(), and makeGuaranteedNoWrapRegion().
|
static |
Produce the smallest range such that all values that may satisfy the given predicate with any value contained within Other is contained in the returned range.
Formally, this returns a superset of 'union over all y in Other . { x : icmp op x y is true }'. If the exact answer is not representable as a ConstantRange, the return value will be a proper superset of the above.
Example: Pred = ult and Other = i8 [2, 5) returns Result = [0, 4)
Definition at line 77 of file ConstantRange.cpp.
References ConstantRange(), getBitWidth(), getLower(), llvm::APInt::getMinValue(), getNonEmpty(), llvm::APInt::getNullValue(), getSignedMax(), getSignedMin(), llvm::APInt::getSignedMinValue(), getUnsignedMax(), getUnsignedMin(), getUpper(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, isEmptySet(), isSingleElement(), llvm_unreachable, and llvm::RISCVFenceField::W.
Referenced by AAValueConstantRangeFloating::calculateCmpInst(), getValueFromICmpCondition(), isImpliedCondMatchingImmOperands(), isKnownNonZeroFromAssume(), isKnownPredicateExtendIdiom(), makeExactICmpRegion(), makeSatisfyingICmpRegion(), processUGT_ADDCST_ADD(), and truncateIVUse().
|
static |
Produce the exact range such that all values in the returned range satisfy the given predicate with any value contained within Other.
Formally, this returns the exact answer when the superset of 'union over all y in Other is exactly same as the subset of intersection over all y in Other. { x : icmp op x y is true}'.
Example: Pred = ult and Other = i8 3 returns [0, 3)
Definition at line 137 of file ConstantRange.cpp.
References assert(), makeAllowedICmpRegion(), and makeSatisfyingICmpRegion().
Referenced by llvm::JumpThreadingPass::ComputeValueKnownInPredecessorsImpl(), foldICmpShlOne(), llvm::ScalarEvolution::forgetValue(), getEquivalentICmp(), getPredicateResult(), isImpliedCondMatchingImmOperands(), isSupportedGuardInstruction(), processUGT_ADDCST_ADD(), simplifyAndOrOfICmpsWithConstants(), llvm::ScalarEvolution::SimplifyICmpOperands(), and simplifyICmpWithConstant().
|
static |
Produce the range that contains X if and only if "X BinOp Other" does not wrap.
Definition at line 296 of file ConstantRange.cpp.
References ConstantRange(), and makeGuaranteedNoWrapRegion().
Referenced by getValueFromOverflowCondition().
|
static |
Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow) for all Y in Other.
However, there may be some Y in Other for which additional X not contained in the result also do not overflow.
NoWrapKind must be one of OBO::NoUnsignedWrap or OBO::NoSignedWrap.
Examples: typedef OverflowingBinaryOperator OBO; #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)
Definition at line 225 of file ConstantRange.cpp.
References llvm::MCID::Add, ashr(), assert(), ConstantRange(), getBitWidth(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), getNonEmpty(), llvm::APInt::getNullValue(), getSignedMax(), llvm::APInt::getSignedMaxValue(), getSignedMin(), llvm::APInt::getSignedMinValue(), getUnsignedMax(), intersectWith(), llvm::Instruction::isBinaryOp(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isStrictlyPositive(), llvm_unreachable, lshr(), makeExactMulNSWRegion(), makeExactMulNUWRegion(), and Unsigned.
Referenced by makeExactNoWrapRegion(), processBinOp(), PushDefUseChildren(), StrengthenNoWrapFlags(), and willNotOverflow().
|
static |
Produce the largest range such that all values in the returned range satisfy the given predicate with all values contained within Other.
Formally, this returns a subset of 'intersection over all y in Other . { x : icmp op x y is true }'. If the exact answer is not representable as a ConstantRange, the return value will be a proper subset of the above.
Example: Pred = ult and Other = i8 [2, 5) returns [0, 2)
Definition at line 127 of file ConstantRange.cpp.
References llvm::CmpInst::getInversePredicate(), inverse(), and makeAllowedICmpRegion().
Referenced by AAValueConstantRangeFloating::calculateCmpInst(), llvm::ValueLatticeElement::getCompare(), isKnownPredicateExtendIdiom(), llvm::ScalarEvolution::isLoopInvariantPredicate(), makeExactICmpRegion(), and SimplifyICmpInst().
| ConstantRange ConstantRange::multiply | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a multiplication of a value in this range and a value in Other, treating both this and Other as unsigned ranges.
Definition at line 934 of file ConstantRange.cpp.
References A, B, llvm::MCID::Compare, ConstantRange(), getBitWidth(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), getUpper(), isEmptySet(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNonNegative(), isSizeStrictlySmallerThan(), isUpperWrapped(), llvm::max(), llvm::APInt::sext(), llvm::APInt::slt(), truncate(), and llvm::APInt::zext().
Referenced by binaryOp(), and GetRangeFromMetadata().
|
inline |
Definition at line 252 of file ConstantRange.h.
References llvm::operator==().
|
inline |
Return true if this range is equal to another range.
Definition at line 249 of file ConstantRange.h.
| ConstantRange ConstantRange::overflowingBinaryOp | ( | Instruction::BinaryOps | BinOp, |
| const ConstantRange & | Other, | ||
| unsigned | NoWrapKind | ||
| ) | const |
Return a new range representing the possible values resulting from an application of the specified overflowing binary operator to a left hand side of this range and a right hand side of Other given the provided knowledge about lack of wrapping NoWrapKind.
Definition at line 819 of file ConstantRange.cpp.
References llvm::MCID::Add, addWithNoWrap(), assert(), binaryOp(), llvm::Instruction::isBinaryOp(), and subWithNoWrap().
| void ConstantRange::print | ( | raw_ostream & | OS | ) | const |
Print out the bounds to a stream.
Definition at line 1542 of file ConstantRange.cpp.
References isEmptySet(), isFullSet(), and llvm::LegalizeActions::Lower.
Referenced by dump(), llvm::operator<<(), and llvm::ScalarEvolution::print().
| ConstantRange ConstantRange::sadd_sat | ( | const ConstantRange & | Other | ) | const |
Perform a signed saturating addition of two constant ranges.
Definition at line 1309 of file ConstantRange.cpp.
References getNonEmpty(), getSignedMax(), getSignedMin(), isEmptySet(), and llvm::APInt::sadd_sat().
Referenced by addWithNoWrap().
| ConstantRange ConstantRange::sdiv | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a signed division of a value in this range and a value in Other.
Division by zero and division of SignedMin by -1 are considered undefined behavior, in line with IR, and do not contribute towards the result.
Definition at line 1052 of file ConstantRange.cpp.
References ConstantRange(), contains(), getBitWidth(), llvm::APInt::getNullValue(), llvm::APInt::getSignedMinValue(), intersectWith(), llvm::APInt::isAllOnesValue(), isEmptySet(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNullValue(), llvm::MipsISD::Lo, llvm::LegalizeActions::Lower, llvm::APInt::sdiv(), Signed, and unionWith().
Referenced by binaryOp().
| ConstantRange ConstantRange::sextOrTrunc | ( | uint32_t | BitWidth | ) | const |
Make this range have the bit width given by BitWidth.
The value is sign extended, truncated, or left alone to make it that width.
Definition at line 767 of file ConstantRange.cpp.
References getBitWidth(), signExtend(), and truncate().
Referenced by llvm::ScalarEvolution::getSignExtendExpr().
| ConstantRange ConstantRange::shl | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a left shift of a value in this range by a value in Other.
TODO: This isn't fully implemented yet.
Definition at line 1215 of file ConstantRange.cpp.
References ConstantRange(), llvm::APInt::countLeadingZeros(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::isNullValue(), llvm::max(), and llvm::APInt::ugt().
Referenced by binaryOp().
| ConstantRange::OverflowResult ConstantRange::signedAddMayOverflow | ( | const ConstantRange & | Other | ) | const |
Return whether signed add of the two ranges always/never overflows.
Definition at line 1446 of file ConstantRange.cpp.
References AlwaysOverflowsHigh, AlwaysOverflowsLow, getBitWidth(), getSignedMax(), llvm::APInt::getSignedMaxValue(), getSignedMin(), llvm::APInt::getSignedMinValue(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), MayOverflow, NeverOverflows, llvm::APInt::sgt(), and llvm::APInt::slt().
Referenced by computeOverflowForSignedAdd().
| ConstantRange::OverflowResult ConstantRange::signedSubMayOverflow | ( | const ConstantRange & | Other | ) | const |
Return whether signed sub of the two ranges always/never overflows.
Definition at line 1492 of file ConstantRange.cpp.
References AlwaysOverflowsHigh, AlwaysOverflowsLow, getBitWidth(), getSignedMax(), llvm::APInt::getSignedMaxValue(), getSignedMin(), llvm::APInt::getSignedMinValue(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), MayOverflow, NeverOverflows, llvm::APInt::sgt(), and llvm::APInt::slt().
Referenced by llvm::computeOverflowForSignedSub().
| ConstantRange ConstantRange::signExtend | ( | uint32_t | BitWidth | ) | const |
Return a new range in the specified integer type, which must be strictly larger than the current type.
The returned range will correspond to the possible range of values if the source range had been sign extended to BitWidth.
Definition at line 686 of file ConstantRange.cpp.
References assert(), ConstantRange(), getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), isEmptySet(), isFullSet(), llvm::APInt::isMinSignedValue(), isSignWrappedSet(), llvm::LegalizeActions::Lower, llvm::APInt::sext(), and llvm::APInt::zext().
Referenced by castOp(), GetRangeFromMetadata(), llvm::ScalarEvolution::getSignExtendExpr(), and sextOrTrunc().
| ConstantRange ConstantRange::smax | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a signed maximum of a value in this range and a value in Other.
Definition at line 988 of file ConstantRange.cpp.
References getNonEmpty(), getSignedMax(), getSignedMin(), isEmptySet(), and llvm::APIntOps::smax().
Referenced by GetRangeFromMetadata().
| ConstantRange ConstantRange::smin | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a signed minimum of a value in this range and a value in Other.
Definition at line 1010 of file ConstantRange.cpp.
References getNonEmpty(), getSignedMax(), getSignedMin(), isEmptySet(), and llvm::APIntOps::smin().
Referenced by GetRangeFromMetadata().
| ConstantRange ConstantRange::smul_sat | ( | const ConstantRange & | Other | ) | const |
Perform a signed saturating multiplication of two constant ranges.
Definition at line 1345 of file ConstantRange.cpp.
References A, B, llvm::MCID::Compare, getBitWidth(), getNonEmpty(), getSignedMax(), getSignedMin(), isEmptySet(), llvm::max(), llvm::APInt::sext(), and llvm::APInt::slt().
| ConstantRange ConstantRange::srem | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a signed remainder operation of a value in this range and a value in Other.
Definition at line 1150 of file ConstantRange.cpp.
References abs(), ConstantRange(), getBitWidth(), llvm::APInt::getNullValue(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::isNonNegative(), llvm::APInt::isNullValue(), llvm::LegalizeActions::Lower, llvm::APInt::ugt(), llvm::APIntOps::umax(), and llvm::APIntOps::umin().
Referenced by binaryOp().
| ConstantRange ConstantRange::sshl_sat | ( | const ConstantRange & | Other | ) | const |
Perform a signed saturating left shift of this constant range by a value in Other.
Definition at line 1380 of file ConstantRange.cpp.
References getNonEmpty(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::isNonNegative(), and llvm::APInt::sshl_sat().
| ConstantRange ConstantRange::ssub_sat | ( | const ConstantRange & | Other | ) | const |
Perform a signed saturating subtraction of two constant ranges.
Definition at line 1327 of file ConstantRange.cpp.
References getNonEmpty(), getSignedMax(), getSignedMin(), isEmptySet(), and llvm::APInt::ssub_sat().
Referenced by subWithNoWrap().
| ConstantRange ConstantRange::sub | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from a subtraction of a value in this range and a value in Other.
Definition at line 884 of file ConstantRange.cpp.
References ConstantRange(), getLower(), getUpper(), isEmptySet(), isFullSet(), isSizeStrictlySmallerThan(), and X.
Referenced by binaryOp(), and subWithNoWrap().
| ConstantRange ConstantRange::subtract | ( | const APInt & | CI | ) | const |
Subtract the specified constant from the endpoints of this constant range.
Definition at line 415 of file ConstantRange.cpp.
References assert(), ConstantRange(), getBitWidth(), llvm::APInt::getBitWidth(), and llvm::LegalizeActions::Lower.
Referenced by foldICmpShlOne(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), and getValueFromICmpCondition().
| ConstantRange ConstantRange::subWithNoWrap | ( | const ConstantRange & | Other, |
| unsigned | NoWrapKind, | ||
| PreferredRangeType | RangeType = Smallest |
||
| ) | const |
Return a new range representing the possible values resulting from an subtraction with wrap type NoWrapKind of a value in this range and a value in Other.
If the result range is disjoint, the preferred range is determined by the PreferredRangeType.
Definition at line 903 of file ConstantRange.cpp.
References getUnsignedMax(), getUnsignedMin(), intersectWith(), isEmptySet(), isFullSet(), ssub_sat(), sub(), and usub_sat().
Referenced by overflowingBinaryOp().
| ConstantRange ConstantRange::truncate | ( | uint32_t | BitWidth | ) | const |
Return a new range in the specified integer type, which must be strictly smaller than the current type.
The returned range will correspond to the possible range of values if the source range had been truncated to the specified type.
Definition at line 704 of file ConstantRange.cpp.
References assert(), llvm::APInt::clearBit(), ConstantRange(), llvm::APInt::countTrailingOnes(), llvm::APInt::getActiveBits(), llvm::APInt::getBitsSetFrom(), getBitWidth(), llvm::APInt::getMaxValue(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::LegalizeActions::Lower, llvm::APInt::setAllBits(), llvm::APInt::trunc(), llvm::APInt::ult(), and unionWith().
Referenced by castOp(), GetRangeFromMetadata(), llvm::ScalarEvolution::getSignExtendExpr(), llvm::ScalarEvolution::getZeroExtendExpr(), multiply(), sextOrTrunc(), and zextOrTrunc().
| ConstantRange ConstantRange::uadd_sat | ( | const ConstantRange & | Other | ) | const |
Perform an unsigned saturating addition of two constant ranges.
Definition at line 1300 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APInt::uadd_sat().
Referenced by addWithNoWrap().
| ConstantRange ConstantRange::udiv | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from an unsigned division of a value in this range and a value in Other.
Definition at line 1032 of file ConstantRange.cpp.
References getLower(), getNonEmpty(), getUnsignedMax(), getUnsignedMin(), getUpper(), isEmptySet(), llvm::APInt::isNullValue(), llvm::LegalizeActions::Lower, and llvm::APInt::udiv().
Referenced by binaryOp(), and GetRangeFromMetadata().
| ConstantRange ConstantRange::umax | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from an unsigned maximum of a value in this range and a value in Other.
Definition at line 999 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APIntOps::umax().
Referenced by binaryOr(), and GetRangeFromMetadata().
| ConstantRange ConstantRange::umin | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from an unsigned minimum of a value in this range and a value in Other.
Definition at line 1021 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APIntOps::umin().
Referenced by binaryAnd(), and GetRangeFromMetadata().
| ConstantRange ConstantRange::umul_sat | ( | const ConstantRange & | Other | ) | const |
Perform an unsigned saturating multiplication of two constant ranges.
Definition at line 1336 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APInt::umul_sat().
| ConstantRange ConstantRange::unionWith | ( | const ConstantRange & | CR, |
| PreferredRangeType | Type = Smallest |
||
| ) | const |
Return the range that results from the union of this range with another range.
The resultant range is guaranteed to include the elements of both sets, but may contain more. For example, [3, 9) union [12,15) is [3, 15), which includes 9, 10, and 11, which were not included in either set before.
Definition at line 553 of file ConstantRange.cpp.
References assert(), ConstantRange(), getBitWidth(), getPreferredRange(), isEmptySet(), isFullSet(), llvm::APInt::isNullValue(), isUpperWrapped(), llvm::LegalizeActions::Lower, Type, llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ule(), llvm::APInt::ult(), and unionWith().
Referenced by getEdgeValueLocal(), getRangeForAffineARHelper(), GetRangeFromMetadata(), isSupportedGuardInstruction(), mapBinOpcode(), llvm::ValueLatticeElement::mergeIn(), processUDivOrURem(), sdiv(), truncate(), tryMergeRange(), llvm::IntegerRangeState::unionAssumed(), llvm::IntegerRangeState::unionKnown(), and unionWith().
| ConstantRange::OverflowResult ConstantRange::unsignedAddMayOverflow | ( | const ConstantRange & | Other | ) | const |
Return whether unsigned add of the two ranges always/never overflows.
Definition at line 1430 of file ConstantRange.cpp.
References AlwaysOverflowsHigh, getUnsignedMax(), getUnsignedMin(), isEmptySet(), MayOverflow, NeverOverflows, and llvm::APInt::ugt().
Referenced by llvm::computeOverflowForUnsignedAdd().
| ConstantRange::OverflowResult ConstantRange::unsignedMulMayOverflow | ( | const ConstantRange & | Other | ) | const |
Return whether unsigned mul of the two ranges always/never overflows.
Definition at line 1522 of file ConstantRange.cpp.
References AlwaysOverflowsHigh, getUnsignedMax(), getUnsignedMin(), isEmptySet(), MayOverflow, NeverOverflows, and llvm::APInt::umul_ov().
Referenced by llvm::computeOverflowForUnsignedMul().
| ConstantRange::OverflowResult ConstantRange::unsignedSubMayOverflow | ( | const ConstantRange & | Other | ) | const |
Return whether unsigned sub of the two ranges always/never overflows.
Definition at line 1476 of file ConstantRange.cpp.
References AlwaysOverflowsLow, getUnsignedMax(), getUnsignedMin(), isEmptySet(), MayOverflow, NeverOverflows, and llvm::APInt::ult().
Referenced by llvm::computeOverflowForUnsignedSub().
| ConstantRange ConstantRange::urem | ( | const ConstantRange & | Other | ) | const |
Return a new range representing the possible values resulting from an unsigned remainder operation of a value in this range and a value in Other.
Definition at line 1137 of file ConstantRange.cpp.
References getBitWidth(), getNonEmpty(), llvm::APInt::getNullValue(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::APInt::isNullValue(), llvm::APInt::ult(), and llvm::APIntOps::umin().
Referenced by binaryOp().
| ConstantRange ConstantRange::ushl_sat | ( | const ConstantRange & | Other | ) | const |
Perform an unsigned saturating left shift of this constant range by a value in Other.
Definition at line 1371 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APInt::ushl_sat().
| ConstantRange ConstantRange::usub_sat | ( | const ConstantRange & | Other | ) | const |
Perform an unsigned saturating subtraction of two constant ranges.
Definition at line 1318 of file ConstantRange.cpp.
References getNonEmpty(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), and llvm::APInt::usub_sat().
Referenced by subWithNoWrap().
| ConstantRange ConstantRange::zeroExtend | ( | uint32_t | BitWidth | ) | const |
Return a new range in the specified integer type, which must be strictly larger than the current type.
The returned range will correspond to the possible range of values if the source range had been zero extended to BitWidth.
Definition at line 669 of file ConstantRange.cpp.
References assert(), ConstantRange(), getBitWidth(), llvm::APInt::getOneBitSet(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::LegalizeActions::Lower, and llvm::APInt::zext().
Referenced by castOp(), GetRangeFromMetadata(), llvm::ScalarEvolution::getZeroExtendExpr(), and zextOrTrunc().
| ConstantRange ConstantRange::zextOrTrunc | ( | uint32_t | BitWidth | ) | const |
Make this range have the bit width given by BitWidth.
The value is zero extended, truncated, or left alone to make it that width.
Definition at line 758 of file ConstantRange.cpp.
References getBitWidth(), truncate(), and zeroExtend().
Referenced by llvm::StackSafetyInfo::FunctionInfo::FunctionInfo(), and llvm::ScalarEvolution::getZeroExtendExpr().
1.8.13