15#ifndef LLVM_ADT_GENERICFLOATINGPOINTPREDICATEUTILS_H
16#define LLVM_ADT_GENERICFLOATINGPOINTPREDICATEUTILS_H
27 using ValueRefT =
typename ContextT::ValueRefT;
28 using FunctionT =
typename ContextT::FunctionT;
30 constexpr static ValueRefT Invalid = {};
36 LLVM_ABI static bool lookThroughFAbs(
const FunctionT &
F, ValueRefT
LHS,
39 LLVM_ABI static std::optional<APFloat> matchConstantFloat(
const FunctionT &
F,
44 static std::tuple<ValueRefT, FPClassTest, FPClassTest>
52 static std::pair<ValueRefT, FPClassTest>
54 ValueRefT
RHS,
bool LookThroughSrc) {
55 std::optional<APFloat> ConstRHS = matchConstantFloat(
F,
RHS);
62 static std::pair<ValueRefT, FPClassTest>
64 const APFloat &ConstRHS,
bool LookThroughSrc) {
66 auto [Src, ClassIfTrue, ClassIfFalse] =
69 if (Src && ClassIfTrue == ~ClassIfFalse)
70 return {Src, ClassIfTrue};
92 static std::tuple<ValueRefT, FPClassTest, FPClassTest>
102 return exactClass(Src,
fcNone);
106 const bool IsNegativeRHS = (RHSClass &
fcNegative) == RHSClass;
107 const bool IsPositiveRHS = (RHSClass &
fcPositive) == RHSClass;
108 const bool IsNaN = (RHSClass & ~fcNan) ==
fcNone;
118 return exactClass(Src, ~
fcNan);
122 return exactClass(Src,
fcNan);
124 const bool IsFabs = LookThroughSrc && lookThroughFAbs(
F,
LHS, Src);
128 const bool IsZero = (OrigClass &
fcZero) == OrigClass;
138 auto ExactClass = [IsFabs, Src](
FPClassTest Mask) {
141 return exactClass(Src, Mask);
146 return exactClass(Src,
fcZero);
150 return exactClass(Src, ~
fcZero);
156 return exactClass(Src, ~
fcNan);
158 return exactClass(Src,
fcNan);
180 const bool IsDenormalRHS = (OrigClass &
fcSubnormal) == OrigClass;
182 const bool IsInf = (OrigClass &
fcInf) == OrigClass;
224 Mask = ~fcNegInf & ~fcNan;
228 Mask = ~fcPosInf & ~fcNan;
312 return exactClass(Src, Mask);
320 return {Src, Class, ~fcNan};
324 return {Src, ~fcNan, RHSClass |
fcNan};
333 "should have been recognized as an exact class test");
345 return {Src, ~fcNan,
fcNan};
354 return {Src,
fcNan, ~fcNan};
373 return {Src, ClassesGE, ~ClassesGE | RHSClass};
376 return {Src, ClassesGE |
fcNan, ~(ClassesGE |
fcNan) | RHSClass};
379 return {Src, ClassesLE, ~ClassesLE | RHSClass};
382 return {Src, ClassesLE |
fcNan, ~(ClassesLE |
fcNan) | RHSClass};
386 }
else if (IsPositiveRHS) {
402 return {Src, ClassesGE, ~ClassesGE | RHSClass};
405 return {Src, ClassesGE |
fcNan, ~(ClassesGE |
fcNan) | RHSClass};
408 return {Src, ClassesLE, ~ClassesLE | RHSClass};
411 return {Src, ClassesLE |
fcNan, ~(ClassesLE |
fcNan) | RHSClass};
420 static std::tuple<ValueRefT, FPClassTest, FPClassTest>
422 const APFloat &ConstRHS,
bool LookThroughSrc) {
427 const bool IsFabs = LookThroughSrc && lookThroughFAbs(
F,
LHS, Src);
465 return exactClass(Src, Mask);
471 static std::tuple<ValueRefT, FPClassTest, FPClassTest>
473 ValueRefT
RHS,
bool LookThroughSrc) {
474 std::optional<APFloat> ConstRHS = matchConstantFloat(
F,
RHS);
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...
Utilities for dealing with flags related to floating point properties and mode controls.
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
LLVM_ABI FPClassTest classify() const
Return the FPClassTest which will return true for the value.
bool isSmallestNormalized() const
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.
static std::tuple< ValueRefT, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, const APFloat &ConstRHS, bool LookThroughSrc)
static std::pair< ValueRefT, FPClassTest > fcmpToClassTest(FCmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, const APFloat &ConstRHS, bool LookThroughSrc)
static std::tuple< ValueRefT, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, FPClassTest RHSClass, bool LookThroughSrc)
Compute the possible floating-point classes that LHS could be based on fcmp \Pred LHS,...
static std::pair< ValueRefT, FPClassTest > fcmpToClassTest(FCmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, ValueRefT RHS, bool LookThroughSrc)
Returns a pair of values, which if passed to llvm.is.fpclass, returns the same result as an fcmp with...
static std::tuple< ValueRefT, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, ValueRefT RHS, bool LookThroughSrc)
#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.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI FPClassTest inverse_fabs(FPClassTest Mask)
Return the test mask which returns true after fabs is applied to the value.
Represent subnormal handling kind for floating point instruction inputs and outputs.
@ IEEE
IEEE-754 denormal numbers preserved.