LLVM  13.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
llvm::KnownBits Struct Reference

#include "llvm/Support/KnownBits.h"

Collaboration diagram for llvm::KnownBits:
Collaboration graph
[legend]

Public Member Functions

 KnownBits ()
 
 KnownBits (unsigned BitWidth)
 Create a known bits object of BitWidth bits initialized to unknown. More...
 
unsigned getBitWidth () const
 Get the bit width of this value. More...
 
bool hasConflict () const
 Returns true if there is conflicting information. More...
 
bool isConstant () const
 Returns true if we know the value of all bits. More...
 
const APIntgetConstant () const
 Returns the value when all bits have a known value. More...
 
bool isUnknown () const
 Returns true if we don't know any bits. More...
 
void resetAll ()
 Resets the known state of all bits. More...
 
bool isZero () const
 Returns true if value is all zero. More...
 
bool isAllOnes () const
 Returns true if value is all one bits. More...
 
void setAllZero ()
 Make all bits known to be zero and discard any previous information. More...
 
void setAllOnes ()
 Make all bits known to be one and discard any previous information. More...
 
bool isNegative () const
 Returns true if this value is known to be negative. More...
 
bool isNonNegative () const
 Returns true if this value is known to be non-negative. More...
 
bool isNonZero () const
 Returns true if this value is known to be non-zero. More...
 
bool isStrictlyPositive () const
 Returns true if this value is known to be positive. More...
 
void makeNegative ()
 Make this value negative. More...
 
void makeNonNegative ()
 Make this value non-negative. More...
 
APInt getMinValue () const
 Return the minimal unsigned value possible given these KnownBits. More...
 
APInt getSignedMinValue () const
 Return the minimal signed value possible given these KnownBits. More...
 
APInt getMaxValue () const
 Return the maximal unsigned value possible given these KnownBits. More...
 
APInt getSignedMaxValue () const
 Return the maximal signed value possible given these KnownBits. More...
 
KnownBits trunc (unsigned BitWidth) const
 Return known bits for a truncation of the value we're tracking. More...
 
KnownBits anyext (unsigned BitWidth) const
 Return known bits for an "any" extension of the value we're tracking, where we don't know anything about the extended bits. More...
 
KnownBits zext (unsigned BitWidth) const
 Return known bits for a zero extension of the value we're tracking. More...
 
KnownBits sext (unsigned BitWidth) const
 Return known bits for a sign extension of the value we're tracking. More...
 
KnownBits anyextOrTrunc (unsigned BitWidth) const
 Return known bits for an "any" extension or truncation of the value we're tracking. More...
 
KnownBits zextOrTrunc (unsigned BitWidth) const
 Return known bits for a zero extension or truncation of the value we're tracking. More...
 
KnownBits sextOrTrunc (unsigned BitWidth) const
 Return known bits for a sign extension or truncation of the value we're tracking. More...
 
KnownBits sextInReg (unsigned SrcBitWidth) const
 Return known bits for a in-register sign extension of the value we're tracking. More...
 
KnownBits extractBits (unsigned NumBits, unsigned BitPosition) const
 Return a KnownBits with the extracted bits [bitPosition,bitPosition+numBits). More...
 
KnownBits makeGE (const APInt &Val) const
 Return KnownBits based on this, but updated given that the underlying value is known to be greater than or equal to Val. More...
 
unsigned countMinTrailingZeros () const
 Returns the minimum number of trailing zero bits. More...
 
unsigned countMinTrailingOnes () const
 Returns the minimum number of trailing one bits. More...
 
unsigned countMinLeadingZeros () const
 Returns the minimum number of leading zero bits. More...
 
unsigned countMinLeadingOnes () const
 Returns the minimum number of leading one bits. More...
 
unsigned countMinSignBits () const
 Returns the number of times the sign bit is replicated into the other bits. More...
 
unsigned countMaxTrailingZeros () const
 Returns the maximum number of trailing zero bits possible. More...
 
unsigned countMaxTrailingOnes () const
 Returns the maximum number of trailing one bits possible. More...
 
unsigned countMaxLeadingZeros () const
 Returns the maximum number of leading zero bits possible. More...
 
unsigned countMaxLeadingOnes () const
 Returns the maximum number of leading one bits possible. More...
 
unsigned countMinPopulation () const
 Returns the number of bits known to be one. More...
 
unsigned countMaxPopulation () const
 Returns the maximum number of bits that could be one. More...
 
