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);
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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 bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
static bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
This class represents a range of floating-point values.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
bool containsQNaN() const
static ConstantFPRange getNonNaN(const fltSemantics &Sem)
Helper for [-inf, inf] to represent all non-NaN values.
bool containsSNaN() const
const APFloat * getSingleElement(bool ExcludesNaN=false) const
If this set contains a single element, return it, otherwise return null.
static 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...
bool operator==(const ConstantFPRange &CR) const
Return true if this range is equal to another range.
static ConstantFPRange getNaNOnly(const fltSemantics &Sem, bool MayBeQNaN, bool MayBeSNaN)
Create a range which only contains NaNs.
ConstantFPRange unionWith(const ConstantFPRange &CR) const
Return the smallest range that results from the union of this range with another range.
std::optional< bool > getSignBit() const
Return true if the sign bit of all values in this range is 1.
static 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...
bool isEmptySet() const
Return true if this set contains no members.
static ConstantFPRange getFinite(const fltSemantics &Sem)
Helper for (-inf, inf) to represent all finite values.
void print(raw_ostream &OS) const
Print out the bounds to a stream.
ConstantFPRange intersectWith(const ConstantFPRange &CR) const
Return the range that results from the intersection of this range with another range.
void dump() const
Allow printing from a debugger easily.
FPClassTest classify() const
Return the FPClassTest which will return true for the value.
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...
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 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 2019 maximumNumber semantics.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
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 2019 minimumNumber 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.