LLVM: llvm::ConstantRange Class Reference (original) (raw)

This class represents a range of values. More...

#include "[llvm/IR/ConstantRange.h](ConstantRange%5F8h%5Fsource.html)"

Public Types
enum PreferredRangeType { Smallest, Unsigned, Signed }
If represented precisely, the result of some range operations may consist of multiple disjoint ranges. More...
enum class OverflowResult { AlwaysOverflowsLow, AlwaysOverflowsHigh, MayOverflow, NeverOverflows }
Represents whether an operation on the given constant range is known to always or never overflow. More...
Public Member Functions
LLVM_ABI ConstantRange (uint32_t BitWidth, bool isFullSet)
Initialize a full or empty set for the specified bit width.
LLVM_ABI ConstantRange (APInt Value)
Initialize a range to hold the single specified value.
LLVM_ABI ConstantRange (APInt Lower, APInt Upper)
Initialize a range of values explicitly.
LLVM_ABI std::pair< ConstantRange, ConstantRange > splitPosNeg () const
Split the ConstantRange into positive and negative components, ignoring zero values.
LLVM_ABI bool icmp (CmpInst::Predicate Pred, const ConstantRange &Other) const
Does the predicate Pred hold between ranges this and Other?
LLVM_ABI bool getEquivalentICmp (CmpInst::Predicate &Pred, APInt &RHS) const
Set up Pred and RHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this.
LLVM_ABI void getEquivalentICmp (CmpInst::Predicate &Pred, APInt &RHS, APInt &Offset) const
Set up Pred, RHS and Offset such that (V + Offset) Pred RHS is true iff V is in the range.
const APInt & getLower () const
Return the lower value for this range.
const APInt & getUpper () const
Return the upper value for this range.
uint32_t getBitWidth () const
Get the bit width of this ConstantRange.
LLVM_ABI bool isFullSet () const
Return true if this set contains all of the elements possible for this data-type.
LLVM_ABI bool isEmptySet () const
Return true if this set contains no members.
LLVM_ABI bool isWrappedSet () const
Return true if this set wraps around the unsigned domain.
LLVM_ABI bool isUpperWrapped () const
Return true if the exclusive upper bound wraps around the unsigned domain.
LLVM_ABI bool isSignWrappedSet () const
Return true if this set wraps around the signed domain.
LLVM_ABI bool isUpperSignWrapped () const
Return true if the (exclusive) upper bound wraps around the signed domain.
LLVM_ABI bool contains (const APInt &Val) const
Return true if the specified value is in the set.
LLVM_ABI bool contains (const ConstantRange &CR) const
Return true if the other range is a subset of this one.
const APInt * getSingleElement () const
If this set contains a single element, return it, otherwise return null.
const APInt * getSingleMissingElement () const
If this set contains all but a single element, return it, otherwise return null.
bool isSingleElement () const
Return true if this set contains exactly one member.
LLVM_ABI bool isSizeStrictlySmallerThan (const ConstantRange &CR) const
Compare set size of this range with the range CR.
LLVM_ABI bool isSizeLargerThan (uint64_t MaxSize) const
Compare set size of this range with Value.
LLVM_ABI bool isAllNegative () const
Return true if all values in this range are negative.
LLVM_ABI bool isAllNonNegative () const
Return true if all values in this range are non-negative.
LLVM_ABI bool isAllPositive () const
Return true if all values in this range are positive.
LLVM_ABI APInt getUnsignedMax () const
Return the largest unsigned value contained in the ConstantRange.
LLVM_ABI APInt getUnsignedMin () const
Return the smallest unsigned value contained in the ConstantRange.
LLVM_ABI APInt getSignedMax () const
Return the largest signed value contained in the ConstantRange.
LLVM_ABI APInt getSignedMin () const
Return the smallest signed value contained in the ConstantRange.
bool operator== (const ConstantRange &CR) const
Return true if this range is equal to another range.
bool operator!= (const ConstantRange &CR) const
LLVM_ABI unsigned getActiveBits () const
Compute the maximal number of active bits needed to represent every value in this range.
LLVM_ABI unsigned getMinSignedBits () const
Compute the maximal number of bits needed to represent every value in this signed range.
LLVM_ABI ConstantRange subtract (const APInt &CI) const
Subtract the specified constant from the endpoints of this constant range.
LLVM_ABI ConstantRange difference (const ConstantRange &CR) const
Subtract the specified range from this range (aka relative complement of the sets).
LLVM_ABI ConstantRange intersectWith (const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
LLVM_ABI ConstantRange unionWith (const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
LLVM_ABI std::optional< ConstantRange > exactIntersectWith (const ConstantRange &CR) const
Intersect the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.
LLVM_ABI std::optional< ConstantRange > exactUnionWith (const ConstantRange &CR) const
Union the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.
LLVM_ABI 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.
LLVM_ABI ConstantRange zeroExtend (uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type.
LLVM_ABI ConstantRange signExtend (uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type.
LLVM_ABI ConstantRange truncate (uint32_t BitWidth, unsigned NoWrapKind=0) const
Return a new range in the specified integer type, which must be strictly smaller than the current type.
LLVM_ABI ConstantRange zextOrTrunc (uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
LLVM_ABI ConstantRange sextOrTrunc (uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI ConstantRange multiplyWithNoWrap (const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const
Return a new range representing the possible values resulting from a multiplication with wrap type NoWrapKind of a value in this range and a value in Other.
LLVM_ABI ConstantRange smul_fast (const ConstantRange &Other) const
Return range of possible values for a signed multiplication of this and Other.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI ConstantRange binaryNot () const
Return a new range representing the possible values resulting from a binary-xor of a value in this range by an all-one value, aka bitwise complement operation.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI ConstantRange binaryXor (const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-xor of a value in this range by a value in Other.
LLVM_ABI 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.
LLVM_ABI ConstantRange shlWithNoWrap (const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const
Return a new range representing the possible values resulting from a left shift with wrap type NoWrapKind of a value in this range and a value in Other.
LLVM_ABI 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.
LLVM_ABI 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.
LLVM_ABI ConstantRange uadd_sat (const ConstantRange &Other) const
Perform an unsigned saturating addition of two constant ranges.
LLVM_ABI ConstantRange sadd_sat (const ConstantRange &Other) const
Perform a signed saturating addition of two constant ranges.
LLVM_ABI ConstantRange usub_sat (const ConstantRange &Other) const
Perform an unsigned saturating subtraction of two constant ranges.
LLVM_ABI ConstantRange ssub_sat (const ConstantRange &Other) const
Perform a signed saturating subtraction of two constant ranges.
LLVM_ABI ConstantRange umul_sat (const ConstantRange &Other) const
Perform an unsigned saturating multiplication of two constant ranges.
LLVM_ABI ConstantRange smul_sat (const ConstantRange &Other) const
Perform a signed saturating multiplication of two constant ranges.
LLVM_ABI ConstantRange ushl_sat (const ConstantRange &Other) const
Perform an unsigned saturating left shift of this constant range by a value in Other.
LLVM_ABI ConstantRange sshl_sat (const ConstantRange &Other) const
Perform a signed saturating left shift of this constant range by a value in Other.
LLVM_ABI ConstantRange inverse () const
Return a new range that is the logical not of the current set.
LLVM_ABI ConstantRange abs (bool IntMinIsPoison=false) const
Calculate absolute value range.
LLVM_ABI ConstantRange ctlz (bool ZeroIsPoison=false) const
Calculate ctlz range.
LLVM_ABI ConstantRange cttz (bool ZeroIsPoison=false) const
Calculate cttz range.
LLVM_ABI ConstantRange ctpop () const
Calculate ctpop range.
LLVM_ABI OverflowResult unsignedAddMayOverflow (const ConstantRange &Other) const
Return whether unsigned add of the two ranges always/never overflows.
LLVM_ABI OverflowResult signedAddMayOverflow (const ConstantRange &Other) const
Return whether signed add of the two ranges always/never overflows.
LLVM_ABI OverflowResult unsignedSubMayOverflow (const ConstantRange &Other) const
Return whether unsigned sub of the two ranges always/never overflows.
LLVM_ABI OverflowResult signedSubMayOverflow (const ConstantRange &Other) const
Return whether signed sub of the two ranges always/never overflows.
LLVM_ABI OverflowResult unsignedMulMayOverflow (const ConstantRange &Other) const
Return whether unsigned mul of the two ranges always/never overflows.
LLVM_ABI KnownBits toKnownBits () const
Return known bits for values in this range.
LLVM_ABI void print (raw_ostream &OS) const
Print out the bounds to a stream.
LLVM_ABI void dump () const
Allow printing from a debugger easily.
Static Public Member Functions
static ConstantRange getEmpty (uint32_t BitWidth)
Create empty constant range with the given bit width.
static ConstantRange getFull (uint32_t BitWidth)
Create full constant range with the given bit width.
static ConstantRange getNonEmpty (APInt Lower, APInt Upper)
Create non-empty constant range with the given bounds.
static LLVM_ABI ConstantRange fromKnownBits (const KnownBits &Known, bool IsSigned)
Initialize a range based on a known bits constraint.
static LLVM_ABI 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.
static LLVM_ABI 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.
static LLVM_ABI 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.
static LLVM_ABI bool areInsensitiveToSignednessOfICmpPredicate (const ConstantRange &CR1, const ConstantRange &CR2)
Return true iff CR1 ult CR2 is equivalent to CR1 slt CR2.
static LLVM_ABI bool areInsensitiveToSignednessOfInvertedICmpPredicate (const ConstantRange &CR1, const ConstantRange &CR2)
Return true iff CR1 ult CR2 is equivalent to CR1 sge CR2.
static LLVM_ABI CmpInst::Predicate getEquivalentPredWithFlippedSignedness (CmpInst::Predicate Pred, const ConstantRange &CR1, const ConstantRange &CR2)
If the comparison between constant ranges this and Other is insensitive to the signedness of the comparison predicate, return a predicate equivalent to Pred, with flipped signedness (i.e.
static LLVM_ABI 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.
static LLVM_ABI 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.
static LLVM_ABI ConstantRange makeMaskNotEqualRange (const APInt &Mask, const APInt &C)
Initialize a range containing all values X that satisfy (X & Mask) / != C.
static LLVM_ABI bool isIntrinsicSupported (Intrinsic::ID IntrinsicID)
Returns true if ConstantRange calculations are supported for intrinsic with IntrinsicID.
static LLVM_ABI ConstantRange intrinsic (Intrinsic::ID IntrinsicID, ArrayRef< ConstantRange > Ops)
Compute range of intrinsic result for the given operand ranges.

This class represents a range of values.

Definition at line 47 of file ConstantRange.h.

OverflowResult

Represents whether an operation on the given constant range is known to always or never overflow.

Enumerator
AlwaysOverflowsLow Always overflows in the direction of signed/unsigned min value.
AlwaysOverflowsHigh Always overflows in the direction of signed/unsigned max value.
MayOverflow May or may not overflow.
NeverOverflows Never overflows.

Definition at line 579 of file ConstantRange.h.

PreferredRangeType

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 333 of file ConstantRange.h.

ConstantRange::ConstantRange ( uint32_t BitWidth, bool isFullSet ) explicit

Initialize a full or empty set for the specified bit width.

Definition at line 45 of file ConstantRange.cpp.

References llvm::BitWidth, and llvm::Full.

Referenced by abs(), add(), addWithNoWrap(), areInsensitiveToSignednessOfICmpPredicate(), areInsensitiveToSignednessOfInvertedICmpPredicate(), ashr(), binaryAnd(), binaryNot(), binaryOp(), binaryOr(), binaryXor(), castOp(), contains(), ctlz(), ctpop(), cttz(), difference(), exactIntersectWith(), exactUnionWith(), fromKnownBits(), getEmpty(), getEquivalentPredWithFlippedSignedness(), getFull(), getNonEmpty(), icmp(), intersectWith(), intrinsic(), inverse(), isSizeStrictlySmallerThan(), lshr(), makeAllowedICmpRegion(), makeExactICmpRegion(), makeExactNoWrapRegion(), makeGuaranteedNoWrapRegion(), makeMaskNotEqualRange(), makeSatisfyingICmpRegion(), multiply(), multiplyWithNoWrap(), operator!=(), operator==(), overflowingBinaryOp(), sadd_sat(), sdiv(), sextOrTrunc(), shl(), shlWithNoWrap(), signedAddMayOverflow(), signedSubMayOverflow(), signExtend(), smax(), smin(), smul_fast(), smul_sat(), splitPosNeg(), srem(), sshl_sat(), ssub_sat(), sub(), subtract(), subWithNoWrap(), truncate(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unionWith(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), usub_sat(), zeroExtend(), and zextOrTrunc().

ConstantRange() [2/3]

ConstantRange::ConstantRange ( APInt Value )

ConstantRange() [3/3]

ConstantRange::ConstantRange ( APInt Lower,
APInt Upper )

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 52 of file ConstantRange.cpp.

References assert(), and llvm::move().

abs()

Calculate absolute value range.

If the original range contains signed min, then the resulting range will contain signed min if and only if IntMinIsPoison is false.

Definition at line 1973 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), getNonEmpty(), getSignedMax(), getSignedMin(), llvm::APInt::getSignedMinValue(), llvm::APInt::getZero(), isEmptySet(), isSignWrappedSet(), llvm::Lo, llvm::SMax, llvm::SMin, llvm::APIntOps::umax(), and llvm::APIntOps::umin().

Referenced by processSRem().

add()

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 1103 of file ConstantRange.cpp.

References ConstantRange(), getLower(), getUpper(), isEmptySet(), isFullSet(), llvm::Other, and X.

Referenced by addWithNoWrap(), binaryOp(), llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(), foldICmpUSubSatOrUAddSatWithConstant(), getEquivalentICmp(), and llvm::simplifyInstruction().

addWithNoWrap()

areInsensitiveToSignednessOfICmpPredicate()

areInsensitiveToSignednessOfInvertedICmpPredicate()

ashr()

binaryAnd()

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 1610 of file ConstantRange.cpp.

References ConstantRange(), estimateBitMaskedAndLowerBound(), fromKnownBits(), getNonEmpty(), getUnsignedMax(), intersectWith(), isEmptySet(), llvm::Other, toKnownBits(), and llvm::APIntOps::umin().

Referenced by binaryOp(), and canScalarizeAccess().

binaryNot()

binaryOp()

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 971 of file ConstantRange.cpp.

References add(), ashr(), assert(), binaryAnd(), binaryOr(), binaryXor(), ConstantRange(), llvm::Instruction::isBinaryOp(), lshr(), multiply(), llvm::Other, sdiv(), shl(), srem(), sub(), udiv(), and urem().

Referenced by overflowingBinaryOp().

binaryOr()

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 1622 of file ConstantRange.cpp.

References binaryNot(), ConstantRange(), estimateBitMaskedAndLowerBound(), fromKnownBits(), getNonEmpty(), getUnsignedMin(), intersectWith(), isEmptySet(), llvm::Other, toKnownBits(), and llvm::APIntOps::umax().

Referenced by binaryOp().

binaryXor()

Return a new range representing the possible values resulting from a binary-xor of a value in this range by a value in Other.

Definition at line 1642 of file ConstantRange.cpp.

References binaryNot(), ConstantRange(), fromKnownBits(), getBitWidth(), getSingleElement(), intersectWith(), isEmptySet(), isSingleElement(), llvm::KnownBits::One, llvm::Other, sub(), toKnownBits(), Unsigned, and llvm::KnownBits::Zero.

Referenced by binaryOp().

castOp()

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 788 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), getNonEmpty(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm_unreachable, signExtend(), llvm::SMax, llvm::SMin, truncate(), zeroExtend(), and llvm::APInt::zext().

contains() [1/2]

Return true if the specified value is in the set.

Definition at line 517 of file ConstantRange.cpp.

References isFullSet(), and isUpperWrapped().

Referenced by addNoUndefAttrs(), canScalarizeAccess(), cmpExcludesZero(), llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(), ctlz(), cttz(), foldCtpop(), llvm::ScalarEvolution::getMulExpr(), getRangeForAffineARHelper(), llvm::ScalarEvolution::getSignExtendExprImpl(), llvm::ScalarEvolution::getTripCountFromExitCount(), llvm::ScalarEvolution::getZeroExtendExprImpl(), icmp(), llvm::RecurrenceDescriptor::isFindIVPattern(), llvm::SelectionDAG::isKnownNeverZero(), llvm::ValueLatticeElement::markConstantRange(), narrowSDivOrSRem(), processAShr(), processBinOp(), processSwitch(), sdiv(), simplifyICmpWithConstant(), simplifySwitchOnSelectUsingRanges(), splitGlobal(), and willNotOverflow().

contains() [2/2]

ctlz()

Calculate ctlz range.

If ZeroIsPoison is set, the range is computed ignoring a possible zero value contained in the input range.

Definition at line 2015 of file ConstantRange.cpp.

References ConstantRange(), contains(), llvm::countl_zero(), getBitWidth(), getLower(), getNonEmpty(), getUnsignedMax(), getUnsignedMin(), getUpper(), llvm::APInt::getZero(), isEmptySet(), and isZero().

ctpop()

cttz()

Calculate cttz range.

If ZeroIsPoison is set, the range is computed ignoring a possible zero value contained in the input range.

Definition at line 2075 of file ConstantRange.cpp.

References llvm::BitWidth, ConstantRange(), contains(), getBitWidth(), getNonEmpty(), getUnsignedCountTrailingZerosRange(), llvm::APInt::getZero(), isEmptySet(), isFullSet(), isWrappedSet(), and unionWith().

difference()

dump()

exactIntersectWith()

exactUnionWith()

fromKnownBits()

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 60 of file ConstantRange.cpp.

References ConstantRange(), llvm::KnownBits::getBitWidth(), llvm::KnownBits::getMaxValue(), llvm::KnownBits::getMinValue(), llvm::KnownBits::hasConflict(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isUnknown(), and llvm::APInt::setSignBit().

Referenced by binaryAnd(), binaryOr(), binaryXor(), llvm::computeConstantRangeIncludingKnownBits(), llvm::SelectionDAG::computeOverflowForSignedSub(), llvm::SelectionDAG::computeOverflowForUnsignedAdd(), llvm::computeOverflowForUnsignedMul(), llvm::SelectionDAG::computeOverflowForUnsignedMul(), llvm::SelectionDAG::computeOverflowForUnsignedSub(), llvm::GISelValueTracking::getValidShiftAmountRange(), llvm::SelectionDAG::getValidShiftAmountRange(), isSignificantBitCheckWellFormed(), llvm::CombinerHelper::matchAddOverflow(), and llvm::CombinerHelper::matchSuboCarryOut().

getActiveBits()

unsigned ConstantRange::getActiveBits ( ) const

getBitWidth()

uint32_t llvm::ConstantRange::getBitWidth ( ) const inline

Get the bit width of this ConstantRange.

Definition at line 215 of file ConstantRange.h.

Referenced by abs(), binaryNot(), binaryXor(), castOp(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), computeOverflowForSignedAdd(), ctlz(), ctpop(), cttz(), emitConstantRange(), llvm::Attribute::getAsString(), getDomain(), getEquivalentICmp(), getRangeForAffineARHelper(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), llvm::ConstantRangeList::insert(), intersectWith(), llvm::SelectionDAG::isKnownNeverZero(), isSizeLargerThan(), isSizeStrictlySmallerThan(), makeAllowedICmpRegion(), multiply(), multiplyWithNoWrap(), sdiv(), sextOrTrunc(), shl(), signedAddMayOverflow(), signedSubMayOverflow(), signExtend(), splitPosNeg(), srem(), subtract(), llvm::ConstantRangeList::subtract(), toKnownBits(), truncate(), llvm::typeIncompatible(), unionWith(), urem(), llvm::InstCombinerImpl::visitCallInst(), zeroExtend(), and zextOrTrunc().

getEmpty()

getEquivalentICmp() [1/2]

getEquivalentICmp() [2/2]

Set up Pred, RHS and Offset such that (V + Offset) Pred RHS is true iff V is in the range.

Prefers using Offset == 0 if possible.

Definition at line 216 of file ConstantRange.cpp.

References add(), 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 llvm::Offset.

getEquivalentPredWithFlippedSignedness()

If the comparison between constant ranges this and Other is insensitive to the signedness of the comparison predicate, return a predicate equivalent to Pred, with flipped signedness (i.e.

unsigned instead of signed or vice versa), and maybe inverted, otherwise returns CmpInst::Predicate::BAD_ICMP_PREDICATE.

Definition at line 198 of file ConstantRange.cpp.

References areInsensitiveToSignednessOfICmpPredicate(), areInsensitiveToSignednessOfInvertedICmpPredicate(), assert(), llvm::CmpInst::BAD_ICMP_PREDICATE, ConstantRange(), llvm::ICmpInst::getFlippedSignednessPredicate(), llvm::CmpInst::getInversePredicate(), llvm::CmpInst::isIntPredicate(), and llvm::CmpInst::isRelational().

Referenced by processICmp().

getFull()

getLower()

const APInt & llvm::ConstantRange::getLower ( ) const inline

Return the lower value for this range.

Definition at line 209 of file ConstantRange.h.

Referenced by add(), ctlz(), emitConstantRange(), llvm::Attribute::get(), llvm::Attribute::getAsString(), getEquivalentICmp(), getRangeForAffineARHelper(), getSignedMin(), getUnsignedMin(), llvm::ConstantRangeList::insert(), makeAllowedICmpRegion(), llvm::operator<<(), llvm::ConstantRangeList::print(), llvm::AttributeImpl::Profile(), splitGlobal(), sub(), llvm::ConstantRangeList::subtract(), and llvm::ConstantRangeList::unionWith().

getMinSignedBits()

unsigned ConstantRange::getMinSignedBits ( ) const

getNonEmpty()

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 ConstantRange().

Referenced by abs(), ashr(), binaryAnd(), binaryOr(), castOp(), llvm::computeConstantRange(), computeShlNSWWithNegLHS(), computeShlNSWWithNNegLHS(), computeShlNUW(), ctlz(), ctpop(), cttz(), llvm::InstCombinerImpl::foldICmpWithClamp(), getRangeForAffineARHelper(), getRangeForIntrinsic(), getRangeForSelectPattern(), getValueFromICmpCtpop(), llvm::RecurrenceDescriptor::isFindIVPattern(), lshr(), makeAllowedICmpRegion(), makeExactMulNSWRegion(), makeExactMulNUWRegion(), makeGuaranteedNoWrapRegion(), makeMaskNotEqualRange(), multiplyWithNoWrap(), sadd_sat(), shl(), smax(), smin(), smul_fast(), smul_sat(), sshl_sat(), ssub_sat(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unionWithMinMaxIntrinsicClamp(), urem(), ushl_sat(), and usub_sat().

getSignedMax()

APInt ConstantRange::getSignedMax ( ) const

Return the largest signed value contained in the ConstantRange.

Definition at line 505 of file ConstantRange.cpp.

References getBitWidth(), llvm::APInt::getSignedMaxValue(), getUpper(), isFullSet(), and isUpperSignWrapped().

Referenced by abs(), ashr(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), getMinSignedBits(), icmp(), makeAllowedICmpRegion(), multiply(), sadd_sat(), signedAddMayOverflow(), signedSubMayOverflow(), smax(), smin(), smul_fast(), smul_sat(), srem(), sshl_sat(), and ssub_sat().

getSignedMin()

APInt ConstantRange::getSignedMin ( ) const

Return the smallest signed value contained in the ConstantRange.

Definition at line 511 of file ConstantRange.cpp.

References getBitWidth(), getLower(), llvm::APInt::getSignedMinValue(), isFullSet(), and isSignWrappedSet().

Referenced by abs(), ashr(), computeKnownFPClass(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), getMinSignedBits(), icmp(), makeAllowedICmpRegion(), multiply(), multiplyWithNoWrap(), sadd_sat(), signedAddMayOverflow(), signedSubMayOverflow(), smax(), smin(), smul_fast(), smul_sat(), srem(), sshl_sat(), and ssub_sat().

getSingleElement()

const APInt * llvm::ConstantRange::getSingleElement ( ) const inline

If this set contains a single element, return it, otherwise return null.

Definition at line 257 of file ConstantRange.h.

Referenced by llvm::ValueLatticeElement::asConstantInteger(), binaryXor(), computeKnownFPClass(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), llvm::AAValueConstantRange::getAssumedConstant(), llvm::LazyValueInfo::getConstant(), llvm::SCCPInstVisitor::getConstant(), llvm::LazyValueInfo::getConstantOnEdge(), getEquivalentICmp(), llvm::SelectionDAG::getVScale(), icmp(), isSingleElement(), multiply(), processSDiv(), processSwitch(), simplifyIntrinsic(), srem(), and urem().

getSingleMissingElement()

const APInt * llvm::ConstantRange::getSingleMissingElement ( ) const inline

getUnsignedMax()

APInt ConstantRange::getUnsignedMax ( ) const

Return the largest unsigned value contained in the ConstantRange.

Definition at line 493 of file ConstantRange.cpp.

References getBitWidth(), llvm::APInt::getMaxValue(), getUpper(), isFullSet(), and isUpperWrapped().

Referenced by binaryAnd(), llvm::SelectionDAG::computeKnownBits(), ctlz(), findContiguousCases(), getActiveBits(), llvm::AArch64TargetMachine::getSubtargetImpl(), getValueFromICmpCtpop(), icmp(), lshr(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), multiply(), mustBeFiniteCountedLoop(), processAnd(), shl(), llvm::simplifyInstruction(), srem(), subWithNoWrap(), toKnownBits(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), and usub_sat().

getUnsignedMin()

APInt ConstantRange::getUnsignedMin ( ) const

Return the smallest unsigned value contained in the ConstantRange.

Definition at line 499 of file ConstantRange.cpp.

References getBitWidth(), getLower(), llvm::APInt::getMinValue(), isFullSet(), and isWrappedSet().

Referenced by binaryOr(), ctlz(), findContiguousCases(), llvm::AArch64TargetMachine::getSubtargetImpl(), getValueFromICmpCtpop(), icmp(), lshr(), makeAllowedICmpRegion(), multiply(), shl(), srem(), toKnownBits(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), ushl_sat(), and usub_sat().

getUpper()

const APInt & llvm::ConstantRange::getUpper ( ) const inline

Return the upper value for this range.

Definition at line 212 of file ConstantRange.h.

Referenced by add(), ctlz(), emitConstantRange(), llvm::Attribute::get(), llvm::Attribute::getAsString(), getEquivalentICmp(), getRangeForAffineARHelper(), getSignedMax(), getUnsignedMax(), llvm::ConstantRangeList::insert(), makeAllowedICmpRegion(), multiply(), llvm::operator<<(), llvm::ConstantRangeList::print(), llvm::AttributeImpl::Profile(), simplifySwitchLookup(), splitGlobal(), sub(), llvm::ConstantRangeList::subtract(), and llvm::ConstantRangeList::unionWith().

icmp()

Does the predicate Pred hold between ranges this and Other?

NOTE: false does not mean that inverse predicate holds!

Definition at line 253 of file ConstantRange.cpp.

References ConstantRange(), contains(), getSignedMax(), getSignedMin(), getSingleElement(), getUnsignedMax(), getUnsignedMin(), 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, inverse(), isEmptySet(), llvm_unreachable, llvm::Other, llvm::APInt::sge(), llvm::APInt::sgt(), llvm::APInt::sle(), llvm::APInt::slt(), llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ule(), and llvm::APInt::ult().

Referenced by expandUDivOrURem(), getDomain(), getPredicateResult(), isImpliedCondCommonOperandWithCR(), processCmpIntrinsic(), processMinMaxIntrinsic(), processSRem(), llvm::simplifyInstruction(), and llvm::InstCombinerImpl::visitCallInst().

intersectWith()

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 591 of file ConstantRange.cpp.

References assert(), ConstantRange(), getBitWidth(), getPreferredRange(), intersectWith(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::APInt::ule(), and llvm::APInt::ult().

Referenced by AddParamAndFnBasicAttributes(), AddReturnAttributes(), areNonOverlapSameBaseLoadAndStore(), binaryAnd(), binaryOr(), binaryXor(), llvm::computeConstantRange(), llvm::computeConstantRangeIncludingKnownBits(), difference(), exactIntersectWith(), exactUnionWith(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), llvm::CallBase::getRange(), llvm::inferAttribute(), llvm::ValueLatticeElement::intersect(), intersectWith(), makeGuaranteedNoWrapRegion(), shlWithNoWrap(), smax(), smin(), splitPosNeg(), umax(), and umin().

intrinsic()

inverse()

Return a new range that is the logical not of the current set.

Definition at line 1965 of file ConstantRange.cpp.

References ConstantRange(), isEmptySet(), and isFullSet().

Referenced by llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(), difference(), exactIntersectWith(), exactUnionWith(), foldICmpUSubSatOrUAddSatWithConstant(), llvm::InstCombinerImpl::foldICmpWithClamp(), getValueFromOverflowCondition(), icmp(), makeSatisfyingICmpRegion(), simplifyICmpWithConstant(), and llvm::simplifyInstruction().

isAllNegative()

bool ConstantRange::isAllNegative ( ) const

isAllNonNegative()

bool ConstantRange::isAllNonNegative ( ) const

isAllPositive()

bool ConstantRange::isAllPositive ( ) const

isEmptySet()

bool ConstantRange::isEmptySet ( ) const

Return true if this set contains no members.

Definition at line 428 of file ConstantRange.cpp.

Referenced by abs(), add(), addWithNoWrap(), areInsensitiveToSignednessOfICmpPredicate(), areInsensitiveToSignednessOfInvertedICmpPredicate(), areNonOverlapSameBaseLoadAndStore(), ashr(), binaryAnd(), binaryOr(), binaryXor(), contains(), ctlz(), ctpop(), cttz(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), getActiveBits(), llvm::AAValueConstantRange::getAssumedConstant(), getEquivalentICmp(), getMinSignedBits(), llvm::ValueLatticeElement::getRange(), icmp(), llvm::ConstantRangeList::insert(), intersectWith(), inverse(), isAllNegative(), isAllPositive(), lshr(), makeAllowedICmpRegion(), makeGuaranteedNoWrapRegion(), llvm::ValueLatticeElement::markConstantRange(), multiply(), multiplyWithNoWrap(), print(), sadd_sat(), shl(), shlWithNoWrap(), signedAddMayOverflow(), signedSubMayOverflow(), signExtend(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithConstant(), smax(), smin(), smul_fast(), smul_sat(), srem(), sshl_sat(), ssub_sat(), sub(), llvm::ConstantRangeList::subtract(), subWithNoWrap(), toKnownBits(), truncate(), uadd_sat(), udiv(), umax(), umin(), umul_sat(), unionWith(), unsignedAddMayOverflow(), unsignedMulMayOverflow(), unsignedSubMayOverflow(), urem(), ushl_sat(), usub_sat(), and zeroExtend().

isFullSet()

bool ConstantRange::isFullSet ( ) const

Return true if this set contains all of the elements possible for this data-type.

Definition at line 424 of file ConstantRange.cpp.

Referenced by add(), addWithNoWrap(), contains(), contains(), ctpop(), cttz(), llvm::Attribute::get(), getEquivalentICmp(), llvm::ValueLatticeElement::getRange(), getRangeForAffineARHelper(), getSignedMax(), getSignedMin(), getUnsignedMax(), getUnsignedMin(), llvm::ConstantRangeList::insert(), llvm::AttributeSet::intersectWith(), intersectWith(), inverse(), isAllNegative(), isAllPositive(), isSizeLargerThan(), isSizeStrictlySmallerThan(), llvm::ValueLatticeElement::markConstantRange(), multiplyWithNoWrap(), print(), signExtend(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithConstant(), llvm::simplifyInstruction(), sub(), llvm::ConstantRangeList::subtract(), subWithNoWrap(), truncate(), unionWith(), llvm::InstCombinerImpl::visitCallInst(), and zeroExtend().

isIntrinsicSupported()

isSignWrappedSet()

bool ConstantRange::isSignWrappedSet ( ) const

isSingleElement()

bool llvm::ConstantRange::isSingleElement ( ) const inline

isSizeLargerThan()

bool ConstantRange::isSizeLargerThan ( uint64_t MaxSize ) const

isSizeStrictlySmallerThan()

isUpperSignWrapped()

bool ConstantRange::isUpperSignWrapped ( ) const

Return true if the (exclusive) upper bound wraps around the signed domain.

Special cases:

Definition at line 444 of file ConstantRange.cpp.

Referenced by getSignedMax(), and isAllNegative().

isUpperWrapped()

bool ConstantRange::isUpperWrapped ( ) const

isWrappedSet()

bool ConstantRange::isWrappedSet ( ) const

lshr()

makeAllowedICmpRegion()

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 109 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), getLower(), llvm::APInt::getMinValue(), getNonEmpty(), getSignedMax(), getSignedMin(), llvm::APInt::getSignedMinValue(), getUnsignedMax(), getUnsignedMin(), getUpper(), llvm::APInt::getZero(), 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, llvm::SMax, llvm::SMin, llvm::UMax, and llvm::UMin.

Referenced by llvm::computeConstantRange(), computeKnownBitsFromCmp(), isImpliedCondCommonOperandWithCR(), isSignificantBitCheckWellFormed(), makeExactICmpRegion(), and makeSatisfyingICmpRegion().

makeExactICmpRegion()

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 169 of file ConstantRange.cpp.

References llvm::CallingConv::C, ConstantRange(), and makeAllowedICmpRegion().

Referenced by cmpExcludesZero(), computeKnownBitsFromOperator(), llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(), llvm::InstCombinerImpl::foldICmpAddConstant(), foldICmpUSubSatOrUAddSatWithConstant(), llvm::InstCombinerImpl::foldICmpWithDominatingICmp(), getEquivalentICmp(), getValueFromICmpCtpop(), llvm::isKnownInversion(), simplifyAndOrOfICmpsWithConstants(), llvm::ScalarEvolution::SimplifyICmpOperands(), simplifyICmpWithConstant(), llvm::simplifyInstruction(), and simplifySwitchOnSelectUsingRanges().

makeExactNoWrapRegion()

makeGuaranteedNoWrapRegion()

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 325 of file ConstantRange.cpp.

References ashr(), assert(), llvm::BitWidth, llvm::CallingConv::C, ConstantRange(), llvm::APInt::getMaxValue(), llvm::APInt::getMinValue(), getNonEmpty(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), getUnsignedMax(), llvm::APInt::getZero(), intersectWith(), llvm::Instruction::isBinaryOp(), isEmptySet(), llvm_unreachable, lshr(), makeExactMulNSWRegion(), makeExactMulNUWRegion(), llvm::Other, llvm::SMax, llvm::SMin, and Unsigned.

Referenced by llvm::ScalarEvolution::getMulExpr(), makeExactNoWrapRegion(), processBinOp(), llvm::refineInstruction(), StrengthenNoWrapFlags(), and willNotOverflow().

makeMaskNotEqualRange()

makeSatisfyingICmpRegion()

multiply()

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 1200 of file ConstantRange.cpp.

References A(), B(), llvm::CallingConv::C, ConstantRange(), getBitWidth(), getSignedMax(), getSignedMin(), getSingleElement(), getUnsignedMax(), getUnsignedMin(), getUpper(), llvm::APInt::getZero(), isEmptySet(), llvm::APInt::isMinSignedValue(), llvm::APInt::isNonNegative(), isSizeStrictlySmallerThan(), isUpperWrapped(), llvm::Other, llvm::APInt::sext(), truncate(), and llvm::APInt::zext().

Referenced by binaryOp(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::isKnownNeverZero(), multiplyWithNoWrap(), and llvm::InstCombinerImpl::visitCallInst().

multiplyWithNoWrap()

Return a new range representing the possible values resulting from a multiplication 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](#a0e6f2069000829208cbac185a07d8082 "If represented precisely, the result of some range operations may consist of multiple disjoint ranges...").

Definition at line 1268 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), getNonEmpty(), getSignedMin(), llvm::APInt::getSignedMinValue(), llvm::APInt::getZero(), isEmptySet(), isFullSet(), multiply(), llvm::OverflowingBinaryOperator::NoSignedWrap, llvm::OverflowingBinaryOperator::NoUnsignedWrap, llvm::Other, smul_sat(), and umul_sat().

Referenced by overflowingBinaryOp().

operator!=()

operator==()

overflowingBinaryOp()

print()

sadd_sat()

sdiv()

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 1394 of file ConstantRange.cpp.

References ConstantRange(), contains(), getBitWidth(), llvm::APInt::getSignedMinValue(), llvm::APInt::getZero(), llvm::Lo, llvm::APInt::sdiv(), sdiv(), Signed, splitPosNeg(), and unionWith().

Referenced by binaryOp(), processSDiv(), and sdiv().

sextOrTrunc()

shl()

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 1675 of file ConstantRange.cpp.

References ConstantRange(), llvm::APInt::countl_one(), llvm::countl_zero(), llvm::APInt::getBitsSetFrom(), getBitWidth(), getNonEmpty(), getUnsignedMax(), getUnsignedMin(), llvm::APInt::getZero(), isAllNegative(), isEmptySet(), llvm::Other, llvm::APInt::ugt(), and llvm::APInt::ule().

Referenced by binaryOp(), and shlWithNoWrap().

shlWithNoWrap()

Return a new range representing the possible values resulting from a left shift 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](#a0e6f2069000829208cbac185a07d8082 "If represented precisely, the result of some range operations may consist of multiple disjoint ranges...").

Definition at line 1796 of file ConstantRange.cpp.

References computeShlNSW(), computeShlNUW(), ConstantRange(), intersectWith(), isEmptySet(), llvm_unreachable, llvm::OverflowingBinaryOperator::NoSignedWrap, llvm::OverflowingBinaryOperator::NoUnsignedWrap, llvm::Other, and shl().

Referenced by overflowingBinaryOp().

signedAddMayOverflow()

Return whether signed add of the two ranges always/never overflows.

Definition at line 2183 of file ConstantRange.cpp.

References AlwaysOverflowsHigh, AlwaysOverflowsLow, ConstantRange(), getBitWidth(), getSignedMax(), llvm::APInt::getSignedMaxValue(), getSignedMin(), llvm::APInt::getSignedMinValue(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), MayOverflow, NeverOverflows, llvm::Other, llvm::APInt::sgt(), and llvm::APInt::slt().

Referenced by computeOverflowForSignedAdd(), and llvm::CombinerHelper::matchAddOverflow().

signedSubMayOverflow()

Return whether signed sub of the two ranges always/never overflows.

Definition at line 2229 of file ConstantRange.cpp.

References AlwaysOverflowsHigh, AlwaysOverflowsLow, ConstantRange(), getBitWidth(), getSignedMax(), llvm::APInt::getSignedMaxValue(), getSignedMin(), llvm::APInt::getSignedMinValue(), isEmptySet(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), MayOverflow, NeverOverflows, llvm::Other, llvm::APInt::sgt(), and llvm::APInt::slt().

Referenced by llvm::computeOverflowForSignedSub(), llvm::SelectionDAG::computeOverflowForSignedSub(), and llvm::CombinerHelper::matchSuboCarryOut().

signExtend()

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 859 of file ConstantRange.cpp.

References assert(), ConstantRange(), getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), isEmptySet(), isFullSet(), and isSignWrappedSet().

Referenced by castOp(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), llvm::ScalarEvolution::getSignExtendExprImpl(), and sextOrTrunc().

smax()

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 1318 of file ConstantRange.cpp.

References ConstantRange(), getNonEmpty(), getSignedMax(), getSignedMin(), intersectWith(), isEmptySet(), isSignWrappedSet(), llvm::Other, Signed, llvm::APIntOps::smax(), and unionWith().

smin()

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 1346 of file ConstantRange.cpp.

References ConstantRange(), getNonEmpty(), getSignedMax(), getSignedMin(), intersectWith(), isEmptySet(), isSignWrappedSet(), llvm::Other, Signed, llvm::APIntOps::smin(), and unionWith().

smul_fast()

smul_sat()

splitPosNeg()

srem()

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 1498 of file ConstantRange.cpp.

References ConstantRange(), getBitWidth(), getSignedMax(), getSignedMin(), getSingleElement(), getUnsignedMax(), getUnsignedMin(), llvm::APInt::getZero(), isEmptySet(), llvm::APInt::isNonNegative(), llvm::APInt::isZero(), llvm::APInt::ugt(), llvm::APIntOps::umax(), and llvm::APIntOps::umin().

Referenced by binaryOp().

sshl_sat()

ssub_sat()

sub()

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 1150 of file ConstantRange.cpp.

References ConstantRange(), getLower(), getUpper(), isEmptySet(), isFullSet(), llvm::Other, and X.

Referenced by binaryNot(), binaryOp(), binaryXor(), computeKnownBitsFromCmp(), foldICmpUSubSatOrUAddSatWithConstant(), llvm::simplifyInstruction(), and subWithNoWrap().

subtract()

subWithNoWrap()

toKnownBits()

KnownBits ConstantRange::toKnownBits ( ) const

Return known bits for values in this range.

Definition at line 80 of file ConstantRange.cpp.

References llvm::APInt::clearLowBits(), getBitWidth(), llvm::APIntOps::GetMostSignificantDifferentBit(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), llvm::KnownBits::makeConstant(), llvm::KnownBits::One, and llvm::KnownBits::Zero.

Referenced by binaryAnd(), binaryOr(), binaryXor(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromCmp(), and computeKnownBitsFromOperator().

truncate()

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 with wrap type NoWrapKind. Note that the result of trunc nuw is exact.

Definition at line 879 of file ConstantRange.cpp.

References assert(), llvm::APInt::clearBit(), ConstantRange(), llvm::APInt::getActiveBits(), llvm::APInt::getBitsSetFrom(), getBitWidth(), llvm::APInt::getMaxValue(), llvm::APInt::getOneBitSet(), llvm::APInt::getZero(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::TruncInst::NoUnsignedWrap, llvm::APInt::setAllBits(), llvm::APInt::trunc(), and llvm::APInt::ult().

Referenced by castOp(), llvm::InstCombinerImpl::foldICmpAddConstant(), llvm::ScalarEvolution::getSignExtendExprImpl(), llvm::ScalarEvolution::getZeroExtendExprImpl(), multiply(), sextOrTrunc(), and zextOrTrunc().

uadd_sat()

udiv()

umax()

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 1332 of file ConstantRange.cpp.

References ConstantRange(), getNonEmpty(), getUnsignedMax(), getUnsignedMin(), intersectWith(), isEmptySet(), isWrappedSet(), llvm::Other, llvm::APIntOps::umax(), unionWith(), and Unsigned.

umin()

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 1360 of file ConstantRange.cpp.

References ConstantRange(), getNonEmpty(), getUnsignedMax(), getUnsignedMin(), intersectWith(), isEmptySet(), isWrappedSet(), llvm::Other, llvm::APIntOps::umin(), unionWith(), and Unsigned.

umul_sat()

unionWith()

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 697 of file ConstantRange.cpp.

References assert(), ConstantRange(), getBitWidth(), getPreferredRange(), isEmptySet(), isFullSet(), isUpperWrapped(), llvm::APInt::uge(), llvm::APInt::ugt(), llvm::APInt::ule(), llvm::APInt::ult(), and unionWith().

Referenced by llvm::computeConstantRange(), computeShlNSW(), ctpop(), cttz(), exactIntersectWith(), exactUnionWith(), llvm::getConstantRangeFromMetadata(), llvm::AttributeSet::intersectWith(), sdiv(), smax(), smin(), llvm::Constant::toConstantRange(), tryMergeRange(), umax(), umin(), and unionWith().

unsignedAddMayOverflow()

Return whether unsigned add of the two ranges always/never overflows.

Definition at line 2167 of file ConstantRange.cpp.

References AlwaysOverflowsHigh, ConstantRange(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), MayOverflow, NeverOverflows, llvm::Other, and llvm::APInt::ugt().

Referenced by llvm::computeOverflowForUnsignedAdd(), llvm::SelectionDAG::computeOverflowForUnsignedAdd(), and llvm::CombinerHelper::matchAddOverflow().

unsignedMulMayOverflow()

unsignedSubMayOverflow()

Return whether unsigned sub of the two ranges always/never overflows.

Definition at line 2213 of file ConstantRange.cpp.

References AlwaysOverflowsLow, ConstantRange(), getUnsignedMax(), getUnsignedMin(), isEmptySet(), MayOverflow, NeverOverflows, llvm::Other, and llvm::APInt::ult().

Referenced by llvm::computeOverflowForUnsignedSub(), llvm::SelectionDAG::computeOverflowForUnsignedSub(), and llvm::CombinerHelper::matchSuboCarryOut().

urem()

ushl_sat()

usub_sat()

zeroExtend()

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 840 of file ConstantRange.cpp.

References assert(), ConstantRange(), getBitWidth(), llvm::APInt::getOneBitSet(), isEmptySet(), isFullSet(), isUpperWrapped(), and llvm::APInt::zext().

Referenced by castOp(), llvm::SelectionDAG::ComputeNumSignBits(), computeNumSignBitsFromRangeMetadata(), llvm::ScalarEvolution::getZeroExtendExprImpl(), and zextOrTrunc().

zextOrTrunc()


The documentation for this class was generated from the following files: