42 : Lower(
llvm_move(V)), Upper(Lower + 1) {}
47 "ConstantRange with unequal bit widths");
49 "Lower == Upper, but they aren't min or max value!");
68 if (UMax.isMinValue())
74 if (SMax.isMinSignedValue())
80 if (UMax.isMaxValue())
86 if (SMax.isMaxSignedValue())
92 if (UMin.isMaxValue())
98 if (SMin.isMaxSignedValue())
104 if (UMin.isMinValue())
110 if (SMin.isMinSignedValue())
133 return Lower.
ugt(Upper);
214 return Lower.
ule(V) && V.
ult(Upper);
215 return Lower.
ule(V) || V.
ult(Upper);
263 "ConstantRange types don't agree!");
273 if (Lower.
ult(CR.Lower)) {
274 if (Upper.
ule(CR.Lower))
277 if (Upper.
ult(CR.Upper))
282 if (Upper.
ult(CR.Upper))
285 if (Lower.
ult(CR.Upper))
292 if (CR.Lower.
ult(Upper)) {
293 if (CR.Upper.
ult(Upper))
296 if (CR.Upper.
ule(Lower))
303 if (CR.Lower.
ult(Lower)) {
304 if (CR.Upper.
ule(Lower))
312 if (CR.Upper.
ult(Upper)) {
313 if (CR.Lower.
ult(Upper)) {
319 if (CR.Lower.
ult(Lower))
324 if (CR.Upper.
ule(Lower)) {
325 if (CR.Lower.
ult(Lower))
344 "ConstantRange types don't agree!");
352 if (CR.Upper.
ult(Lower) || Upper.
ult(CR.Lower)) {
354 APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
360 APInt L = Lower, U = Upper;
363 if ((CR.Upper - 1).ugt(U - 1))
366 if (L == 0 && U == 0)
375 if (CR.Upper.
ule(Upper) || CR.Lower.
uge(Lower))
380 if (CR.Lower.
ule(Upper) && Lower.
ule(CR.Upper))
386 if (Upper.
ule(CR.Lower) && CR.Upper.
ule(Lower)) {
387 APInt d1 = CR.Lower - Upper, d2 = Lower - CR.Upper;
395 if (Upper.
ult(CR.Lower) && Lower.
ult(CR.Upper))
400 assert(CR.Lower.
ult(Upper) && CR.Upper.
ult(Lower) &&
401 "ConstantRange::unionWith missed a case with one range wrapped");
407 if (CR.Lower.
ule(Upper) || Lower.
ule(CR.Upper))
410 APInt L = Lower, U = Upper;
427 assert(SrcTySize < DstTySize &&
"Not a value extension");
430 APInt LowerExt(DstTySize, 0);
432 LowerExt = Lower.
zext(DstTySize);
447 assert(SrcTySize < DstTySize &&
"Not a value extension");
466 assert(
getBitWidth() > DstTySize &&
"Not a value truncation");
474 MaxBitValue.
setBit(DstTySize);
476 APInt LowerDiv(Lower), UpperDiv(Upper);
484 if (Upper.
uge(MaxValue))
492 if (LowerDiv == UpperDiv)
497 if (LowerDiv.uge(MaxValue)) {
500 UpperDiv = UpperDiv - MaxBitValue * Div;
503 if (UpperDiv.
ule(MaxValue))
508 APInt UpperModulo = UpperDiv - MaxBitValue;
509 if (UpperModulo.
ult(LowerDiv))
520 if (SrcTySize > DstTySize)
522 if (SrcTySize < DstTySize)
531 if (SrcTySize > DstTySize)
533 if (SrcTySize < DstTySize)
548 if (NewLower == NewUpper)
569 if (NewLower == NewUpper)
596 this_max * Other_max + 1);
727 OS <<
"[" << Lower <<
"," << Upper <<
")";
APInt getSignedMin() const
ConstantRange sextOrTrunc(uint32_t BitWidth) const
void setBit(unsigned bitPosition)
Set a given bit to 1.
uint32_t getBitWidth() const
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
APInt getSignedMax() const
bool isSingleElement() const
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
ConstantRange smax(const ConstantRange &Other) const
ConstantRange truncate(uint32_t BitWidth) const
#define llvm_unreachable(msg)
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
APInt umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
enable_if_c< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, std::size_t >::type countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
ConstantRange signExtend(uint32_t BitWidth) const
ConstantRange multiply(const ConstantRange &Other) const
bool contains(const APInt &Val) const
ConstantRange unionWith(const ConstantRange &CR) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(unsigned shiftAmt) const
Left-shift function.
ConstantRange subtract(const APInt &CI) const
bool ult(const APInt &RHS) const
Unsigned less than comparison.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ConstantRange intersectWith(const ConstantRange &CR) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const
Truncate to new width.
ConstantRange lshr(const ConstantRange &Other) const
bool isWrappedSet() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
ConstantRange udiv(const ConstantRange &Other) const
ConstantRange(uint32_t BitWidth, bool isFullSet=true)
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
bool isMaxValue() const
Determine if this is the largest unsigned value.
ConstantRange sub(const ConstantRange &Other) const
void print(raw_ostream &OS) const
ConstantRange zeroExtend(uint32_t BitWidth) const
ConstantRange difference(const ConstantRange &CR) const
Subtract the specified range from this range (aka relative complement of the sets).
ConstantRange add(const ConstantRange &Other) const
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
bool isSignWrappedSet() const
ConstantRange inverse() const
const APInt & getLower() const
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
APInt umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
APInt smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
ConstantRange binaryOr(const ConstantRange &Other) const
Class for arbitrary precision integers.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
bool isMinValue() const
Determine if this is the smallest unsigned value.
ConstantRange shl(const ConstantRange &Other) const
ConstantRange umax(const ConstantRange &Other) const
bool isAllOnesValue() const
Determine if all bits are set.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const
Unsigned division operation.
unsigned greater or equal
static ConstantRange makeICmpRegion(unsigned Pred, const ConstantRange &Other)
ConstantRange binaryAnd(const ConstantRange &Other) const
const APInt & getUpper() const
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
static void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
ConstantRange zextOrTrunc(uint32_t BitWidth) const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const
Zero extend to a new width.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
APInt getUnsignedMax() const
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
APInt getUnsignedMin() const