Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Public Types |Public Member Functions |Static Public Member Functions |List of all members
llvm::ConstantRange Class Reference

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 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

 ConstantRange (uint32_tBitWidth,boolisFullSet)
 Initialize a full or empty set for the specified bit width.
 
 ConstantRange (APIntValue)
 Initialize a range to hold the single specified value.
 
 ConstantRange (APInt Lower,APInt Upper)
 Initialize a range of values explicitly.
 
bool icmp (CmpInst::Predicate Pred,constConstantRange &Other)const
 Does the predicatePred hold between ranges this andOther? NOTE: false does not mean that inverse predicate holds!
 
bool getEquivalentICmp (CmpInst::Predicate &Pred,APInt &RHS)const
 Set upPred andRHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this.
 
void getEquivalentICmp (CmpInst::Predicate &Pred,APInt &RHS,APInt &Offset)const
 Set upPred,RHS andOffset such that (V + Offset) Pred RHS is true iff V is in the range.
 
constAPIntgetLower ()const
 Return the lower value for this range.
 
constAPIntgetUpper ()const
 Return the upper value for this range.
 
uint32_t getBitWidth ()const
 Get the bit width of thisConstantRange.
 
bool isFullSet ()const
 Return true if this set contains all of the elements possible for this data-type.
 
bool isEmptySet ()const
 Return true if this set contains no members.
 
bool isWrappedSet ()const
 Return true if this set wraps around the unsigned domain.
 
bool isUpperWrapped ()const
 Return true if the exclusive upper bound wraps around the unsigned domain.
 
bool isSignWrappedSet ()const
 Return true if this set wraps around the signed domain.
 
bool isUpperSignWrapped ()const
 Return true if the (exclusive) upper bound wraps around the signed domain.
 
bool contains (constAPInt &Val)const
 Return true if the specified value is in the set.
 
bool contains (constConstantRange &CR)const
 Return true if the other range is a subset of this one.
 
constAPIntgetSingleElement ()const
 If this set contains a single element, return it, otherwise return null.
 
constAPIntgetSingleMissingElement ()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.
 
bool isSizeStrictlySmallerThan (constConstantRange &CR)const
 Compare set size of this range with the range CR.
 
bool isSizeLargerThan (uint64_t MaxSize)const
 Compare set size of this range withValue.
 
bool isAllNegative ()const
 Return true if all values in this range are negative.
 
bool isAllNonNegative ()const
 Return true if all values in this range are non-negative.
 
bool isAllPositive ()const
 Return true if all values in this range are positive.
 
APInt getUnsignedMax ()const
 Return the largest unsigned value contained in theConstantRange.
 
APInt getUnsignedMin ()const
 Return the smallest unsigned value contained in theConstantRange.
 
APInt getSignedMax ()const
 Return the largest signed value contained in theConstantRange.
 
APInt getSignedMin ()const
 Return the smallest signed value contained in theConstantRange.
 
bool operator== (constConstantRange &CR)const
 Return true if this range is equal to another range.
 
bool operator!= (constConstantRange &CR)const
 
unsigned getActiveBits ()const
 Compute the maximal number of active bits needed to represent every value in this range.
 
unsigned getMinSignedBits ()const
 Compute the maximal number of bits needed to represent every value in this signed range.
 
ConstantRange subtract (constAPInt &CI)const
 Subtract the specified constant from the endpoints of this constant range.
 
ConstantRange difference (constConstantRange &CR)const
 Subtract the specified range from this range (aka relative complement of the sets).
 
ConstantRange intersectWith (constConstantRange &CR,PreferredRangeTypeType=Smallest)const
 Return the range that results from the intersection of this range with another range.
 
ConstantRange unionWith (constConstantRange &CR,PreferredRangeTypeType=Smallest)const
 Return the range that results from the union of this range with another range.
 
std::optional<ConstantRangeexactIntersectWith (constConstantRange &CR)const
 Intersect the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.
 
std::optional<ConstantRangeexactUnionWith (constConstantRange &CR)const
 Union the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.
 
ConstantRange castOp (Instruction::CastOps CastOp,uint32_tBitWidth)const
 Return a new range representing the possible values resulting from an application of the specified cast operator to this range.
 
ConstantRange zeroExtend (uint32_tBitWidth)const
 Return a new range in the specified integer type, which must be strictly larger than the current type.
 
ConstantRange signExtend (uint32_tBitWidth)const
 Return a new range in the specified integer type, which must be strictly larger than the current type.
 
ConstantRange truncate (uint32_tBitWidth)const
 Return a new range in the specified integer type, which must be strictly smaller than the current type.
 
ConstantRange zextOrTrunc (uint32_tBitWidth)const
 Make this range have the bit width given byBitWidth.
 
ConstantRange sextOrTrunc (uint32_tBitWidth)const
 Make this range have the bit width given byBitWidth.
 