void insertBits (const KnownBits &SubBits, unsigned BitPosition)
 Insert the bits from a smaller known bits starting at bitPosition. More...
 
KnownBits extractBits (unsigned NumBits, unsigned BitPosition)
 Return a subset of the known bits from [bitPosition,bitPosition+numBits). More...
 
KnownBitsoperator&= (const KnownBits &RHS)
 Update known bits based on ANDing with RHS. More...
 
KnownBitsoperator|= (const KnownBits &RHS)
 Update known bits based on ORing with RHS. More...
 
KnownBitsoperator^= (const KnownBits &RHS)
 Update known bits based on XORing with RHS. More...
 
KnownBits abs (bool IntMinIsPoison=false) const
 Compute known bits for the absolute value. More...
 
KnownBits byteSwap ()
 
KnownBits reverseBits ()
 
void print (raw_ostream &OS) const
 
void dump () const
 

Static Public Member Functions

static KnownBits makeConstant (const APInt &C)
 Create known bits from a known constant. More...
 
static KnownBits commonBits (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits common to LHS and RHS. More...
 
static bool haveNoCommonBitsSet (const KnownBits &LHS, const KnownBits &RHS)
 Return true if LHS and RHS have no common bits set. More...
 
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. More...
 
static KnownBits computeForAddSub (bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS)
 Compute known bits resulting from adding LHS and RHS. More...
 
static KnownBits mul (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits resulting from multiplying LHS and RHS. More...
 
static KnownBits mulhs (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits from sign-extended multiply-hi. More...
 
static KnownBits mulhu (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits from zero-extended multiply-hi. More...
 
static KnownBits udiv (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for udiv(LHS, RHS). More...
 
static KnownBits urem (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for urem(LHS, RHS). More...
 
static KnownBits srem (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for srem(LHS, RHS). More...
 
static KnownBits umax (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for umax(LHS, RHS). More...
 
static KnownBits umin (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for umin(LHS, RHS). More...
 
static KnownBits smax (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for smax(LHS, RHS). More...
 
static KnownBits smin (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for smin(LHS, RHS). More...
 
static KnownBits shl (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for shl(LHS, RHS). More...
 
static KnownBits lshr (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for lshr(LHS, RHS). More...
 
static KnownBits ashr (const KnownBits &LHS, const KnownBits &RHS)
 Compute known bits for ashr(LHS, RHS). More...
 
static Optional< bool > eq (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_EQ result. More...
 
static Optional< bool > ne (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_NE result. More...
 
static Optional< bool > ugt (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_UGT result. More...
 
static Optional< bool > uge (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_UGE result. More...
 
static Optional< bool > ult (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_ULT result. More...
 
static Optional< bool > ule (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_ULE result. More...
 
static Optional< bool > sgt (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_SGT result. More...
 
static Optional< bool > sge (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_SGE result. More...
 
static Optional< bool > slt (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_SLT result. More...
 
static Optional< bool > sle (const KnownBits &LHS, const KnownBits &RHS)
 Determine if these known bits always give the same ICMP_SLE result. More...
 

Public Attributes

APInt Zero
 
APInt One
 

Detailed Description

Definition at line 23 of file KnownBits.h.

Constructor & Destructor Documentation

◆ KnownBits() [1/2]

llvm::KnownBits::KnownBits ( )
inline

◆ KnownBits() [2/2]

llvm::KnownBits::KnownBits ( unsigned  BitWidth)
inline

Create a known bits object of BitWidth bits initialized to unknown.

Definition at line 37 of file KnownBits.h.

Member Function Documentation

◆ abs()

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

◆ anyext()

KnownBits llvm::KnownBits::anyext ( unsigned  BitWidth) const
inline

Return known bits for an "any" extension of the value we're tracking, where we don't know anything about the extended bits.

Definition at line 156 of file KnownBits.h.

References llvm::BitWidth, KnownBits(), One, Zero, and llvm::APInt::zext().

Referenced by anyextOrTrunc(), llvm::SelectionDAG::computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::FunctionLoweringInfo::GetLiveOutRegInfo(), and llvm::TargetLowering::SimplifyDemandedBits().

◆ anyextOrTrunc()

KnownBits llvm::KnownBits::anyextOrTrunc ( unsigned  BitWidth) const
inline

Return known bits for an "any" extension or truncation of the value we're tracking.

Definition at line 175 of file KnownBits.h.

References anyext(), llvm::BitWidth, getBitWidth(), and trunc().

Referenced by llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), and llvm::TargetLowering::SimplifyDemandedBits().

◆ ashr()

KnownBits KnownBits::ashr ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ byteSwap()

KnownBits llvm::KnownBits::byteSwap ( )
inline

◆ commonBits()

static KnownBits llvm::KnownBits::commonBits ( const KnownBits LHS,
const KnownBits RHS 
)
inlinestatic

◆ computeForAddCarry()

KnownBits KnownBits::computeForAddCarry ( const KnownBits LHS,
const KnownBits RHS,
const KnownBits Carry 
)
static

Compute known bits resulting from adding LHS, RHS and a 1-bit Carry.

Definition at line 50 of file KnownBits.cpp.

References assert(), computeForAddCarry(), getBitWidth(), llvm::APInt::getBoolValue(), One, and Zero.

Referenced by computeForAddSub(), and llvm::SelectionDAG::computeKnownBits().

◆ computeForAddSub()

KnownBits KnownBits::computeForAddSub ( bool  Add,
bool  NSW,
const KnownBits LHS,
KnownBits  RHS 
)
static

◆ countMaxLeadingOnes()

unsigned llvm::KnownBits::countMaxLeadingOnes ( ) const
inline

Returns the maximum number of leading one bits possible.

Definition at line 264 of file KnownBits.h.

References llvm::APInt::countLeadingZeros(), and Zero.

◆ countMaxLeadingZeros()

unsigned llvm::KnownBits::countMaxLeadingZeros ( ) const
inline

◆ countMaxPopulation()

unsigned llvm::KnownBits::countMaxPopulation ( ) const
inline

◆ countMaxTrailingOnes()

unsigned llvm::KnownBits::countMaxTrailingOnes ( ) const
inline

Returns the maximum number of trailing one bits possible.

Definition at line 254 of file KnownBits.h.

References llvm::APInt::countTrailingZeros(), and Zero.

◆ countMaxTrailingZeros()

unsigned llvm::KnownBits::countMaxTrailingZeros ( ) const
inline

Returns the maximum number of trailing zero bits possible.

Definition at line 249 of file KnownBits.h.

References llvm::APInt::countTrailingZeros(), and One.

Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), and foldCttzCtlz().

◆ countMinLeadingOnes()

unsigned llvm::KnownBits::countMinLeadingOnes ( ) const
inline

◆ countMinLeadingZeros()

unsigned llvm::KnownBits::countMinLeadingZeros ( ) const
inline

◆ countMinPopulation()

unsigned llvm::KnownBits::countMinPopulation ( ) const
inline

◆ countMinSignBits()

unsigned llvm::KnownBits::countMinSignBits ( ) const
inline

Returns the number of times the sign bit is replicated into the other bits.

Definition at line 240 of file KnownBits.h.

References countMinLeadingOnes(), countMinLeadingZeros(), isNegative(), and isNonNegative().

Referenced by llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), and ComputeNumSignBitsImpl().

◆ countMinTrailingOnes()

unsigned llvm::KnownBits::countMinTrailingOnes ( ) const
inline

Returns the minimum number of trailing one bits.

Definition at line 224 of file KnownBits.h.

References llvm::APInt::countTrailingOnes(), and One.

Referenced by computeKnownBitsFromOperator().

◆ countMinTrailingZeros()

unsigned llvm::KnownBits::countMinTrailingZeros ( ) const
inline

◆ dump()

void KnownBits::dump ( ) const

Definition at line 611 of file KnownBits.cpp.

References llvm::dbgs(), and print().

◆ eq()

Optional< bool > KnownBits::eq ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_EQ result.

Definition at line 333 of file KnownBits.cpp.

References getConstant(), llvm::APInt::intersects(), isConstant(), llvm::None, One, and Zero.

Referenced by ne().

◆ extractBits() [1/2]

KnownBits llvm::KnownBits::extractBits ( unsigned  NumBits,
unsigned  BitPosition 
)
inline

Return a subset of the known bits from [bitPosition,bitPosition+numBits).

Definition at line 380 of file KnownBits.h.

References llvm::APInt::extractBits(), KnownBits(), One, and Zero.

◆ extractBits() [2/2]

KnownBits llvm::KnownBits::extractBits ( unsigned  NumBits,
unsigned  BitPosition 
) const
inline

◆ getBitWidth()

unsigned llvm::KnownBits::getBitWidth ( ) const
inline

Get the bit width of this value.

Definition at line 40 of file KnownBits.h.

References assert(), llvm::APInt::getBitWidth(), One, and Zero.

Referenced by abs(), anyextOrTrunc(), ashr(), computeForAddCarry(), llvm::SelectionDAG::computeKnownBits(), computeKnownBits(), llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), countMaxPopulation(), foldShiftIntoShiftInAnotherHandOfAndInICmp(), llvm::ConstantRange::fromKnownBits(), llvm::FunctionLoweringInfo::GetLiveOutRegInfo(), llvm::getOrEnforceKnownAlignment(), isConstant(), lshr(), makeGE(), llvm::CombinerHelper::matchCombineTruncOfShl(), mul(), mulhs(), mulhu(), llvm::AMDGPUTargetLowering::performTruncateCombine(), sextInReg(), sextOrTrunc(), shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), SimplifyShift(), smax(), smin(), srem(), tryBitfieldInsertOpFromOr(), udiv(), urem(), llvm::InstCombinerImpl::visitSwitchInst(), zext(), and zextOrTrunc().

◆ getConstant()

const APInt& llvm::KnownBits::getConstant ( ) const
inline

Returns the value when all bits have a known value.

This just returns One with a protective assertion.

Definition at line 57 of file KnownBits.h.

References assert(), isConstant(), and One.

Referenced by ashr(), computeKnownBitsFromOperator(), eq(), lshr(), llvm::AMDGPUTargetLowering::performTruncateCombine(), shl(), srem(), urem(), and llvm::InstCombinerImpl::visitReturnInst().

◆ getMaxValue()

APInt llvm::KnownBits::getMaxValue ( ) const
inline

◆ getMinValue()

APInt llvm::KnownBits::getMinValue ( ) const
inline

Return the minimal unsigned value possible given these KnownBits.

Definition at line 118 of file KnownBits.h.

References One.

Referenced by ashr(), computeForAddCarry(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), llvm::ConstantRange::fromKnownBits(), lshr(), shl(), SimplifyShift(), simplifyX86immShift(), ugt(), and umax().

◆ getSignedMaxValue()

APInt llvm::KnownBits::getSignedMaxValue ( ) const
inline

Return the maximal signed value possible given these KnownBits.

Definition at line 140 of file KnownBits.h.

References llvm::APInt::isSignBitClear(), One, and Zero.

Referenced by llvm::InstCombinerImpl::foldICmpUsingKnownBits(), and sgt().

◆ getSignedMinValue()

APInt llvm::KnownBits::getSignedMinValue ( ) const
inline

Return the minimal signed value possible given these KnownBits.

Definition at line 124 of file KnownBits.h.

References llvm::APInt::isSignBitClear(), One, llvm::APInt::setSignBit(), and Zero.

Referenced by llvm::InstCombinerImpl::foldICmpUsingKnownBits(), and sgt().

◆ hasConflict()

bool llvm::KnownBits::hasConflict ( ) const
inline

◆ haveNoCommonBitsSet()

static bool llvm::KnownBits::haveNoCommonBitsSet ( const KnownBits LHS,
const KnownBits RHS 
)
inlinestatic

Return true if LHS and RHS have no common bits set.

Definition at line 289 of file KnownBits.h.

References Zero.

Referenced by llvm::haveNoCommonBitsSet(), and llvm::SelectionDAG::haveNoCommonBitsSet().

◆ insertBits()

void llvm::KnownBits::insertBits ( const KnownBits SubBits,
unsigned  BitPosition 
)
inline

Insert the bits from a smaller known bits starting at bitPosition.

Definition at line 374 of file KnownBits.h.

References llvm::APInt::insertBits(), One, and Zero.

Referenced by llvm::GISelKnownBits::computeKnownBitsImpl().

◆ isAllOnes()

bool llvm::KnownBits::isAllOnes ( ) const
inline

Returns true if value is all one bits.

Definition at line 78 of file KnownBits.h.

References assert(), hasConflict(), llvm::APInt::isAllOnesValue(), and One.

Referenced by computeKnownBitsFromAssume(), and llvm::InstCombinerImpl::visitCallInst().

◆ isConstant()

bool llvm::KnownBits::isConstant ( ) const
inline

◆ isNegative()

bool llvm::KnownBits::isNegative ( ) const
inline

◆ isNonNegative()

bool llvm::KnownBits::isNonNegative ( ) const
inline

◆ isNonZero()

bool llvm::KnownBits::isNonZero ( ) const
inline

Returns true if this value is known to be non-zero.

Definition at line 102 of file KnownBits.h.

References llvm::APInt::isNullValue(), and One.

Referenced by computeKnownBitsMul().

◆ isStrictlyPositive()

bool llvm::KnownBits::isStrictlyPositive ( ) const
inline

Returns true if this value is known to be positive.

Definition at line 105 of file KnownBits.h.

References llvm::APInt::isNullValue(), llvm::APInt::isSignBitSet(), One, and Zero.

Referenced by llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode().

◆ isUnknown()

bool llvm::KnownBits::isUnknown ( ) const
inline

◆ isZero()

bool llvm::KnownBits::isZero ( ) const
inline

◆ lshr()

KnownBits KnownBits::lshr ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ makeConstant()

static KnownBits llvm::KnownBits::makeConstant ( const APInt C)
inlinestatic

◆ makeGE()

KnownBits KnownBits::makeGE ( const APInt Val) const

Return KnownBits based on this, but updated given that the underlying value is known to be greater than or equal to Val.

Definition at line 105 of file KnownBits.cpp.

References llvm::APInt::clearLowBits(), llvm::countLeadingOnes(), getBitWidth(), KnownBits(), N, One, and Zero.

Referenced by umax().

◆ makeNegative()

void llvm::KnownBits::makeNegative ( )
inline

Make this value negative.

Definition at line 108 of file KnownBits.h.

References One, and llvm::APInt::setSignBit().

Referenced by computeForAddSub(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), and computeKnownBitsMul().

◆ makeNonNegative()

void llvm::KnownBits::makeNonNegative ( )
inline

◆ mul()

KnownBits KnownBits::mul ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ mulhs()

KnownBits KnownBits::mulhs ( const KnownBits LHS,
const KnownBits RHS 
)
static

Compute known bits from sign-extended multiply-hi.

Definition at line 495 of file KnownBits.cpp.

References assert(), llvm::BitWidth, extractBits(), getBitWidth(), hasConflict(), mul(), and sext().

Referenced by llvm::SelectionDAG::computeKnownBits().

◆ mulhu()

KnownBits KnownBits::mulhu ( const KnownBits LHS,
const KnownBits RHS 
)
static

Compute known bits from zero-extended multiply-hi.

Definition at line 504 of file KnownBits.cpp.

References assert(), llvm::BitWidth, extractBits(), getBitWidth(), hasConflict(), mul(), and zext().

Referenced by llvm::SelectionDAG::computeKnownBits().

◆ ne()

Optional< bool > KnownBits::ne ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_NE result.

Definition at line 341 of file KnownBits.cpp.

References eq(), and llvm::None.

◆ operator&=()

KnownBits & KnownBits::operator&= ( const KnownBits RHS)

Update known bits based on ANDing with RHS.

Definition at line 583 of file KnownBits.cpp.

References One, and Zero.

◆ operator^=()

KnownBits & KnownBits::operator^= ( const KnownBits RHS)

Update known bits based on XORing with RHS.

Definition at line 599 of file KnownBits.cpp.

References move, One, and Zero.

◆ operator|=()

KnownBits & KnownBits::operator|= ( const KnownBits RHS)

Update known bits based on ORing with RHS.

Definition at line 591 of file KnownBits.cpp.

References One, and Zero.

◆ print()

void KnownBits::print ( raw_ostream OS) const

Definition at line 608 of file KnownBits.cpp.

References One, and Zero.

Referenced by dump().

◆ resetAll()

void llvm::KnownBits::resetAll ( )
inline

◆ reverseBits()

KnownBits llvm::KnownBits::reverseBits ( )
inline

◆ setAllOnes()

void llvm::KnownBits::setAllOnes ( )
inline

Make all bits known to be one and discard any previous information.

Definition at line 90 of file KnownBits.h.

References llvm::APInt::clearAllBits(), One, llvm::APInt::setAllBits(), and Zero.

Referenced by computeKnownBitsFromAssume().

◆ setAllZero()

void llvm::KnownBits::setAllZero ( )
inline

◆ sext()

KnownBits llvm::KnownBits::sext ( unsigned  BitWidth) const
inline

◆ sextInReg()

KnownBits KnownBits::sextInReg ( unsigned  SrcBitWidth) const

Return known bits for a in-register sign extension of the value we're tracking.

Definition at line 88 of file KnownBits.cpp.

References assert(), llvm::BitWidth, getBitWidth(), One, and Zero.

Referenced by llvm::SelectionDAG::computeKnownBits(), and llvm::GISelKnownBits::computeKnownBitsImpl().

◆ sextOrTrunc()

KnownBits llvm::KnownBits::sextOrTrunc ( unsigned  BitWidth) const
inline

Return known bits for a sign extension or truncation of the value we're tracking.

Definition at line 195 of file KnownBits.h.

References llvm::BitWidth, getBitWidth(), sext(), and trunc().

Referenced by computeKnownBitsFromOperator().

◆ sge()

Optional< bool > KnownBits::sge ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_SGE result.

Definition at line 381 of file KnownBits.cpp.

References llvm::None, and sgt().

Referenced by sle().

◆ sgt()

Optional< bool > KnownBits::sgt ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_SGT result.

Definition at line 371 of file KnownBits.cpp.

References getSignedMaxValue(), getSignedMinValue(), llvm::None, llvm::APInt::sgt(), and llvm::APInt::sle().

Referenced by sge(), and slt().

◆ shl()

KnownBits KnownBits::shl ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ sle()

Optional< bool > KnownBits::sle ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_SLE result.

Definition at line 391 of file KnownBits.cpp.

References sge().

◆ slt()

Optional< bool > KnownBits::slt ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_SLT result.

Definition at line 387 of file KnownBits.cpp.

References sgt().

◆ smax()

KnownBits KnownBits::smax ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ smin()

KnownBits KnownBits::smin ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ srem()

KnownBits KnownBits::srem ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ trunc()

KnownBits llvm::KnownBits::trunc ( unsigned  BitWidth) const
inline

◆ udiv()

KnownBits KnownBits::udiv ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ uge()

Optional< bool > KnownBits::uge ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_UGE result.

Definition at line 357 of file KnownBits.cpp.

References llvm::None, and ugt().

Referenced by llvm::TargetLowering::SimplifyDemandedBits(), and ule().

◆ ugt()

Optional< bool > KnownBits::ugt ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_UGT result.

Definition at line 347 of file KnownBits.cpp.

References getMaxValue(), getMinValue(), llvm::None, llvm::APInt::ugt(), and llvm::APInt::ule().

Referenced by llvm::TargetLowering::SimplifyDemandedBits(), uge(), and ult().

◆ ule()

Optional< bool > KnownBits::ule ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_ULE result.

Definition at line 367 of file KnownBits.cpp.

References uge().

Referenced by llvm::TargetLowering::SimplifyDemandedBits().

◆ ult()

Optional< bool > KnownBits::ult ( const KnownBits LHS,
const KnownBits RHS 
)
static

Determine if these known bits always give the same ICMP_ULT result.

Definition at line 363 of file KnownBits.cpp.

References ugt().

Referenced by llvm::TargetLowering::SimplifyDemandedBits().

◆ umax()

KnownBits KnownBits::umax ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ umin()

KnownBits KnownBits::umin ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ urem()

KnownBits KnownBits::urem ( const KnownBits LHS,
const KnownBits RHS 
)
static

◆ zext()

KnownBits llvm::KnownBits::zext ( unsigned  BitWidth) const
inline

◆ zextOrTrunc()

KnownBits llvm::KnownBits::zextOrTrunc ( unsigned  BitWidth) const
inline

Member Data Documentation

◆ One

APInt llvm::KnownBits::One

Definition at line 25 of file KnownBits.h.

Referenced by abs(), llvm::FunctionLoweringInfo::AddLiveOutRegInfo(), anyext(), ashr(), byteSwap(), llvm::SelectionDAGISel::CheckOrMask(), commonBits(), computeForAddCarry(), computeForAddCarry(), computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), computeKnownBits(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::GISelKnownBits::computeNumSignBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), countMaxLeadingZeros(), countMaxTrailingZeros(), countMinLeadingOnes(), countMinPopulation(), countMinTrailingOnes(), determineLiveOperandBitsAddCarry(), llvm::DemandedBits::determineLiveOperandBitsSub(), dumpResult(), eliminateDeadSwitchCases(), eq(), extractBits(), foldCttzCtlz(), llvm::InstCombinerImpl::foldICmpTruncConstant(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), getBitWidth(), getConstant(), llvm::GISelKnownBits::getKnownOnes(), getMinValue(), getSignedMaxValue(), getSignedMinValue(), getValueFromICmpCondition(), hasConflict(), insertBits(), isAllOnes(), isConstant(), isKnownNonEqual(), isKnownNonZero(), isKnownToBeAPowerOfTwo(), isNegative(), isNonZero(), isStrictlyPositive(), isUnknown(), lshr(), makeGE(), makeNegative(), llvm::CombinerHelper::matchRedundantAnd(), llvm::CombinerHelper::matchRedundantOr(), mul(), operator&=(), operator^=(), operator|=(), print(), resetAll(), reverseBits(), setAllOnes(), setAllZero(), sext(), sextInReg(), shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), SimplifyRightShift(), SimplifyShift(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), smax(), smin(), srem(), trunc(), urem(), and zext().

◆ Zero

APInt llvm::KnownBits::Zero

Definition at line 24 of file KnownBits.h.

Referenced by abs(), llvm::FunctionLoweringInfo::AddLiveOutRegInfo(), adjustForRedundantAnd(), anyext(), ashr(), byteSwap(), commonBits(), computeForAddCarry(), computeForAddCarry(), computeForAddSub(), llvm::SelectionDAG::computeKnownBits(), computeKnownBits(), llvm::GISelKnownBits::computeKnownBitsForAlignment(), llvm::SITargetLowering::computeKnownBitsForFrameIndex(), llvm::TargetLowering::computeKnownBitsForFrameIndex(), llvm::SITargetLowering::computeKnownBitsForTargetInstr(), llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::RISCVTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::PPCTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), llvm::GISelKnownBits::computeKnownBitsImpl(), llvm::GISelKnownBits::computeNumSignBits(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), llvm::SelectionDAG::computeOverflowKind(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), countMaxLeadingOnes(), countMaxPopulation(), countMaxTrailingOnes(), countMinLeadingZeros(), countMinTrailingZeros(), determineLiveOperandBitsAddCarry(), llvm::DemandedBits::determineLiveOperandBitsSub(), dumpResult(), eliminateDeadSwitchCases(), eq(), extractBits(), llvm::InstCombinerImpl::foldAddWithConstant(), foldCtpop(), llvm::InstCombinerImpl::foldICmpTruncConstant(), llvm::InstCombinerImpl::foldICmpUsingKnownBits(), foldMaskAndShiftToScale(), getBitWidth(), llvm::GISelKnownBits::getKnownZeroes(), getMaxValue(), getSignedMaxValue(), getSignedMinValue(), getValueFromICmpCondition(), hasConflict(), haveNoCommonBitsSet(), insertBits(), isBitfieldPositioningOp(), isConstant(), isKnownNonEqual(), isKnownToBeAPowerOfTwo(), isNonNegative(), isStrictlyPositive(), isTruePredicate(), isTruncateOf(), isUnknown(), isZero(), knownBitsForWorkitemID(), LowerMUL(), lshr(), makeGE(), makeNonNegative(), MaskedValueIsZero(), llvm::CombinerHelper::matchRedundantAnd(), llvm::CombinerHelper::matchRedundantOr(), matchRotateSub(), mul(), operator&=(), operator^=(), operator|=(), llvm::ARMTargetLowering::PerformCMOVCombine(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), print(), provablyDisjointOr(), resetAll(), reverseBits(), llvm::PPCTargetLowering::SelectAddressRegImm(), llvm::PPCTargetLowering::SelectAddressRegImm34(), llvm::PPCTargetLowering::SelectAddressRegReg(), llvm::RISCVDAGToDAGISel::selectShiftMask(), setAllOnes(), setAllZero(), sext(), sextInReg(), shl(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), llvm::InstCombinerImpl::SimplifyDemandedUseBits(), llvm::X86TTIImpl::simplifyDemandedUseBitsIntrinsic(), llvm::InstCombinerImpl::SimplifyMultipleUseDemandedBits(), llvm::TargetLowering::SimplifyMultipleUseDemandedBits(), SimplifyShift(), llvm::InstCombinerImpl::simplifyShrShlDemandedBits(), SimplifySubInst(), smax(), smin(), srem(), trunc(), tryBitfieldInsertOpFromOr(), tryBitfieldInsertOpFromOrAndImm(), udiv(), urem(), llvm::InstCombinerImpl::visitSub(), and zext().


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