17void ConstantFPRange::makeEmpty() {
25void ConstantFPRange::makeFull() {
37ConstantFPRange::ConstantFPRange(
const fltSemantics &Sem,
bool IsFullSet)
41 MayBeQNaN = IsFullSet;
42 MayBeSNaN = IsFullSet;
50 bool IsSNaN =
Value.isSignaling();
54 Lower = Upper =
Value;
55 MayBeQNaN = MayBeSNaN =
false;
62 assert(!
LHS.isNaN() && !
RHS.isNaN() &&
"Unordered compare");
63 if (
LHS.isZero() &&
RHS.isZero()) {
64 if (
LHS.isNegative() ==
RHS.isNegative())
84 bool MayBeQNaNVal,
bool MayBeSNaNVal)
86 MayBeQNaN(MayBeQNaNVal), MayBeSNaN(MayBeSNaNVal) {
88 "Should only use the same semantics");
99 bool MayBeQNaN,
bool MayBeSNaN) {
120 if (V.isNegInfinity())
121 return ConstantFPRange::getEmpty(Sem);
132 if (V.isPosInfinity())
133 return ConstantFPRange::getEmpty(Sem);
148 if (
Lower.isPosZero())
150 if (
Upper.isNegZero())
160 ContainsNaN, ContainsNaN);
166 if (
Other.isEmptySet())
169 return getFull(
Other.getSemantics());
171 return getEmpty(
Other.getSemantics());
175 return getFull(
Other.getSemantics());
177 return getEmpty(
Other.getSemantics());
188 if (
const APFloat *SingleElement =
189 Other.getSingleElement(
true)) {
190 const fltSemantics &Sem = SingleElement->getSemantics();
191 if (SingleElement->isPosInfinity())
196 if (SingleElement->isNegInfinity())
203 : getFull(
Other.getSemantics());
224 if (
Other.isEmptySet())
225 return getFull(
Other.getSemantics());
227 return getEmpty(
Other.getSemantics());
229 return getFull(
Other.getSemantics());
233 return getFull(
Other.getSemantics());
235 return getEmpty(
Other.getSemantics());
246 : getEmpty(
Other.getSemantics()),
250 return getEmpty(
Other.getSemantics());
268std::optional<ConstantFPRange>
294 "Should only use the same semantics");
304 "Should only use the same semantics");
306 if (CR.MayBeQNaN && !MayBeQNaN)
309 if (CR.MayBeSNaN && !MayBeSNaN)
317 if (!ExcludesNaN && (MayBeSNaN || MayBeQNaN))
329 if (MayBeSNaN != CR.MayBeSNaN || MayBeQNaN != CR.MayBeQNaN)
343 assert(LowerMask <= UpperMask &&
"Range is nan-only.");
345 Mask |= (UpperMask << 1) - LowerMask;
358 OS <<
'[' << Lower <<
", " << Upper <<
']';
360 if (MayBeSNaN || MayBeQNaN) {
363 if (MayBeSNaN && MayBeQNaN)
373#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
380 "Should only use the same semantics");
385 MayBeQNaN & CR.MayBeQNaN, MayBeSNaN & CR.MayBeSNaN);
390 "Should only use the same semantics");
392 MayBeQNaN | CR.MayBeQNaN, MayBeSNaN | CR.MayBeSNaN);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
static APFloat::cmpResult strictCompare(const APFloat &LHS, const APFloat &RHS)
static ConstantFPRange extendZeroIfEqual(const ConstantFPRange &CR, FCmpInst::Predicate Pred)
Make sure that +0/-0 are both included in the range.
static bool fcmpPredExcludesEqual(FCmpInst::Predicate Pred)
Return true for ULT/UGT/OLT/OGT.
static ConstantFPRange makeLessThan(APFloat V, FCmpInst::Predicate Pred)
Return [-inf, V) or [-inf, V].
static void canonicalizeRange(APFloat &Lower, APFloat &Upper)
static ConstantFPRange makeGreaterThan(APFloat V, FCmpInst::Predicate Pred)
Return (V, +inf] or [V, +inf].
static bool isNonCanonicalEmptySet(const APFloat &Lower, const APFloat &Upper)
static ConstantFPRange setNaNField(const ConstantFPRange &CR, FCmpInst::Predicate Pred)
bool bitwiseIsEqual(const APFloat &RHS) const
bool isPosInfinity() const
const fltSemantics & getSemantics() const
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
LLVM_ABI FPClassTest classify() const
Return the FPClassTest which will return true for the value.
bool isNegInfinity() const
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static LLVM_ABI bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
static LLVM_ABI bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
This class represents a range of floating-point values.
LLVM_ABI bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
bool containsQNaN() const
static LLVM_ABI ConstantFPRange getNonNaN(const fltSemantics &Sem)
Helper for [-inf, inf] to represent all non-NaN values.
bool containsSNaN() const
LLVM_ABI const APFloat * getSingleElement(bool ExcludesNaN=false) const
If this set contains a single element, return it, otherwise return null.
static LLVM_ABI ConstantFPRange makeSatisfyingFCmpRegion(FCmpInst::Predicate Pred, const ConstantFPRange &Other)
Produce the largest range such that all values in the returned range satisfy the given predicate with...
LLVM_ABI bool operator==(const ConstantFPRange &CR) const
Return true if this range is equal to another range.
static LLVM_ABI ConstantFPRange getNaNOnly(const fltSemantics &Sem, bool MayBeQNaN, bool MayBeSNaN)
Create a range which only contains NaNs.
LLVM_ABI ConstantFPRange unionWith(const ConstantFPRange &CR) const
Return the smallest range that results from the union of this range with another range.
LLVM_ABI std::optional< bool > getSignBit() const
Return true if the sign bit of all values in this range is 1.
static LLVM_ABI ConstantFPRange makeAllowedFCmpRegion(FCmpInst::Predicate Pred, const ConstantFPRange &Other)
Produce the smallest range such that all values that may satisfy the given predicate with any value c...
LLVM_ABI bool isNaNOnly() const
LLVM_ABI bool isEmptySet() const
Return true if this set contains no members.
static LLVM_ABI ConstantFPRange getFinite(const fltSemantics &Sem)
Helper for (-inf, inf) to represent all finite values.
LLVM_ABI void print(raw_ostream &OS) const
Print out the bounds to a stream.
LLVM_ABI ConstantFPRange intersectWith(const ConstantFPRange &CR) const
Return the range that results from the intersection of this range with another range.
LLVM_ABI void dump() const
Allow printing from a debugger easily.
LLVM_ABI FPClassTest classify() const
Return the FPClassTest which will return true for the value.
LLVM_ABI bool fcmp(FCmpInst::Predicate Pred, const ConstantFPRange &Other) const
Does the predicate Pred hold between ranges this and Other? NOTE: false does not mean that inverse pr...
LLVM_ABI bool contains(const APFloat &Val) const
Return true if the specified value is in the set.
const APFloat & getUpper() const
Return the upper value for this range.
const APFloat & getLower() const
Return the lower value for this range.
static LLVM_ABI std::optional< ConstantFPRange > makeExactFCmpRegion(FCmpInst::Predicate Pred, const APFloat &Other)
Produce the exact range such that all values in the returned range satisfy the given predicate with a...
const fltSemantics & getSemantics() const
Get the semantics of this ConstantFPRange.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 maxNum semantics.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 minNum semantics.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.