LLVM 22.0.0git
ConstantFPRange.cpp File Reference
#include "llvm/IR/ConstantFPRange.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/FloatingPointMode.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>

Go to the source code of this file.

Classes

struct  SameSignRange
 Represent a contiguous range of values sharing the same sign. More...

Functions

static APFloat::cmpResult strictCompare (const APFloat &LHS, const APFloat &RHS)
static bool isNonCanonicalEmptySet (const APFloat &Lower, const APFloat &Upper)
static void canonicalizeRange (APFloat &Lower, APFloat &Upper)
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 ConstantFPRange makeGreaterThan (APFloat V, FCmpInst::Predicate Pred)
 Return (V, +inf] or [V, +inf].
static ConstantFPRange extendZeroIfEqual (const ConstantFPRange &CR, FCmpInst::Predicate Pred)
 Make sure that +0/-0 are both included in the range.
static ConstantFPRange setNaNField (const ConstantFPRange &CR, FCmpInst::Predicate Pred)
static bool removeInf (APFloat &Lower, APFloat &Upper, bool &HasPosInf, bool &HasNegInf)
 Return true if the finite part is not empty after removing infinities.
static void splitPosNeg (const APFloat &Lower, const APFloat &Upper, std::optional< SameSignRange > &NegPart, std::optional< SameSignRange > &PosPart)
 Split the range into positive and negative components.

Function Documentation

◆ canonicalizeRange()

void canonicalizeRange ( APFloat & Lower,
APFloat & Upper )
static

◆ extendZeroIfEqual()

◆ fcmpPredExcludesEqual()

bool fcmpPredExcludesEqual ( FCmpInst::Predicate Pred)
static

Return true for ULT/UGT/OLT/OGT.

Definition at line 113 of file ConstantFPRange.cpp.

References llvm::CmpInst::FCMP_OEQ.

Referenced by extendZeroIfEqual(), makeGreaterThan(), and makeLessThan().

◆ isNonCanonicalEmptySet()

bool isNonCanonicalEmptySet ( const APFloat & Lower,
const APFloat & Upper )
static

◆ makeGreaterThan()

ConstantFPRange makeGreaterThan ( APFloat V,
FCmpInst::Predicate Pred )
static

◆ makeLessThan()

ConstantFPRange makeLessThan ( APFloat V,
FCmpInst::Predicate Pred )
static

◆ removeInf()

bool removeInf ( APFloat & Lower,
APFloat & Upper,
bool & HasPosInf,
bool & HasNegInf )
static

Return true if the finite part is not empty after removing infinities.

Definition at line 419 of file ConstantFPRange.cpp.

References assert(), llvm::APFloatBase::cmpGreaterThan, llvm::APFloat::getLargest(), llvm::Lower, strictCompare(), and llvm::Upper.

Referenced by llvm::ConstantFPRange::add(), and llvm::ConstantFPRange::getWithoutInf().

◆ setNaNField()

◆ splitPosNeg()

void splitPosNeg ( const APFloat & Lower,
const APFloat & Upper,
std::optional< SameSignRange > & NegPart,
std::optional< SameSignRange > & PosPart )
static

Split the range into positive and negative components.

Definition at line 555 of file ConstantFPRange.cpp.

References llvm::abs(), assert(), llvm::APFloatBase::cmpGreaterThan, llvm::APFloat::getZero(), llvm::Lower, strictCompare(), and llvm::Upper.

Referenced by llvm::ConstantFPRange::div(), and llvm::ConstantFPRange::mul().

◆ strictCompare()