Lines Matching refs:V
115 static const Instruction *safeCxtI(const Value *V, const Instruction *CxtI) { in safeCxtI() argument
122 CxtI = dyn_cast<Instruction>(V); in safeCxtI()
129 static void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
133 void llvm::computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, in computeKnownBits() argument
137 ::computeKnownBits(V, KnownZero, KnownOne, DL, Depth, in computeKnownBits()
138 Query(AC, safeCxtI(V, CxtI), DT)); in computeKnownBits()
156 static void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne,
160 void llvm::ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, in ComputeSignBit() argument
164 ::ComputeSignBit(V, KnownZero, KnownOne, DL, Depth, in ComputeSignBit()
165 Query(AC, safeCxtI(V, CxtI), DT)); in ComputeSignBit()
168 static bool isKnownToBeAPowerOfTwo(Value *V, bool OrZero, unsigned Depth,
171 bool llvm::isKnownToBeAPowerOfTwo(Value *V, const DataLayout &DL, bool OrZero, in isKnownToBeAPowerOfTwo() argument
175 return ::isKnownToBeAPowerOfTwo(V, OrZero, Depth, in isKnownToBeAPowerOfTwo()
176 Query(AC, safeCxtI(V, CxtI), DT), DL); in isKnownToBeAPowerOfTwo()
179 static bool isKnownNonZero(Value *V, const DataLayout &DL, unsigned Depth,
182 bool llvm::isKnownNonZero(Value *V, const DataLayout &DL, unsigned Depth, in isKnownNonZero() argument
185 return ::isKnownNonZero(V, DL, Depth, Query(AC, safeCxtI(V, CxtI), DT)); in isKnownNonZero()
188 static bool MaskedValueIsZero(Value *V, const APInt &Mask, const DataLayout &DL,
191 bool llvm::MaskedValueIsZero(Value *V, const APInt &Mask, const DataLayout &DL, in MaskedValueIsZero() argument
194 return ::MaskedValueIsZero(V, Mask, DL, Depth, in MaskedValueIsZero()
195 Query(AC, safeCxtI(V, CxtI), DT)); in MaskedValueIsZero()
198 static unsigned ComputeNumSignBits(Value *V, const DataLayout &DL,
201 unsigned llvm::ComputeNumSignBits(Value *V, const DataLayout &DL, in ComputeNumSignBits() argument
205 return ::ComputeNumSignBits(V, DL, Depth, Query(AC, safeCxtI(V, CxtI), DT)); in ComputeNumSignBits()
378 const Value *V = WorkSet.pop_back_val(); in isEphemeralValueOf() local
379 if (!Visited.insert(V).second) in isEphemeralValueOf()
384 for (const User *I : V->users()) in isEphemeralValueOf()
391 if (V == E) in isEphemeralValueOf()
394 EphValues.insert(V); in isEphemeralValueOf()
395 if (const User *U = dyn_cast<User>(V)) in isEphemeralValueOf()
430 static bool isValidAssumeForContext(Value *V, const Query &Q) { in isValidAssumeForContext() argument
431 Instruction *Inv = cast<Instruction>(V); in isValidAssumeForContext()
521 static void computeKnownBitsFromTrueCondition(Value *V, ICmpInst *Cmp, in computeKnownBitsFromTrueCondition() argument
531 if (LHS != V && RHS != V) in computeKnownBitsFromTrueCondition()
544 if (LHS == V) { in computeKnownBitsFromTrueCondition()
556 if (LHS == V) in computeKnownBitsFromTrueCondition()
558 else if (RHS == V) in computeKnownBitsFromTrueCondition()
567 if (LHS == V) { in computeKnownBitsFromTrueCondition()
576 if (LHS == V) { in computeKnownBitsFromTrueCondition()
595 static void computeKnownBitsFromDominatingCondition(Value *V, APInt &KnownZero, in computeKnownBitsFromDominatingCondition() argument
606 if (auto VI = dyn_cast<Instruction>(V)) in computeKnownBitsFromDominatingCondition()
656 computeKnownBitsFromTrueCondition(V, Cmp, KnownZero, KnownOne, DL, Depth, in computeKnownBitsFromDominatingCondition()
662 for (auto U : V->users()) { in computeKnownBitsFromDominatingCondition()
690 computeKnownBitsFromTrueCondition(V, Cmp, KnownZero, KnownOne, DL, Depth, in computeKnownBitsFromDominatingCondition()
696 static void computeKnownBitsFromAssume(Value *V, APInt &KnownZero, in computeKnownBitsFromAssume() argument
724 if (Arg == V && isValidAssumeForContext(I, Q)) { in computeKnownBitsFromAssume()
736 auto m_V = m_CombineOr(m_Specific(V), in computeKnownBitsFromAssume()
737 m_CombineOr(m_PtrToInt(m_Specific(V)), in computeKnownBitsFromAssume()
738 m_BitCast(m_Specific(V)))); in computeKnownBitsFromAssume()
1412 void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, in computeKnownBits() argument
1414 assert(V && "No Value?"); in computeKnownBits()
1418 assert((V->getType()->isIntOrIntVectorTy() || in computeKnownBits()
1419 V->getType()->getScalarType()->isPointerTy()) && in computeKnownBits()
1421 assert((DL.getTypeSizeInBits(V->getType()->getScalarType()) == BitWidth) && in computeKnownBits()
1422 (!V->getType()->isIntOrIntVectorTy() || in computeKnownBits()
1423 V->getType()->getScalarSizeInBits() == BitWidth) && in computeKnownBits()
1428 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { in computeKnownBits()
1435 if (isa<ConstantPointerNull>(V) || in computeKnownBits()
1436 isa<ConstantAggregateZero>(V)) { in computeKnownBits()
1444 if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(V)) { in computeKnownBits()
1458 if (auto *GO = dyn_cast<GlobalObject>(V)) { in computeKnownBits()
1483 if (Argument *A = dyn_cast<Argument>(V)) { in computeKnownBits()
1501 computeKnownBitsFromAssume(V, KnownZero, KnownOne, DL, Depth, Q); in computeKnownBits()
1505 computeKnownBitsFromDominatingCondition(V, KnownZero, KnownOne, DL, in computeKnownBits()
1520 if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) { in computeKnownBits()
1526 if (Operator *I = dyn_cast<Operator>(V)) in computeKnownBits()
1533 computeKnownBitsFromAssume(V, KnownZero, KnownOne, DL, Depth, Q); in computeKnownBits()
1538 computeKnownBitsFromDominatingCondition(V, KnownZero, KnownOne, DL, Depth, in computeKnownBits()
1546 void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, in ComputeSignBit() argument
1548 unsigned BitWidth = getBitWidth(V->getType(), DL); in ComputeSignBit()
1556 computeKnownBits(V, ZeroBits, OneBits, DL, Depth, Q); in ComputeSignBit()
1565 bool isKnownToBeAPowerOfTwo(Value *V, bool OrZero, unsigned Depth, in isKnownToBeAPowerOfTwo() argument
1567 if (Constant *C = dyn_cast<Constant>(V)) { in isKnownToBeAPowerOfTwo()
1577 if (match(V, m_Shl(m_One(), m_Value()))) in isKnownToBeAPowerOfTwo()
1582 if (match(V, m_LShr(m_SignBit(), m_Value()))) in isKnownToBeAPowerOfTwo()
1591 if (OrZero && (match(V, m_Shl(m_Value(X), m_Value())) || in isKnownToBeAPowerOfTwo()
1592 match(V, m_Shr(m_Value(X), m_Value())))) in isKnownToBeAPowerOfTwo()
1595 if (ZExtInst *ZI = dyn_cast<ZExtInst>(V)) in isKnownToBeAPowerOfTwo()
1598 if (SelectInst *SI = dyn_cast<SelectInst>(V)) in isKnownToBeAPowerOfTwo()
1602 if (OrZero && match(V, m_And(m_Value(X), m_Value(Y)))) { in isKnownToBeAPowerOfTwo()
1615 if (match(V, m_Add(m_Value(X), m_Value(Y)))) { in isKnownToBeAPowerOfTwo()
1616 OverflowingBinaryOperator *VOBO = cast<OverflowingBinaryOperator>(V); in isKnownToBeAPowerOfTwo()
1627 unsigned BitWidth = V->getType()->getScalarSizeInBits(); in isKnownToBeAPowerOfTwo()
1647 if (match(V, m_Exact(m_LShr(m_Value(), m_Value()))) || in isKnownToBeAPowerOfTwo()
1648 match(V, m_Exact(m_UDiv(m_Value(), m_Value())))) { in isKnownToBeAPowerOfTwo()
1649 return isKnownToBeAPowerOfTwo(cast<Operator>(V)->getOperand(0), OrZero, in isKnownToBeAPowerOfTwo()
1741 bool isKnownNonZero(Value *V, const DataLayout &DL, unsigned Depth, in isKnownNonZero() argument
1743 if (Constant *C = dyn_cast<Constant>(V)) { in isKnownNonZero()
1753 if (Instruction* I = dyn_cast<Instruction>(V)) { in isKnownNonZero()
1757 if (IntegerType* Ty = dyn_cast<IntegerType>(V->getType())) { in isKnownNonZero()
1770 if (V->getType()->isPointerTy()) { in isKnownNonZero()
1771 if (isKnownNonNull(V)) in isKnownNonZero()
1773 if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) in isKnownNonZero()
1778 unsigned BitWidth = getBitWidth(V->getType()->getScalarType(), DL); in isKnownNonZero()
1782 if (match(V, m_Or(m_Value(X), m_Value(Y)))) in isKnownNonZero()
1786 if (isa<SExtInst>(V) || isa<ZExtInst>(V)) in isKnownNonZero()
1787 return isKnownNonZero(cast<Instruction>(V)->getOperand(0), DL, Depth, Q); in isKnownNonZero()
1791 if (BitWidth && match(V, m_Shl(m_Value(X), m_Value(Y)))) { in isKnownNonZero()
1793 OverflowingBinaryOperator *BO = cast<OverflowingBinaryOperator>(V); in isKnownNonZero()
1805 else if (match(V, m_Shr(m_Value(X), m_Value(Y)))) { in isKnownNonZero()
1807 PossiblyExactOperator *BO = cast<PossiblyExactOperator>(V); in isKnownNonZero()
1817 else if (match(V, m_Exact(m_IDiv(m_Value(X), m_Value())))) { in isKnownNonZero()
1821 else if (match(V, m_Add(m_Value(X), m_Value(Y)))) { in isKnownNonZero()
1860 else if (match(V, m_Mul(m_Value(X), m_Value(Y)))) { in isKnownNonZero()
1861 OverflowingBinaryOperator *BO = cast<OverflowingBinaryOperator>(V); in isKnownNonZero()
1869 else if (SelectInst *SI = dyn_cast<SelectInst>(V)) { in isKnownNonZero()
1878 computeKnownBits(V, KnownZero, KnownOne, DL, Depth, Q); in isKnownNonZero()
1891 bool MaskedValueIsZero(Value *V, const APInt &Mask, const DataLayout &DL, in MaskedValueIsZero() argument
1894 computeKnownBits(V, KnownZero, KnownOne, DL, Depth, Q); in MaskedValueIsZero()
1908 unsigned ComputeNumSignBits(Value *V, const DataLayout &DL, unsigned Depth, in ComputeNumSignBits() argument
1910 unsigned TyBits = DL.getTypeSizeInBits(V->getType()->getScalarType()); in ComputeNumSignBits()
1920 Operator *U = dyn_cast<Operator>(V); in ComputeNumSignBits()
1921 switch (Operator::getOpcode(V)) { in ComputeNumSignBits()
2108 computeKnownBits(V, KnownZero, KnownOne, DL, Depth, Q); in ComputeNumSignBits()
2132 bool llvm::ComputeMultiple(Value *V, unsigned Base, Value *&Multiple, in ComputeMultiple() argument
2136 assert(V && "No Value?"); in ComputeMultiple()
2138 assert(V->getType()->isIntegerTy() && "Not integer or pointer type!"); in ComputeMultiple()
2140 Type *T = V->getType(); in ComputeMultiple()
2142 ConstantInt *CI = dyn_cast<ConstantInt>(V); in ComputeMultiple()
2148 Multiple = V; in ComputeMultiple()
2152 ConstantExpr *CO = dyn_cast<ConstantExpr>(V); in ComputeMultiple()
2167 Operator *I = dyn_cast<Operator>(V); in ComputeMultiple()
2191 Op1 = ConstantInt::get(V->getContext(), API); in ComputeMultiple()
2254 bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) { in CannotBeNegativeZero() argument
2255 if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V)) in CannotBeNegativeZero()
2264 const Operator *I = dyn_cast<Operator>(V); in CannotBeNegativeZero()
2305 bool llvm::CannotBeOrderedLessThanZero(const Value *V, unsigned Depth) { in CannotBeOrderedLessThanZero() argument
2306 if (const ConstantFP *CFP = dyn_cast<ConstantFP>(V)) in CannotBeOrderedLessThanZero()
2315 const Operator *I = dyn_cast<Operator>(V); in CannotBeOrderedLessThanZero()
2366 Value *llvm::isBytewiseValue(Value *V) { in isBytewiseValue() argument
2368 if (V->getType()->isIntegerTy(8)) return V; in isBytewiseValue()
2371 if (Constant *C = dyn_cast<Constant>(V)) in isBytewiseValue()
2373 return Constant::getNullValue(Type::getInt8Ty(V->getContext())); in isBytewiseValue()
2377 if (ConstantFP *CFP = dyn_cast<ConstantFP>(V)) { in isBytewiseValue()
2379 V = ConstantExpr::getBitCast(CFP, Type::getInt32Ty(V->getContext())); in isBytewiseValue()
2381 V = ConstantExpr::getBitCast(CFP, Type::getInt64Ty(V->getContext())); in isBytewiseValue()
2386 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { in isBytewiseValue()
2392 return ConstantInt::get(V->getContext(), CI->getValue().trunc(8)); in isBytewiseValue()
2398 if (ConstantDataSequential *CA = dyn_cast<ConstantDataSequential>(V)) { in isBytewiseValue()
2464 Value *V = FindInsertedValue(From, Idxs); in BuildSubAggregate() local
2466 if (!V) in BuildSubAggregate()
2470 return llvm::InsertValueInst::Create(To, V, makeArrayRef(Idxs).slice(IdxSkip), in BuildSubAggregate()
2504 Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range, in FindInsertedValue() argument
2509 return V; in FindInsertedValue()
2511 assert((V->getType()->isStructTy() || V->getType()->isArrayTy()) && in FindInsertedValue()
2513 assert(ExtractValueInst::getIndexedType(V->getType(), idx_range) && in FindInsertedValue()
2516 if (Constant *C = dyn_cast<Constant>(V)) { in FindInsertedValue()
2522 if (InsertValueInst *I = dyn_cast<InsertValueInst>(V)) { in FindInsertedValue()
2543 return BuildSubAggregate(V, makeArrayRef(idx_range.begin(), req_idx), in FindInsertedValue()
2562 if (ExtractValueInst *I = dyn_cast<ExtractValueInst>(V)) { in FindInsertedValue()
2625 bool llvm::getConstantStringInfo(const Value *V, StringRef &Str, in getConstantStringInfo() argument
2627 assert(V); in getConstantStringInfo()
2630 V = V->stripPointerCasts(); in getConstantStringInfo()
2634 if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { in getConstantStringInfo()
2666 const GlobalVariable *GV = dyn_cast<GlobalVariable>(V); in getConstantStringInfo()
2711 static uint64_t GetStringLengthH(Value *V, SmallPtrSetImpl<PHINode*> &PHIs) { in GetStringLengthH() argument
2713 V = V->stripPointerCasts(); in GetStringLengthH()
2717 if (PHINode *PN = dyn_cast<PHINode>(V)) { in GetStringLengthH()
2739 if (SelectInst *SI = dyn_cast<SelectInst>(V)) { in GetStringLengthH()
2752 if (!getConstantStringInfo(V, StrData)) in GetStringLengthH()
2760 uint64_t llvm::GetStringLength(Value *V) { in GetStringLength() argument
2761 if (!V->getType()->isPointerTy()) return 0; in GetStringLength()
2764 uint64_t Len = GetStringLengthH(V, PHIs); in GetStringLength()
2796 Value *llvm::GetUnderlyingObject(Value *V, const DataLayout &DL, in GetUnderlyingObject() argument
2798 if (!V->getType()->isPointerTy()) in GetUnderlyingObject()
2799 return V; in GetUnderlyingObject()
2801 if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { in GetUnderlyingObject()
2802 V = GEP->getPointerOperand(); in GetUnderlyingObject()
2803 } else if (Operator::getOpcode(V) == Instruction::BitCast || in GetUnderlyingObject()
2804 Operator::getOpcode(V) == Instruction::AddrSpaceCast) { in GetUnderlyingObject()
2805 V = cast<Operator>(V)->getOperand(0); in GetUnderlyingObject()
2806 } else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) { in GetUnderlyingObject()
2808 return V; in GetUnderlyingObject()
2809 V = GA->getAliasee(); in GetUnderlyingObject()
2812 if (Instruction *I = dyn_cast<Instruction>(V)) in GetUnderlyingObject()
2815 V = Simplified; in GetUnderlyingObject()
2819 return V; in GetUnderlyingObject()
2821 assert(V->getType()->isPointerTy() && "Unexpected operand type!"); in GetUnderlyingObject()
2823 return V; in GetUnderlyingObject()
2826 void llvm::GetUnderlyingObjects(Value *V, SmallVectorImpl<Value *> &Objects, in GetUnderlyingObjects() argument
2831 Worklist.push_back(V); in GetUnderlyingObjects()
2868 bool llvm::onlyUsedByLifetimeMarkers(const Value *V) { in onlyUsedByLifetimeMarkers() argument
2869 for (const User *U : V->users()) { in onlyUsedByLifetimeMarkers()
2925 static bool isDereferenceableFromAttribute(const Value *V, const DataLayout &DL, in isDereferenceableFromAttribute() argument
2929 Type *VTy = V->getType(); in isDereferenceableFromAttribute()
2935 return isDereferenceableFromAttribute(V, Offset, Ty, DL, CtxI, DT, TLI); in isDereferenceableFromAttribute()
2942 static bool isDereferenceablePointer(const Value *V, const DataLayout &DL, in isDereferenceablePointer() argument
2951 if (isa<AllocaInst>(V)) return true; in isDereferenceablePointer()
2960 if (const BitCastOperator *BC = dyn_cast<BitCastOperator>(V)) { in isDereferenceablePointer()
2971 if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) in isDereferenceablePointer()
2975 if (const Argument *A = dyn_cast<Argument>(V)) in isDereferenceablePointer()
2979 if (isDereferenceableFromAttribute(V, DL, CtxI, DT, TLI)) in isDereferenceablePointer()
2983 if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { in isDereferenceablePointer()
3006 if (const IntrinsicInst *I = dyn_cast<IntrinsicInst>(V)) in isDereferenceablePointer()
3013 if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V)) in isDereferenceablePointer()
3021 bool llvm::isDereferenceablePointer(const Value *V, const DataLayout &DL, in isDereferenceablePointer() argument
3029 Type *VTy = V->getType(); in isDereferenceablePointer()
3033 const Value *BV = V->stripAndAccumulateInBoundsConstantOffsets(DL, Offset); in isDereferenceablePointer()
3042 return ::isDereferenceablePointer(V, DL, CtxI, DT, TLI, Visited); in isDereferenceablePointer()
3045 bool llvm::isSafeToSpeculativelyExecute(const Value *V, in isSafeToSpeculativelyExecute() argument
3049 const Operator *Inst = dyn_cast<Operator>(V); in isSafeToSpeculativelyExecute()
3064 const APInt *V; in isSafeToSpeculativelyExecute() local
3065 if (match(Inst->getOperand(1), m_APInt(V))) in isSafeToSpeculativelyExecute()
3066 return *V != 0; in isSafeToSpeculativelyExecute()
3159 bool llvm::isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI) { in isKnownNonNull() argument
3161 if (isa<AllocaInst>(V)) return true; in isKnownNonNull()
3164 if (const Argument *A = dyn_cast<Argument>(V)) in isKnownNonNull()
3168 if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) in isKnownNonNull()
3172 if (const LoadInst *LI = dyn_cast<LoadInst>(V)) in isKnownNonNull()
3175 if (auto CS = ImmutableCallSite(V)) in isKnownNonNull()
3180 if (isOperatorNewLikeFn(V, TLI, /*LookThroughBitCast=*/true)) in isKnownNonNull()
3186 static bool isKnownNonNullFromDominatingCondition(const Value *V, in isKnownNonNullFromDominatingCondition() argument
3190 for (auto U : V->users()) { in isKnownNonNullFromDominatingCondition()
3214 m_c_ICmp(Pred, m_Specific(V), m_Zero()))) { in isKnownNonNullFromDominatingCondition()
3232 bool llvm::isKnownNonNullAt(const Value *V, const Instruction *CtxI, in isKnownNonNullAt() argument
3234 if (isKnownNonNull(V, TLI)) in isKnownNonNullAt()
3237 return CtxI ? ::isKnownNonNullFromDominatingCondition(V, CtxI, DT) : false; in isKnownNonNullAt()
3415 SelectPatternFlavor llvm::matchSelectPattern(Value *V, in matchSelectPattern() argument
3418 SelectInst *SI = dyn_cast<SelectInst>(V); in matchSelectPattern()