Go to the documentation of this file.
14 #ifndef LLVM_SUPPORT_KNOWNBITS_H
15 #define LLVM_SUPPORT_KNOWNBITS_H
42 "Zero and One should have the same width!");
314 return (
LHS.Zero |
RHS.Zero).isAllOnes();
327 bool NoUndefSelfMultiply =
false);
unsigned countMaxActiveBits() const
Returns the maximum number of bits needed to represent all possible unsigned values with these known ...
KnownBits anyext(unsigned BitWidth) const
Return known bits for an "any" extension of the value we're tracking, where we don't know anything ab...
APInt reverseBits() const
static KnownBits shl(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for shl(LHS, RHS).
void setAllBits()
Set every bit to 1.
void clearAllBits()
Set every bit to 0.
static KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for lshr(LHS, RHS).
void print(raw_ostream &OS) const
This is an optimization pass for GlobalISel generic memory operations.
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
KnownBits trunc(unsigned BitWidth) const
Return known bits for a truncation of the value we're tracking.
void resetAll()
Resets the known state of all bits.
APInt getMinValue() const
Return the minimal unsigned value possible given these KnownBits.
void insertBits(const KnownBits &SubBits, unsigned BitPosition)
Insert the bits from a smaller known bits starting at bitPosition.
bool isUnknown() const
Returns true if we don't know any bits.
unsigned countMaxLeadingOnes() const
Returns the maximum number of leading one bits possible.
KnownBits makeGE(const APInt &Val) const
Return KnownBits based on this, but updated given that the underlying value is known to be greater th...
KnownBits anyextOrTrunc(unsigned BitWidth) const
Return known bits for an "any" extension or truncation of the value we're tracking.
bool isNonZero() const
Returns true if this value is known to be non-zero.
static Optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
const APInt & getConstant() const
Returns the value when all bits have a known value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool operator!=(const KnownBits &Other) const
bool isZero() const
Returns true if value is all zero.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
unsigned countPopulation() const
Count the number of bits set.
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
void makeNegative()
Make this value negative.
bool isNonNegative() const
Returns true if this value is known to be non-negative.
static KnownBits mulhu(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from zero-extended multiply-hi.
static bool haveNoCommonBitsSet(const KnownBits &LHS, const KnownBits &RHS)
Return true if LHS and RHS have no common bits set.
KnownBits & operator&=(const KnownBits &RHS)
Update known bits based on ANDing with RHS.
static KnownBits umax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umax(LHS, RHS).
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
(vector float) vec_cmpeq(*A, *B) C
static KnownBits smin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smin(LHS, RHS).
bool hasConflict() const
Returns true if there is conflicting information.
KnownBits abs(bool IntMinIsPoison=false) const
Compute known bits for the absolute value.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
static KnownBits computeForAddCarry(const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry)
Compute known bits resulting from adding LHS, RHS and a 1-bit Carry.
This class implements an extremely fast bulk output stream that can only output to a stream.
bool isSignBitClear() const
Determine if sign bit of this APInt is clear.
bool isNegative() const
Returns true if this value is known to be negative.
KnownBits sext(unsigned BitWidth) const
Return known bits for a sign extension of the value we're tracking.
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
void setSignBit()
Set the sign bit to 1.
static Optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
static Optional< bool > eq(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_EQ result.
static Optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
bool isAllOnes() const
Returns true if value is all one bits.
KnownBits & operator|=(const KnownBits &RHS)
Update known bits based on ORing with RHS.
APInt operator|(APInt a, const APInt &b)
unsigned countMinLeadingOnes() const
Returns the minimum number of leading one bits.
static Optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
KnownBits extractBits(unsigned NumBits, unsigned BitPosition) const
Return a subset of the known bits from [bitPosition,bitPosition+numBits).
static Optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
unsigned countMaxLeadingZeros() const
Returns the maximum number of leading zero bits possible.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned countMaxTrailingZeros() const
Returns the maximum number of trailing zero bits possible.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
unsigned countMinSignBits() const
Returns the number of times the sign bit is replicated into the other bits.
unsigned countMaxPopulation() const
Returns the maximum number of bits that could be one.
static KnownBits urem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for urem(LHS, RHS).
KnownBits(unsigned BitWidth)
Create a known bits object of BitWidth bits initialized to unknown.
static KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for ashr(LHS, RHS).
static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS)
Compute known bits resulting from adding LHS and RHS.
Class for arbitrary precision integers.
KnownBits sextInReg(unsigned SrcBitWidth) const
Return known bits for a in-register sign extension of the value we're tracking.
KnownBits zext(unsigned BitWidth) const
Return known bits for a zero extension of the value we're tracking.
static KnownBits smax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smax(LHS, RHS).
APInt zext(unsigned width) const
Zero extend to a new width.
APInt operator^(APInt a, const APInt &b)
static KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from sign-extended multiply-hi.
APInt operator&(APInt a, const APInt &b)
static Optional< bool > ne(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_NE result.
KnownBits zextOrTrunc(unsigned BitWidth) const
Return known bits for a zero extension or truncation of the value we're tracking.
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
APInt trunc(unsigned width) const
Truncate to new width.
static KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for udiv(LHS, RHS).
unsigned countMinPopulation() const
Returns the number of bits known to be one.
unsigned countMaxTrailingOnes() const
Returns the maximum number of trailing one bits possible.
constexpr unsigned BitWidth
void setAllZero()
Make all bits known to be zero and discard any previous information.
APInt sext(unsigned width) const
Sign extend to a new width.
bool isStrictlyPositive() const
Returns true if this value is known to be positive.
APInt getSignedMinValue() const
Return the minimal signed value possible given these KnownBits.
KnownBits & operator^=(const KnownBits &RHS)
Update known bits based on XORing with RHS.
static KnownBits umin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umin(LHS, RHS).
void setAllOnes()
Make all bits known to be one and discard any previous information.
static KnownBits mul(const KnownBits &LHS, const KnownBits &RHS, bool NoUndefSelfMultiply=false)
Compute known bits resulting from multiplying LHS and RHS.
bool isSignBitSet() const
Determine if sign bit of this APInt is set.
unsigned countTrailingOnes() const
Count the number of trailing one bits.
static KnownBits commonBits(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits common to LHS and RHS.
unsigned countMaxSignificantBits() const
Returns the maximum number of bits needed to represent all possible signed values with these known bi...
static KnownBits srem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for srem(LHS, RHS).
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
bool isConstant() const
Returns true if we know the value of all bits.
static Optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
bool operator==(const KnownBits &Other) const
APInt getSignedMaxValue() const
Return the maximal signed value possible given these KnownBits.
unsigned countMinTrailingOnes() const
Returns the minimum number of trailing one bits.
unsigned getBitWidth() const
Get the bit width of this value.
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
static Optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
KnownBits sextOrTrunc(unsigned BitWidth) const
Return known bits for a sign extension or truncation of the value we're tracking.
unsigned countLeadingOnes() const
Count the number of leading one bits.
void makeNonNegative()
Make this value non-negative.
Optional< std::vector< StOtherPiece > > Other
static Optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.