|
LLVM 24.0.0git
|
#include "llvm/Analysis/ValueTracking.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/FloatingPointMode.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/iterator_range.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/AssumeBundleQueries.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/DomConditionCache.h"#include "llvm/Analysis/GuardUtils.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/Loads.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/VectorUtils.h"#include "llvm/Analysis/WithCache.h"#include "llvm/IR/Argument.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/BundleAttributes.h"#include "llvm/IR/Constant.h"#include "llvm/IR/ConstantFPRange.h"#include "llvm/IR/ConstantRange.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/DiagnosticInfo.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/EHPersonalities.h"#include "llvm/IR/Function.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/IntrinsicsAArch64.h"#include "llvm/IR/IntrinsicsAMDGPU.h"#include "llvm/IR/IntrinsicsRISCV.h"#include "llvm/IR/IntrinsicsX86.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Module.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/KnownBits.h"#include "llvm/Support/KnownFPClass.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/UndefPoison.h"#include "llvm/TargetParser/RISCVTargetParser.h"#include <algorithm>#include <cassert>#include <cstdint>#include <optional>#include <utility>Go to the source code of this file.
Functions | |
| template<typename InstTy> | |
| static bool | matchTwoInputRecurrence (const PHINode *PN, InstTy *&Inst, Value *&Init, Value *&OtherOp) |
| static unsigned | getBitWidth (Type *Ty, const DataLayout &DL) |
| Returns the bitwidth of the given scalar or pointer type. | |
| static const Instruction * | safeCtxI (const Value *V, const Instruction *CtxI) |
| static void | computeKnownBits (const Value *V, const APInt &DemandedElts, KnownBits &Known, const SimplifyQuery &Q, unsigned Depth) |
| Determine which bits of V are known to be either zero or one and return them in the Known bit set. | |
| static NoCommonBitsSetResult | haveNoCommonBitsSetSpecialCases (const Value *LHS, const Value *RHS, const SimplifyQuery &SQ) |
| static bool | isKnownNonZero (const Value *V, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return true if the given value is known to be non-zero when defined. | |
| static bool | isKnownNonEqual (const Value *V1, const Value *V2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return true if it is known that V1 != V2. | |
| static bool | isTruePredicate (CmpInst::Predicate Pred, const Value *LHS, const Value *RHS) |
| Return true if "icmp Pred LHS RHS" is always true. | |
| static unsigned | ComputeNumSignBits (const Value *V, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| static unsigned | ComputeNumSignBits (const Value *V, const SimplifyQuery &Q, unsigned Depth=0) |
| static void | computeKnownBitsFromLerpPattern (const Value *Op0, const Value *Op1, const APInt &DemandedElts, KnownBits &KnownOut, const SimplifyQuery &Q, unsigned Depth) |
| Try to detect the lerp pattern: a * (b - c) + c * d where a >= 0, b >= 0, c >= 0, d >= 0, and b >= c. | |
| static void | computeKnownBitsFromEuclideanRem (const Value *Op0, const Value *Op1, const APInt &DemandedElts, KnownBits &KnownOut, const SimplifyQuery &Q, unsigned Depth) |
| Infer non-negativity for R + (R < 0 ? | |
| static void | computeKnownBitsAddSub (bool Add, const Value *Op0, const Value *Op1, bool NSW, bool NUW, const APInt &DemandedElts, KnownBits &KnownOut, KnownBits &Known2, const SimplifyQuery &Q, unsigned Depth) |
| static void | computeKnownBitsMul (const Value *Op0, const Value *Op1, bool NSW, bool NUW, const APInt &DemandedElts, KnownBits &Known, KnownBits &Known2, const SimplifyQuery &Q, unsigned Depth) |
| static bool | isEphemeralValueOf (const Instruction *I, const Value *E) |
| static bool | hasNoFreeInRange (BasicBlock::const_iterator Begin, BasicBlock::const_iterator End, unsigned &NumChecked) |
| static bool | cmpExcludesZero (CmpInst::Predicate Pred, const Value *RHS) |
| static bool | isKnownNonZeroFromAssume (const Value *V, const SimplifyQuery &Q) |
| static void | computeKnownBitsFromCmp (const Value *V, CmpInst::Predicate Pred, Value *LHS, Value *RHS, KnownBits &Known, const SimplifyQuery &Q) |
| static void | computeKnownBitsFromICmpCond (const Value *V, ICmpInst *Cmp, KnownBits &Known, const SimplifyQuery &SQ, bool Invert) |
| static void | computeKnownBitsFromCond (const Value *V, Value *Cond, KnownBits &Known, const SimplifyQuery &SQ, bool Invert, unsigned Depth) |
| static void | computeKnownBitsFromShiftOperator (const Operator *I, const APInt &DemandedElts, KnownBits &Known, KnownBits &Known2, const SimplifyQuery &Q, unsigned Depth, function_ref< KnownBits(const KnownBits &, const KnownBits &, bool)> KF) |
| Compute known bits from a shift operator, including those with a non-constant shift amount. | |
| static KnownBits | getKnownBitsFromAndXorOr (const Operator *I, const APInt &DemandedElts, const KnownBits &KnownLHS, const KnownBits &KnownRHS, const SimplifyQuery &Q, unsigned Depth) |
| static KnownBits | computeKnownBitsForHorizontalOperation (const Operator *I, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth, const function_ref< KnownBits(const KnownBits &, const KnownBits &)> KnownBitsFunc) |
| static bool | isReadVLENB (const IntrinsicInst &II) |
Return true if II reads a register named "vlenb". | |
| static ConstantRange | getRISCVVLENBRange (const IntrinsicInst &II, unsigned Width) |
| Return the value range of a RISC-V vlenb CSR read. | |
| static bool | isSignedMinMaxClamp (const Value *Select, const Value *&In, const APInt *&CLow, const APInt *&CHigh) |
| static bool | isSignedMinMaxIntrinsicClamp (const IntrinsicInst *II, const APInt *&CLow, const APInt *&CHigh) |
| static void | unionWithMinMaxIntrinsicClamp (const IntrinsicInst *II, KnownBits &Known) |
| static void | computeKnownBitsForRecurrenceOperands (const PHINode *P, Value *Start, Value *Step, const APInt &DemandedElts, KnownBits &KnownStart, KnownBits &KnownStep, const SimplifyQuery &Q, unsigned Depth) |
| static void | computeKnownBitsFromOperator (const Operator *I, const APInt &DemandedElts, KnownBits &Known, const SimplifyQuery &Q, unsigned Depth) |
| static bool | isPowerOfTwoRecurrence (const PHINode *PN, bool OrZero, SimplifyQuery &Q, unsigned Depth) |
| Try to detect a recurrence that the value of the induction variable is always a power of two (or zero). | |
| static bool | isImpliedToBeAPowerOfTwoFromCond (const Value *V, bool OrZero, const Value *Cond, bool CondIsTrue) |
Return true if we can infer that V is known to be a power of 2 from dominating condition Cond (e.g., ctpop(V) == 1). | |
| static bool | isGEPKnownNonNull (const GEPOperator *GEP, const SimplifyQuery &Q, unsigned Depth) |
| Test whether a GEP's result is known to be non-null. | |
| static bool | isKnownNonNullFromDominatingCondition (const Value *V, const Instruction *CtxI, const DominatorTree *DT) |
| 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? | |
| static bool | isNonZeroRecurrence (const PHINode *PN) |
| Try to detect a recurrence that monotonically increases/decreases from a non-zero starting value. | |
| static bool | matchOpWithOpEqZero (Value *Op0, Value *Op1) |
| static bool | isNonZeroAddrPlusOffset (const SimplifyQuery &Q, Value *X, Value *Y) |
| Return true if "addr(P) + Off" cannot be zero. | |
| static bool | isNonZeroAdd (const APInt &DemandedElts, const SimplifyQuery &Q, unsigned BitWidth, Value *X, Value *Y, bool NSW, bool NUW, unsigned Depth) |
| static bool | isNonZeroSub (const APInt &DemandedElts, const SimplifyQuery &Q, unsigned BitWidth, Value *X, Value *Y, unsigned Depth) |
| static bool | isNonZeroMul (const APInt &DemandedElts, const SimplifyQuery &Q, unsigned BitWidth, Value *X, Value *Y, bool NSW, bool NUW, unsigned Depth) |
| static bool | isNonZeroShift (const Operator *I, const APInt &DemandedElts, const SimplifyQuery &Q, const KnownBits &KnownVal, unsigned Depth) |
| static bool | isKnownNonZeroFromOperator (const Operator *I, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| static std::optional< std::pair< Value *, Value * > > | getInvertibleOperands (const Operator *Op1, const Operator *Op2) |
| If the pair of operators are the same invertible function, return the the operands of the function corresponding to each input. | |
| static bool | isModifyingBinopOfNonZero (const Value *V1, const Value *V2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return true if V1 == (binop V2, X), where X is known non-zero. | |
| static bool | isNonEqualMul (const Value *V1, const Value *V2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return true if V2 == V1 * C, where V1 is known non-zero, C is not 0/1 and the multiplication is nuw or nsw. | |
| static bool | isNonEqualShl (const Value *V1, const Value *V2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return true if V2 == V1 << C, where V1 is known non-zero, C is not 0 and the shift is nuw or nsw. | |
| static bool | isNonEqualPHIs (const PHINode *PN1, const PHINode *PN2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| static bool | isNonEqualSelect (const Value *V1, const Value *V2, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| static bool | isNonEqualPointersWithRecursiveGEP (const Value *A, const Value *B, const SimplifyQuery &Q) |
| static bool | isKnownNonEqualFromContext (const Value *V1, const Value *V2, const SimplifyQuery &Q, unsigned Depth) |
| static bool | isNonEqualURem (const Value *X, const Value *Rem, const SimplifyQuery &Q) |
| static unsigned | computeNumSignBitsVectorConstant (const Value *V, const APInt &DemandedElts, unsigned TyBits) |
| For vector constants, loop over the elements and find the constant with the minimum number of sign bits. | |
| static unsigned | ComputeNumSignBitsImpl (const Value *V, const APInt &DemandedElts, const SimplifyQuery &Q, unsigned Depth) |
| Return the number of times the sign bit of the register is replicated into the other bits. | |
| static std::tuple< int, int, int > | computeKnownExponentRangeFromContext (const Value *V, const SimplifyQuery &Q) |
Compute the minimum and maximum values (inclusive) for the exponent of V, assuming it is not nan. | |
| static Value * | BuildSubAggregate (Value *From, Value *To, Type *IndexedType, SmallVectorImpl< unsigned > &Idxs, unsigned IdxSkip, BasicBlock::iterator InsertBefore) |
| static Value * | BuildSubAggregate (Value *From, ArrayRef< unsigned > idx_range, BasicBlock::iterator InsertBefore) |
| static uint64_t | GetStringLengthH (const Value *V, SmallPtrSetImpl< const PHINode * > &PHIs, unsigned CharSize) |
| If we can compute the length of the string pointed to by the specified pointer, return 'len+1'. | |
| static bool | isSameUnderlyingObjectInLoop (const PHINode *PN, const LoopInfo *LI) |
PN defines a loop-variant pointer to an object. | |
| static const Value * | getUnderlyingObjectFromInt (const Value *V) |
| This is the function that does the work of looking through basic ptrtoint+arithmetic+inttoptr sequences. | |
| static OverflowResult | mapOverflowResult (ConstantRange::OverflowResult OR) |
| Convert ConstantRange OverflowResult into ValueTracking OverflowResult. | |
| static OverflowResult | computeOverflowForSignedAdd (const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const AddOperator *Add, const SimplifyQuery &SQ) |
| static bool | shiftAmountKnownInRange (const Value *ShiftAmount) |
| Shifts return poison if shiftwidth is larger than the bitwidth. | |
| static bool | canCreateUndefOrPoison (const Operator *Op, UndefPoisonKind Kind, bool ConsiderFlagsAndMetadata) |
| static bool | directlyImpliesPoison (const Value *ValAssumedPoison, const Value *V, unsigned Depth) |
| static bool | impliesPoison (const Value *ValAssumedPoison, const Value *V, unsigned Depth) |
| static bool | programUndefinedIfUndefOrPoison (const Value *V, bool PoisonOnly) |
| static bool | isGuaranteedNotToBeUndefOrPoison (const Value *V, AssumptionCache *AC, const Instruction *CtxI, const DominatorTree *DT, unsigned Depth, UndefPoisonKind Kind) |
| template<typename CallableT> | |
| static bool | handleGuaranteedWellDefinedOps (const Instruction *I, const CallableT &Handle) |
Enumerates all operands of I that are guaranteed to not be undef or poison. | |
| template<typename CallableT> | |
| static bool | handleGuaranteedNonPoisonOps (const Instruction *I, const CallableT &Handle) |
Enumerates all operands of I that are guaranteed to not be poison. | |
| static bool | isKnownNonNaN (const Value *V, FastMathFlags FMF) |
| static bool | isKnownNonZero (const Value *V) |
| static SelectPatternResult | matchFastFloatClamp (CmpInst::Predicate Pred, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS) |
| Match clamp pattern for float types without care about NaNs or signed zeros. | |
| static SelectPatternResult | matchClamp (CmpInst::Predicate Pred, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal) |
| Recognize variations of: CLAMP(v,l,h) ==> ((v) < (l) ? | |
| static Value * | getNotValue (Value *V) |
| If the input value is the result of a 'not' op, constant integer, or vector splat of a constant integer, return the bitwise-not source value. | |
| 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. | |
| static SelectPatternResult | matchSelectPattern (CmpInst::Predicate Pred, FastMathFlags FMF, Value *CmpLHS, Value *CmpRHS, Value *TrueVal, Value *FalseVal, Value *&LHS, Value *&RHS) |
| static Value * | lookThroughCastConst (CmpInst *CmpI, Type *SrcTy, Constant *C, Instruction::CastOps *CastOp) |
| static Value * | lookThroughCast (CmpInst *CmpI, Value *V1, Value *V2, Instruction::CastOps *CastOp) |
| Helps to match a select pattern in case of a type mismatch. | |
| template<typename InstTy> | |
| static bool | matchThreeInputRecurrence (const PHINode *PN, InstTy *&Inst, Value *&Init, Value *&OtherOp0, Value *&OtherOp1) |
| static std::optional< bool > | isImpliedCondOperands (CmpInst::Predicate Pred, const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS) |
| Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred
ALHS ARHS" is true. | |
| static std::optional< bool > | isImpliedCondCommonOperandWithCR (CmpPredicate LPred, const ConstantRange &LCR, CmpPredicate RPred, const ConstantRange &RCR) |
| Return true if "icmp LPred X, LCR" implies "icmp RPred X, RCR" is true. | |
| static std::optional< bool > | isImpliedCondICmps (CmpPredicate LPred, const Value *L0, const Value *L1, CmpPredicate RPred, const Value *R0, const Value *R1, const DataLayout &DL, bool LHSIsTrue) |
| Return true if LHS implies RHS (expanded to its components as "R0 RPred R1") is true. | |
| static std::optional< bool > | isImpliedCondFCmps (FCmpInst::Predicate LPred, const Value *L0, const Value *L1, FCmpInst::Predicate RPred, const Value *R0, const Value *R1, const DataLayout &DL, bool LHSIsTrue) |
| Return true if LHS implies RHS (expanded to its components as "R0 RPred R1") is true. | |
| static std::optional< bool > | isImpliedCondAndOr (const Instruction *LHS, CmpPredicate RHSPred, const Value *RHSOp0, const Value *RHSOp1, const DataLayout &DL, bool LHSIsTrue, unsigned Depth) |
| Return true if LHS implies RHS is true. | |
| static std::pair< Value *, bool > | getDomPredecessorCondition (const Instruction *ContextI) |
| static void | setLimitsForBinOp (const BinaryOperator &BO, APInt &Lower, APInt &Upper, const InstrInfoQuery &IIQ, bool PreferSignedRange) |
| static ConstantRange | getRangeForIntrinsic (const IntrinsicInst &II, bool UseInstrInfo) |
| static ConstantRange | getRangeForSelectPattern (const SelectInst &SI, const InstrInfoQuery &IIQ) |
| static void | setLimitForFPToI (const Instruction *I, APInt &Lower, APInt &Upper) |
| static void | addValueAffectedByCondition (Value *V, function_ref< void(Value *)> InsertAffected) |
Variables | |
| static cl::opt< unsigned > | DomConditionsMaxUses ("dom-conditions-max-uses", cl::Hidden, cl::init(20)) |
| static constexpr unsigned | MaxInstrsToCheckForFree = 32 |
| Maximum number of instructions to check between assume and context instruction. | |
|
static |
Definition at line 9319 of file ValueTracking.cpp.
References assert(), llvm::dyn_cast(), I, llvm::isa(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::PatternMatch::m_PtrToIntOrAddr(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and V.
Referenced by llvm::findValuesAffectedByCondition().
|
static |
Definition at line 5385 of file ValueTracking.cpp.
References BuildSubAggregate(), llvm::PoisonValue::get(), llvm::ExtractValueInst::getIndexedType(), llvm::Value::getType(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
|
static |
Definition at line 5326 of file ValueTracking.cpp.
References llvm::ArrayRef(), BuildSubAggregate(), llvm::cast(), llvm::InsertValueInst::Create(), llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), llvm::FindInsertedValue(), llvm::InsertValueInst::getAggregateOperand(), llvm::StructType::getElementType(), llvm::StructType::getNumElements(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and V.
Referenced by BuildSubAggregate(), BuildSubAggregate(), and llvm::FindInsertedValue().
|
static |
Definition at line 6446 of file ValueTracking.cpp.
References llvm::cast(), llvm::dyn_cast(), II, llvm::includesPoison(), llvm::is_contained(), llvm::isa(), llvm::Instruction::isBinaryOp(), llvm::PoisonMaskElem, and shiftAmountKnownInRange().
|
static |
Definition at line 858 of file ValueTracking.cpp.
References C(), llvm::ConstantRange::contains(), llvm::dyn_cast(), llvm::APInt::getZero(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Zero(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), Pred, RHS, and Zero.
Referenced by isImpliedCondICmps(), isKnownNonNullFromDominatingCondition(), isKnownNonZeroFromAssume(), and isKnownNonZeroFromOperator().
|
static |
Determine which bits of V are known to be either zero or one and return them in the Known bit set.
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 demanded elements in the vector specified by DemandedElts.
Definition at line 2681 of file ValueTracking.cpp.
References A(), assert(), llvm::BitWidth, C(), llvm::computeKnownBits(), llvm::computeKnownBitsFromContext(), computeKnownBitsFromOperator(), llvm::Depth, llvm::SimplifyQuery::DL, llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::Constant::getAggregateElement(), llvm::APInt::getBitWidth(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::Type::getScalarType(), llvm::DataLayout::getTypeSizeInBits(), I, llvm::isa(), llvm::Type::isPointerTy(), llvm::Known, llvm::Log2(), llvm::PatternMatch::m_APInt(), llvm::KnownBits::makeConstant(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, Range, and V.
Referenced by llvm::TargetTransformInfoImplBase::computeKnownBitsAddrSpaceCast().
|
static |
Definition at line 553 of file ValueTracking.cpp.
References llvm::Add, llvm::KnownBits::computeForAddSub(), llvm::computeKnownBits(), computeKnownBitsFromEuclideanRem(), computeKnownBitsFromLerpPattern(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DL, llvm::CmpInst::ICMP_SLE, llvm::isImpliedByDomCondition(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isUnknown(), llvm::PatternMatch::m_c_SMin(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::KnownBits::makeNonNegative(), and llvm::PatternMatch::match().
Referenced by computeKnownBitsFromOperator().
|
static |
Definition at line 1349 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::Depth, llvm::SimplifyQuery::DL, llvm::getHorizDemandedEltsForFirstOperand(), llvm::DataLayout::getTypeSizeInBits(), I, and llvm::APInt::isZero().
Referenced by llvm::X86TargetLowering::computeKnownBitsForTargetNode(), and computeKnownBitsFromOperator().
|
static |
Definition at line 1536 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::getWithoutCondContext(), and P.
Referenced by computeKnownBitsFromOperator().
|
static |
Definition at line 967 of file ValueTracking.cpp.
References llvm::BitWidth, C(), llvm::SimplifyQuery::DL, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::Known, LHS, llvm::PatternMatch::m_AddLike(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_NUWAdd(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_PtrToIntSameSize(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::KnownBits::makeConstant(), llvm::PatternMatch::match(), llvm::Offset, Pred, RHS, llvm::ConstantRange::sub(), llvm::ConstantRange::toKnownBits(), uint64_t, V, and Y.
Referenced by computeKnownBitsFromICmpCond().
|
static |
Definition at line 1095 of file ValueTracking.cpp.
References A(), llvm::KnownBits::anyext(), B(), llvm::cast(), computeKnownBitsFromCond(), computeKnownBitsFromICmpCond(), Cond, llvm::Depth, llvm::dyn_cast(), hasNoUnsignedWrap(), llvm::KnownBits::intersectWith(), llvm::Known, llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOp(), llvm::PatternMatch::m_LogicalOr(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, llvm::KnownBits::setAllOnes(), llvm::KnownBits::setAllZero(), llvm::KnownBits::unionWith(), V, and llvm::KnownBits::zext().
Referenced by llvm::adjustKnownBitsForSelectArm(), computeKnownBitsFromCond(), and llvm::computeKnownBitsFromContext().
|
static |
Infer non-negativity for R + (R < 0 ?
A : 0), where R = srem X, Y. A must be a non-negative Y or abs(Y).
Definition at line 502 of file ValueTracking.cpp.
References llvm::SimplifyQuery::AC, llvm::computeKnownBits(), Cond, llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DT, llvm::isGuaranteedNotToBeUndef(), llvm::isSignBitCheck(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Intrinsic(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SRem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::KnownBits::makeNonNegative(), llvm::PatternMatch::match(), and Pred.
Referenced by computeKnownBitsAddSub().
|
static |
Definition at line 1073 of file ValueTracking.cpp.
References llvm::KnownBits::anyext(), llvm::cast(), computeKnownBitsFromCmp(), hasNoUnsignedWrap(), llvm::Known, LHS, llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::match(), Pred, RHS, V, and llvm::KnownBits::zext().
Referenced by computeKnownBitsFromCond(), and llvm::computeKnownBitsFromContext().
|
static |
Try to detect the lerp pattern: a * (b - c) + c * d where a >= 0, b >= 0, c >= 0, d >= 0, and b >= c.
In that particular case, we can use the following chain of reasoning:
a * (b - c) + c * d <= a' * (b - c) + a' * c = a' * b where a' = max(a, d)
Since that is true for arbitrary a, b, c and d within our constraints, we can conclude that:
max(a * (b - c) + c * d) <= max(max(a), max(d)) * max(b) = U
Considering that any result of the lerp would be less or equal to U, it would have at least the number of leading 0s as in U.
While being quite a specific situation, it is fairly common in computer graphics in the shape of alpha blending.
Modifies given KnownOut in-place with the inferred information.
Definition at line 386 of file ValueTracking.cpp.
References A(), B(), llvm::BitWidth, C(), llvm::computeKnownBits(), llvm::APInt::countl_zero(), D(), llvm::Depth, llvm::KnownBits::getMaxValue(), llvm::KnownBits::getMinValue(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::KnownBits::isNonNegative(), llvm::APInt::isSubsetOf(), LHS, llvm::PatternMatch::m_c_Mul(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_NUWSub(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::KnownBits::makeConstant(), llvm::PatternMatch::match(), RHS, llvm::APInt::setHighBits(), llvm::APIntOps::umax(), llvm::APInt::umul_ov(), V, and llvm::KnownBits::Zero.
Referenced by computeKnownBitsAddSub().
|
static |
Definition at line 1553 of file ValueTracking.cpp.
References llvm::KnownBits::abs(), llvm::SimplifyQuery::AC, llvm::KnownBits::add(), llvm::adjustKnownBitsForSelectArm(), llvm::KnownBits::anyextOrTrunc(), llvm::KnownBits::ashr(), assert(), llvm::bit_width(), llvm::BitWidth, llvm::breakSelfRecursivePHI(), llvm::KnownBits::byteSwap(), C(), llvm::cast(), llvm::APInt::clearBit(), llvm::KnownBits::clmul(), llvm::computeKnownBits(), computeKnownBitsAddSub(), computeKnownBitsForHorizontalOperation(), computeKnownBitsForRecurrenceOperands(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), computeKnownBitsMul(), llvm::computeKnownFPClass(), llvm::countl_zero(), llvm::KnownBits::countMaxPopulation(), llvm::KnownBits::countMaxTrailingZeros(), llvm::KnownBits::countMinLeadingOnes(), llvm::KnownBits::countMinLeadingZeros(), llvm::KnownBits::countMinTrailingZeros(), llvm::countr_zero(), llvm::KnownBits::ctlz(), llvm::SimplifyQuery::CtxI, llvm::RISCVVType::decodeVSEW(), llvm::Depth, llvm::SimplifyQuery::DL, llvm::SimplifyQuery::DT, llvm::dyn_cast(), llvm::KnownBits::extractBits(), llvm::fcAllFlags, llvm::fcNegNormal, llvm::ConstantRange::fromKnownBits(), llvm::KnownBits::fshl(), llvm::KnownBits::fshr(), GEP, llvm::gep_type_begin(), getAlign(), llvm::APInt::getAllOnes(), llvm::APInt::getBitWidth(), llvm::StructLayout::getElementOffset(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::DataLayout::getIndexTypeSizeInBits(), llvm::ExtractValueInst::getIndices(), llvm::CmpInst::getInversePredicate(), getKnownBitsFromAndXorOr(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::InstrInfoQuery::getMetadata(), llvm::ExtractValueInst::getNumIndices(), llvm::APInt::getOneBitSet(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::Type::getScalarType(), llvm::generic_gep_type_iterator< ItTy >::getSequentialElementStride(), llvm::RISCVVType::getSEWLMULRatio(), llvm::getShuffleDemandedElts(), llvm::Constant::getSplatValue(), llvm::getSplatValue(), llvm::DataLayout::getStructLayout(), llvm::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::ConstantRange::getUnsignedMax(), llvm::getVScaleRange(), llvm::SimplifyQuery::getWithInstruction(), llvm::SimplifyQuery::getWithoutCondContext(), llvm::APInt::getZero(), llvm::APInt::getZExtValue(), llvm::KnownBits::hasConflict(), llvm::InstrInfoQuery::hasNoSignedWrap(), llvm::InstrInfoQuery::hasNoUnsignedWrap(), I, llvm::CmpInst::ICMP_NE, II, llvm::SimplifyQuery::IIQ, llvm::isa(), llvm::isa_and_nonnull(), llvm::KnownBits::isConstant(), llvm::InstrInfoQuery::isExact(), llvm::isGuaranteedNotToBePoison(), llvm::isGuaranteedNotToBeUndef(), llvm::Type::isIntegerTy(), llvm::KnownFPClass::isKnownNever(), llvm::DataLayout::isLittleEndian(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::Constant::isNullValue(), llvm::Type::isPointerTy(), llvm::isPowerOf2_32(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::CmpInst::isSigned(), llvm::Type::isSized(), llvm::isUIntN(), llvm::KnownBits::isUnknown(), llvm::Type::isVectorTy(), llvm::APInt::isZero(), llvm::Known, LHS, llvm::Log2(), llvm::Log2_32(), llvm::KnownBits::lshr(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BasicBlock(), llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_Ctlz(), llvm::PatternMatch::m_ElementWiseBitCast(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::ConstantRange::makeAllowedICmpRegion(), llvm::KnownBits::makeConstant(), llvm::PatternMatch::match(), llvm::matchSimpleRecurrence(), matchTwoInputRecurrence(), llvm::MaxAnalysisRecursionDepth, llvm::KnownBits::mul(), llvm::KnownBits::mulhs(), llvm::KnownBits::mulhu(), llvm::Offset, llvm::KnownBits::One, P, llvm::KnownBits::pdep(), llvm::KnownBits::pext(), Pred, Range, llvm::APInt::reverseBits(), llvm::KnownBits::reverseBits(), RHS, llvm::RISCV::RVVBitsPerBlock, llvm::KnownBits::sadd_sat(), llvm::APIntOps::ScaleBitMask(), llvm::KnownBits::sdiv(), llvm::APInt::setBit(), llvm::APInt::setBitsFrom(), llvm::APInt::setLowBits(), llvm::APInt::sextOrTrunc(), llvm::KnownBits::sextOrTrunc(), llvm::APInt::shl(), llvm::KnownBits::shl(), llvm::KnownBits::smax(), llvm::KnownBits::smin(), llvm::Splat, llvm::KnownBits::srem(), llvm::KnownBits::ssub_sat(), llvm::KnownBits::sub(), llvm::ConstantRange::toKnownBits(), llvm::KnownBits::uadd_sat(), llvm::KnownBits::udiv(), uint64_t, llvm::APInt::ult(), llvm::KnownBits::umax(), llvm::KnownBits::umin(), llvm::APInt::umul_ov(), llvm::KnownBits::unionWith(), unionWithMinMaxIntrinsicClamp(), llvm::KnownBits::urem(), llvm::KnownBits::usub_sat(), V, X, Y, and llvm::KnownBits::Zero.
Referenced by computeKnownBits().
|
static |
Compute known bits from a shift operator, including those with a non-constant shift amount.
Known is the output of this function. Known2 is a pre-allocated temporary with the same bit width as Known and on return contains the known bit of the shift value source. KF is an operator-specific function that, given the known-bits and a shift amount, compute the implied known-bits of the shift operator's result respectively for that shift amount. The results from calling KF are conservatively combined for all permitted shift amounts.
Definition at line 1263 of file ValueTracking.cpp.
References llvm::computeKnownBits(), llvm::Depth, I, llvm::isKnownNonZero(), and llvm::Known.
Referenced by computeKnownBitsFromOperator().
|
static |
Definition at line 590 of file ValueTracking.cpp.
References llvm::SimplifyQuery::AC, llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DT, llvm::APInt::getHighBitsSet(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::isGuaranteedNotToBeUndef(), llvm::isKnownNegative(), llvm::isKnownNonNegative(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isNonZero(), llvm::Known, llvm::KnownBits::makeConstant(), llvm::KnownBits::mul(), and llvm::KnownBits::sgt().
Referenced by computeKnownBitsFromOperator().
|
static |
Compute the minimum and maximum values (inclusive) for the exponent of V, assuming it is not nan.
Returns {min, max, max-assuming-nonzero}. A value frexp(0) = 0, so the tighter max-assuming-nonzero bound is only usable when V is known not to be a logical zero (e.g., for fabs(x) < 0.25, the non-0 exponent range is [-149, -2], but the 0 edge case is above this range).
Definition at line 5169 of file ValueTracking.cpp.
References llvm::DomConditionCache::conditionsFor(), llvm::SimplifyQuery::CtxI, llvm::SimplifyQuery::DC, llvm::DominatorTree::dominates(), llvm::SimplifyQuery::DT, llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNO, llvm::APFloat::getExactLog2Abs(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::APFloatBase::IEK_Inf, llvm::APFloatBase::IEK_NaN, llvm::ilogb(), llvm::PatternMatch::m_FAbs(), llvm::PatternMatch::m_FCmp(), llvm::PatternMatch::m_Finite(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), Pred, and V.
Referenced by llvm::computeConstantRange().
|
static |
Definition at line 4583 of file ValueTracking.cpp.
References assert(), ComputeNumSignBitsImpl(), llvm::Depth, and V.
Definition at line 341 of file ValueTracking.cpp.
References llvm::ComputeNumSignBits(), llvm::Depth, llvm::dyn_cast(), llvm::APInt::getAllOnes(), and V.
|
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. For vectors, return the number of sign bits for the vector element with the minimum number of known sign bits of the demanded elements in the vector specified by DemandedElts.
Definition at line 4597 of file ValueTracking.cpp.
References assert(), llvm::cast(), llvm::APInt::ceilLogBase2(), llvm::computeKnownBits(), llvm::ComputeNumSignBits(), computeNumSignBitsVectorConstant(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DL, llvm::dyn_cast(), llvm::APInt::getAllOnes(), llvm::APInt::getBitWidth(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::APInt::getNumSignBits(), llvm::APInt::getOneBitSet(), llvm::Operator::getOpcode(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::getShuffleDemandedElts(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::SimplifyQuery::getWithoutCondContext(), llvm::APInt::getZExtValue(), II, llvm::isa(), llvm::Type::isPointerTy(), isSignedMinMaxClamp(), isSignedMinMaxIntrinsicClamp(), llvm::APInt::isStrictlyPositive(), llvm::Known, LHS, llvm::APInt::logBase2(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, RHS, llvm::APIntOps::ScaleBitMask(), llvm::APInt::uge(), V, and X.
Referenced by ComputeNumSignBits().
|
static |
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 4556 of file ValueTracking.cpp.
References llvm::cast(), llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::isa(), and V.
Referenced by ComputeNumSignBitsImpl().
|
static |
Definition at line 6257 of file ValueTracking.cpp.
References llvm::Add, llvm::computeConstantRangeIncludingKnownBits(), llvm::computeKnownBitsFromContext(), llvm::ComputeNumSignBits(), llvm::ConstantRange::getBitWidth(), llvm::ConstantRange::isAllNegative(), llvm::ConstantRange::isAllNonNegative(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), LHS, mapOverflowResult(), llvm::MayOverflow, llvm::NeverOverflows, RHS, and llvm::ConstantRange::signedAddMayOverflow().
|
static |
Definition at line 6541 of file ValueTracking.cpp.
References llvm::any_of(), llvm::Depth, llvm::dyn_cast(), I, II, llvm::is_contained(), llvm::PatternMatch::m_ExtractValue(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_WithOverflowInst(), llvm::PatternMatch::match(), and V.
Referenced by impliesPoison().
|
static |
Returns the bitwidth of the given scalar or pointer type.
For vector types, returns the element type's bitwidth.
Definition at line 102 of file ValueTracking.cpp.
References llvm::BitWidth, and DL.
Referenced by canConvertValue(), llvm::FunctionComparator::cmpTypes(), combineAnd(), combineAVX512SetCCToKMOV(), combineOr(), llvm::computeKnownBits(), llvm::computeKnownBits(), llvm::APInt::concat(), llvm::AAPotentialConstantValues::getAssumedMinTrailingZeros(), llvm::AMDGPULibFuncBase::Param::getFromTy(), getMangledTypeStr(), getTargetConstantBitsFromNode(), getTypeID(), llvm::MVT::getVT(), llvm::X86TTIImpl::hasConditionalLoadStoreForType(), instCombineSVECondLast(), isKnownNonZeroFromOperator(), LLVMCreateGenericValueOfInt(), llvm::ExecutionEngine::LoadValueFromMemory(), llvm::APInt::operator[](), and llvm::InstCombinerImpl::SimplifyDemandedInstructionBits().
|
static |
Definition at line 8705 of file ValueTracking.cpp.
References assert(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::isImpliedByDomCondition(), and llvm::isImpliedByDomCondition().
|
static |
If the pair of operators are the same invertible function, return the the operands of the function corresponding to each input.
Otherwise, return std::nullopt. An invertible function is one that is 1-to-1 and maps every input value to exactly one output value. This is equivalent to saying that Op1 and Op2 are equal exactly when the specified pair of operands are equal, (except that Op1 and Op2 may be poison more often.)
Definition at line 4124 of file ValueTracking.cpp.
References llvm::cast(), getInvertibleOperands(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getType(), llvm::isa(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::matchSimpleRecurrence(), llvm::Other, and llvm::Values.
Referenced by getInvertibleOperands(), and isKnownNonEqual().
|
static |
Definition at line 1279 of file ValueTracking.cpp.
References llvm::BitWidth, llvm::KnownBits::blsi(), llvm::KnownBits::blsmsk(), llvm::computeKnownBits(), llvm::KnownBits::countMaxTrailingZeros(), llvm::KnownBits::countMinTrailingOnes(), llvm::Depth, llvm::KnownBits::getBitWidth(), I, llvm::APInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_Add(), llvm::MIPatternMatch::m_AllOnes(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Deferred(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::KnownBits::One, llvm::APInt::setBit(), X, Y, and llvm::KnownBits::Zero.
Referenced by llvm::analyzeKnownBitsFromAndXorOr(), and computeKnownBitsFromOperator().
If the input value is the result of a 'not' op, constant integer, or vector splat of a constant integer, return the bitwise-not source value.
TODO: This could be extended to handle non-splat vector integer constants.
Definition at line 7396 of file ValueTracking.cpp.
References C(), llvm::PatternMatch::m_APInt(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and V.
Referenced by matchMinMax().
|
static |
Definition at line 8980 of file ValueTracking.cpp.
References C(), llvm::APInt::getMaxValue(), llvm::ConstantRange::getNonEmpty(), getRISCVVLENBRange(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::getVScaleRange(), llvm::APInt::getZero(), II, isReadVLENB(), llvm_unreachable, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_One(), llvm::PatternMatch::match(), and llvm::Upper.
Referenced by llvm::computeConstantRange().
|
static |
Definition at line 9115 of file ValueTracking.cpp.
References llvm::BitWidth, C(), llvm::cast(), llvm::ConstantRange::getNonEmpty(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::APInt::getZero(), llvm::InstrInfoQuery::hasNoSignedWrap(), LHS, llvm::PatternMatch::m_APInt(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), RHS, 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::computeConstantRange().
|
static |
Return the value range of a RISC-V vlenb CSR read.
RVV requires VLEN to be a power of two in [32, 65536] (Zvl32b is the smallest vector extension), so VLENB = VLEN/8 is in [4, 8192]. This architectural bound is independent of any function attribute and stays sound for Zvl32b, whose VLEN (32) is not representable as an integer vscale (VLEN / RVVBitsPerBlock). A vscale_range attribute, when present, pins the subtarget's VLEN in units of RVVBitsPerBlock (64 bits) and so gives a tighter VLENB = vscale * RVVBytesPerBlock.
Definition at line 1430 of file ValueTracking.cpp.
References F, llvm::getVScaleRange(), II, llvm::ConstantRange::multiply(), Range, and llvm::RISCV::RVVBytesPerBlock.
Referenced by getRangeForIntrinsic().
|
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 5632 of file ValueTracking.cpp.
References llvm::dyn_cast(), E(), llvm::getConstantDataArrayInfo(), GetStringLengthH(), llvm::SmallPtrSetImpl< PtrType >::insert(), uint64_t, and V.
Referenced by llvm::GetStringLength(), and GetStringLengthH().
This is the function that does the work of looking through basic ptrtoint+arithmetic+inttoptr sequences.
Definition at line 5918 of file ValueTracking.cpp.
References assert(), llvm::dyn_cast(), llvm::Operator::getOpcode(), llvm::isa(), and V.
Referenced by llvm::getUnderlyingObjectsForCodeGen().
|
static |
Enumerates all operands of I that are guaranteed to not be poison.
Definition at line 7135 of file ValueTracking.cpp.
References handleGuaranteedWellDefinedOps(), and I.
Referenced by llvm::mustTriggerUB().
|
static |
Enumerates all operands of I that are guaranteed to not be undef or poison.
If the callback Handle returns true, stop processing and return true. Otherwise, return false.
Definition at line 7075 of file ValueTracking.cpp.
References llvm::CallBase::arg_size(), llvm::cast(), llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledOperand(), getCondition(), llvm::getPointerOperand(), I, llvm::CallBase::isIndirectCall(), and llvm::CallBase::paramHasAttr().
Referenced by handleGuaranteedNonPoisonOps(), and programUndefinedIfUndefOrPoison().
|
static |
Definition at line 779 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::End, I, llvm::make_range(), and MaxInstrsToCheckForFree.
Referenced by llvm::willNotFreeBetween().
|
static |
Definition at line 158 of file ValueTracking.cpp.
References A(), llvm::SimplifyQuery::AC, B(), llvm::SimplifyQuery::CtxI, llvm::SimplifyQuery::DT, llvm::isGuaranteedNotToBeUndef(), llvm::Known, LHS, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), llvm::OnlyIfUndefIgnored, RHS, llvm::Unknown, V, and Y.
Referenced by llvm::getNoCommonBitsSetResult().
Definition at line 6569 of file ValueTracking.cpp.
References llvm::all_of(), llvm::canCreatePoison(), llvm::cast(), llvm::Depth, directlyImpliesPoison(), llvm::dyn_cast(), I, llvm::isGuaranteedNotToBePoison(), and V.
|
static |
Definition at line 687 of file ValueTracking.cpp.
References llvm::dyn_cast(), E(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and V.
Referenced by llvm::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 3115 of file ValueTracking.cpp.
References assert(), llvm::cast(), llvm::Depth, llvm::SimplifyQuery::DL, llvm::dyn_cast(), F, GEP, llvm::gep_type_begin(), llvm::gep_type_end(), llvm::StructLayout::getElementOffset(), llvm::DataLayout::getStructLayout(), llvm::ConstantInt::getZExtValue(), I, llvm::isKnownNonZero(), llvm::MaxAnalysisRecursionDepth, llvm::NullPointerIsDefined(), and uint64_t.
Referenced by isKnownNonZeroFromOperator().
|
static |
Definition at line 6596 of file ValueTracking.cpp.
References A(), llvm::all_of(), llvm::any_of(), C(), llvm::canCreateUndefOrPoison(), llvm::cast(), Cond, llvm::Depth, llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::Instruction::getDataLayout(), llvm::GlobalVariable::getGlobalSize(), llvm::DomTreeNodeBase< NodeT >::getIDom(), llvm::getKnowledgeValidInContext(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::getSplatValue(), llvm::GlobalValue::hasExternalWeakLinkage(), I, llvm::includesPoison(), llvm::includesUndef(), llvm::isa(), llvm::GlobalValue::isAbsoluteSymbolRef(), llvm::isGuaranteedNotToBeUndefOrPoison(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_PtrAdd(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, llvm::programUndefinedIfUndefOrPoison(), llvm::APInt::sge(), llvm::APInt::slt(), llvm::Splat, and V.
|
static |
Return true if LHS implies RHS is true.
Return false if LHS implies RHS is false. Otherwise, return std::nullopt if we can't infer anything. We expect the RHS to be an icmp and the LHS to be an 'and', 'or', or a 'select' instruction.
Definition at line 8563 of file ValueTracking.cpp.
References assert(), llvm::Depth, DL, llvm::isImpliedCondition(), LHS, llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::MaxAnalysisRecursionDepth.
Referenced by llvm::isImpliedCondition().
|
static |
Return true if "icmp LPred X, LCR" implies "icmp RPred X, RCR" is true.
Return false if "icmp LPred X, LCR" implies "icmp RPred X, RCR" is false. Otherwise, return std::nullopt if we can't infer anything.
Definition at line 8344 of file ValueTracking.cpp.
References llvm::CmpPredicate::dropSameSign(), llvm::ICmpInst::getFlippedSignednessPredicate(), llvm::CmpInst::getInversePredicate(), llvm::CmpPredicate::hasSameSign(), llvm::ConstantRange::icmp(), llvm::ConstantRange::makeAllowedICmpRegion(), and Pred.
Referenced by isImpliedCondICmps().
|
static |
Return true if LHS implies RHS (expanded to its components as "R0 RPred R1") is true.
Return false if LHS implies RHS is false. Otherwise, return std::nullopt if we can't infer anything.
Definition at line 8499 of file ValueTracking.cpp.
References DL, llvm::CmpInst::getInversePredicate(), llvm::ICmpInst::getSwappedCmpPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_ImmConstant(), llvm::ConstantFPRange::makeExactFCmpRegion(), llvm::PatternMatch::match(), and std::swap().
Referenced by llvm::isImpliedCondition().
|
static |
Return true if LHS implies RHS (expanded to its components as "R0 RPred R1") is true.
Return false if LHS implies RHS is false. Otherwise, return std::nullopt if we can't infer anything.
Definition at line 8376 of file ValueTracking.cpp.
References A(), B(), llvm::ConstantRange::binaryAnd(), cmpExcludesZero(), llvm::computeConstantRange(), DL, llvm::CmpPredicate::dropSameSign(), llvm::ICmpInst::getInverseCmpPredicate(), llvm::CmpInst::getInversePredicate(), llvm::CmpPredicate::getMatching(), llvm::CmpPredicate::getPreferredSignedPredicate(), llvm::ICmpInst::getSwappedCmpPredicate(), llvm::ConstantRange::icmp(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::ICmpInst::isImpliedByMatchingCmp(), isImpliedCondCommonOperandWithCR(), isImpliedCondOperands(), llvm::CmpInst::isSigned(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_NonNegative(), llvm::PatternMatch::m_NonPositive(), llvm::PatternMatch::m_NSWSub(), llvm::PatternMatch::m_PtrToIntOrAddr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, P, 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 std::nullopt.
Definition at line 8304 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, isTruePredicate(), and Pred.
Referenced by isImpliedCondICmps().
|
static |
Return true if we can infer that V is known to be a power of 2 from dominating condition Cond (e.g., ctpop(V) == 1).
Definition at line 2880 of file ValueTracking.cpp.
References Cond, llvm::CmpInst::getInversePredicate(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Ctpop(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), Pred, and V.
Referenced by llvm::isKnownToBeAPowerOfTwo().
|
static |
Return true if it is known that V1 != V2.
Definition at line 4473 of file ValueTracking.cpp.
References A(), B(), llvm::cast(), llvm::computeKnownBits(), llvm::Depth, llvm::SimplifyQuery::DL, llvm::dyn_cast(), getInvertibleOperands(), llvm::Value::getType(), llvm::APInt::intersects(), llvm::isKnownNonEqual(), isKnownNonEqualFromContext(), isModifyingBinopOfNonZero(), isNonEqualMul(), isNonEqualPHIs(), isNonEqualPointersWithRecursiveGEP(), isNonEqualSelect(), isNonEqualShl(), isNonEqualURem(), llvm::KnownBits::isUnknown(), llvm::PatternMatch::m_PtrToIntSameSize(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::MaxAnalysisRecursionDepth, llvm::O1, llvm::O2, llvm::KnownBits::One, llvm::V1, llvm::Values, and llvm::KnownBits::Zero.
|
static |
Definition at line 4399 of file ValueTracking.cpp.
References llvm::SimplifyQuery::AC, assert(), llvm::AssumptionCache::assumptionsFor(), llvm::cast(), Cond, llvm::DomConditionCache::conditionsFor(), llvm::SimplifyQuery::CtxI, llvm::SimplifyQuery::DC, llvm::Depth, llvm::SimplifyQuery::DL, llvm::DominatorTree::dominates(), llvm::SimplifyQuery::DT, llvm::Instruction::getFunction(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, llvm::CmpInst::ICMP_NE, llvm::isImpliedCondition(), llvm::isValidAssumeForContext(), V, and llvm::V1.
Referenced by isKnownNonEqual().
|
static |
Definition at line 7259 of file ValueTracking.cpp.
References C(), llvm::dyn_cast(), E(), I, llvm::isa(), llvm::FastMathFlags::noNaNs(), and V.
Referenced by matchSelectPattern().
|
static |
Definition at line 3179 of file ValueTracking.cpp.
References assert(), llvm::cast(), cmpExcludesZero(), DomConditionsMaxUses, llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::Instruction::getFunction(), llvm::CmpInst::getInversePredicate(), llvm::getLoadStorePointerOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Value::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::isGuard(), llvm::Type::isIntegerTy(), llvm::isValidAssumeForContext(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_IDiv(), llvm::PatternMatch::m_IRem(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::NullPointerIsDefined(), llvm::SmallVectorImpl< T >::pop_back_val(), Pred, llvm::SmallVectorTemplateBase< T, bool >::push_back(), RHS, llvm::Instruction::users(), and V.
Referenced by isKnownNonZero().
Definition at line 7282 of file ValueTracking.cpp.
References C(), llvm::dyn_cast(), E(), I, and V.
|
static |
Return true if the given value is known to be non-zero when defined.
For vectors, return true if every demanded element is known to be non-zero when defined. For pointers, if the context instruction and dominator tree are specified, perform context-sensitive analysis and return true if the pointer couldn't possibly be null at the specified instruction. Supports values with integer or pointer type and vectors of integers.
Definition at line 4007 of file ValueTracking.cpp.
References A(), assert(), C(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DT, llvm::dyn_cast(), llvm::PointerType::getAddressSpace(), llvm::APInt::getBitWidth(), llvm::SimplifyQuery::getFunction(), llvm::GlobalValue::getType(), I, llvm::isa(), isKnownNonNullFromDominatingCondition(), llvm::isKnownNonZero(), isKnownNonZeroFromAssume(), isKnownNonZeroFromOperator(), llvm::Constant::isNullValue(), llvm::MaxAnalysisRecursionDepth, llvm::NullPointerIsDefined(), Range, llvm::stripNullTest(), and V.
|
static |
Definition at line 924 of file ValueTracking.cpp.
References llvm::SimplifyQuery::AC, assert(), llvm::assumeBundleImpliesNonNull(), llvm::AssumptionCache::assumptionsFor(), llvm::cast(), cmpExcludesZero(), llvm::SimplifyQuery::CtxI, llvm::AssumptionCache::ExprResultIdx, llvm::Instruction::getFunction(), I, llvm::isValidAssumeForContext(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Pred, RHS, and V.
Referenced by isKnownNonZero().
|
static |
Definition at line 3513 of file ValueTracking.cpp.
References A(), llvm::KnownBits::abs(), llvm::SimplifyQuery::AC, llvm::all_of(), B(), llvm::BitWidth, C(), Call, llvm::cast(), llvm::APInt::clearBit(), cmpExcludesZero(), llvm::computeKnownBits(), llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::SimplifyQuery::DL, llvm::SimplifyQuery::DT, llvm::dyn_cast(), llvm::DataLayout::getAddressSizeInBits(), llvm::APInt::getAllOnes(), llvm::CallBase::getArgOperand(), llvm::getArgumentAliasingToReturnedPointer(), llvm::BinaryOpIntrinsic::getBinaryOp(), getBitWidth(), llvm::APInt::getBitWidth(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::CmpInst::getInversePredicate(), llvm::InstrInfoQuery::getMetadata(), llvm::APInt::getOneBitSet(), llvm::Type::getScalarType(), llvm::getShuffleDemandedElts(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::SimplifyQuery::getWithoutCondContext(), llvm::APInt::getZero(), llvm::InstrInfoQuery::hasNoSignedWrap(), llvm::InstrInfoQuery::hasNoUnsignedWrap(), I, if(), II, llvm::SimplifyQuery::IIQ, llvm::isa(), llvm::PossiblyExactOperator::isExact(), isGEPKnownNonNull(), llvm::isGuaranteedNotToBePoison(), llvm::Type::isIntOrIntVectorTy(), llvm::isKnownNonEqual(), llvm::isKnownNonZero(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isNonZero(), isNonZeroAdd(), isNonZeroMul(), isNonZeroRecurrence(), isNonZeroShift(), isNonZeroSub(), llvm::Type::isPtrOrPtrVectorTy(), llvm::KnownBits::isUnknown(), llvm::APInt::isZero(), llvm::Known, llvm::APInt::lshr(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BasicBlock(), llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_c_ICmp(), llvm::PatternMatch::m_ExtractValue(), llvm::PatternMatch::m_NUWAdd(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_WithOverflowInst(), llvm::PatternMatch::match(), matchOpWithOpEqZero(), llvm::MaxAnalysisRecursionDepth, llvm::NullPointerIsDefined(), llvm::KnownBits::One, Pred, Range, rangeMetadataExcludesValue(), llvm::APInt::reverseBits(), llvm::KnownBits::uge(), llvm::InstrInfoQuery::UseInstrInfo, and X.
Referenced by isKnownNonZero().
|
static |
Return true if V1 == (binop V2, X), where X is known non-zero.
Only handle a small subset of binops where (binop V2, X) with non-zero X implies V2 != V1.
Definition at line 4240 of file ValueTracking.cpp.
References llvm::cast(), llvm::Depth, llvm::dyn_cast(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::isKnownNonZero(), and llvm::V1.
Referenced by isKnownNonEqual().
|
static |
Return true if V2 == V1 * C, where V1 is known non-zero, C is not 0/1 and the multiplication is nuw or nsw.
Definition at line 4269 of file ValueTracking.cpp.
References C(), llvm::Depth, llvm::dyn_cast(), llvm::isKnownNonZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), and llvm::V1.
Referenced by isKnownNonEqual().
|
static |
Definition at line 4296 of file ValueTracking.cpp.
References llvm::PHINode::blocks(), C1, llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::PHINode::getIncomingValueForBlock(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::SimplifyQuery::getWithoutCondContext(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isKnownNonEqual(), llvm::PatternMatch::m_APInt(), and llvm::PatternMatch::match().
Referenced by isKnownNonEqual().
|
static |
Definition at line 4352 of file ValueTracking.cpp.
References A(), B(), llvm::SimplifyQuery::DL, llvm::dyn_cast(), llvm::DataLayout::getIndexTypeSizeInBits(), llvm::isa(), llvm::APInt::isNegative(), llvm::APInt::isStrictlyPositive(), llvm::APInt::sge(), llvm::APInt::sle(), and llvm::Value::stripAndAccumulateInBoundsConstantOffsets().
Referenced by isKnownNonEqual().
|
static |
Definition at line 4327 of file ValueTracking.cpp.
References llvm::Depth, llvm::dyn_cast(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::SelectInst::getTrueValue(), llvm::isKnownNonEqual(), and llvm::V1.
Referenced by isKnownNonEqual().
|
static |
Return true if V2 == V1 << C, where V1 is known non-zero, C is not 0 and the shift is nuw or nsw.
Definition at line 4284 of file ValueTracking.cpp.
References C(), llvm::Depth, llvm::dyn_cast(), llvm::isKnownNonZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), and llvm::V1.
Referenced by isKnownNonEqual().
Definition at line 4456 of file ValueTracking.cpp.
References llvm::SimplifyQuery::CtxI, llvm::SimplifyQuery::DL, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULE, llvm::isImpliedByDomCondition(), isTruePredicate(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by isKnownNonEqual().
|
static |
Definition at line 3369 of file ValueTracking.cpp.
References llvm::KnownBits::add(), llvm::BitWidth, llvm::computeKnownBits(), llvm::Depth, llvm::APInt::getSignedMaxValue(), llvm::APInt::intersects(), llvm::isKnownNonZero(), llvm::isKnownToBeAPowerOfTwo(), llvm::KnownBits::isNegative(), llvm::KnownBits::isNonNegative(), llvm::KnownBits::isNonZero(), isNonZeroAddrPlusOffset(), matchOpWithOpEqZero(), llvm::KnownBits::One, X, and Y.
Referenced by isKnownNonZeroFromOperator().
|
static |
Return true if "addr(P) + Off" cannot be zero.
The object P points to cannot cross the unsigned address space boundary, including the address one past its end, so an offset that stays within the object cannot wrap around to zero. This holds even if the object starts at the zero address, which is all that null_pointer_is_valid permits, so a non-zero offset is enough.
Definition at line 3338 of file ValueTracking.cpp.
References llvm::SimplifyQuery::DL, llvm::DataLayout::getAddressSizeInBits(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_PtrToAddr(), llvm::PatternMatch::m_PtrToInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Off, P, uint64_t, X, and Y.
Referenced by isNonZeroAdd().
|
static |
Definition at line 3434 of file ValueTracking.cpp.
References llvm::BitWidth, llvm::computeKnownBits(), llvm::KnownBits::countMaxTrailingZeros(), llvm::Depth, llvm::isKnownNonZero(), llvm::KnownBits::isNonZero(), llvm::KnownBits::One, X, and Y.
Referenced by isKnownNonZeroFromOperator().
Try to detect a recurrence that monotonically increases/decreases from a non-zero starting value.
These are common as induction variables.
Definition at line 3296 of file ValueTracking.cpp.
References llvm::BinaryOperator::getOpcode(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Instruction::isExact(), llvm::APInt::isNegative(), llvm::APInt::isZero(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), and llvm::matchSimpleRecurrence().
Referenced by isKnownNonZeroFromOperator().
|
static |
Definition at line 3462 of file ValueTracking.cpp.
References llvm::APInt::ashr(), llvm::computeKnownBits(), llvm::Depth, llvm::APInt::getAllOnes(), llvm::KnownBits::getBitWidth(), llvm::KnownBits::getMaxValue(), I, llvm::isKnownNonZero(), llvm::KnownBits::isUnknown(), llvm_unreachable, llvm::APInt::lshr(), llvm::KnownBits::One, llvm::APInt::shl(), llvm::APInt::uge(), and llvm::KnownBits::Zero.
Referenced by isKnownNonZeroFromOperator().
|
static |
Definition at line 3418 of file ValueTracking.cpp.
References llvm::BitWidth, C(), llvm::Depth, llvm::dyn_cast(), llvm::isKnownNonZero(), matchOpWithOpEqZero(), X, and Y.
Referenced by isKnownNonZeroFromOperator().
|
static |
Try to detect a recurrence that the value of the induction variable is always a power of two (or zero).
Definition at line 2823 of file ValueTracking.cpp.
References llvm::SimplifyQuery::CtxI, llvm::Depth, llvm::PHINode::getIncomingBlock(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::InstrInfoQuery::hasNoSignedWrap(), llvm::InstrInfoQuery::hasNoUnsignedWrap(), llvm::SimplifyQuery::IIQ, llvm::InstrInfoQuery::isExact(), llvm::isKnownToBeAPowerOfTwo(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_SignMask(), llvm::PatternMatch::match(), llvm::matchSimpleRecurrence(), and llvm::User::operands().
Referenced by llvm::isKnownToBeAPowerOfTwo().
|
static |
Return true if II reads a register named "vlenb".
On RISC-V this is the VLENB CSR, which holds VLEN/8: a non-zero power of two bounded by the target's VLEN range. Callers must ensure the target is RISC-V.
Definition at line 1411 of file ValueTracking.cpp.
References llvm::dyn_cast(), II, and RegName.
Referenced by getRangeForIntrinsic(), and 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 5754 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::PHINode::getNumIncomingValues(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and llvm::Load.
Referenced by llvm::getUnderlyingObjects().
|
static |
Definition at line 1480 of file ValueTracking.cpp.
References assert(), llvm::cast(), llvm::SelectPatternResult::Flavor, llvm::getInverseMinMaxFlavor(), llvm::isa(), LHS, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::matchSelectPattern(), RHS, Select, llvm::APInt::sle(), llvm::SPF_SMAX, llvm::SPF_SMIN, and std::swap().
Referenced by ComputeNumSignBitsImpl().
|
static |
Definition at line 1509 of file ValueTracking.cpp.
References assert(), llvm::dyn_cast(), llvm::getInverseMinMaxIntrinsic(), II, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::sle(), and std::swap().
Referenced by ComputeNumSignBitsImpl(), and unionWithMinMaxIntrinsicClamp().
Return true if "icmp Pred LHS RHS" is always true.
Definition at line 8222 of file ValueTracking.cpp.
References C(), llvm::cast(), hasNoUnsignedWrap(), llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::isTrueWhenEqual(), LHS, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_Add(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_SMax(), llvm::PatternMatch::m_c_SMin(), llvm::PatternMatch::m_c_UMax(), llvm::PatternMatch::m_c_UMin(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_NSWAdd(), llvm::PatternMatch::m_NSWAddLike(), llvm::PatternMatch::m_NUWAddLike(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_UDiv(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Pred, RHS, llvm::APInt::sle(), llvm::APInt::ule(), and X.
Referenced by isImpliedCondOperands(), and isNonEqualURem().
|
static |
Helps to match a select pattern in case of a type mismatch.
The function processes the case when type of true and false values of a select instruction differs from type of the cmp instruction operands because of a cast instruction. The function checks if it is legal to move the cast operation after "select". If yes, it returns the new second value of "select" (with the assumption that cast is moved):
Definition at line 7907 of file ValueTracking.cpp.
References assert(), C(), llvm::dyn_cast(), llvm::User::getOperand(), llvm::Value::getType(), lookThroughCastConst(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), and llvm::V1.
Referenced by llvm::matchDecomposedSelectPattern().
|
static |
Definition at line 7812 of file ValueTracking.cpp.
References C(), llvm::ConstantFoldCastOperand(), DL, llvm::Instruction::getDataLayout(), llvm::User::getOperand(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::CmpInst::isSigned(), llvm::CmpInst::isUnsigned(), llvm::PatternMatch::m_Constant(), and llvm::PatternMatch::match().
Referenced by lookThroughCast().
|
static |
Convert ConstantRange OverflowResult into ValueTracking OverflowResult.
Definition at line 6163 of file ValueTracking.cpp.
References llvm::ConstantRange::AlwaysOverflowsHigh, llvm::AlwaysOverflowsHigh, llvm::ConstantRange::AlwaysOverflowsLow, llvm::AlwaysOverflowsLow, llvm_unreachable, llvm::ConstantRange::MayOverflow, llvm::MayOverflow, llvm::ConstantRange::NeverOverflows, and llvm::NeverOverflows.
Referenced by computeOverflowForSignedAdd(), llvm::computeOverflowForSignedSub(), llvm::SelectionDAG::computeOverflowForSignedSub(), llvm::computeOverflowForUnsignedAdd(), llvm::SelectionDAG::computeOverflowForUnsignedAdd(), llvm::computeOverflowForUnsignedMul(), llvm::SelectionDAG::computeOverflowForUnsignedMul(), llvm::computeOverflowForUnsignedSub(), and llvm::SelectionDAG::computeOverflowForUnsignedSub().
|
static |
Recognize variations of: CLAMP(v,l,h) ==> ((v) < (l) ?
(l) : ((v) > (h) ? (h) : (v)))
Definition at line 7359 of file ValueTracking.cpp.
References C1, llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_SMax(), llvm::PatternMatch::m_SMin(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_UMax(), llvm::PatternMatch::m_UMin(), llvm::PatternMatch::match(), Pred, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::SPF_UNKNOWN, llvm::SPNB_NA, and std::swap().
Referenced by matchMinMax().
|
static |
Match clamp pattern for float types without care about NaNs or signed zeros.
Given non-min/max outer cmp/select from the clamp pattern this function recognizes if it can be substitued by a "canonical" min/max pattern.
Definition at line 7303 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::getInversePredicate(), llvm::APFloat::isFinite(), LHS, llvm::PatternMatch::m_APFloat(), llvm::PatternMatch::m_FMaxNum(), llvm::PatternMatch::m_FMinNum(), llvm::PatternMatch::m_OrdOrUnordFMax(), llvm::PatternMatch::m_OrdOrUnordFMin(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), Pred, RHS, llvm::SPF_FMAXNUM, llvm::SPF_FMINNUM, llvm::SPF_UNKNOWN, llvm::SPNB_NA, llvm::SPNB_RETURNS_ANY, and std::swap().
Referenced by matchSelectPattern().
|
static |
Match non-obvious integer minimum and maximum sequences.
Definition at line 7409 of file ValueTracking.cpp.
References C1, llvm::SelectPatternResult::Flavor, getNotValue(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm::APInt::isMaxSignedValue(), llvm::APInt::isMinSignedValue(), LHS, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), matchClamp(), Pred, RHS, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, llvm::SPF_UMIN, llvm::SPF_UNKNOWN, and llvm::SPNB_NA.
Referenced by matchSelectPattern().
Definition at line 3326 of file ValueTracking.cpp.
References llvm::CmpInst::ICMP_EQ, llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_SpecificICmp(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExtOrSExt(), and llvm::PatternMatch::match().
Referenced by isKnownNonZeroFromOperator(), isNonZeroAdd(), and isNonZeroSub().
|
static |
Definition at line 7649 of file ValueTracking.cpp.
References llvm::cast(), llvm::getSelectPattern(), llvm::CmpInst::getSwappedPredicate(), llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::isFPPredicate(), llvm::CmpInst::isIntPredicate(), llvm::isKnownNegation(), isKnownNonNaN(), llvm::isKnownNonZero(), llvm::CmpInst::isOrdered(), LHS, llvm::MIPatternMatch::m_AllOnes(), llvm::PatternMatch::m_AnyZeroFP(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_NSWMul(), llvm::PatternMatch::m_NSWShl(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_StrictlyPositive(), llvm::PatternMatch::m_Value(), llvm::MIPatternMatch::m_ZeroInt(), llvm::PatternMatch::match(), matchFastFloatClamp(), matchMinMax(), llvm::FastMathFlags::noSignedZeros(), Pred, RHS, llvm::SPF_ABS, llvm::SPF_NABS, llvm::SPF_UNKNOWN, llvm::SPNB_NA, llvm::SPNB_RETURNS_ANY, llvm::SPNB_RETURNS_NAN, llvm::SPNB_RETURNS_OTHER, and std::swap().
|
static |
Definition at line 8135 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), I, and Operation.
Referenced by llvm::matchSimpleTernaryIntrinsicRecurrence().
|
static |
Definition at line 8108 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), I, LHS, Operation, and RHS.
Referenced by computeKnownBitsFromOperator(), llvm::matchSimpleBinaryIntrinsicRecurrence(), and llvm::matchSimpleRecurrence().
Definition at line 7157 of file ValueTracking.cpp.
References llvm::BasicBlock::begin(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dyn_cast(), llvm::End, llvm::BasicBlock::end(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHIIt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getSingleSuccessor(), handleGuaranteedWellDefinedOps(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isGuaranteedToTransferExecutionToSuccessor(), llvm::make_range(), llvm::mustTriggerUB(), llvm::PoisonOnly, llvm::propagatesPoison(), and V.
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 3279 of file ValueTracking.cpp.
References assert(), llvm::mdconst::extract(), Lower, Range, and llvm::Upper.
Referenced by isKnownNonZeroFromOperator().
|
static |
Definition at line 111 of file ValueTracking.cpp.
References llvm::dyn_cast(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and V.
Referenced by llvm::computeKnownBits(), llvm::computeKnownBits(), llvm::ComputeNumSignBits(), and llvm::isKnownToBeAPowerOfTwo().
|
static |
Definition at line 9162 of file ValueTracking.cpp.
References llvm::BitWidth, I, llvm::isa(), Lower, and llvm::Upper.
Referenced by llvm::computeConstantRange().
|
static |
Definition at line 8755 of file ValueTracking.cpp.
References llvm::APInt::ashr(), assert(), C(), llvm::APInt::getAllOnes(), llvm::APInt::getBitsSetFrom(), llvm::APInt::getHighBitsSet(), llvm::APInt::getMaxValue(), llvm::APInt::getOneBitSet(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), llvm::InstrInfoQuery::hasNoSignedWrap(), llvm::Instruction::hasNoSignedWrap(), llvm::InstrInfoQuery::hasNoUnsignedWrap(), llvm::InstrInfoQuery::isExact(), Lower, llvm::APInt::lshr(), llvm::PatternMatch::m_APInt(), llvm::MIPatternMatch::m_Neg(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::match(), llvm::APInt::sdiv(), std::swap(), llvm::APInt::udiv(), and llvm::Upper.
Referenced by llvm::computeConstantRange().
Shifts return poison if shiftwidth is larger than the bitwidth.
Definition at line 6422 of file ValueTracking.cpp.
References llvm::all_of(), C(), llvm::dyn_cast(), llvm::dyn_cast_or_null(), llvm::isa(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by canCreateUndefOrPoison().
|
static |
Definition at line 1528 of file ValueTracking.cpp.
References llvm::ConstantRange::getNonEmpty(), II, isSignedMinMaxIntrinsicClamp(), and llvm::Known.
Referenced by computeKnownBitsFromOperator().
|
static |
Referenced by isKnownNonNullFromDominatingCondition().
|
staticconstexpr |
Maximum number of instructions to check between assume and context instruction.
Definition at line 94 of file ValueTracking.cpp.
Referenced by hasNoFreeInRange().