ConstantRange binaryOp (Instruction::BinaryOps BinOp,constConstantRange &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 ofOther.
 
ConstantRange overflowingBinaryOp (Instruction::BinaryOps BinOp,constConstantRange &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 ofOther given the provided knowledge about lack of wrappingNoWrapKind.
 
ConstantRange add (constConstantRange &Other)const
 Return a new range representing the possible values resulting from an addition of a value in this range and a value inOther.
 
ConstantRange addWithNoWrap (constConstantRange &Other,unsigned NoWrapKind,PreferredRangeType RangeType=Smallest)const
 Return a new range representing the possible values resulting from an addition with wrap typeNoWrapKind of a value in this range and a value inOther.
 
ConstantRange sub (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a subtraction of a value in this range and a value inOther.
 
ConstantRange subWithNoWrap (constConstantRange &Other,unsigned NoWrapKind,PreferredRangeType RangeType=Smallest)const
 Return a new range representing the possible values resulting from an subtraction with wrap typeNoWrapKind of a value in this range and a value inOther.
 
ConstantRange multiply (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a multiplication of a value in this range and a value inOther, treating both this andOther as unsigned ranges.
 
ConstantRange multiplyWithNoWrap (constConstantRange &Other,unsigned NoWrapKind,PreferredRangeType RangeType=Smallest)const
 Return a new range representing the possible values resulting from a multiplication with wrap typeNoWrapKind of a value in this range and a value inOther.
 
ConstantRange smul_fast (constConstantRange &Other)const
 Return range of possible values for a signed multiplication of this andOther.
 
ConstantRange smax (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a signed maximum of a value in this range and a value inOther.
 
ConstantRange umax (constConstantRange &Other)const
 Return a new range representing the possible values resulting from an unsigned maximum of a value in this range and a value inOther.
 
ConstantRange smin (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a signed minimum of a value in this range and a value inOther.
 
ConstantRange umin (constConstantRange &Other)const
 Return a new range representing the possible values resulting from an unsigned minimum of a value in this range and a value inOther.
 
ConstantRange udiv (constConstantRange &Other)const
 Return a new range representing the possible values resulting from an unsigned division of a value in this range and a value inOther.
 
ConstantRange sdiv (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a signed division of a value in this range and a value inOther.
 
ConstantRange urem (constConstantRange &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 inOther.
 
ConstantRange srem (constConstantRange &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 inOther.
 
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.
 
ConstantRange binaryAnd (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a binary-and of a value in this range by a value inOther.
 
ConstantRange binaryOr (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a binary-or of a value in this range by a value inOther.
 
ConstantRange binaryXor (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a binary-xor of a value in this range by a value inOther.
 
ConstantRange shl (constConstantRange &Other)const
 Return a new range representing the possible values resulting from a left shift of a value in this range by a value inOther.
 
ConstantRange shlWithNoWrap (constConstantRange &Other,unsigned NoWrapKind,PreferredRangeType RangeType=Smallest)const
 Return a new range representing the possible values resulting from a left shift with wrap typeNoWrapKind of a value in this range and a value inOther.
 
ConstantRange lshr (constConstantRange &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 inOther.
 
ConstantRange ashr (constConstantRange &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 inOther.
 
ConstantRange uadd_sat (constConstantRange &Other)const
 Perform an unsigned saturating addition of two constant ranges.
 
ConstantRange sadd_sat (constConstantRange &Other)const
 Perform a signed saturating addition of two constant ranges.
 
ConstantRange usub_sat (constConstantRange &Other)const
 Perform an unsigned saturating subtraction of two constant ranges.
 
ConstantRange ssub_sat (constConstantRange &Other)const
 Perform a signed saturating subtraction of two constant ranges.
 
ConstantRange umul_sat (constConstantRange &Other)const
 Perform an unsigned saturating multiplication of two constant ranges.
 
ConstantRange smul_sat (constConstantRange &Other)const
 Perform a signed saturating multiplication of two constant ranges.
 
ConstantRange ushl_sat (constConstantRange &Other)const
 Perform an unsigned saturating left shift of this constant range by a value inOther.
 
ConstantRange sshl_sat (constConstantRange &Other)const
 Perform a signed saturating left shift of this constant range by a value inOther.
 
ConstantRange inverse ()const
 Return a new range that is the logical not of the current set.
 
ConstantRange abs (bool IntMinIsPoison=false)const
 Calculate absolute value range.
 
ConstantRange ctlz (bool ZeroIsPoison=false)const
 Calculate ctlz range.
 
ConstantRange cttz (bool ZeroIsPoison=false)const
 Calculate cttz range.
 
ConstantRange ctpop ()const
 Calculate ctpop range.
 
OverflowResult unsignedAddMayOverflow (constConstantRange &Other)const
 Return whether unsigned add of the two ranges always/never overflows.
 
OverflowResult signedAddMayOverflow (constConstantRange &Other)const
 Return whether signed add of the two ranges always/never overflows.
 
OverflowResult unsignedSubMayOverflow (constConstantRange &Other)const
 Return whether unsigned sub of the two ranges always/never overflows.
 
OverflowResult signedSubMayOverflow (constConstantRange &Other)const
 Return whether signed sub of the two ranges always/never overflows.
 
OverflowResult unsignedMulMayOverflow (constConstantRange &Other)const
 Return whether unsigned mul of the two ranges always/never overflows.
 
KnownBits toKnownBits ()const
 Return known bits for values in this range.
 
void print (raw_ostream &OS)const
 Print out the bounds to a stream.
 
void dump ()const
 Allow printing from a debugger easily.
 

Static Public Member Functions

staticConstantRange getEmpty (uint32_tBitWidth)
 Create empty constant range with the given bit width.
 
staticConstantRange getFull (uint32_tBitWidth)
 Create full constant range with the given bit width.
 
staticConstantRange getNonEmpty (APInt Lower,APInt Upper)
 Create non-empty constant range with the given bounds.
 
staticConstantRange fromKnownBits (constKnownBits &Known,bool IsSigned)
 Initialize a range based on a known bits constraint.
 
staticConstantRange makeAllowedICmpRegion (CmpInst::Predicate Pred,constConstantRange &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.
 
staticConstantRange makeSatisfyingICmpRegion (CmpInst::Predicate Pred,constConstantRange &Other)
 Produce the largest range such that all values in the returned range satisfy the given predicate with all values contained within Other.
 
staticConstantRange makeExactICmpRegion (CmpInst::Predicate Pred,constAPInt &Other)
 Produce the exact range such that all values in the returned range satisfy the given predicate with any value contained within Other.
 
staticbool areInsensitiveToSignednessOfICmpPredicate (constConstantRange &CR1,constConstantRange &CR2)
 Return true iff CR1 ult CR2 is equivalent to CR1 slt CR2.
 
staticbool areInsensitiveToSignednessOfInvertedICmpPredicate (constConstantRange &CR1,constConstantRange &CR2)
 Return true iff CR1 ult CR2 is equivalent to CR1 sge CR2.
 
staticCmpInst::Predicate getEquivalentPredWithFlippedSignedness (CmpInst::Predicate Pred,constConstantRange &CR1,constConstantRange &CR2)
 If the comparison between constant ranges this and Other is insensitive to the signedness of the comparison predicate, return a predicate equivalent toPred, with flipped signedness (i.e.
 
staticConstantRange makeGuaranteedNoWrapRegion (Instruction::BinaryOps BinOp,constConstantRange &Other,unsigned NoWrapKind)
 Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow) forall Y in Other.
 
staticConstantRange makeExactNoWrapRegion (Instruction::BinaryOps BinOp,constAPInt &Other,unsigned NoWrapKind)
 Produce the range that contains X if and only if "X BinOp Other" does not wrap.
 
staticConstantRange makeMaskNotEqualRange (constAPInt &Mask,constAPInt &C)
 Initialize a range containing all values X that satisfy(X & Mask) != C.
 
staticbool isIntrinsicSupported (Intrinsic::ID IntrinsicID)
 Returns true ifConstantRange calculations are supported for intrinsic withIntrinsicID.
 
staticConstantRange intrinsic (Intrinsic::ID IntrinsicID,ArrayRef<ConstantRange > Ops)
 Compute range of intrinsic result for the given operand ranges.
 

Detailed Description

This class represents a range of values.

Definition at line47 of fileConstantRange.h.

Member Enumeration Documentation

◆ OverflowResult

enum classllvm::ConstantRange::OverflowResult
strong

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 line567 of fileConstantRange.h.

◆ PreferredRangeType

enumllvm::ConstantRange::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 line327 of fileConstantRange.h.

Constructor & Destructor Documentation

◆ ConstantRange()[1/3]

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

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

Definition at line45 of fileConstantRange.cpp.

◆ ConstantRange()[2/3]

ConstantRange::ConstantRange(APInt Value)

Initialize a range to hold the single specified value.

Definition at line49 of fileConstantRange.cpp.

◆ 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 twoAPInt's are not the same bit width.

Definition at line52 of fileConstantRange.cpp.

Referencesassert(),llvm::APInt::getBitWidth(),llvm::APInt::isMaxValue(), andllvm::APInt::isMinValue().

Member Function Documentation

◆ abs()

ConstantRange ConstantRange::abs(bool IntMinIsPoison =false) const

Calculate absolute value range.

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

Definition at line1943 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getNonEmpty(),getSignedMax(),getSignedMin(),llvm::APInt::getSignedMinValue(),llvm::APInt::getZero(),isEmptySet(),isSignWrappedSet(),llvm::APInt::isStrictlyPositive(),llvm::Lo,llvm::SMax,llvm::SMin,llvm::APIntOps::umax(), andllvm::APIntOps::umin().

Referenced byprocessSRem().

◆ add()

ConstantRange ConstantRange::add(constConstantRangeOther) const

Return a new range representing the possible values resulting from an addition of a value in this range and a value inOther.

Definition at line1067 of fileConstantRange.cpp.

ReferencesgetLower(),getUpper(),isEmptySet(),isFullSet(),llvm::Other, andX.

Referenced byaddWithNoWrap(),binaryOp(),llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(),foldICmpUSubSatOrUAddSatWithConstant(), andgetEquivalentICmp().

◆ addWithNoWrap()

ConstantRange ConstantRange::addWithNoWrap(constConstantRangeOther,
unsigned NoWrapKind,
PreferredRangeType RangeType =Smallest 
) const

Return a new range representing the possible values resulting from an addition with wrap typeNoWrapKind of a value in this range and a value inOther.

If the result range is disjoint, the preferred range is determined by thePreferredRangeType.

Definition at line1086 of fileConstantRange.cpp.

Referencesadd(),isEmptySet(),isFullSet(),llvm::Other,sadd_sat(), anduadd_sat().

Referenced byoverflowingBinaryOp().

◆ areInsensitiveToSignednessOfICmpPredicate()

bool ConstantRange::areInsensitiveToSignednessOfICmpPredicate(constConstantRangeCR1,
constConstantRangeCR2 
)
static

Return true iff CR1 ult CR2 is equivalent to CR1 slt CR2.

Does not depend on strictness/direction of the predicate.

Definition at line170 of fileConstantRange.cpp.

ReferencesisAllNegative(),isAllNonNegative(), andisEmptySet().

Referenced bygetEquivalentPredWithFlippedSignedness(),processICmp(), andprocessMinMaxIntrinsic().

◆ areInsensitiveToSignednessOfInvertedICmpPredicate()

bool ConstantRange::areInsensitiveToSignednessOfInvertedICmpPredicate(constConstantRangeCR1,
constConstantRangeCR2 
)
static

Return true iff CR1 ult CR2 is equivalent to CR1 sge CR2.

Does not depend on strictness/direction of the predicate.

Definition at line179 of fileConstantRange.cpp.

ReferencesisAllNegative(),isAllNonNegative(), andisEmptySet().

Referenced bygetEquivalentPredWithFlippedSignedness().

◆ ashr()

ConstantRange ConstantRange::ashr(constConstantRangeOther) const

Return a new range representing the possible values resulting from a arithmetic right shift of a value in this range and a value inOther.

Definition at line1799 of fileConstantRange.cpp.

Referencesllvm::APInt::ashr(),getNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::max(), andllvm::Other.

Referenced bybinaryOp(), andmakeGuaranteedNoWrapRegion().

◆ binaryAnd()

ConstantRange ConstantRange::binaryAnd(constConstantRangeOther) const

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

Definition at line1580 of fileConstantRange.cpp.

ReferencesestimateBitMaskedAndLowerBound(),fromKnownBits(),getNonEmpty(),getUnsignedMax(),intersectWith(),isEmptySet(),llvm::Other,toKnownBits(), andllvm::APIntOps::umin().

Referenced bybinaryOp(), andcanScalarizeAccess().

◆ binaryNot()

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

Definition at line1519 of fileConstantRange.cpp.

Referencesllvm::APInt::getAllOnes(),getBitWidth(), andsub().

Referenced bybinaryOr(), andbinaryXor().

◆ binaryOp()

ConstantRange ConstantRange::binaryOp(Instruction::BinaryOps BinOp,
constConstantRangeOther 
) 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 ofOther.

Definition at line935 of fileConstantRange.cpp.

Referencesadd(),ashr(),assert(),binaryAnd(),binaryOr(),binaryXor(),llvm::Instruction::isBinaryOp(),lshr(),multiply(),llvm::Other,sdiv(),shl(),srem(),sub(),udiv(), andurem().

Referenced byoverflowingBinaryOp().

◆ binaryOr()

ConstantRange ConstantRange::binaryOr(constConstantRangeOther) const

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

Definition at line1592 of fileConstantRange.cpp.

ReferencesbinaryNot(),estimateBitMaskedAndLowerBound(),fromKnownBits(),getNonEmpty(),getUnsignedMin(),intersectWith(),isEmptySet(),llvm::Other,toKnownBits(), andllvm::APIntOps::umax().

Referenced bybinaryOp().

◆ binaryXor()

ConstantRange ConstantRange::binaryXor(constConstantRangeOther) const

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

Definition at line1612 of fileConstantRange.cpp.

ReferencesbinaryNot(),fromKnownBits(),getBitWidth(),getSingleElement(),intersectWith(),isEmptySet(),isSingleElement(),llvm::KnownBits::One,llvm::Other,sub(),toKnownBits(),Unsigned, andllvm::KnownBits::Zero.

Referenced bybinaryOp().

◆ castOp()

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 line778 of fileConstantRange.cpp.

ReferencesgetBitWidth(),llvm::APInt::getMaxValue(),llvm::APInt::getMinValue(),getNonEmpty(),llvm::APInt::getSignedMaxValue(),llvm::APInt::getSignedMinValue(),llvm_unreachable,signExtend(),llvm::SMax,llvm::SMin,truncate(),zeroExtend(), andllvm::APInt::zext().

◆ contains()[1/2]

bool ConstantRange::contains(constAPIntVal) const

Return true if the specified value is in the set.

Definition at line507 of fileConstantRange.cpp.

ReferencesisFullSet(),isUpperWrapped(), andllvm::APInt::ule().

Referenced bycanScalarizeAccess(),cmpExcludesZero(),llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(),llvm::copyRangeMetadata(),ctlz(),cttz(),foldCtpop(),llvm::ScalarEvolution::getMulExpr(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getRangeForAffineARHelper(),llvm::ScalarEvolution::getSignExtendExprImpl(),llvm::ScalarEvolution::getTripCountFromExitCount(),llvm::ScalarEvolution::getZeroExtendExprImpl(),icmp(),llvm::is_contained(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),llvm::SelectionDAG::isKnownNeverZero(),isKnownNonZero(),isKnownNonZeroFromOperator(),llvm::ValueLatticeElement::markConstantRange(),narrowSDivOrSRem(),processAbsIntrinsic(),processAShr(),processBinOp(),rangeMetadataExcludesValue(),sdiv(),simplifyICmpWithConstant(),simplifySwitchOnSelectUsingRanges(),SolveQuadraticAddRecRange(),splitGlobal(), andwillNotOverflow().

◆ contains()[2/2]

bool ConstantRange::contains(constConstantRangeCR) const

Return true if the other range is a subset of this one.

Definition at line516 of fileConstantRange.cpp.

ReferencesisEmptySet(),isFullSet(),isUpperWrapped(),llvm::Other, andllvm::APInt::ule().

◆ ctlz()

ConstantRange ConstantRange::ctlz(bool ZeroIsPoison =false) const

Calculate ctlz range.

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

Definition at line1985 of fileConstantRange.cpp.

Referencescontains(),llvm::countl_zero(),getBitWidth(),getLower(),getNonEmpty(),getUnsignedMax(),getUnsignedMin(),getUpper(),llvm::APInt::getZero(),isEmptySet(), andisZero().

◆ ctpop()

ConstantRange ConstantRange::ctpop() const

Calculate ctpop range.

Definition at line2117 of fileConstantRange.cpp.

Referencesllvm::BitWidth,llvm::APInt::countl_one(),getBitWidth(),getNonEmpty(),getUnsignedPopCountRange(),llvm::APInt::getZero(),isEmptySet(),isFullSet(),isWrappedSet(), andunionWith().

◆ cttz()

ConstantRange ConstantRange::cttz(bool ZeroIsPoison =false) const

Calculate cttz range.

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

Definition at line2045 of fileConstantRange.cpp.

Referencesllvm::BitWidth,contains(),getBitWidth(),getNonEmpty(),getUnsignedCountTrailingZerosRange(),llvm::APInt::getZero(),isEmptySet(),isFullSet(),isWrappedSet(),llvm::APInt::isZero(), andunionWith().

◆ difference()

ConstantRange ConstantRange::difference(constConstantRangeCR) const

Subtract the specified range from this range (aka relative complement of the sets).

Definition at line557 of fileConstantRange.cpp.

ReferencesintersectWith(), andinverse().

Referenced byllvm::InstCombinerImpl::foldICmpWithDominatingICmp().

◆ dump()

LLVM_DUMP_METHOD void ConstantRange::dump() const

Allow printing from a debugger easily.

Definition at line2259 of fileConstantRange.cpp.

Referencesllvm::dbgs(), andprint().

◆ exactIntersectWith()

std::optional<ConstantRange > ConstantRange::exactIntersectWith(constConstantRangeCR) const

Intersect the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.

Definition at line761 of fileConstantRange.cpp.

ReferencesintersectWith(),inverse(), andunionWith().

Referenced byfoldICmpUSubSatOrUAddSatWithConstant().

◆ exactUnionWith()

std::optional<ConstantRange > ConstantRange::exactUnionWith(constConstantRangeCR) const

Union the two ranges and return the result if it can be represented exactly, otherwise return std::nullopt.

Definition at line770 of fileConstantRange.cpp.

ReferencesintersectWith(),inverse(), andunionWith().

Referenced byfoldICmpUSubSatOrUAddSatWithConstant().

◆ fromKnownBits()

ConstantRange ConstantRange::fromKnownBits(constKnownBitsKnown,
bool IsSigned 
)
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 line60 of fileConstantRange.cpp.

Referencesllvm::APInt::clearSignBit(),llvm::KnownBits::getBitWidth(),llvm::KnownBits::getMaxValue(),llvm::KnownBits::getMinValue(),llvm::KnownBits::hasConflict(),llvm::KnownBits::isNegative(),llvm::KnownBits::isNonNegative(), andllvm::KnownBits::isUnknown().

Referenced bybinaryAnd(),binaryOr(),binaryXor(),llvm::computeConstantRangeIncludingKnownBits(),llvm::SelectionDAG::computeOverflowForSignedSub(),llvm::SelectionDAG::computeOverflowForUnsignedAdd(),llvm::computeOverflowForUnsignedMul(),llvm::SelectionDAG::computeOverflowForUnsignedMul(),llvm::SelectionDAG::computeOverflowForUnsignedSub(),llvm::SelectionDAG::getValidShiftAmountRange(),llvm::CombinerHelper::matchAddOverflow(), andllvm::CombinerHelper::matchSuboCarryOut().

◆ getActiveBits()

unsigned ConstantRange::getActiveBits() const

Compute the maximal number of active bits needed to represent every value in this range.

Definition at line534 of fileConstantRange.cpp.

Referencesllvm::APInt::getActiveBits(),getUnsignedMax(), andisEmptySet().

Referenced byllvm::TargetLoweringBase::getBitWidthForCttzElements(),narrowUDivOrURem(), andllvm::refineInstruction().

◆ getBitWidth()

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

Get the bit width of thisConstantRange.

Definition at line209 of fileConstantRange.h.

Referenced byabs(),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(),isKnownNonZero(),isKnownNonZeroFromOperator(),isSizeLargerThan(),isSizeStrictlySmallerThan(),makeAllowedICmpRegion(),multiply(),multiplyWithNoWrap(),sdiv(),sextOrTrunc(),shl(),signedAddMayOverflow(),signedSubMayOverflow(),signExtend(),srem(),subtract(),llvm::ConstantRangeList::subtract(),toKnownBits(),truncate(),llvm::AttributeFuncs::typeIncompatible(),unionWith(),urem(),zeroExtend(), andzextOrTrunc().

◆ getEmpty()

staticConstantRange llvm::ConstantRange::getEmpty(uint32_t BitWidth)
inlinestatic

Create empty constant range with the given bit width.

Definition at line73 of fileConstantRange.h.

ReferencesBitWidth.

◆ getEquivalentICmp()[1/2]

bool ConstantRange::getEquivalentICmp(CmpInst::PredicatePred,
APIntRHS 
) const

Set upPred andRHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this.

Return true if successful.

Definition at line236 of fileConstantRange.cpp.

ReferencesgetEquivalentICmp(),llvm::Offset, andRHS.

Referenced byllvm::InstCombinerImpl::foldICmpAddConstant(),getEquivalentICmp(), andllvm::ScalarEvolution::SimplifyICmpOperands().

◆ getEquivalentICmp()[2/2]

void ConstantRange::getEquivalentICmp(CmpInst::PredicatePred,
APIntRHS,
APIntOffset 
) const

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

Prefers using Offset == 0 if possible.

Definition at line206 of fileConstantRange.cpp.

Referencesadd(),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(),llvm::Offset, andRHS.

◆ getEquivalentPredWithFlippedSignedness()

CmpInst::Predicate ConstantRange::getEquivalentPredWithFlippedSignedness(CmpInst::Predicate Pred,
constConstantRangeCR1,
constConstantRangeCR2 
)
static

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

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

Definition at line188 of fileConstantRange.cpp.

ReferencesareInsensitiveToSignednessOfICmpPredicate(),areInsensitiveToSignednessOfInvertedICmpPredicate(),assert(),llvm::CmpInst::BAD_ICMP_PREDICATE,llvm::ICmpInst::getFlippedSignednessPredicate(),llvm::CmpInst::getInversePredicate(),llvm::CmpInst::isIntPredicate(), andllvm::CmpInst::isRelational().

Referenced byprocessICmp().

◆ getFull()

staticConstantRange llvm::ConstantRange::getFull(uint32_t BitWidth)
inlinestatic

Create full constant range with the given bit width.

Definition at line78 of fileConstantRange.h.

ReferencesBitWidth.

◆ getLower()

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

Return the lower value for this range.

Definition at line203 of fileConstantRange.h.

Referenced byadd(),ctlz(),emitConstantRange(),llvm::Attribute::get(),llvm::Attribute::getAsString(),getEquivalentICmp(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getRangeForAffineARHelper(),getSignedMin(),getUnsignedMin(),llvm::ConstantRangeList::insert(),llvm::ConstantRangeList::intersectWith(),llvm::ConstantRangeList::isOrderedRanges(),lowerKernelArguments(),makeAllowedICmpRegion(),llvm::operator<<(),llvm::ConstantRangeList::print(),llvm::AttributeImpl::Profile(),SolveQuadraticAddRecRange(),splitGlobal(),sub(),llvm::ConstantRangeList::subtract(),llvm::ConstantRangeList::unionWith(), andwriteFunctionTypeMetadataRecords().

◆ getMinSignedBits()

unsigned ConstantRange::getMinSignedBits() const

Compute the maximal number of bits needed to represent every value in this signed range.

Definition at line541 of fileConstantRange.cpp.

ReferencesgetSignedMax(),getSignedMin(), andisEmptySet().

Referenced bynarrowSDivOrSRem(), andllvm::refineInstruction().

◆ getNonEmpty()

staticConstantRange llvm::ConstantRange::getNonEmpty(APInt Lower,
APInt Upper 
)
inlinestatic

Create non-empty constant range with the given bounds.

If Lower and Upper are the same, a full range is returned.

Definition at line84 of fileConstantRange.h.

Referencesllvm::Upper.

Referenced byabs(),ashr(),binaryAnd(),binaryOr(),castOp(),llvm::computeConstantRange(),computeShlNSWWithNegLHS(),computeShlNSWWithNNegLHS(),computeShlNUW(),ctlz(),ctpop(),cttz(),getRangeForAffineARHelper(),getRangeForIntrinsic(),getRangeForSelectPattern(),getValueFromICmpCtpop(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),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(), andusub_sat().

◆ getSignedMax()

APInt ConstantRange::getSignedMax() const

Return the largest signed value contained in theConstantRange.

Definition at line495 of fileConstantRange.cpp.

ReferencesgetBitWidth(),llvm::APInt::getSignedMaxValue(),getUpper(),isFullSet(), andisUpperSignWrapped().

Referenced byabs(),ashr(),llvm::SelectionDAG::ComputeNumSignBits(),computeNumSignBitsFromRangeMetadata(),getMinSignedBits(),llvm::ScalarEvolution::getSignedRangeMax(),icmp(),makeAllowedICmpRegion(),multiply(),processAbsIntrinsic(),sadd_sat(),signedAddMayOverflow(),signedSubMayOverflow(),smax(),smin(),smul_fast(),smul_sat(),srem(),sshl_sat(),ssub_sat(), andstripAndAccumulateOffsets().

◆ getSignedMin()

APInt ConstantRange::getSignedMin() const

Return the smallest signed value contained in theConstantRange.

Definition at line501 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getLower(),llvm::APInt::getSignedMinValue(),isFullSet(), andisSignWrappedSet().

Referenced byabs(),ashr(),computeKnownFPClass(),llvm::SelectionDAG::ComputeNumSignBits(),computeNumSignBitsFromRangeMetadata(),getMinSignedBits(),llvm::ScalarEvolution::getSignedRangeMin(),icmp(),makeAllowedICmpRegion(),multiply(),multiplyWithNoWrap(),sadd_sat(),signedAddMayOverflow(),signedSubMayOverflow(),smax(),smin(),smul_fast(),smul_sat(),srem(),sshl_sat(),ssub_sat(), andstripAndAccumulateOffsets().

◆ getSingleElement()

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

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

Definition at line251 of fileConstantRange.h.

Referencesllvm::Upper.

Referenced byllvm::ValueLatticeElement::asConstantInteger(),binaryXor(),computeKnownFPClass(),llvm::InstCombinerImpl::foldICmpWithDominatingICmp(),llvm::AAValueConstantRange::getAssumedConstant(),llvm::SCCPInstVisitor::getConstant(),llvm::LazyValueInfo::getConstant(),llvm::LazyValueInfo::getConstantOnEdge(),getEquivalentICmp(),llvm::SelectionDAG::getVScale(),icmp(),multiply(),processSDiv(),simplifyIntrinsic(),srem(), andurem().

◆ getSingleMissingElement()

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

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

Definition at line259 of fileConstantRange.h.

Referencesllvm::Upper.

Referenced bygetEquivalentICmp().

◆ getUnsignedMax()

APInt ConstantRange::getUnsignedMax() const

Return the largest unsigned value contained in theConstantRange.

Definition at line483 of fileConstantRange.cpp.

ReferencesgetBitWidth(),llvm::APInt::getMaxValue(),getUpper(),isFullSet(), andisUpperWrapped().

Referenced byllvm::SCEVAAResult::alias(),binaryAnd(),llvm::SelectionDAG::computeKnownBits(),computeKnownBitsFromOperator(),llvm::computeKnownBitsFromRangeMetadata(),ctlz(),getActiveBits(),llvm::AArch64TargetMachine::getSubtargetImpl(),llvm::ScalarEvolution::getUnsignedRangeMax(),getValueFromICmpCtpop(),icmp(),lshr(),makeAllowedICmpRegion(),makeGuaranteedNoWrapRegion(),multiply(),mustBeFiniteCountedLoop(),processAnd(),shl(),srem(),subWithNoWrap(),toKnownBits(),uadd_sat(),udiv(),umax(),umin(),umul_sat(),unsignedAddMayOverflow(),unsignedMulMayOverflow(),unsignedSubMayOverflow(),urem(),ushl_sat(), andusub_sat().

◆ getUnsignedMin()

APInt ConstantRange::getUnsignedMin() const

Return the smallest unsigned value contained in theConstantRange.

Definition at line489 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getLower(),llvm::APInt::getMinValue(),isFullSet(), andisWrappedSet().

Referenced byllvm::SCEVAAResult::alias(),binaryOr(),llvm::computeKnownBitsFromRangeMetadata(),ctlz(),llvm::AArch64TargetMachine::getSubtargetImpl(),llvm::ScalarEvolution::getUnsignedRangeMin(),getValueFromICmpCtpop(),icmp(),lshr(),makeAllowedICmpRegion(),multiply(),shl(),srem(),toKnownBits(),uadd_sat(),udiv(),umax(),umin(),umul_sat(),unsignedAddMayOverflow(),unsignedMulMayOverflow(),unsignedSubMayOverflow(),ushl_sat(), andusub_sat().

◆ getUpper()

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

Return the upper value for this range.

Definition at line206 of fileConstantRange.h.

Referencesllvm::Upper.

Referenced byadd(),ctlz(),emitConstantRange(),llvm::Attribute::get(),llvm::Attribute::getAsString(),getEquivalentICmp(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getRangeForAffineARHelper(),getSignedMax(),getUnsignedMax(),llvm::ConstantRangeList::insert(),llvm::ConstantRangeList::intersectWith(),llvm::ConstantRangeList::isOrderedRanges(),lowerKernelArguments(),makeAllowedICmpRegion(),multiply(),llvm::operator<<(),llvm::ConstantRangeList::print(),llvm::AttributeImpl::Profile(),SolveQuadraticAddRecRange(),splitGlobal(),sub(),llvm::ConstantRangeList::subtract(),switchToLookupTable(),llvm::ConstantRangeList::unionWith(), andwriteFunctionTypeMetadataRecords().

◆ icmp()

bool ConstantRange::icmp(CmpInst::Predicate Pred,
constConstantRangeOther 
) const

Does the predicatePred hold between ranges this andOther? NOTE: false does not mean that inverse predicate holds!

Definition at line243 of fileConstantRange.cpp.

Referencescontains(),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(), andllvm::APInt::ult().

Referenced byexpandUDivOrURem(),getDomain(),getPredicateResult(),isImpliedCondCommonOperandWithCR(),processAbsIntrinsic(),processCmpIntrinsic(),processMinMaxIntrinsic(),processSRem(), andllvm::InstCombinerImpl::visitCallInst().

◆ intersectWith()

ConstantRange ConstantRange::intersectWith(constConstantRangeCR,
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 line581 of fileConstantRange.cpp.

Referencesassert(),getBitWidth(),getPreferredRange(),intersectWith(),isEmptySet(),isFullSet(),isUpperWrapped(),llvm::APInt::ule(), andllvm::APInt::ult().

Referenced byAddParamAndFnBasicAttributes(),AddReturnAttributes(),areNonOverlapSameBaseLoadAndStore(),binaryAnd(),binaryOr(),binaryXor(),llvm::computeConstantRange(),llvm::computeConstantRangeIncludingKnownBits(),difference(),exactIntersectWith(),exactUnionWith(),foldCtpop(),llvm::InstCombinerImpl::foldICmpWithDominatingICmp(),llvm::inferAttribute(),llvm::ARMTTIImpl::instCombineIntrinsic(),llvm::ValueLatticeElement::intersect(),llvm::IntegerRangeState::intersectKnown(),intersectWith(),makeGuaranteedNoWrapRegion(),sdiv(),shlWithNoWrap(),smax(),smin(),umax(),umin(), andllvm::IntegerRangeState::unionAssumed().

◆ intrinsic()

ConstantRange ConstantRange::intrinsic(Intrinsic::ID IntrinsicID,
ArrayRef<ConstantRangeOps 
)
static

Compute range of intrinsic result for the given operand ranges.

Definition at line1021 of fileConstantRange.cpp.

Referencesassert(),llvm::APInt::getBitWidth(),llvm::APInt::getBoolValue(),isIntrinsicSupported(), andllvm_unreachable.

◆ inverse()

ConstantRange ConstantRange::inverse() const

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

Definition at line1935 of fileConstantRange.cpp.

ReferencesisEmptySet(), andisFullSet().

Referenced byllvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(),difference(),exactIntersectWith(),exactUnionWith(),foldICmpUSubSatOrUAddSatWithConstant(),getValueFromOverflowCondition(),icmp(),makeSatisfyingICmpRegion(), andsimplifyICmpWithConstant().

◆ isAllNegative()

bool ConstantRange::isAllNegative() const

Return true if all values in this range are negative.

Definition at line458 of fileConstantRange.cpp.

ReferencesisEmptySet(),isFullSet(),llvm::APInt::isStrictlyPositive(), andisUpperSignWrapped().

Referenced byareInsensitiveToSignednessOfICmpPredicate(),areInsensitiveToSignednessOfInvertedICmpPredicate(),computeKnownFPClass(),computeOverflowForSignedAdd(),expandUDivOrURem(), andshl().

◆ isAllNonNegative()

bool ConstantRange::isAllNonNegative() const

Return true if all values in this range are non-negative.

Definition at line468 of fileConstantRange.cpp.

Referencesllvm::APInt::isNonNegative(), andisSignWrappedSet().

Referenced byareInsensitiveToSignednessOfICmpPredicate(),areInsensitiveToSignednessOfInvertedICmpPredicate(),computeKnownFPClass(),computeOverflowForSignedAdd(),getDomain(),processAShr(),processPossibleNonNeg(),processSExt(),processSIToFP(), andllvm::refineInstruction().

◆ isAllPositive()

bool ConstantRange::isAllPositive() const

Return true if all values in this range are positive.

Definition at line473 of fileConstantRange.cpp.

ReferencesisEmptySet(),isFullSet(),isSignWrappedSet(), andllvm::APInt::isStrictlyPositive().

◆ isEmptySet()

bool ConstantRange::isEmptySet() const

Return true if this set contains no members.

Definition at line418 of fileConstantRange.cpp.

Referencesllvm::APInt::isMinValue().

Referenced byabs(),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(),sdiv(),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(), andzeroExtend().

◆ isFullSet()

bool ConstantRange::isFullSet() const

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

Definition at line414 of fileConstantRange.cpp.

Referencesllvm::APInt::isMaxValue().

Referenced byadd(),llvm::AttrBuilder::addConstantRangeAttr(),addWithNoWrap(),contains(),ctpop(),cttz(),llvm::Attribute::get(),getEquivalentICmp(),llvm::MDNode::getMostGenericRange(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),llvm::ValueLatticeElement::getRange(),getRangeForAffineARHelper(),getSignedMax(),getSignedMin(),getUnsignedMax(),getUnsignedMin(),llvm::ConstantRangeList::insert(),intersectWith(),llvm::AttributeSet::intersectWith(),inverse(),isAllNegative(),isAllPositive(),isSizeLargerThan(),isSizeStrictlySmallerThan(),llvm::IntegerRangeState::isValidState(),llvm::ValueLatticeElement::markConstantRange(),multiplyWithNoWrap(),print(),signExtend(),llvm::ScalarEvolution::SimplifyICmpOperands(),simplifyICmpWithConstant(),stripAndAccumulateOffsets(),sub(),llvm::ConstantRangeList::subtract(),subWithNoWrap(),truncate(),unionWith(),llvm::InstCombinerImpl::visitCallInst(), andzeroExtend().

◆ isIntrinsicSupported()

bool ConstantRange::isIntrinsicSupported(Intrinsic::ID IntrinsicID)
static

Returns true ifConstantRange calculations are supported for intrinsic withIntrinsicID.

Definition at line1001 of fileConstantRange.cpp.

Referenced byintrinsic().

◆ isSignWrappedSet()

bool ConstantRange::isSignWrappedSet() const

Return true if this set wraps around the signed domain.

Special cases:

  • Empty set: Not wrapped.
  • Full set: Not wrapped.
  • [X, SignedMin) == [X, SignedMax]: Not wrapped.

Definition at line430 of fileConstantRange.cpp.

Referencesllvm::APInt::isMinSignedValue(), andllvm::APInt::sgt().

Referenced byabs(),getPreferredRange(),getSignedMin(),isAllNonNegative(),isAllPositive(),signExtend(),smax(), andsmin().

◆ isSingleElement()

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

Return true if this set contains exactly one member.

Definition at line266 of fileConstantRange.h.

Referenced bybinaryXor(),hasSingleValue(),llvm::hasSingleValue(),llvm::inferAttribute(),llvm::SCCPSolver::isConstant(),llvm::ValueLatticeElement::isConstantRange(), andmakeAllowedICmpRegion().

◆ isSizeLargerThan()

bool ConstantRange::isSizeLargerThan(uint64_t MaxSize) const

Compare set size of this range withValue.

Definition at line449 of fileConstantRange.cpp.

ReferencesgetBitWidth(),llvm::APInt::getMaxValue(),isFullSet(), andllvm::APInt::ugt().

Referenced byprocessSwitch().

◆ isSizeStrictlySmallerThan()

bool ConstantRange::isSizeStrictlySmallerThan(constConstantRangeCR) const

Compare set size of this range with the range CR.

Definition at line439 of fileConstantRange.cpp.

Referencesassert(),getBitWidth(),isFullSet(), andllvm::Other.

Referenced bygetPreferredRange(), andmultiply().

◆ isUpperSignWrapped()

bool ConstantRange::isUpperSignWrapped() const

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

Special cases:

  • Empty set: Not wrapped.
  • Full set: Not wrapped.
  • [X, SignedMin): Wrapped.

Definition at line434 of fileConstantRange.cpp.

Referencesllvm::APInt::sgt().

Referenced bygetSignedMax(), andisAllNegative().

◆ isUpperWrapped()

bool ConstantRange::isUpperWrapped() const

Return true if the exclusive upper bound wraps around the unsigned domain.

Special cases:

  • Empty set: Not wrapped.
  • Full set: Not wrapped.
  • [X, 0): Wrapped.

Definition at line426 of fileConstantRange.cpp.

Referencesllvm::APInt::ugt().

Referenced bycontains(),getUnsignedMax(),intersectWith(),multiply(),switchToLookupTable(),truncate(),unionWith(), andzeroExtend().

◆ isWrappedSet()

bool ConstantRange::isWrappedSet() const

Return true if this set wraps around the unsigned domain.

Special cases:

  • Empty set: Not wrapped.
  • Full set: Not wrapped.
  • [X, 0) == [X, Max]: Not wrapped.

Definition at line422 of fileConstantRange.cpp.

Referencesllvm::APInt::isZero(), andllvm::APInt::ugt().

Referenced byctpop(),cttz(),getPreferredRange(),getUnsignedMin(),umax(), andumin().

◆ lshr()

ConstantRange ConstantRange::lshr(constConstantRangeOther) const

Return a new range representing the possible values resulting from a logical right shift of a value in this range and a value inOther.

Definition at line1789 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::APInt::lshr(),llvm::max(), andllvm::Other.

Referenced bybinaryOp(), andmakeGuaranteedNoWrapRegion().

◆ makeAllowedICmpRegion()

ConstantRange ConstantRange::makeAllowedICmpRegion(CmpInst::Predicate Pred,
constConstantRangeOther 
)
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 aConstantRange, 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 line98 of fileConstantRange.cpp.

ReferencesgetBitWidth(),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, andllvm::UMin.

Referenced byllvm::computeConstantRange(),computeKnownBitsFromCmp(),isImpliedCondCommonOperandWithCR(),makeExactICmpRegion(), andmakeSatisfyingICmpRegion().

◆ makeExactICmpRegion()

ConstantRange ConstantRange::makeExactICmpRegion(CmpInst::Predicate Pred,
constAPIntOther 
)
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 line158 of fileConstantRange.cpp.

Referencesassert(),llvm::CallingConv::C,makeAllowedICmpRegion(), andmakeSatisfyingICmpRegion().

Referenced bycmpExcludesZero(),computeKnownBitsFromOperator(),llvm::JumpThreadingPass::computeValueKnownInPredecessorsImpl(),llvm::InstCombinerImpl::foldICmpAddConstant(),foldICmpUSubSatOrUAddSatWithConstant(),llvm::InstCombinerImpl::foldICmpWithDominatingICmp(),getEquivalentICmp(),getValueFromICmpCtpop(),llvm::isKnownInversion(),simplifyAndOrOfICmpsWithConstants(),llvm::ScalarEvolution::SimplifyICmpOperands(),simplifyICmpWithConstant(), andsimplifySwitchOnSelectUsingRanges().

◆ makeExactNoWrapRegion()

ConstantRange ConstantRange::makeExactNoWrapRegion(Instruction::BinaryOps BinOp,
constAPIntOther,
unsigned NoWrapKind 
)
static

Produce the range that contains X if and only if "X BinOp Other" does not wrap.

Definition at line389 of fileConstantRange.cpp.

ReferencesmakeGuaranteedNoWrapRegion(), andllvm::Other.

Referenced byfoldICmpUSubSatOrUAddSatWithConstant(), andgetValueFromOverflowCondition().

◆ makeGuaranteedNoWrapRegion()

ConstantRange ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
constConstantRangeOther,
unsigned NoWrapKind 
)
static

Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow) forall Y in Other.

However, there may besome 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: typedefOverflowingBinaryOperator 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 line315 of fileConstantRange.cpp.

Referencesashr(),assert(),llvm::BitWidth,llvm::CallingConv::C,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, andUnsigned.

Referenced byllvm::ScalarEvolution::getMulExpr(),makeExactNoWrapRegion(),processBinOp(),llvm::refineInstruction(),StrengthenNoWrapFlags(), andwillNotOverflow().

◆ makeMaskNotEqualRange()

ConstantRange ConstantRange::makeMaskNotEqualRange(constAPIntMask,
constAPIntC 
)
static

Initialize a range containing all values X that satisfy(X & Mask) != C.

Note that the range returned may contain values where(X & Mask) == C holds, making it less precise, but still conservative.

Definition at line397 of fileConstantRange.cpp.

Referencesllvm::BitWidth,llvm::CallingConv::C,getNonEmpty(), andllvm::APInt::getOneBitSet().

◆ makeSatisfyingICmpRegion()

ConstantRange ConstantRange::makeSatisfyingICmpRegion(CmpInst::Predicate Pred,
constConstantRangeOther 
)
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 aConstantRange, the return value will be a proper subset of the above.

Example: Pred = ult and Other = i8 [2, 5) returns [0, 2)

Definition at line148 of fileConstantRange.cpp.

Referencesllvm::CmpInst::getInversePredicate(),inverse(), andmakeAllowedICmpRegion().

Referenced bymakeExactICmpRegion().

◆ multiply()

ConstantRange ConstantRange::multiply(constConstantRangeOther) const

Return a new range representing the possible values resulting from a multiplication of a value in this range and a value inOther, treating both this andOther as unsigned ranges.

Definition at line1164 of fileConstantRange.cpp.

ReferencesA,B,llvm::CallingConv::C,getBitWidth(),getSignedMax(),getSignedMin(),getSingleElement(),getUnsignedMax(),getUnsignedMin(),getUpper(),llvm::APInt::getZero(),isEmptySet(),llvm::APInt::isMinSignedValue(),llvm::APInt::isNonNegative(),isSizeStrictlySmallerThan(),isUpperWrapped(),llvm::Other,llvm::APInt::sext(),sub(),truncate(), andllvm::APInt::zext().

Referenced bybinaryOp(),llvm::SelectionDAG::computeKnownBits(),llvm::SelectionDAG::isKnownNeverZero(), andmultiplyWithNoWrap().

◆ multiplyWithNoWrap()

ConstantRange ConstantRange::multiplyWithNoWrap(constConstantRangeOther,
unsigned NoWrapKind,
PreferredRangeType RangeType =Smallest 
) const

Return a new range representing the possible values resulting from a multiplication with wrap typeNoWrapKind of a value in this range and a value inOther.

If the result range is disjoint, the preferred range is determined by thePreferredRangeType.

Definition at line1232 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getNonEmpty(),getSignedMin(),llvm::APInt::getSignedMinValue(),llvm::APInt::getZero(),isEmptySet(),isFullSet(),multiply(),llvm::OverflowingBinaryOperator::NoSignedWrap,llvm::OverflowingBinaryOperator::NoUnsignedWrap,llvm::Other,smul_sat(), andumul_sat().

Referenced byoverflowingBinaryOp().

◆ operator!=()

bool llvm::ConstantRange::operator!=(constConstantRangeCR) const
inline

Definition at line299 of fileConstantRange.h.

Referencesllvm::operator==().

◆ operator==()

bool llvm::ConstantRange::operator==(constConstantRangeCR) const
inline

Return true if this range is equal to another range.

Definition at line296 of fileConstantRange.h.

Referencesllvm::Upper.

◆ overflowingBinaryOp()

ConstantRange ConstantRange::overflowingBinaryOp(Instruction::BinaryOps BinOp,
constConstantRangeOther,
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 ofOther given the provided knowledge about lack of wrappingNoWrapKind.

Definition at line980 of fileConstantRange.cpp.

ReferencesaddWithNoWrap(),assert(),binaryOp(),llvm::Instruction::isBinaryOp(),multiplyWithNoWrap(),llvm::Other,shlWithNoWrap(), andsubWithNoWrap().

◆ print()

void ConstantRange::print(raw_ostreamOS) const

Print out the bounds to a stream.

Definition at line2249 of fileConstantRange.cpp.

ReferencesisEmptySet(),isFullSet(), andOS.

Referenced bydump(),llvm::operator<<(), andllvm::ScalarEvolution::print().

◆ sadd_sat()

ConstantRange ConstantRange::sadd_sat(constConstantRangeOther) const

Perform a signed saturating addition of two constant ranges.

Definition at line1858 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::sadd_sat().

Referenced byaddWithNoWrap().

◆ sdiv()

ConstantRange ConstantRange::sdiv(constConstantRangeOther) const

Return a new range representing the possible values resulting from a signed division of a value in this range and a value inOther.

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 line1358 of fileConstantRange.cpp.

Referencescontains(),getBitWidth(),llvm::APInt::getSignedMinValue(),llvm::APInt::getZero(),intersectWith(),llvm::APInt::isAllOnes(),isEmptySet(),llvm::APInt::isMinSignedValue(),llvm::APInt::isZero(),llvm::Lo,RHS,llvm::APInt::sdiv(),sdiv(),Signed, andunionWith().

Referenced bybinaryOp(),processSDiv(), andsdiv().

◆ sextOrTrunc()

ConstantRange ConstantRange::sextOrTrunc(uint32_t BitWidth) const

Make this range have the bit width given byBitWidth.

The value is sign extended, truncated, or left alone to make it that width.

Definition at line926 of fileConstantRange.cpp.

ReferencesgetBitWidth(),signExtend(), andtruncate().

Referenced byllvm::ScalarEvolution::getSignExtendExprImpl(), andwriteFunctionTypeMetadataRecords().

◆ shl()

ConstantRange ConstantRange::shl(constConstantRangeOther) const

Return a new range representing the possible values resulting from a left shift of a value in this range by a value inOther.

TODO: This isn't fully implemented yet.

Definition at line1645 of fileConstantRange.cpp.

Referencesllvm::APInt::countl_one(),llvm::countl_zero(),llvm::APInt::getBitsSetFrom(),getBitWidth(),getNonEmpty(),getUnsignedMax(),getUnsignedMin(),llvm::APInt::getZero(),isAllNegative(),isEmptySet(),llvm::Other,RHS,llvm::APInt::ugt(), andllvm::APInt::ule().

Referenced bybinaryOp(), andshlWithNoWrap().

◆ shlWithNoWrap()

ConstantRange ConstantRange::shlWithNoWrap(constConstantRangeOther,
unsigned NoWrapKind,
PreferredRangeType RangeType =Smallest 
) const

Return a new range representing the possible values resulting from a left shift with wrap typeNoWrapKind of a value in this range and a value inOther.

If the result range is disjoint, the preferred range is determined by thePreferredRangeType.

Definition at line1766 of fileConstantRange.cpp.

ReferencescomputeShlNSW(),computeShlNUW(),intersectWith(),isEmptySet(),llvm_unreachable,llvm::OverflowingBinaryOperator::NoSignedWrap,llvm::OverflowingBinaryOperator::NoUnsignedWrap,llvm::Other, andshl().

Referenced byoverflowingBinaryOp().

◆ signedAddMayOverflow()

ConstantRange::OverflowResult ConstantRange::signedAddMayOverflow(constConstantRangeOther) const

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

Definition at line2153 of fileConstantRange.cpp.

ReferencesAlwaysOverflowsHigh,AlwaysOverflowsLow,getBitWidth(),getSignedMax(),llvm::APInt::getSignedMaxValue(),getSignedMin(),llvm::APInt::getSignedMinValue(),isEmptySet(),llvm::APInt::isNegative(),llvm::APInt::isNonNegative(),MayOverflow,NeverOverflows,llvm::Other,llvm::APInt::sgt(), andllvm::APInt::slt().

Referenced bycomputeOverflowForSignedAdd(), andllvm::CombinerHelper::matchAddOverflow().

◆ signedSubMayOverflow()

ConstantRange::OverflowResult ConstantRange::signedSubMayOverflow(constConstantRangeOther) const

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

Definition at line2199 of fileConstantRange.cpp.

ReferencesAlwaysOverflowsHigh,AlwaysOverflowsLow,getBitWidth(),getSignedMax(),llvm::APInt::getSignedMaxValue(),getSignedMin(),llvm::APInt::getSignedMinValue(),isEmptySet(),llvm::APInt::isNegative(),llvm::APInt::isNonNegative(),MayOverflow,NeverOverflows,llvm::Other,llvm::APInt::sgt(), andllvm::APInt::slt().

Referenced byllvm::computeOverflowForSignedSub(),llvm::SelectionDAG::computeOverflowForSignedSub(), andllvm::CombinerHelper::matchSuboCarryOut().

◆ signExtend()

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 line846 of fileConstantRange.cpp.

Referencesassert(),getBitWidth(),llvm::APInt::getHighBitsSet(),llvm::APInt::getLowBitsSet(),isEmptySet(),isFullSet(),llvm::APInt::isMinSignedValue(),isSignWrappedSet(),llvm::APInt::sext(), andllvm::APInt::zext().

Referenced bycastOp(),llvm::SelectionDAG::ComputeNumSignBits(),computeNumSignBitsFromRangeMetadata(),llvm::ScalarEvolution::getSignExtendExprImpl(), andsextOrTrunc().

◆ smax()

ConstantRange ConstantRange::smax(constConstantRangeOther) const

Return a new range representing the possible values resulting from a signed maximum of a value in this range and a value inOther.

Definition at line1282 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getSignedMax(),getSignedMin(),intersectWith(),isEmptySet(),isSignWrappedSet(),llvm::Other,Signed,llvm::APIntOps::smax(), andunionWith().

◆ smin()

ConstantRange ConstantRange::smin(constConstantRangeOther) const

Return a new range representing the possible values resulting from a signed minimum of a value in this range and a value inOther.

Definition at line1310 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getSignedMax(),getSignedMin(),intersectWith(),isEmptySet(),isSignWrappedSet(),llvm::Other,Signed,llvm::APIntOps::smin(), andunionWith().

◆ smul_fast()

ConstantRange ConstantRange::smul_fast(constConstantRangeOther) const

Return range of possible values for a signed multiplication of this andOther.

However, if overflow is possible always return a full range rather than trying to determine a more precise result.

Definition at line1262 of fileConstantRange.cpp.

ReferencesA,B,getNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::smul_ov().

◆ smul_sat()

ConstantRange ConstantRange::smul_sat(constConstantRangeOther) const

Perform a signed saturating multiplication of two constant ranges.

Definition at line1894 of fileConstantRange.cpp.

ReferencesA,B,getNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::smul_sat().

Referenced bymultiplyWithNoWrap().

◆ srem()

ConstantRange ConstantRange::srem(constConstantRangeOther) const

Return a new range representing the possible values resulting from a signed remainder operation of a value in this range and a value inOther.

Definition at line1468 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getSignedMax(),getSignedMin(),getSingleElement(),getUnsignedMax(),getUnsignedMin(),llvm::APInt::getZero(),isEmptySet(),llvm::APInt::isNonNegative(),llvm::APInt::isZero(),RHS,llvm::APInt::ugt(),llvm::APIntOps::umax(),llvm::APIntOps::umin(), andllvm::Upper.

Referenced bybinaryOp().

◆ sshl_sat()

ConstantRange ConstantRange::sshl_sat(constConstantRangeOther) const

Perform a signed saturating left shift of this constant range by a value inOther.

Definition at line1924 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::APInt::isNonNegative(),llvm::Other, andllvm::APInt::sshl_sat().

◆ ssub_sat()

ConstantRange ConstantRange::ssub_sat(constConstantRangeOther) const

Perform a signed saturating subtraction of two constant ranges.

Definition at line1876 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getSignedMax(),getSignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::ssub_sat().

Referenced bysubWithNoWrap().

◆ sub()

ConstantRange ConstantRange::sub(constConstantRangeOther) const

Return a new range representing the possible values resulting from a subtraction of a value in this range and a value inOther.

Definition at line1114 of fileConstantRange.cpp.

ReferencesgetLower(),getUpper(),isEmptySet(),isFullSet(),llvm::Other, andX.

Referenced bybinaryNot(),binaryOp(),binaryXor(),computeKnownBitsFromCmp(),foldICmpUSubSatOrUAddSatWithConstant(),multiply(), andsubWithNoWrap().

◆ subtract()

ConstantRange ConstantRange::subtract(constAPIntCI) const

Subtract the specified constant from the endpoints of this constant range.

Definition at line549 of fileConstantRange.cpp.

Referencesassert(),llvm::APInt::getBitWidth(), andgetBitWidth().

Referenced byllvm::InstCombinerImpl::foldICmpAddConstant(),llvm::TargetLoweringBase::getBitWidthForCttzElements(), andllvm::SCEVAddRecExpr::getNumIterationsInRange().

◆ subWithNoWrap()

ConstantRange ConstantRange::subWithNoWrap(constConstantRangeOther,
unsigned NoWrapKind,
PreferredRangeType RangeType =Smallest 
) const

Return a new range representing the possible values resulting from an subtraction with wrap typeNoWrapKind of a value in this range and a value inOther.

If the result range is disjoint, the preferred range is determined by thePreferredRangeType.

Definition at line1133 of fileConstantRange.cpp.

ReferencesgetUnsignedMax(),isEmptySet(),isFullSet(),llvm::Other,ssub_sat(),sub(), andusub_sat().

Referenced byoverflowingBinaryOp().

◆ toKnownBits()

KnownBits ConstantRange::toKnownBits() const

Return known bits for values in this range.

Definition at line80 of fileConstantRange.cpp.

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

Referenced bybinaryAnd(),binaryOr(),binaryXor(),computeKnownBits(),llvm::SelectionDAG::computeKnownBits(),computeKnownBitsFromCmp(), andcomputeKnownBitsFromOperator().

◆ truncate()

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 line864 of fileConstantRange.cpp.

Referencesassert(),llvm::APInt::clearBit(),llvm::APInt::countr_one(),llvm::APInt::getActiveBits(),llvm::APInt::getBitsSetFrom(),getBitWidth(),llvm::APInt::getMaxValue(),isEmptySet(),isFullSet(),isUpperWrapped(),llvm::APInt::setAllBits(),llvm::APInt::trunc(),llvm::APInt::ult(), andunionWith().

Referenced bycastOp(),llvm::InstCombinerImpl::foldICmpAddConstant(),llvm::ScalarEvolution::getSignExtendExprImpl(),llvm::ScalarEvolution::getZeroExtendExprImpl(),multiply(),sextOrTrunc(), andzextOrTrunc().

◆ uadd_sat()

ConstantRange ConstantRange::uadd_sat(constConstantRangeOther) const

Perform an unsigned saturating addition of two constant ranges.

Definition at line1849 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::uadd_sat().

Referenced byaddWithNoWrap(), andexpandUDivOrURem().

◆ udiv()

ConstantRange ConstantRange::udiv(constConstantRangeOther) const

Return a new range representing the possible values resulting from an unsigned division of a value in this range and a value inOther.

Definition at line1338 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::APInt::isZero(),RHS,llvm::APInt::udiv(), andllvm::Upper.

Referenced bybinaryOp().

◆ umax()

ConstantRange ConstantRange::umax(constConstantRangeOther) const

Return a new range representing the possible values resulting from an unsigned maximum of a value in this range and a value inOther.

Definition at line1296 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),intersectWith(),isEmptySet(),isWrappedSet(),llvm::Other,llvm::APIntOps::umax(),unionWith(), andUnsigned.

◆ umin()

ConstantRange ConstantRange::umin(constConstantRangeOther) const

Return a new range representing the possible values resulting from an unsigned minimum of a value in this range and a value inOther.

Definition at line1324 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),intersectWith(),isEmptySet(),isWrappedSet(),llvm::Other,llvm::APIntOps::umin(),unionWith(), andUnsigned.

◆ umul_sat()

ConstantRange ConstantRange::umul_sat(constConstantRangeOther) const

Perform an unsigned saturating multiplication of two constant ranges.

Definition at line1885 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::umul_sat().

Referenced byllvm::TargetLoweringBase::getBitWidthForCttzElements(), andmultiplyWithNoWrap().

◆ unionWith()

ConstantRange ConstantRange::unionWith(constConstantRangeCR,
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 line687 of fileConstantRange.cpp.

Referencesassert(),getBitWidth(),getPreferredRange(),isEmptySet(),isFullSet(),isUpperWrapped(),llvm::APInt::uge(),llvm::APInt::ugt(),llvm::APInt::ule(),llvm::APInt::ult(), andunionWith().

Referenced byllvm::computeConstantRange(),computeShlNSW(),ctpop(),cttz(),exactIntersectWith(),exactUnionWith(),llvm::getConstantRangeFromMetadata(),llvm::AttributeSet::intersectWith(),llvm::IntegerRangeState::operator&=(),sdiv(),smax(),smin(),llvm::Constant::toConstantRange(),truncate(),tryMergeRange(),umax(),umin(),llvm::IntegerRangeState::unionAssumed(), andunionWith().

◆ unsignedAddMayOverflow()

ConstantRange::OverflowResult ConstantRange::unsignedAddMayOverflow(constConstantRangeOther) const

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

Definition at line2137 of fileConstantRange.cpp.

ReferencesAlwaysOverflowsHigh,getUnsignedMax(),getUnsignedMin(),isEmptySet(),MayOverflow,NeverOverflows,llvm::Other, andllvm::APInt::ugt().

Referenced byllvm::computeOverflowForUnsignedAdd(),llvm::SelectionDAG::computeOverflowForUnsignedAdd(), andllvm::CombinerHelper::matchAddOverflow().

◆ unsignedMulMayOverflow()

ConstantRange::OverflowResult ConstantRange::unsignedMulMayOverflow(constConstantRangeOther) const

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

Definition at line2229 of fileConstantRange.cpp.

ReferencesAlwaysOverflowsHigh,getUnsignedMax(),getUnsignedMin(),isEmptySet(),MayOverflow,NeverOverflows,llvm::Other, andllvm::APInt::umul_ov().

Referenced byllvm::computeOverflowForUnsignedMul(), andllvm::SelectionDAG::computeOverflowForUnsignedMul().

◆ unsignedSubMayOverflow()

ConstantRange::OverflowResult ConstantRange::unsignedSubMayOverflow(constConstantRangeOther) const

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

Definition at line2183 of fileConstantRange.cpp.

ReferencesAlwaysOverflowsLow,getUnsignedMax(),getUnsignedMin(),isEmptySet(),MayOverflow,NeverOverflows,llvm::Other, andllvm::APInt::ult().

Referenced byllvm::computeOverflowForUnsignedSub(),llvm::SelectionDAG::computeOverflowForUnsignedSub(), andllvm::CombinerHelper::matchSuboCarryOut().

◆ urem()

ConstantRange ConstantRange::urem(constConstantRangeOther) const

Return a new range representing the possible values resulting from an unsigned remainder operation of a value in this range and a value inOther.

Definition at line1446 of fileConstantRange.cpp.

ReferencesgetBitWidth(),getNonEmpty(),getSingleElement(),getUnsignedMax(),llvm::APInt::getZero(),isEmptySet(),RHS,llvm::APIntOps::umin(), andllvm::Upper.

Referenced bybinaryOp(), andcanScalarizeAccess().

◆ ushl_sat()

ConstantRange ConstantRange::ushl_sat(constConstantRangeOther) const

Perform an unsigned saturating left shift of this constant range by a value inOther.

Definition at line1915 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::ushl_sat().

◆ usub_sat()

ConstantRange ConstantRange::usub_sat(constConstantRangeOther) const

Perform an unsigned saturating subtraction of two constant ranges.

Definition at line1867 of fileConstantRange.cpp.

ReferencesgetNonEmpty(),getUnsignedMax(),getUnsignedMin(),isEmptySet(),llvm::Other, andllvm::APInt::usub_sat().

Referenced bysubWithNoWrap().

◆ zeroExtend()

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 line829 of fileConstantRange.cpp.

Referencesassert(),getBitWidth(),llvm::APInt::getOneBitSet(),isEmptySet(),isFullSet(),isUpperWrapped(), andllvm::APInt::zext().

Referenced bycastOp(),llvm::SelectionDAG::ComputeNumSignBits(),computeNumSignBitsFromRangeMetadata(),llvm::ScalarEvolution::getZeroExtendExprImpl(), andzextOrTrunc().

◆ zextOrTrunc()

ConstantRange ConstantRange::zextOrTrunc(uint32_t BitWidth) const

Make this range have the bit width given byBitWidth.

The value is zero extended, truncated, or left alone to make it that width.

Definition at line917 of fileConstantRange.cpp.

ReferencesgetBitWidth(),truncate(), andzeroExtend().

Referenced byllvm::ScalarEvolution::getZeroExtendExprImpl().


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

Generated on Sun Jul 20 2025 15:55:44 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp