|
LLVM
3.7.0
|
#include "llvm/Analysis/ValueTracking.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/ConstantRange.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/Statepoint.h"#include "llvm/Support/Debug.h"#include "llvm/Support/MathExtras.h"#include <cstring>Go to the source code of this file.
Typedefs | |
| typedef SmallPtrSet< const Value *, 8 > | ExclInvsSet |
Functions | |
| static unsigned | getBitWidth (Type *Ty, const DataLayout &DL) |
| Returns the bitwidth of the given scalar or pointer type (if unknown returns 0). More... | |
| static const Instruction * | safeCxtI (const Value *V, const Instruction *CxtI) |
| static void | computeKnownBits (Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOne bit sets. More... | |
| static void | ComputeSignBit (Value *V, bool &KnownZero, bool &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Determine whether the sign bit is known to be zero or one. More... | |
| static bool | isKnownToBeAPowerOfTwo (Value *V, bool OrZero, unsigned Depth, const Query &Q, const DataLayout &DL) |
| Return true if the given value is known to have exactly one bit set when defined. More... | |
| static bool | isKnownNonZero (Value *V, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Return true if the given value is known to be non-zero when defined. More... | |
| static bool | MaskedValueIsZero (Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Return true if 'V & Mask' is known to be zero. More... | |
| static unsigned | ComputeNumSignBits (Value *V, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Return the number of times the sign bit of the register is replicated into the other bits. More... | |
| static void | computeKnownBitsAddSub (bool Add, Value *Op0, Value *Op1, bool NSW, APInt &KnownZero, APInt &KnownOne, APInt &KnownZero2, APInt &KnownOne2, const DataLayout &DL, unsigned Depth, const Query &Q) |
| static void | computeKnownBitsMul (Value *Op0, Value *Op1, bool NSW, APInt &KnownZero, APInt &KnownOne, APInt &KnownZero2, APInt &KnownOne2, const DataLayout &DL, unsigned Depth, const Query &Q) |
| static bool | isEphemeralValueOf (Instruction *I, const Value *E) |
| static bool | isAssumeLikeIntrinsic (const Instruction *I) |
| static bool | isValidAssumeForContext (Value *V, const Query &Q) |
| template<typename LHS , typename RHS > | |
| match_combine_or < CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > , CmpClass_match< RHS, LHS, ICmpInst, ICmpInst::Predicate > > | m_c_ICmp (ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) |
| template<typename LHS , typename RHS > | |
| match_combine_or < BinaryOp_match< LHS, RHS, Instruction::And > , BinaryOp_match< RHS, LHS, Instruction::And > > | m_c_And (const LHS &L, const RHS &R) |
| template<typename LHS , typename RHS > | |
| match_combine_or < BinaryOp_match< LHS, RHS, Instruction::Or > , BinaryOp_match< RHS, LHS, Instruction::Or > > | m_c_Or (const LHS &L, const RHS &R) |
| template<typename LHS , typename RHS > | |
| match_combine_or < BinaryOp_match< LHS, RHS, Instruction::Xor > , BinaryOp_match< RHS, LHS, Instruction::Xor > > | m_c_Xor (const LHS &L, const RHS &R) |
| static void | computeKnownBitsFromTrueCondition (Value *V, ICmpInst *Cmp, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Compute known bits in 'V' under the assumption that the condition 'Cmp' is true (at the context instruction.) This is mostly a utility function for the prototype dominating conditions reasoning below. More... | |
| static void | computeKnownBitsFromDominatingCondition (Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Compute known bits in 'V' from conditions which are known to be true along all paths leading to the context instruction. More... | |
| static void | computeKnownBitsFromAssume (Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| static void | computeKnownBitsFromOperator (Operator *I, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth, const Query &Q) |
| static bool | isGEPKnownNonNull (GEPOperator *GEP, const DataLayout &DL, unsigned Depth, const Query &Q) |
| Test whether a GEP's result is known to be non-null. More... | |
| static bool | rangeMetadataExcludesValue (MDNode *Ranges, const APInt &Value) |
| Does the 'Range' metadata (which must be a valid MD_range operand list) ensure that the value it's attached to is never Value? 'RangeType' is is the type of the value described by the range. More... | |
| static Value * | BuildSubAggregate (Value *From, Value *To, Type *IndexedType, SmallVectorImpl< unsigned > &Idxs, unsigned IdxSkip, Instruction *InsertBefore) |
| static Value * | BuildSubAggregate (Value *From, ArrayRef< unsigned > idx_range, Instruction *InsertBefore) |
| static uint64_t | GetStringLengthH (Value *V, SmallPtrSetImpl< PHINode * > &PHIs) |
| If we can compute the length of the string pointed to by the specified pointer, return 'len+1'. More... | |
| static bool | isSameUnderlyingObjectInLoop (PHINode *PN, LoopInfo *LI) |
PN defines a loop-variant pointer to an object. More... | |
| static bool | isDereferenceableFromAttribute (const Value *BV, APInt Offset, Type *Ty, const DataLayout &DL, const Instruction *CtxI, const DominatorTree *DT, const TargetLibraryInfo *TLI) |
| static bool | isDereferenceableFromAttribute (const Value *V, const DataLayout &DL, const Instruction *CtxI, const DominatorTree *DT, const TargetLibraryInfo *TLI) |
| static bool | isDereferenceablePointer (const Value *V, const DataLayout &DL, const Instruction *CtxI, const DominatorTree *DT, const TargetLibraryInfo *TLI, SmallPtrSetImpl< const Value * > &Visited) |
| Return true if Value is always a dereferenceable pointer. More... | |
| static bool | isKnownNonNullFromDominatingCondition (const Value *V, const Instruction *CtxI, const DominatorTree *DT) |
| static SelectPatternFlavor | matchSelectPattern (ICmpInst::Predicate Pred, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS) |
| static Constant * | lookThroughCast (ICmpInst *CmpI, Value *V1, Value *V2, Instruction::CastOps *CastOp) |
Variables | |
| const unsigned | MaxDepth = 6 |
| static cl::opt< bool > | EnableDomConditions ("value-tracking-dom-conditions", cl::Hidden, cl::init(false)) |
| Enable an experimental feature to leverage information about dominating conditions to compute known bits. More... | |
| static cl::opt< unsigned > | DomConditionsMaxDepth ("dom-conditions-max-depth", cl::Hidden, cl::init(1)) |
| static cl::opt< unsigned > | DomConditionsMaxDomBlocks ("dom-conditions-dom-blocks", cl::Hidden, cl::init(20000)) |
| How many dominating blocks should be scanned looking for dominating conditions? More... | |
| static cl::opt< unsigned > | DomConditionsMaxUses ("dom-conditions-max-uses", cl::Hidden, cl::init(2000)) |
| static cl::opt< bool > | DomConditionsSingleCmpUse ("dom-conditions-single-cmp-use", cl::Hidden, cl::init(false)) |
| typedef SmallPtrSet<const Value *, 8> ExclInvsSet |
Definition at line 89 of file ValueTracking.cpp.
|
static |
Definition at line 2427 of file ValueTracking.cpp.
References llvm::InsertValueInst::Create(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::FindInsertedValue(), llvm::InsertValueInst::getAggregateOperand(), llvm::StructType::getElementType(), llvm::StructType::getNumElements(), llvm::makeArrayRef(), llvm::SmallVectorTemplateBase< T, isPodLike >::pop_back(), and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().
Referenced by BuildSubAggregate(), and llvm::FindInsertedValue().
|
static |
|
static |
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOne bit sets.
NOTE: we cannot consider 'undef' to be "IsZero" here. The problem is that we cannot optimize based on the assumption that it is zero without changing it to be an explicit zero. If we don't change it to zero, other code could optimized based on the contradictory assumption that it is non-zero. Because instcombine aggressively folds operations with undef args anyway, this won't lose us code quality.
This function is defined on values with integer type, values with pointer type, and vectors of integers. In the case where V is a vector, known zero, and known one values are the same width as the vector element, and the bit is set only if it is true for all of the elements in the vector.
Definition at line 1412 of file ValueTracking.cpp.
References llvm::ARM_PROC::A, Align(), llvm::APInt::clearAllBits(), llvm::computeKnownBits(), computeKnownBitsFromAssume(), computeKnownBitsFromDominatingCondition(), computeKnownBitsFromOperator(), llvm::countTrailingZeros(), DomConditionsMaxDepth, EnableDomConditions, llvm::DataLayout::getABITypeAlignment(), llvm::APInt::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::APInt::getLowBitsSet(), llvm::DataLayout::getPreferredAlignment(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), I, llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPointerTy(), llvm::Type::isSized(), MaxDepth, and llvm::APInt::setAllBits().
|
static |
Definition at line 208 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::countLeadingZeros(), llvm::APInt::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APInt::getSignBit(), llvm::APInt::isNegative(), llvm::APInt::setBit(), and std::swap().
Referenced by computeKnownBitsFromOperator().
|
static |
Definition at line 696 of file ValueTracking.cpp.
References llvm::ARM_PROC::A, llvm::APInt::clearAllBits(), llvm::computeKnownBits(), llvm::CallInst::getArgOperand(), llvm::APInt::getBitWidth(), llvm::CallInst::getCalledFunction(), llvm::APInt::getHighBitsSet(), llvm::Function::getIntrinsicID(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::APInt::getSignBit(), llvm::ConstantInt::getZExtValue(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::APInt::isAllOnesValue(), llvm::isKnownToBeAPowerOfTwo(), llvm::APInt::isNegative(), llvm::isValidAssumeForContext(), llvm::APInt::lshr(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_BitCast(), m_c_And(), m_c_ICmp(), m_c_Or(), m_c_Xor(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), MaxDepth, and llvm::APInt::setAllBits().
Referenced by computeKnownBits().
|
static |
Compute known bits in 'V' from conditions which are known to be true along all paths leading to the context instruction.
In particular, look for cases where one branch of an interesting condition dominates the context instruction. This does not do general dataflow. NOTE: This code is EXPERIMENTAL and currently off by default.
Definition at line 595 of file ValueTracking.cpp.
References computeKnownBitsFromTrueCondition(), DomConditionsMaxDomBlocks, DomConditionsMaxUses, DomConditionsSingleCmpUse, llvm::dyn_cast(), llvm::BranchInst::getCondition(), llvm::Instruction::getParent(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUse(), llvm::BranchInst::isUnconditional(), llvm::Value::users(), and VI.
Referenced by computeKnownBits().
|
static |
Definition at line 944 of file ValueTracking.cpp.
References llvm::APInt::abs(), Align(), llvm::APIntOps::And(), llvm::Call, llvm::computeKnownBits(), computeKnownBitsAddSub(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsMul(), llvm::APInt::countLeadingOnes(), llvm::countTrailingZeros(), llvm::dyn_cast(), llvm::gep_type_begin(), llvm::AllocaInst::getAlignment(), llvm::APInt::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::StructLayout::getElementOffset(), llvm::SequentialType::getElementType(), llvm::APInt::getHighBitsSet(), llvm::PHINode::getIncomingValue(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::ExtractValueInst::getIndices(), llvm::APInt::getLowBitsSet(), llvm::PHINode::getNumIncomingValues(), llvm::ExtractValueInst::getNumIndices(), llvm::User::getNumOperands(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Constant::getSplatValue(), llvm::ConstantInt::getTrue(), llvm::AllocaInst::getType(), llvm::Value::getType(), llvm::PHINode::hasConstantValue(), I, llvm::PHINode::incoming_values(), llvm::Type::isIntegerTy(), llvm::APInt::isNonNegative(), llvm::Type::isPointerTy(), llvm::APInt::isPowerOf2(), llvm::Type::isSized(), llvm::Type::isVectorTy(), llvm::Constant::isZeroValue(), llvm::SPII::Load, llvm::Log2_32(), llvm::APIntOps::lshr(), MaxDepth, llvm::LLVMContext::MD_range, fuzzer::min(), llvm::APIntOps::Or(), P, llvm::TargetOpcode::PHI, llvm::MCID::Select, llvm::APInt::setBit(), llvm::APInt::trunc(), llvm::APIntOps::Xor(), llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().
Referenced by computeKnownBits().
|
static |
Compute known bits in 'V' under the assumption that the condition 'Cmp' is true (at the context instruction.) This is mostly a utility function for the prototype dominating conditions reasoning below.
Definition at line 521 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::APInt::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::APInt::getSignBit(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::APInt::isAllOnesValue(), llvm::isKnownToBeAPowerOfTwo(), and llvm_unreachable.
Referenced by computeKnownBitsFromDominatingCondition().
|
static |
Definition at line 288 of file ValueTracking.cpp.
References llvm::APInt::clearAllBits(), llvm::computeKnownBits(), llvm::APInt::countLeadingOnes(), llvm::APInt::countTrailingOnes(), llvm::APInt::getBitWidth(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::isKnownNonZero(), llvm::APInt::isNegative(), fuzzer::min(), and llvm::APInt::setBit().
Referenced by computeKnownBitsFromOperator().
|
static |
Return the number of times the sign bit of the register is replicated into the other bits.
We know that at least 1 bit is always equal to the sign bit (itself), but other cases can give us information. For example, immediately after an "ashr X, 2", we know that the top 3 bits are all equal to each other, so we return 3.
'Op' must have a scalar integer type.
Definition at line 1908 of file ValueTracking.cpp.
References llvm::APIntOps::And(), llvm::APInt::ceilLogBase2(), llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::APInt::countLeadingZeros(), llvm::dyn_cast(), llvm::APInt::getBitWidth(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::APInt::getZExtValue(), llvm::APInt::isNegative(), llvm::APInt::isStrictlyPositive(), llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), fuzzer::min(), llvm::APIntOps::Or(), llvm::TargetOpcode::PHI, llvm::MCID::Select, and llvm::APIntOps::Xor().
Referenced by llvm::ComputeNumSignBits().
|
static |
Determine whether the sign bit is known to be zero or one.
Convenience wrapper around computeKnownBits.
Definition at line 1546 of file ValueTracking.cpp.
References llvm::computeKnownBits(), getBitWidth(), and llvm::Value::getType().
|
static |
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
For vector types, returns the element type's bitwidth.
Definition at line 74 of file ValueTracking.cpp.
References llvm::DataLayout::getPointerTypeSizeInBits(), and llvm::Type::getScalarSizeInBits().
Referenced by CanBeSMax(), CanBeSMin(), llvm::ARMTargetLowering::canCombineStoreAndExtract(), canConvertValue(), ComputeSignBit(), llvm::ConstantFoldCastInstruction(), DecodeFixedType(), dyn_castZExtVal(), ExtractConstantBytes(), llvm::ExecutionEngine::getConstantValue(), llvm::EVT::getEVT(), llvm::Type::getIntegerBitWidth(), getNoopInput(), llvm::Type::getPrimitiveSizeInBits(), llvm::NVPTXTargetLowering::getPrototype(), GetRangeFromMetadata(), getTypePrefix(), llvm::MVT::getVT(), IsIncrementNSW(), IsIncrementNUW(), llvm::Type::isIntegerTy(), isKnownNonZero(), LLVMCreateGenericValueOfInt(), LLVMGetIntTypeWidth(), llvm::ExecutionEngine::LoadValueFromMemory(), llvm::orc::OrcMCJITReplacement::runFunction(), llvm::MCJIT::runFunction(), llvm::UnrollRuntimeLoopProlog(), llvm::InstCombiner::visitICmpInst(), llvm::InstCombiner::visitICmpInstWithInstAndIntCst(), llvm::InstCombiner::visitSwitchInst(), and WriteTypeTable().
|
static |
If we can compute the length of the string pointed to by the specified pointer, return 'len+1'.
If we can't, return 0.
Definition at line 2711 of file ValueTracking.cpp.
References llvm::getConstantStringInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), SI, llvm::StringRef::size(), and llvm::Value::stripPointerCasts().
Referenced by llvm::GetStringLength().
|
static |
Definition at line 408 of file ValueTracking.cpp.
References F().
Referenced by isValidAssumeForContext().
|
static |
Definition at line 2880 of file ValueTracking.cpp.
References llvm::ARM_PROC::A, llvm::CS, llvm::APInt::getBitWidth(), llvm::ConstantInt::getLimitedValue(), llvm::DataLayout::getTypeStoreSize(), llvm::isKnownNonNullAt(), llvm::APInt::isNonNegative(), llvm::Type::isSized(), llvm::LLVMContext::MD_dereferenceable, and llvm::LLVMContext::MD_dereferenceable_or_null.
Referenced by isDereferenceableFromAttribute(), llvm::isDereferenceablePointer(), and isDereferenceablePointer().
|
static |
Definition at line 2925 of file ValueTracking.cpp.
References llvm::Type::getPointerElementType(), llvm::Value::getType(), llvm::DataLayout::getTypeStoreSizeInBits(), isDereferenceableFromAttribute(), and llvm::Type::isSized().
|
static |
Return true if Value is always a dereferenceable pointer.
Test if V is always a pointer to allocated and suitably aligned memory for a simple load or store.
Definition at line 2942 of file ValueTracking.cpp.
References llvm::ARM_PROC::A, GEP, llvm::DataLayout::getABITypeAlignment(), llvm::GCRelocateOperands::getDerivedPtr(), llvm::Type::getPointerElementType(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::DataLayout::getTypeStoreSize(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), isDereferenceableFromAttribute(), llvm::isDereferenceablePointer(), and llvm::Type::isSized().
Referenced by llvm::isDereferenceablePointer(), isSafePHIToSpeculate(), and isSafeSelectToSpeculate().
|
static |
Definition at line 372 of file ValueTracking.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isSafeToSpeculativelyExecute(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::Value::users().
Referenced by isValidAssumeForContext().
|
static |
Test whether a GEP's result is known to be non-null.
Uses properties inherent in a GEP to try to determine whether it is known to be non-null.
Currently this routine does not support vector GEPs.
Definition at line 1662 of file ValueTracking.cpp.
References llvm::gep_type_begin(), llvm::gep_type_end(), llvm::StructLayout::getElementOffset(), llvm::GEPOperator::getPointerAddressSpace(), llvm::GEPOperator::getPointerOperand(), llvm::DataLayout::getStructLayout(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::ConstantInt::getZExtValue(), llvm::GEPOperator::isInBounds(), llvm::isKnownNonZero(), llvm::Type::isPointerTy(), and MaxDepth.
Referenced by isKnownNonZero().
|
static |
Definition at line 3186 of file ValueTracking.cpp.
References DomConditionsMaxUses, DomConditionsSingleCmpUse, llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::Instruction::getParent(), llvm::BranchInst::getSuccessor(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::BranchInst::isConditional(), m_c_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), and llvm::Value::users().
Referenced by llvm::isKnownNonNullAt().
Return true if the given value is known to be non-zero when defined.
For vectors return true if every element is known to be non-zero when defined. Supports values with integer or pointer type and vectors of integers.
Definition at line 1741 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::ComputeSignBit(), GEP, getBitWidth(), llvm::Type::getScalarType(), llvm::APInt::getSignedMaxValue(), llvm::Value::getType(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), I, llvm::PossiblyExactOperator::isExact(), isGEPKnownNonNull(), llvm::isKnownNonNull(), llvm::isKnownNonZero(), llvm::isKnownToBeAPowerOfTwo(), llvm::Type::isPointerTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), MaxDepth, llvm::LLVMContext::MD_range, rangeMetadataExcludesValue(), Ranges, SI, X, and Y.
Referenced by llvm::isKnownNonZero().
|
static |
Return true if the given value is known to have exactly one bit set when defined.
For vectors return true if every element is known to be a power of two when defined. Supports values with integer or pointer types and vectors of integers.
Definition at line 1565 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::APInt::getBoolValue(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_SignBit(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), MaxDepth, SI, X, and Y.
Referenced by llvm::isKnownToBeAPowerOfTwo().
PN defines a loop-variant pointer to an object.
Check if the previous iteration of the loop was referring to the same object as PN.
Definition at line 2772 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::LoopInfoBase< N, M >::getLoopFor(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::Loop::isLoopInvariant(), and llvm::SPII::Load.
Referenced by llvm::GetUnderlyingObjects().
Definition at line 430 of file ValueTracking.cpp.
References llvm::BasicBlock::end(), llvm::Instruction::getParent(), I, llvm::ARM_PROC::IE, isAssumeLikeIntrinsic(), isEphemeralValueOf(), and llvm::isSafeToSpeculativelyExecute().
Referenced by llvm::isValidAssumeForContext().
|
static |
Definition at line 3390 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::ConstantExpr::getIntegerCast(), llvm::CastInst::getOpcode(), llvm::ConstantExpr::getSExt(), llvm::CastInst::getSrcTy(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), T, and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::matchSelectPattern().
|
inline |
Definition at line 500 of file ValueTracking.cpp.
References llvm::PatternMatch::m_And(), and llvm::PatternMatch::m_CombineOr().
Referenced by computeKnownBitsFromAssume().
|
inline |
Definition at line 493 of file ValueTracking.cpp.
References llvm::PatternMatch::m_CombineOr(), and llvm::PatternMatch::m_ICmp().
Referenced by computeKnownBitsFromAssume(), and isKnownNonNullFromDominatingCondition().
|
inline |
Definition at line 507 of file ValueTracking.cpp.
References llvm::PatternMatch::m_CombineOr(), and llvm::PatternMatch::m_Or().
Referenced by computeKnownBitsFromAssume().
|
inline |
Definition at line 514 of file ValueTracking.cpp.
References llvm::PatternMatch::m_CombineOr(), and llvm::PatternMatch::m_Xor().
Referenced by computeKnownBitsFromAssume().
|
static |
Return true if 'V & Mask' is known to be zero.
We use this predicate to simplify operations downstream. Mask is known to be zero for bits that V cannot have.
This function is defined on values with integer type, values with pointer type, and vectors of integers. In the case where V is a vector, the mask, known zero, and known one values are the same width as the vector element, and the bit is set only if it is true for all of the elements in the vector.
Definition at line 1891 of file ValueTracking.cpp.
References llvm::computeKnownBits(), and llvm::APInt::getBitWidth().
Referenced by llvm::MaskedValueIsZero().
|
static |
Definition at line 3319 of file ValueTracking.cpp.
References 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, llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), llvm::SPF_ABS, llvm::SPF_NABS, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, and llvm::SPF_UNKNOWN.
Referenced by llvm::matchSelectPattern().
Does the 'Range' metadata (which must be a valid MD_range operand list) ensure that the value it's attached to is never Value? 'RangeType' is is the type of the value described by the range.
Definition at line 1721 of file ValueTracking.cpp.
References llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and llvm::ConstantInt::getValue().
Referenced by isKnownNonZero().
|
static |
Definition at line 115 of file ValueTracking.cpp.
References llvm::dyn_cast(), and llvm::Instruction::getParent().
Referenced by llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::ComputeSignBit(), llvm::isKnownNonZero(), llvm::isKnownToBeAPowerOfTwo(), and llvm::MaskedValueIsZero().
Referenced by computeKnownBits().
|
static |
How many dominating blocks should be scanned looking for dominating conditions?
Referenced by computeKnownBitsFromDominatingCondition().
|
static |
Referenced by computeKnownBitsFromDominatingCondition(), and isKnownNonNullFromDominatingCondition().
|
static |
Referenced by computeKnownBitsFromDominatingCondition(), and isKnownNonNullFromDominatingCondition().
|
static |
Enable an experimental feature to leverage information about dominating conditions to compute known bits.
The individual options below control how hard we search. The defaults are choosen to be fairly aggressive. If you run into compile time problems when testing, scale them back and report your findings.
Referenced by computeKnownBits().
Definition at line 42 of file ValueTracking.cpp.
Referenced by llvm::SUnit::biasCriticalPath(), computeKnownBits(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::ComputeMultiple(), isGEPKnownNonNull(), isKnownNonZero(), isKnownToBeAPowerOfTwo(), and visitUDivOperand().
1.8.6