Lines Matching refs:ConstantRange
42 ConstantRange::ConstantRange(uint32_t BitWidth, bool Full) in ConstantRange() function in ConstantRange
46 ConstantRange::ConstantRange(APInt V) in ConstantRange() function in ConstantRange
49 ConstantRange::ConstantRange(APInt L, APInt U) in ConstantRange() function in ConstantRange
57 ConstantRange ConstantRange::makeAllowedICmpRegion(CmpInst::Predicate Pred, in makeAllowedICmpRegion()
58 const ConstantRange &CR) { in makeAllowedICmpRegion()
70 return ConstantRange(CR.getUpper(), CR.getLower()); in makeAllowedICmpRegion()
71 return ConstantRange(W); in makeAllowedICmpRegion()
75 return ConstantRange(W, /* empty */ false); in makeAllowedICmpRegion()
76 return ConstantRange(APInt::getMinValue(W), std::move(UMax)); in makeAllowedICmpRegion()
81 return ConstantRange(W, /* empty */ false); in makeAllowedICmpRegion()
82 return ConstantRange(APInt::getSignedMinValue(W), std::move(SMax)); in makeAllowedICmpRegion()
87 return ConstantRange(W); in makeAllowedICmpRegion()
88 return ConstantRange(APInt::getMinValue(W), std::move(UMax) + 1); in makeAllowedICmpRegion()
93 return ConstantRange(W); in makeAllowedICmpRegion()
94 return ConstantRange(APInt::getSignedMinValue(W), std::move(SMax) + 1); in makeAllowedICmpRegion()
99 return ConstantRange(W, /* empty */ false); in makeAllowedICmpRegion()
100 return ConstantRange(std::move(UMin) + 1, APInt::getNullValue(W)); in makeAllowedICmpRegion()
105 return ConstantRange(W, /* empty */ false); in makeAllowedICmpRegion()
106 return ConstantRange(std::move(SMin) + 1, APInt::getSignedMinValue(W)); in makeAllowedICmpRegion()
111 return ConstantRange(W); in makeAllowedICmpRegion()
112 return ConstantRange(std::move(UMin), APInt::getNullValue(W)); in makeAllowedICmpRegion()
117 return ConstantRange(W); in makeAllowedICmpRegion()
118 return ConstantRange(std::move(SMin), APInt::getSignedMinValue(W)); in makeAllowedICmpRegion()
123 ConstantRange ConstantRange::makeSatisfyingICmpRegion(CmpInst::Predicate Pred, in makeSatisfyingICmpRegion()
124 const ConstantRange &CR) { in makeSatisfyingICmpRegion()
133 ConstantRange ConstantRange::makeExactICmpRegion(CmpInst::Predicate Pred, in makeExactICmpRegion()
145 bool ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred, in getEquivalentICmp()
173 assert((!Success || ConstantRange::makeExactICmpRegion(Pred, RHS) == *this) && in getEquivalentICmp()
179 ConstantRange
180 ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, in makeGuaranteedNoWrapRegion()
181 const ConstantRange &Other, in makeGuaranteedNoWrapRegion()
190 [](const ConstantRange &CR0, const ConstantRange &CR1) { in makeGuaranteedNoWrapRegion()
202 ConstantRange Result(BitWidth); in makeGuaranteedNoWrapRegion()
207 return ConstantRange(BitWidth, false); in makeGuaranteedNoWrapRegion()
213 return ConstantRange(BitWidth); in makeGuaranteedNoWrapRegion()
216 SubsetIntersect(Result, ConstantRange(APInt::getNullValue(BitWidth), in makeGuaranteedNoWrapRegion()
224 ConstantRange(APInt::getSignedMinValue(BitWidth), in makeGuaranteedNoWrapRegion()
229 ConstantRange(APInt::getSignedMinValue(BitWidth) - SignedMin, in makeGuaranteedNoWrapRegion()
238 return ConstantRange(BitWidth); in makeGuaranteedNoWrapRegion()
241 SubsetIntersect(Result, ConstantRange(Other.getUnsignedMax(), in makeGuaranteedNoWrapRegion()
249 ConstantRange(APInt::getSignedMinValue(BitWidth) + SignedMax, in makeGuaranteedNoWrapRegion()
254 ConstantRange(APInt::getSignedMinValue(BitWidth), in makeGuaranteedNoWrapRegion()
268 BitWidth](APInt V) -> ConstantRange { in makeGuaranteedNoWrapRegion()
272 return ConstantRange(BitWidth, true); in makeGuaranteedNoWrapRegion()
284 return ConstantRange(-MaxValue, MinValue); in makeGuaranteedNoWrapRegion()
307 return ConstantRange(Lower, Upper + 1); in makeGuaranteedNoWrapRegion()
319 bool ConstantRange::isFullSet() const { in isFullSet()
323 bool ConstantRange::isEmptySet() const { in isEmptySet()
327 bool ConstantRange::isWrappedSet() const { in isWrappedSet()
331 bool ConstantRange::isSignWrappedSet() const { in isSignWrappedSet()
336 APInt ConstantRange::getSetSize() const { in getSetSize()
345 ConstantRange::isSizeStrictlySmallerThan(const ConstantRange &Other) const { in isSizeStrictlySmallerThan()
355 ConstantRange::isSizeLargerThan(uint64_t MaxSize) const { in isSizeLargerThan()
365 APInt ConstantRange::getUnsignedMax() const { in getUnsignedMax()
371 APInt ConstantRange::getUnsignedMin() const { in getUnsignedMin()
377 APInt ConstantRange::getSignedMax() const { in getSignedMax()
383 APInt ConstantRange::getSignedMin() const { in getSignedMin()
389 bool ConstantRange::contains(const APInt &V) const { in contains()
398 bool ConstantRange::contains(const ConstantRange &Other) const { in contains()
416 ConstantRange ConstantRange::subtract(const APInt &Val) const { in subtract()
421 return ConstantRange(Lower - Val, Upper - Val); in subtract()
424 ConstantRange ConstantRange::difference(const ConstantRange &CR) const { in difference()
428 ConstantRange ConstantRange::intersectWith(const ConstantRange &CR) const { in intersectWith()
442 return ConstantRange(getBitWidth(), false); in intersectWith()
445 return ConstantRange(CR.Lower, Upper); in intersectWith()
453 return ConstantRange(Lower, CR.Upper); in intersectWith()
455 return ConstantRange(getBitWidth(), false); in intersectWith()
464 return ConstantRange(CR.Lower, Upper); in intersectWith()
472 return ConstantRange(getBitWidth(), false); in intersectWith()
474 return ConstantRange(Lower, CR.Upper); in intersectWith()
487 return ConstantRange(Lower, CR.Upper); in intersectWith()
495 return ConstantRange(CR.Lower, Upper); in intersectWith()
502 ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const { in unionWith()
516 return ConstantRange(Lower, CR.Upper); in unionWith()
517 return ConstantRange(CR.Lower, Upper); in unionWith()
524 return ConstantRange(getBitWidth()); in unionWith()
526 return ConstantRange(std::move(L), std::move(U)); in unionWith()
538 return ConstantRange(getBitWidth()); in unionWith()
546 return ConstantRange(Lower, CR.Upper); in unionWith()
547 return ConstantRange(CR.Lower, Upper); in unionWith()
553 return ConstantRange(CR.Lower, Upper); in unionWith()
559 return ConstantRange(Lower, CR.Upper); in unionWith()
565 return ConstantRange(getBitWidth()); in unionWith()
570 return ConstantRange(std::move(L), std::move(U)); in unionWith()
573 ConstantRange ConstantRange::castOp(Instruction::CastOps CastOp, in castOp()
591 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in castOp()
597 return ConstantRange(std::move(Min), std::move(Max)); in castOp()
604 return ConstantRange(std::move(SMin), std::move(SMax)); in castOp()
612 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in castOp()
616 ConstantRange ConstantRange::zeroExtend(uint32_t DstTySize) const { in zeroExtend()
617 if (isEmptySet()) return ConstantRange(DstTySize, /*isFullSet=*/false); in zeroExtend()
626 return ConstantRange(std::move(LowerExt), in zeroExtend()
630 return ConstantRange(Lower.zext(DstTySize), Upper.zext(DstTySize)); in zeroExtend()
633 ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const { in signExtend()
634 if (isEmptySet()) return ConstantRange(DstTySize, /*isFullSet=*/false); in signExtend()
641 return ConstantRange(Lower.sext(DstTySize), Upper.zext(DstTySize)); in signExtend()
644 return ConstantRange(APInt::getHighBitsSet(DstTySize,DstTySize-SrcTySize+1), in signExtend()
648 return ConstantRange(Lower.sext(DstTySize), Upper.sext(DstTySize)); in signExtend()
651 ConstantRange ConstantRange::truncate(uint32_t DstTySize) const { in truncate()
654 return ConstantRange(DstTySize, /*isFullSet=*/false); in truncate()
656 return ConstantRange(DstTySize, /*isFullSet=*/true); in truncate()
659 ConstantRange Union(DstTySize, /*isFullSet=*/false); in truncate()
669 return ConstantRange(DstTySize, /*isFullSet=*/true); in truncate()
671 Union = ConstantRange(APInt::getMaxValue(DstTySize),Upper.trunc(DstTySize)); in truncate()
690 return ConstantRange(LowerDiv.trunc(DstTySize), in truncate()
698 return ConstantRange(LowerDiv.trunc(DstTySize), in truncate()
702 return ConstantRange(DstTySize, /*isFullSet=*/true); in truncate()
705 ConstantRange ConstantRange::zextOrTrunc(uint32_t DstTySize) const { in zextOrTrunc()
714 ConstantRange ConstantRange::sextOrTrunc(uint32_t DstTySize) const { in sextOrTrunc()
723 ConstantRange ConstantRange::binaryOp(Instruction::BinaryOps BinOp, in binaryOp()
724 const ConstantRange &Other) const { in binaryOp()
756 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in binaryOp()
760 ConstantRange
761 ConstantRange::add(const ConstantRange &Other) const { in add()
763 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in add()
765 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in add()
770 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in add()
772 ConstantRange X = ConstantRange(std::move(NewLower), std::move(NewUpper)); in add()
776 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in add()
780 ConstantRange ConstantRange::addWithNoSignedWrap(const APInt &Other) const { in addWithNoSignedWrap()
785 auto NSWRange = ConstantRange::makeGuaranteedNoWrapRegion(BinaryOperator::Add, in addWithNoSignedWrap()
786 ConstantRange(Other), in addWithNoSignedWrap()
790 return NSWConstrainedRange.add(ConstantRange(Other)); in addWithNoSignedWrap()
793 ConstantRange
794 ConstantRange::sub(const ConstantRange &Other) const { in sub()
796 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in sub()
798 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in sub()
803 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in sub()
805 ConstantRange X = ConstantRange(std::move(NewLower), std::move(NewUpper)); in sub()
809 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in sub()
813 ConstantRange
814 ConstantRange::multiply(const ConstantRange &Other) const { in multiply()
821 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in multiply()
835 ConstantRange Result_zext = ConstantRange(this_min * Other_min, in multiply()
837 ConstantRange UR = Result_zext.truncate(getBitWidth()); in multiply()
861 ConstantRange Result_sext(std::min(L, Compare), std::max(L, Compare) + 1); in multiply()
862 ConstantRange SR = Result_sext.truncate(getBitWidth()); in multiply()
867 ConstantRange
868 ConstantRange::smax(const ConstantRange &Other) const { in smax()
872 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in smax()
876 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in smax()
877 return ConstantRange(std::move(NewL), std::move(NewU)); in smax()
880 ConstantRange
881 ConstantRange::umax(const ConstantRange &Other) const { in umax()
885 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in umax()
889 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in umax()
890 return ConstantRange(std::move(NewL), std::move(NewU)); in umax()
893 ConstantRange
894 ConstantRange::smin(const ConstantRange &Other) const { in smin()
898 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in smin()
902 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in smin()
903 return ConstantRange(std::move(NewL), std::move(NewU)); in smin()
906 ConstantRange
907 ConstantRange::umin(const ConstantRange &Other) const { in umin()
911 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in umin()
915 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in umin()
916 return ConstantRange(std::move(NewL), std::move(NewU)); in umin()
919 ConstantRange
920 ConstantRange::udiv(const ConstantRange &RHS) const { in udiv()
922 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in udiv()
924 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in udiv()
943 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in udiv()
945 return ConstantRange(std::move(Lower), std::move(Upper)); in udiv()
948 ConstantRange
949 ConstantRange::binaryAnd(const ConstantRange &Other) const { in binaryAnd()
951 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in binaryAnd()
957 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in binaryAnd()
958 return ConstantRange(APInt::getNullValue(getBitWidth()), std::move(umin) + 1); in binaryAnd()
961 ConstantRange
962 ConstantRange::binaryOr(const ConstantRange &Other) const { in binaryOr()
964 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in binaryOr()
970 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in binaryOr()
971 return ConstantRange(std::move(umax), APInt::getNullValue(getBitWidth())); in binaryOr()
974 ConstantRange
975 ConstantRange::shl(const ConstantRange &Other) const { in shl()
977 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in shl()
984 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in shl()
992 return ConstantRange(std::move(min), std::move(max) + 1); in shl()
995 ConstantRange
996 ConstantRange::lshr(const ConstantRange &Other) const { in lshr()
998 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in lshr()
1003 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in lshr()
1005 return ConstantRange(std::move(min), std::move(max)); in lshr()
1008 ConstantRange
1009 ConstantRange::ashr(const ConstantRange &Other) const { in ashr()
1011 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in ashr()
1057 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in ashr()
1059 return ConstantRange(std::move(min), std::move(max)); in ashr()
1062 ConstantRange ConstantRange::inverse() const { in inverse()
1064 return ConstantRange(getBitWidth(), /*isFullSet=*/false); in inverse()
1066 return ConstantRange(getBitWidth(), /*isFullSet=*/true); in inverse()
1067 return ConstantRange(Upper, Lower); in inverse()
1070 void ConstantRange::print(raw_ostream &OS) const { in print()
1080 LLVM_DUMP_METHOD void ConstantRange::dump() const { in dump()
1085 ConstantRange llvm::getConstantRangeFromMetadata(const MDNode &Ranges) { in getConstantRangeFromMetadata()
1093 ConstantRange CR(FirstLow->getValue(), FirstHigh->getValue()); in getConstantRangeFromMetadata()
1101 CR = CR.unionWith(ConstantRange(Low->getValue(), High->getValue())); in getConstantRangeFromMetadata()