|
LLVM
4.0.0
|
#include "llvm/Analysis/ValueTracking.h"#include "llvm/ADT/Optional.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/Loads.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/VectorUtils.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 <algorithm>#include <array>#include <cstring>Go to the source code of this file.
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 (const Value *V, APInt &KnownZero, APInt &KnownOne, 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 (const Value *V, bool &KnownZero, bool &KnownOne, unsigned Depth, const Query &Q) |
| Determine whether the sign bit is known to be zero or one. More... | |
| static bool | isKnownToBeAPowerOfTwo (const Value *V, bool OrZero, unsigned Depth, const Query &Q) |
| Return true if the given value is known to have exactly one bit set when defined. More... | |
| static bool | isKnownNonZero (const Value *V, unsigned Depth, const Query &Q) |
| Return true if the given value is known to be non-zero when defined. More... | |
| static bool | isKnownNonEqual (const Value *V1, const Value *V2, const Query &Q) |
| Return true if it is known that V1 != V2. More... | |
| static bool | MaskedValueIsZero (const Value *V, const APInt &Mask, unsigned Depth, const Query &Q) |
| Return true if 'V & Mask' is known to be zero. More... | |
| static unsigned | ComputeNumSignBits (const Value *V, 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, const Value *Op0, const Value *Op1, bool NSW, APInt &KnownZero, APInt &KnownOne, APInt &KnownZero2, APInt &KnownOne2, unsigned Depth, const Query &Q) |
| static void | computeKnownBitsMul (const Value *Op0, const Value *Op1, bool NSW, APInt &KnownZero, APInt &KnownOne, APInt &KnownZero2, APInt &KnownOne2, unsigned Depth, const Query &Q) |
| static bool | isEphemeralValueOf (const Instruction *I, const Value *E) |
| static bool | isAssumeLikeIntrinsic (const Instruction *I) |
| static void | computeKnownBitsFromAssume (const Value *V, APInt &KnownZero, APInt &KnownOne, unsigned Depth, const Query &Q) |
| static void | computeKnownBitsFromShiftOperator (const Operator *I, APInt &KnownZero, APInt &KnownOne, APInt &KnownZero2, APInt &KnownOne2, unsigned Depth, const Query &Q, function_ref< APInt(const APInt &, unsigned)> KZF, function_ref< APInt(const APInt &, unsigned)> KOF) |
| static void | computeKnownBitsFromOperator (const Operator *I, APInt &KnownZero, APInt &KnownOne, unsigned Depth, const Query &Q) |
| static bool | isGEPKnownNonNull (const GEPOperator *GEP, unsigned Depth, const Query &Q) |
| Test whether a GEP's result is known to be non-null. More... | |
| static bool | rangeMetadataExcludesValue (const 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 bool | isAddOfNonZero (const Value *V1, const Value *V2, const Query &Q) |
| Return true if V2 == V1 + X, where X is known non-zero. More... | |
| static unsigned | computeNumSignBitsVectorConstant (const Value *V, unsigned TyBits) |
| For vector constants, loop over the elements and find the constant with the minimum number of sign bits. More... | |
| static bool | cannotBeOrderedLessThanZeroImpl (const Value *V, const TargetLibraryInfo *TLI, bool SignBitOnly, unsigned Depth) |
If SignBitOnly is true, test for a known 0 sign bit rather than a standard ordered compare. 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 (const Value *V, SmallPtrSetImpl< const PHINode * > &PHIs) |
| If we can compute the length of the string pointed to by the specified pointer, return 'len+1'. More... | |
| static bool | isSameUnderlyingObjectInLoop (const PHINode *PN, const LoopInfo *LI) |
PN defines a loop-variant pointer to an object. More... | |
| static bool | isKnownNonNullFromDominatingCondition (const Value *V, const Instruction *CtxI, const DominatorTree *DT) |
| static OverflowResult | computeOverflowForSignedAdd (const Value *LHS, const Value *RHS, const AddOperator *Add, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) |
| static bool | isKnownNonNaN (const Value *V, FastMathFlags FMF) |
| static bool | isKnownNonZero (const Value *V) |
| static SelectPatternResult | matchMinMax (CmpInst::Predicate Pred, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS) |
| Match non-obvious integer minimum and maximum sequences. More... | |
| static SelectPatternResult | matchSelectPattern (CmpInst::Predicate Pred, FastMathFlags FMF, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS) |
| static Value * | lookThroughCast (CmpInst *CmpI, Value *V1, Value *V2, Instruction::CastOps *CastOp) |
| static bool | isTruePredicate (CmpInst::Predicate Pred, const Value *LHS, const Value *RHS, const DataLayout &DL, unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) |
| Return true if "icmp Pred LHS RHS" is always true. More... | |
| static Optional< bool > | isImpliedCondOperands (CmpInst::Predicate Pred, const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS, const DataLayout &DL, unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) |
| Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred
ALHS ARHS" is true. More... | |
| static bool | isMatchingOps (const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS, bool &IsSwappedOps) |
| Return true if the operands of the two compares match. More... | |
| static Optional< bool > | isImpliedCondMatchingOperands (CmpInst::Predicate APred, const Value *ALHS, const Value *ARHS, CmpInst::Predicate BPred, const Value *BLHS, const Value *BRHS, bool IsSwappedOps) |
| Return true if "icmp1 APred ALHS ARHS" implies "icmp2 BPred BLHS BRHS" is true. More... | |
| static Optional< bool > | isImpliedCondMatchingImmOperands (CmpInst::Predicate APred, const Value *ALHS, const ConstantInt *C1, CmpInst::Predicate BPred, const Value *BLHS, const ConstantInt *C2) |
| Return true if "icmp1 APred ALHS C1" implies "icmp2 BPred BLHS C2" is true. More... | |
Variables | |
| const unsigned | MaxDepth = 6 |
| static cl::opt< unsigned > | DomConditionsMaxUses ("dom-conditions-max-uses", cl::Hidden, cl::init(20)) |
| static cl::opt< bool > | DontImproveNonNegativePhiBits ("dont-improve-non-negative-phi-bits", cl::Hidden, cl::init(true)) |
|
static |
Definition at line 2751 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(), i, llvm::makeArrayRef(), llvm::SmallVectorTemplateBase< T, isPodLike >::pop_back(), and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().
Referenced by BuildSubAggregate(), and llvm::FindInsertedValue().
|
static |
Definition at line 2810 of file ValueTracking.cpp.
References assert(), llvm::ArrayRef< T >::begin(), BuildSubAggregate(), llvm::ArrayRef< T >::end(), llvm::UndefValue::get(), llvm::ExtractValueInst::getIndexedType(), llvm::Value::getType(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
|
static |
If SignBitOnly is true, test for a known 0 sign bit rather than a standard ordered compare.
e.g. make -0.0 olt 0.0 be true because of the sign bit despite comparing equal.
Definition at line 2589 of file ValueTracking.cpp.
References llvm::Call, llvm::dyn_cast(), llvm::getIntrinsicForCallSite(), llvm::Operator::getOpcode(), llvm::User::getOperand(), I, LLVM_FALLTHROUGH, MaxDepth, llvm::maxnum(), llvm::minnum(), and llvm::MCID::Select.
Referenced by llvm::CannotBeOrderedLessThanZero(), and llvm::SignBitMustBeZero().
|
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 1490 of file ValueTracking.cpp.
References assert(), C, llvm::APInt::clearAllBits(), llvm::computeKnownBits(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::countTrailingZeros(), llvm::Constant::getAggregateElement(), llvm::APInt::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::APInt::getLowBitsSet(), llvm::Value::getPointerAlignment(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), i, llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPointerTy(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), MaxDepth, and llvm::APInt::setAllBits().
|
static |
Definition at line 247 of file ValueTracking.cpp.
References assert(), 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 519 of file ValueTracking.cpp.
References A, assert(), B, C, 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(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::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, Query(), and llvm::APInt::setAllBits().
Referenced by computeKnownBits().
|
static |
Definition at line 880 of file ValueTracking.cpp.
References llvm::APInt::abs(), llvm::MCID::Add, llvm::APIntOps::And(), llvm::APIntOps::ashr(), assert(), llvm::APInt::byteSwap(), llvm::Call, llvm::APInt::clearAllBits(), llvm::computeKnownBits(), computeKnownBitsAddSub(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), computeKnownBitsMul(), llvm::APInt::countLeadingOnes(), llvm::APInt::countLeadingZeros(), llvm::APInt::countPopulation(), llvm::APInt::countTrailingOnes(), llvm::countTrailingZeros(), llvm::Depth, DontImproveNonNegativePhiBits, llvm::dyn_cast(), llvm::SelectPatternResult::Flavor, llvm::gep_type_begin(), llvm::AllocaInst::getAlignment(), llvm::AllocaInst::getAllocatedType(), llvm::APInt::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::StructLayout::getElementOffset(), 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::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::PHINode::hasConstantValue(), I, i, llvm::PHINode::incoming_values(), llvm::Type::isIntegerTy(), llvm::SelectPatternResult::isMinOrMax(), llvm::APInt::isNegative(), llvm::APInt::isNonNegative(), llvm::Type::isPointerTy(), llvm::APInt::isPowerOf2(), llvm::Type::isSized(), llvm::Type::isVectorTy(), llvm::Constant::isZeroValue(), L, LLVM_FALLTHROUGH, llvm::SPII::Load, llvm::Log2_32(), llvm::APIntOps::lshr(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), MaxDepth, llvm::LLVMContext::MD_range, fuzzer::min(), Offset, llvm::APIntOps::Or(), P, llvm::MCID::Select, llvm::APInt::setBit(), llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::APInt::trunc(), llvm::APIntOps::Xor(), Y, llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().
Referenced by computeKnownBits().
|
static |
Definition at line 794 of file ValueTracking.cpp.
References llvm::APInt::clearAllBits(), llvm::computeKnownBits(), llvm::APInt::getAllOnesValue(), llvm::APInt::getBitWidth(), llvm::User::getOperand(), llvm::APInt::getZExtValue(), llvm::Optional< T >::hasValue(), llvm::isKnownNonZero(), and llvm::APInt::zextOrTrunc().
Referenced by computeKnownBitsFromOperator().
|
static |
Definition at line 327 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::isKnownNegative(), llvm::isKnownNonNegative(), llvm::isKnownNonZero(), llvm::APInt::isNegative(), fuzzer::min(), and llvm::APInt::setBit().
Referenced by computeKnownBitsFromOperator().
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. For vectors, return the number of sign bits for the vector element with the mininum number of known sign bits.
Definition at line 2084 of file ValueTracking.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), llvm::APInt::ceilLogBase2(), llvm::computeKnownBits(), llvm::ComputeNumSignBits(), computeNumSignBitsVectorConstant(), llvm::APInt::countLeadingOnes(), llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::APInt::getZExtValue(), i, llvm::APInt::isNegative(), llvm::APInt::isStrictlyPositive(), llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), MaxDepth, fuzzer::min(), llvm::APIntOps::Or(), llvm::MCID::Select, and llvm::APIntOps::Xor().
Referenced by llvm::ComputeNumSignBits().
For vector constants, loop over the elements and find the constant with the minimum number of sign bits.
Return 0 if the value is not a vector constant or if any element was not analyzed; otherwise, return the count for the element with the minimum number of sign bits.
Definition at line 2054 of file ValueTracking.cpp.
References llvm::APInt::countLeadingZeros(), llvm::dyn_cast(), i, llvm::APInt::isNegative(), and fuzzer::min().
Referenced by ComputeNumSignBits().
|
static |
Definition at line 3531 of file ValueTracking.cpp.
References llvm::ComputeSignBit(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::MayOverflow, and llvm::NeverOverflows.
Referenced by llvm::computeOverflowForSignedAdd().
|
static |
Determine whether the sign bit is known to be zero or one.
Convenience wrapper around computeKnownBits.
Definition at line 1599 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 62 of file ValueTracking.cpp.
References llvm::DataLayout::getPointerTypeSizeInBits(), and llvm::Type::getScalarSizeInBits().
Referenced by CanBeSMax(), CanBeSMin(), llvm::ARMTargetLowering::canCombineStoreAndExtract(), canConvertValue(), llvm::FunctionComparator::cmpTypes(), collectBitParts(), ComputeSignBit(), llvm::ConstantFoldCastInstruction(), DecodeFixedType(), dyn_castZExtVal(), emitX86MaskSelect(), ExtractConstantBytes(), llvm::ExecutionEngine::getConstantValue(), llvm::EVT::getEVT(), getNoopInput(), llvm::Type::getPrimitiveSizeInBits(), llvm::NVPTXTargetLowering::getPrototype(), llvm::MVT::getVT(), getX86MaskVec(), IsIncrementNSW(), IsIncrementNUW(), llvm::Type::isIntegerTy(), isKnownNonZero(), LLVMCreateGenericValueOfInt(), LLVMGetIntTypeWidth(), llvm::ExecutionEngine::LoadValueFromMemory(), MatchBinaryOp(), llvm::APInt::operator&(), llvm::APInt::operator[](), llvm::APInt::operator|(), llvm::orc::OrcMCJITReplacement::runFunction(), llvm::MCJIT::runFunction(), llvm::UnrollRuntimeLoopRemainder(), UpgradeMaskedLoad(), UpgradeMaskedStore(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitSwitchInst().
|
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 3052 of file ValueTracking.cpp.
References llvm::getConstantStringInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), SI, llvm::StringRef::size(), and llvm::Value::stripPointerCasts().
Referenced by llvm::GetStringLength().
Return true if V2 == V1 + X, where X is known non-zero.
Definition at line 1992 of file ValueTracking.cpp.
References llvm::MCID::Add, llvm::dyn_cast(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), and llvm::isKnownNonZero().
Referenced by isKnownNonEqual().
|
static |
Definition at line 449 of file ValueTracking.cpp.
References F.
Referenced by llvm::isValidAssumeForContext().
|
static |
Definition at line 414 of file ValueTracking.cpp.
References llvm::all_of(), llvm::SmallPtrSetImpl< PtrType >::count(), E, llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), llvm::isSafeToSpeculativelyExecute(), llvm::User::operands(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::Value::users().
Referenced by llvm::isValidAssumeForContext().
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 1717 of file ValueTracking.cpp.
References assert(), llvm::Depth, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::StructLayout::getElementOffset(), llvm::GEPOperator::getPointerAddressSpace(), llvm::GEPOperator::getPointerOperand(), llvm::Value::getType(), llvm::ConstantInt::getZExtValue(), llvm::GEPOperator::isInBounds(), llvm::isKnownNonZero(), llvm::Type::isPointerTy(), and MaxDepth.
Referenced by isKnownNonZero().
|
static |
Return true if "icmp1 APred ALHS C1" implies "icmp2 BPred BLHS C2" is true.
Return false if "icmp1 APred ALHS C1" implies "icmp2 BPred BLHS C2" is false. Otherwise, return None if we can't infer anything.
Definition at line 4328 of file ValueTracking.cpp.
References assert(), llvm::ConstantRange::difference(), llvm::ConstantInt::getValue(), llvm::ConstantRange::intersectWith(), llvm::ConstantRange::isEmptySet(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::ConstantRange::makeExactICmpRegion(), and llvm::None.
Referenced by llvm::isImpliedCondition().
|
static |
Return true if "icmp1 APred ALHS ARHS" implies "icmp2 BPred BLHS BRHS" is true.
Return false if "icmp1 APred ALHS ARHS" implies "icmp2 BPred BLHS BRHS" is false. Otherwise, return None if we can't infer anything.
Definition at line 4304 of file ValueTracking.cpp.
References llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::isImpliedFalseByMatchingCmp(), llvm::CmpInst::isImpliedTrueByMatchingCmp(), llvm::None, and std::swap().
Referenced by llvm::isImpliedCondition().
|
static |
Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred ALHS ARHS" is true.
Otherwise, return None.
Definition at line 4263 of file ValueTracking.cpp.
References llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, isTruePredicate(), and llvm::None.
Referenced by llvm::isImpliedCondition().
Return true if it is known that V1 != V2.
Definition at line 2007 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::Value::getType(), isAddOfNonZero(), llvm::Type::isVectorTy(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::isKnownNonEqual().
|
static |
Definition at line 3889 of file ValueTracking.cpp.
References C, and llvm::FastMathFlags::noNaNs().
Referenced by matchSelectPattern().
|
static |
Definition at line 3395 of file ValueTracking.cpp.
References assert(), DomConditionsMaxUses, llvm::DominatorTree::dominates(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::Type::isPointerTy(), llvm::PatternMatch::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 1795 of file ValueTracking.cpp.
References llvm::all_of(), C, llvm::computeKnownBits(), llvm::ComputeSignBit(), llvm::APInt::countLeadingZeros(), llvm::APInt::countTrailingOnes(), llvm::Depth, 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::ConstantInt::isNegative(), llvm::Constant::isNullValue(), llvm::Type::isPointerTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), MaxDepth, llvm::LLVMContext::MD_range, rangeMetadataExcludesValue(), SI, std::swap(), X, and Y.
Referenced by llvm::isKnownNonZero().
Definition at line 3898 of file ValueTracking.cpp.
References C.
|
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 1618 of file ValueTracking.cpp.
References C, llvm::computeKnownBits(), llvm::Depth, llvm::APInt::getBoolValue(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), llvm::isKnownToBeAPowerOfTwo(), llvm::APInt::isPowerOf2(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Exact(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shl(), 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().
|
static |
Return true if the operands of the two compares match.
IsSwappedOps is true when the operands match, but are swapped.
Definition at line 4292 of file ValueTracking.cpp.
Referenced by llvm::isImpliedCondition().
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 3114 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(), L, and llvm::SPII::Load.
Referenced by llvm::GetUnderlyingObjects().
|
static |
Return true if "icmp Pred LHS RHS" is always true.
Definition at line 4199 of file ValueTracking.cpp.
References A, assert(), B, C, llvm::computeKnownBits(), llvm::Value::getType(), llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_ULE, llvm::APInt::isNegative(), llvm::CmpInst::isTrueWhenEqual(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::APInt::ule(), and X.
Referenced by isImpliedCondOperands().
|
static |
Definition at line 4102 of file ValueTracking.cpp.
References C, llvm::dyn_cast(), llvm::ConstantExpr::getCast(), llvm::ConstantExpr::getFPExtend(), llvm::ConstantExpr::getFPToSI(), llvm::ConstantExpr::getFPToUI(), llvm::ConstantExpr::getFPTrunc(), llvm::ConstantExpr::getIntegerCast(), llvm::CastInst::getOpcode(), llvm::ConstantExpr::getSIToFP(), llvm::CastInst::getSrcTy(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getUIToFP(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), and llvm::NVPTX::PTXLdStInstCode::V2.
Referenced by llvm::matchSelectPattern().
|
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 2043 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::APInt::getBitWidth(), and llvm::BitmaskEnumDetail::Mask().
Referenced by llvm::MaskedValueIsZero().
|
static |
Match non-obvious integer minimum and maximum sequences.
Definition at line 3905 of file ValueTracking.cpp.
References llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::APInt::isAllOnesValue(), llvm::APInt::isMaxSignedValue(), llvm::APInt::isMinSignedValue(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::SPF_UNKNOWN, and llvm::SPNB_NA.
Referenced by matchSelectPattern().
|
static |
Definition at line 3982 of file ValueTracking.cpp.
References llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::getSwappedPredicate(), 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::APInt::isAllOnesValue(), llvm::CmpInst::isFPPredicate(), isKnownNonNaN(), llvm::isKnownNonZero(), llvm::CmpInst::isOrdered(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Neg(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), matchMinMax(), llvm::FastMathFlags::noSignedZeros(), llvm::SPF_ABS, llvm::SPF_FMAXNUM, llvm::SPF_FMINNUM, llvm::SPF_NABS, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::SPF_UNKNOWN, llvm::SPNB_NA, llvm::SPNB_RETURNS_ANY, llvm::SPNB_RETURNS_NAN, llvm::SPNB_RETURNS_OTHER, and std::swap().
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 1776 of file ValueTracking.cpp.
References assert(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::ConstantInt::getValue(), i, llvm::Lower, and llvm::Upper.
Referenced by isKnownNonZero().
|
static |
Definition at line 114 of file ValueTracking.cpp.
References llvm::dyn_cast(), and llvm::Instruction::getParent().
Referenced by llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::ComputeSignBit(), llvm::isKnownNonEqual(), llvm::isKnownNonZero(), llvm::isKnownToBeAPowerOfTwo(), and llvm::MaskedValueIsZero().
Referenced by isKnownNonNullFromDominatingCondition().
|
static |
Referenced by computeKnownBitsFromOperator().
Definition at line 47 of file ValueTracking.cpp.
Referenced by llvm::SUnit::biasCriticalPath(), llvm::CannotBeNegativeZero(), cannotBeOrderedLessThanZeroImpl(), computeKnownBits(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::ComputeMultiple(), ComputeNumSignBits(), isGEPKnownNonNull(), isKnownNonZero(), llvm::isKnownNotFullPoison(), isKnownToBeAPowerOfTwo(), and visitUDivOperand().
1.8.6