25 Zero.setBitVal(SignBitPosition, Val.
One[SignBitPosition]);
26 One.setBitVal(SignBitPosition, Val.
Zero[SignBitPosition]);
31 bool CarryZero,
bool CarryOne) {
33 APInt PossibleSumZero =
LHS.getMaxValue() +
RHS.getMaxValue() + !CarryZero;
34 APInt PossibleSumOne =
LHS.getMinValue() +
RHS.getMinValue() + CarryOne;
37 APInt CarryKnownZero = ~(PossibleSumZero ^
LHS.Zero ^
RHS.Zero);
38 APInt CarryKnownOne = PossibleSumOne ^
LHS.One ^
RHS.One;
43 APInt CarryKnownUnion = std::move(CarryKnownZero) | CarryKnownOne;
44 APInt Known = std::move(LHSKnownUnion) & RHSKnownUnion & CarryKnownUnion;
49 KnownOut.
One = std::move(PossibleSumOne) & Known;
54 const KnownBits &LHS,
const KnownBits &RHS,
const KnownBits &Carry) {
56 return ::computeForAddCarry(
62 const KnownBits &RHS) {
63 unsigned BitWidth = LHS.getBitWidth();
67 if (LHS.isUnknown() && RHS.isUnknown())
70 if (!LHS.isUnknown() && !RHS.isUnknown()) {
77 KnownBits NotRHS = RHS;
147 const KnownBits &Borrow) {
153 return ::computeForAddCarry(LHS, RHS,
167 if (InputMin.
sge(MinInRange) && InputMax.
sle(MaxInRange)) {
171 else if (InputMax.
slt(MinInRange)) {
175 else if (InputMin.
sgt(MaxInRange)) {
207 if (InputMax.
sle(MaxInRange)) {
209 Known.
Zero = InputZeroLower & MinSatKB.
Zero;
210 Known.
One = InputOneLower & MinSatKB.
One;
211 }
else if (InputMin.
sge(MinInRange)) {
213 Known.
Zero = InputZeroLower & MaxSatKB.
Zero;
214 Known.
One = InputOneLower & MaxSatKB.
One;
217 Known.
Zero = InputZeroLower & MinSatKB.
Zero & MaxSatKB.
Zero;
218 Known.
One = InputOneLower & MinSatKB.
One & MaxSatKB.
One;
245 if (InputMax.
ule(MaxInRange)) {
268 if (InputMax.
ule(MaxInRange)) {
270 }
else if (InputMin.
ugt(MaxInRange)) {
282 "Illegal sext-in-register");
287 unsigned ExtBits =
BitWidth - SrcBitWidth;
289 Result.One =
One << ExtBits;
290 Result.Zero =
Zero << ExtBits;
291 Result.One.ashrInPlace(ExtBits);
292 Result.Zero.ashrInPlace(ExtBits);
303 APInt MaskedVal(Val);
313 if (LHS.getMinValue().uge(RHS.getMaxValue()))
315 if (RHS.getMinValue().uge(LHS.getMaxValue()))
321 KnownBits L = LHS.makeGE(RHS.getMinValue());
322 KnownBits R = RHS.makeGE(LHS.getMinValue());
323 return L.intersectWith(R);
328 auto Flip = [](
const KnownBits &Val) {
return KnownBits(Val.
One, Val.
Zero); };
329 return Flip(
umax(Flip(LHS), Flip(RHS)));
333 return flipSignBit(
umax(flipSignBit(LHS), flipSignBit(RHS)));
338 auto Flip = [](
const KnownBits &Val) {
342 Zero.setBitVal(SignBitPosition, Val.
Zero[SignBitPosition]);
343 One.setBitVal(SignBitPosition, Val.
One[SignBitPosition]);
346 return Flip(
umax(Flip(LHS), Flip(RHS)));
352 if (LHS.getMinValue().uge(RHS.getMaxValue()))
355 if (RHS.getMinValue().uge(LHS.getMaxValue()))
371 if (LHS.getSignedMinValue().sge(RHS.getSignedMaxValue()))
374 if (RHS.getSignedMinValue().sge(LHS.getSignedMaxValue()))
384 unsigned SignBitPosition = LHS.getBitWidth() - 1;
385 for (
auto Arg : {&LHS, &RHS}) {
386 bool Tmp = Arg->Zero[SignBitPosition];
387 Arg->Zero.setBitVal(SignBitPosition, Arg->One[SignBitPosition]);
388 Arg->One.setBitVal(SignBitPosition, Tmp);
407 bool NSW,
bool ShAmtNonZero) {
408 unsigned BitWidth = LHS.getBitWidth();
409 auto ShiftByConst = [&](
const KnownBits &LHS,
unsigned ShiftAmt) {
411 bool ShiftedOutZero, ShiftedOutOne;
412 Known.
Zero = LHS.Zero.
ushl_ov(ShiftAmt, ShiftedOutZero);
414 Known.
One = LHS.One.
ushl_ov(ShiftAmt, ShiftedOutOne);
418 if (NUW && ShiftAmt != 0)
420 ShiftedOutZero =
true;
424 else if (ShiftedOutOne)
432 unsigned MinShiftAmount = RHS.getMinValue().getLimitedValue(
BitWidth);
433 if (MinShiftAmount == 0 && ShAmtNonZero)
435 if (LHS.isUnknown()) {
437 if (NUW && NSW && MinShiftAmount != 0)
446 MaxShiftAmount = std::min(MaxShiftAmount, LHS.countMaxLeadingZeros() - 1);
448 MaxShiftAmount = std::min(MaxShiftAmount, LHS.countMaxLeadingZeros());
450 MaxShiftAmount = std::min(
452 std::max(LHS.countMaxLeadingZeros(), LHS.countMaxLeadingOnes()) - 1);
455 if (MinShiftAmount == 0 && MaxShiftAmount ==
BitWidth - 1 &&
461 if (LHS.isNonNegative())
463 if (LHS.isNegative())
470 unsigned ShiftAmtZeroMask = RHS.Zero.zextOrTrunc(32).getZExtValue();
471 unsigned ShiftAmtOneMask = RHS.One.zextOrTrunc(32).getZExtValue();
473 for (
unsigned ShiftAmt = MinShiftAmount; ShiftAmt <= MaxShiftAmount;
476 if ((ShiftAmtZeroMask & ShiftAmt) != 0 ||
477 (ShiftAmtOneMask | ShiftAmt) != ShiftAmt)
491 bool ShAmtNonZero,
bool Exact) {
492 unsigned BitWidth = LHS.getBitWidth();
493 auto ShiftByConst = [&](
const KnownBits &LHS,
unsigned ShiftAmt) {
494 KnownBits Known = LHS;
503 unsigned MinShiftAmount = RHS.getMinValue().getLimitedValue(
BitWidth);
504 if (MinShiftAmount == 0 && ShAmtNonZero)
506 if (LHS.isUnknown()) {
517 unsigned FirstOne = LHS.countMaxTrailingZeros();
518 if (FirstOne < MinShiftAmount) {
523 MaxShiftAmount = std::min(MaxShiftAmount, FirstOne);
526 unsigned ShiftAmtZeroMask = RHS.Zero.zextOrTrunc(32).getZExtValue();
527 unsigned ShiftAmtOneMask = RHS.One.zextOrTrunc(32).getZExtValue();
529 for (
unsigned ShiftAmt = MinShiftAmount; ShiftAmt <= MaxShiftAmount;
532 if ((ShiftAmtZeroMask & ShiftAmt) != 0 ||
533 (ShiftAmtOneMask | ShiftAmt) != ShiftAmt)
547 bool ShAmtNonZero,
bool Exact) {
548 unsigned BitWidth = LHS.getBitWidth();
549 auto ShiftByConst = [&](
const KnownBits &LHS,
unsigned ShiftAmt) {
550 KnownBits Known = LHS;
558 unsigned MinShiftAmount = RHS.getMinValue().getLimitedValue(
BitWidth);
559 if (MinShiftAmount == 0 && ShAmtNonZero)
561 if (LHS.isUnknown()) {
576 unsigned FirstOne = LHS.countMaxTrailingZeros();
577 if (FirstOne < MinShiftAmount) {
582 MaxShiftAmount = std::min(MaxShiftAmount, FirstOne);
585 unsigned ShiftAmtZeroMask = RHS.Zero.zextOrTrunc(32).getZExtValue();
586 unsigned ShiftAmtOneMask = RHS.One.zextOrTrunc(32).getZExtValue();
588 for (
unsigned ShiftAmt = MinShiftAmount; ShiftAmt <= MaxShiftAmount;
591 if ((ShiftAmtZeroMask & ShiftAmt) != 0 ||
592 (ShiftAmtOneMask | ShiftAmt) != ShiftAmt)
605std::optional<bool>
KnownBits::eq(
const KnownBits &LHS,
const KnownBits &RHS) {
606 if (LHS.isConstant() && RHS.isConstant())
607 return std::optional<bool>(LHS.getConstant() == RHS.getConstant());
608 if (LHS.One.intersects(RHS.Zero) || RHS.One.intersects(LHS.Zero))
609 return std::optional<bool>(
false);
613std::optional<bool>
KnownBits::ne(
const KnownBits &LHS,
const KnownBits &RHS) {
614 if (std::optional<bool> KnownEQ =
eq(LHS, RHS))
615 return std::optional<bool>(!*KnownEQ);
621 if (LHS.getMaxValue().ule(RHS.getMinValue()))
622 return std::optional<bool>(
false);
624 if (LHS.getMinValue().ugt(RHS.getMaxValue()))
625 return std::optional<bool>(
true);
630 if (std::optional<bool> IsUGT =
ugt(RHS, LHS))
631 return std::optional<bool>(!*IsUGT);
636 return ugt(RHS, LHS);
640 return uge(RHS, LHS);
645 if (LHS.getSignedMaxValue().sle(RHS.getSignedMinValue()))
646 return std::optional<bool>(
false);
648 if (LHS.getSignedMinValue().sgt(RHS.getSignedMaxValue()))
649 return std::optional<bool>(
true);
654 if (std::optional<bool> KnownSGT =
sgt(RHS, LHS))
655 return std::optional<bool>(!*KnownSGT);
660 return sgt(RHS, LHS);
664 return sge(RHS, LHS);
677 KnownBits Tmp = *
this;
686 false, IntMinIsPoison,
false,
716 if (IntMinIsPoison || (!
One.isZero() && !
One.isMinSignedValue())) {
754 LeadingZeros = LeadingZeros > LostBits ? LeadingZeros - LostBits : 0;
755 Result.Zero.setHighBits(LeadingZeros);
758 LeadingOnes = LeadingOnes > LostBits ? LeadingOnes - LostBits : 0;
759 Result.One.setHighBits(LeadingOnes);
772 std::optional<bool> Overflow;
777 bool MayNegClamp =
true;
778 bool MayPosClamp =
true;
781 if (
Add && ((
LHS.isNegative() &&
RHS.isNonNegative()) ||
782 (
LHS.isNonNegative() &&
RHS.isNegative())))
784 else if (!
Add && (((
LHS.isNegative() &&
RHS.isNegative()) ||
785 (
LHS.isNonNegative() &&
RHS.isNonNegative()))))
802 false, UnsignedLHS, UnsignedRHS);
808 if (
LHS.isNonNegative() &&
RHS.isNonNegative())
814 if (
LHS.isNegative() &&
RHS.isNegative())
818 if (
LHS.isNegative() ||
RHS.isNegative())
820 if (
LHS.isNonNegative() ||
RHS.isNonNegative())
827 if (
LHS.isNegative() &&
RHS.isNonNegative())
833 if (
LHS.isNonNegative() &&
RHS.isNegative())
837 if (
LHS.isNegative() ||
RHS.isNonNegative())
839 if (
LHS.isNonNegative() ||
RHS.isNegative())
844 if (!MayNegClamp && !MayPosClamp)
849 (void)
LHS.getMaxValue().uadd_ov(
RHS.getMaxValue(), Of);
853 (void)
LHS.getMinValue().uadd_ov(
RHS.getMinValue(), Of);
860 (void)
LHS.getMinValue().usub_ov(
RHS.getMaxValue(), Of);
864 (void)
LHS.getMaxValue().usub_ov(
RHS.getMinValue(), Of);
885 "We somehow know overflow without knowing input sign");
946 return flipSignBit(
avgFloorU(flipSignBit(LHS), flipSignBit(RHS)));
954 return flipSignBit(
avgCeilU(flipSignBit(LHS), flipSignBit(RHS)));
962 bool NoUndefSelfMultiply) {
963 unsigned BitWidth = LHS.getBitWidth();
965 assert((!NoUndefSelfMultiply || LHS == RHS) &&
966 "Self multiplication knownbits mismatch");
979 APInt UMaxResult = UMaxLHS.
umul_ov(UMaxRHS, HasOverflow);
980 unsigned LeadZ = HasOverflow ? 0 : UMaxResult.
countl_zero();
1024 const APInt &Bottom0 = LHS.One;
1025 const APInt &Bottom1 = RHS.One;
1029 unsigned TrailBitsKnown0 = (LHS.Zero | LHS.One).
countr_one();
1030 unsigned TrailBitsKnown1 = (RHS.Zero | RHS.One).
countr_one();
1031 unsigned TrailZero0 = LHS.countMinTrailingZeros();
1032 unsigned TrailZero1 = RHS.countMinTrailingZeros();
1033 unsigned TrailZ = TrailZero0 + TrailZero1;
1036 unsigned SmallestOperand =
1037 std::min(TrailBitsKnown0 - TrailZero0, TrailBitsKnown1 - TrailZero1);
1038 unsigned ResultBitsKnown = std::min(SmallestOperand + TrailZ,
BitWidth);
1045 Res.
Zero |= (~BottomKnown).getLoBits(ResultBitsKnown);
1048 if (NoUndefSelfMultiply) {
1050 unsigned TwoTZP1 = 2 * TrailZero0 + 1;
1056 if (TrailZero0 <
BitWidth && LHS.One[TrailZero0]) {
1057 unsigned TwoTZP2 = TwoTZP1 + 1;
1067 unsigned BitWidth = LHS.getBitWidth();
1069 KnownBits WideLHS = LHS.sext(2 *
BitWidth);
1070 KnownBits WideRHS = RHS.sext(2 *
BitWidth);
1075 unsigned BitWidth = LHS.getBitWidth();
1077 KnownBits WideLHS = LHS.zext(2 *
BitWidth);
1078 KnownBits WideRHS = RHS.zext(2 *
BitWidth);
1095 (int)
LHS.countMinTrailingZeros() - (int)
RHS.countMaxTrailingZeros();
1097 (int)
LHS.countMaxTrailingZeros() - (int)
RHS.countMinTrailingZeros();
1101 if (MinTZ == MaxTZ) {
1105 }
else if (MaxTZ < 0) {
1121 if (LHS.isNonNegative() && RHS.isNonNegative())
1122 return udiv(LHS, RHS, Exact);
1124 unsigned BitWidth = LHS.getBitWidth();
1127 if (LHS.isZero() || RHS.isZero()) {
1134 std::optional<APInt> Res;
1135 if (LHS.isNegative() && RHS.isNegative()) {
1144 }
else if (LHS.isNegative() && RHS.isNonNegative()) {
1146 if (Exact || (-LHS.getSignedMaxValue()).uge(RHS.getSignedMaxValue())) {
1149 Res = Denom.
isZero() ? Num : Num.
sdiv(Denom);
1151 }
else if (LHS.isStrictlyPositive() && RHS.isNegative()) {
1153 if (Exact || LHS.getSignedMinValue().uge(-RHS.getSignedMinValue())) {
1156 Res = Num.
sdiv(Denom);
1161 if (Res->isNonNegative()) {
1162 unsigned LeadZ = Res->countLeadingZeros();
1165 unsigned LeadO = Res->countLeadingOnes();
1176 unsigned BitWidth = LHS.getBitWidth();
1179 if (LHS.isZero() || RHS.isZero()) {
1202 unsigned BitWidth = LHS.getBitWidth();
1203 if (!RHS.isZero() && RHS.Zero[0]) {
1205 unsigned RHSZeros = RHS.countMinTrailingZeros();
1207 APInt OnesMask = LHS.One & Mask;
1208 APInt ZerosMask = LHS.Zero & Mask;
1215 KnownBits Known = remGetLowBits(LHS, RHS);
1216 if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
1218 APInt HighBits = ~(RHS.getConstant() - 1);
1219 Known.
Zero |= HighBits;
1226 std::max(LHS.countMinLeadingZeros(), RHS.countMinLeadingZeros());
1232 KnownBits Known = remGetLowBits(LHS, RHS);
1233 if (RHS.isConstant() && RHS.getConstant().isPowerOf2()) {
1235 APInt LowBits = RHS.getConstant() - 1;
1238 if (LHS.isNonNegative() || LowBits.
isSubsetOf(LHS.Zero))
1239 Known.
Zero |= ~LowBits;
1243 if (LHS.isNegative() && LowBits.
intersects(LHS.One))
1244 Known.
One |= ~LowBits;
1251 if (LHS.isNegative() && Known.
isNonZero())
1253 std::max(LHS.countMinLeadingOnes(), RHS.countMinSignBits()));
1254 else if (LHS.isNonNegative())
1256 std::max(LHS.countMinLeadingZeros(), RHS.countMinSignBits()));
1281 Zero = std::move(Z);
1321#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
static KnownBits avgComputeU(KnownBits LHS, KnownBits RHS, bool IsCeil)
static KnownBits computeForSatAddSub(bool Add, bool Signed, const KnownBits &LHS, const KnownBits &RHS)
static KnownBits divComputeLowBit(KnownBits Known, const KnownBits &LHS, const KnownBits &RHS, bool Exact)
static KnownBits computeForAddCarry(const KnownBits &LHS, const KnownBits &RHS, bool CarryZero, bool CarryOne)
static unsigned getMaxShiftAmount(const APInt &MaxValue, unsigned BitWidth)
Class for arbitrary precision integers.
LLVM_ABI APInt umul_ov(const APInt &RHS, bool &Overflow) const
LLVM_ABI APInt usub_sat(const APInt &RHS) const
LLVM_ABI APInt udiv(const APInt &RHS) const
Unsigned division operation.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
LLVM_ABI APInt getLoBits(unsigned numBits) const
Compute an APInt containing numBits lowbits from this APInt.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
LLVM_ABI uint64_t extractBitsAsZExtValue(unsigned numBits, unsigned bitPosition) const
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
LLVM_ABI APInt sadd_sat(const APInt &RHS) const
bool sgt(const APInt &RHS) const
Signed greater than comparison.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
void setSignBit()
Set the sign bit to 1.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
bool isNegative() const
Determine sign of this APInt.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
LLVM_ABI APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
void clearAllBits()
Set every bit to 0.
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
unsigned countl_zero() const
The APInt version of std::countl_zero.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
LLVM_ABI APInt ushl_ov(const APInt &Amt, bool &Overflow) const
unsigned countLeadingZeros() const
unsigned countl_one() const
Count the number of leading one bits.
void clearLowBits(unsigned loBits)
Set bottom loBits bits to 0.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
LLVM_ABI APInt uadd_sat(const APInt &RHS) const
bool getBoolValue() const
Convert APInt to a boolean value.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
bool slt(const APInt &RHS) const
Signed less than comparison.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
void clearSignBit()
Set the sign bit to 0.
LLVM_ABI APInt ssub_sat(const APInt &RHS) const
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
int countr_one(T Value)
Count the number of ones from the least significant bit to the first zero bit.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
int countl_one(T Value)
Count the number of ones from the most significant bit to the first zero bit.
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
static LLVM_ABI KnownBits sadd_sat(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from llvm.sadd.sat(LHS, RHS)
static LLVM_ABI std::optional< bool > eq(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_EQ result.
LLVM_ABI KnownBits sextInReg(unsigned SrcBitWidth) const
Return known bits for a in-register sign extension of the value we're tracking.
static LLVM_ABI KnownBits mulhu(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from zero-extended multiply-hi.
static LLVM_ABI KnownBits smax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smax(LHS, RHS).
bool isNonNegative() const
Returns true if this value is known to be non-negative.
LLVM_ABI KnownBits blsi() const
Compute known bits for X & -X, which has only the lowest bit set of X set.
void makeNonNegative()
Make this value non-negative.
static LLVM_ABI KnownBits usub_sat(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from llvm.usub.sat(LHS, RHS)
unsigned countMinLeadingOnes() const
Returns the minimum number of leading one bits.
LLVM_ABI KnownBits reduceAdd(unsigned NumElts) const
Compute known bits for horizontal add for a vector with NumElts elements, where each element has the ...
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
static LLVM_ABI KnownBits ashr(const KnownBits &LHS, const KnownBits &RHS, bool ShAmtNonZero=false, bool Exact=false)
Compute known bits for ashr(LHS, RHS).
static LLVM_ABI KnownBits ssub_sat(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from llvm.ssub.sat(LHS, RHS)
static LLVM_ABI KnownBits urem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for urem(LHS, RHS).
bool isUnknown() const
Returns true if we don't know any bits.
unsigned countMaxTrailingZeros() const
Returns the maximum number of trailing zero bits possible.
static LLVM_ABI std::optional< bool > ne(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_NE result.
LLVM_ABI KnownBits makeGE(const APInt &Val) const
Return KnownBits based on this, but updated given that the underlying value is known to be greater th...
APInt getSignedMaxValue() const
Return the maximal signed value possible given these KnownBits.
LLVM_ABI KnownBits blsmsk() const
Compute known bits for X ^ (X - 1), which has all bits up to and including the lowest set bit of X se...
void makeNegative()
Make this value negative.
void setAllConflict()
Make all bits known to be both zero and one.
KnownBits trunc(unsigned BitWidth) const
Return known bits for a truncation of the value we're tracking.
bool hasConflict() const
Returns true if there is conflicting information.
static LLVM_ABI std::optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
unsigned countMaxPopulation() const
Returns the maximum number of bits that could be one.
void setAllZero()
Make all bits known to be zero and discard any previous information.
LLVM_ABI KnownBits & operator|=(const KnownBits &RHS)
Update known bits based on ORing with RHS.
LLVM_ABI void print(raw_ostream &OS) const
unsigned getBitWidth() const
Get the bit width of this value.
static LLVM_ABI KnownBits umax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umax(LHS, RHS).
bool isConstant() const
Returns true if we know the value of all bits.
void resetAll()
Resets the known state of all bits.
LLVM_DUMP_METHOD void dump() const
static LLVM_ABI KnownBits lshr(const KnownBits &LHS, const KnownBits &RHS, bool ShAmtNonZero=false, bool Exact=false)
Compute known bits for lshr(LHS, RHS).
bool isNonZero() const
Returns true if this value is known to be non-zero.
static LLVM_ABI KnownBits abdu(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for abdu(LHS, RHS).
KnownBits extractBits(unsigned NumBits, unsigned BitPosition) const
Return a subset of the known bits from [bitPosition,bitPosition+numBits).
static LLVM_ABI KnownBits avgFloorU(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from APIntOps::avgFloorU.
KnownBits intersectWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for both this and RHS.
static LLVM_ABI KnownBits computeForSubBorrow(const KnownBits &LHS, KnownBits RHS, const KnownBits &Borrow)
Compute known bits results from subtracting RHS from LHS with 1-bit Borrow.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
static LLVM_ABI KnownBits abds(KnownBits LHS, KnownBits RHS)
Compute known bits for abds(LHS, RHS).
static LLVM_ABI KnownBits smin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smin(LHS, RHS).
LLVM_ABI KnownBits & operator&=(const KnownBits &RHS)
Update known bits based on ANDing with RHS.
static LLVM_ABI KnownBits mulhs(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits from sign-extended multiply-hi.
static LLVM_ABI KnownBits srem(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for srem(LHS, RHS).
static LLVM_ABI std::optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
static LLVM_ABI KnownBits udiv(const KnownBits &LHS, const KnownBits &RHS, bool Exact=false)
Compute known bits for udiv(LHS, RHS).
static LLVM_ABI std::optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
APInt getMinValue() const
Return the minimal unsigned value possible given these KnownBits.
static LLVM_ABI KnownBits computeForAddSub(bool Add, bool NSW, bool NUW, const KnownBits &LHS, const KnownBits &RHS)
Compute known bits resulting from adding LHS and RHS.
static LLVM_ABI KnownBits sdiv(const KnownBits &LHS, const KnownBits &RHS, bool Exact=false)
Compute known bits for sdiv(LHS, RHS).
static LLVM_ABI std::optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
static LLVM_ABI KnownBits avgFloorS(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from APIntOps::avgFloorS.
static LLVM_ABI std::optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
bool isNegative() const
Returns true if this value is known to be negative.
LLVM_ABI KnownBits truncSSat(unsigned BitWidth) const
Truncate with signed saturation (signed input -> signed output)
static LLVM_ABI KnownBits computeForAddCarry(const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry)
Compute known bits resulting from adding LHS, RHS and a 1-bit Carry.
void setAllOnes()
Make all bits known to be one and discard any previous information.
static LLVM_ABI KnownBits avgCeilU(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from APIntOps::avgCeilU.
static LLVM_ABI KnownBits uadd_sat(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from llvm.uadd.sat(LHS, RHS)
static LLVM_ABI KnownBits mul(const KnownBits &LHS, const KnownBits &RHS, bool NoUndefSelfMultiply=false)
Compute known bits resulting from multiplying LHS and RHS.
LLVM_ABI KnownBits abs(bool IntMinIsPoison=false) const
Compute known bits for the absolute value.
static LLVM_ABI std::optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
static LLVM_ABI std::optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.
unsigned countMinPopulation() const
Returns the number of bits known to be one.
LLVM_ABI KnownBits truncUSat(unsigned BitWidth) const
Truncate with unsigned saturation (unsigned input -> unsigned output)
static LLVM_ABI std::optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
APInt getSignedMinValue() const
Return the minimal signed value possible given these KnownBits.
LLVM_ABI KnownBits & operator^=(const KnownBits &RHS)
Update known bits based on XORing with RHS.
static LLVM_ABI KnownBits shl(const KnownBits &LHS, const KnownBits &RHS, bool NUW=false, bool NSW=false, bool ShAmtNonZero=false)
Compute known bits for shl(LHS, RHS).
static LLVM_ABI KnownBits umin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umin(LHS, RHS).
LLVM_ABI KnownBits truncSSatU(unsigned BitWidth) const
Truncate with signed saturation to unsigned (signed input -> unsigned output)
static LLVM_ABI KnownBits avgCeilS(const KnownBits &LHS, const KnownBits &RHS)
Compute knownbits resulting from APIntOps::avgCeilS.
const APInt & getConstant() const
Returns the value when all bits have a known value.