38#include "llvm/IR/IntrinsicsAMDGPU.h"
85 KnownFromContext.
knownNot(~(CondIsTrue ? MaskIfTrue : MaskIfFalse));
89 KnownFromContext.
knownNot(CondIsTrue ? ~Mask : Mask);
95 if (TrueIfSigned == CondIsTrue)
111 return KnownFromContext;
131 return KnownFromContext;
141 "Got assumption for the wrong function!");
142 assert(
I->getIntrinsicID() == Intrinsic::assume &&
143 "must be an assume intrinsic");
149 true, Q.
CtxI, KnownFromContext);
152 return KnownFromContext;
156 Value *Arm,
bool Invert,
162 !Invert, SQ.
CtxI, KnownSrc,
186 const APInt &DemandedElts,
197 KnownSrc, Q,
Depth + 1);
199 const fltSemantics &DstTy =
Op->getType()->getScalarType()->getFltSemantics();
201 Op->getOperand(0)->getType()->getScalarType()->getFltSemantics();
204 const Function *
F =
I ?
I->getFunction() :
nullptr;
217 unsigned Depth,
bool IsAdd,
bool IsStrict) {
230 bool WantNaN = (InterestedClasses &
fcNan) !=
fcNone;
234 if (!WantNaN && !WantNegative && !WantNegZero && !WantSubnormal)
240 if (InterestedClasses &
fcNan)
241 InterestedSrcs |=
fcInf;
253 WantSubnormal || !IsAdd) {
258 Op->getType()->getScalarType()->getFltSemantics();
285 const APInt &DemandedElts,
296 if (InterestedClasses &
fcNan) {
318 F ?
F->getDenormalMode(
Op->getType()->getScalarType()->getFltSemantics())
323 FPClassTest InterestedSrcs = InterestedLHS | InterestedRHS;
325 if (InterestedSrcs !=
fcNone)
333 if (InterestedLHS !=
fcNone)
348 case Intrinsic::minimum:
350 case Intrinsic::maximum:
352 case Intrinsic::minimumnum:
354 case Intrinsic::maximumnum:
356 case Intrinsic::minnum:
358 case Intrinsic::maxnum:
373 const Value *SubFloorX;
385 assert(
Known.isUnknown() &&
"should not be called with known information");
417 unsigned NumElts = VFVTy->getNumElements();
418 for (
unsigned i = 0; i != NumElts; ++i) {
419 if (!DemandedElts[i])
442 for (
size_t I = 0,
E = CDS->getNumElements();
I !=
E; ++
I)
450 for (
const Use &
Op : CA->operands()) {
465 KnownNotFromFlags |= CB->getRetNoFPClass();
467 KnownNotFromFlags |= Arg->getNoFPClass();
471 if (
FPOp->hasNoNaNs())
472 KnownNotFromFlags |=
fcNan;
473 if (
FPOp->hasNoInfs())
474 KnownNotFromFlags |=
fcInf;
478 KnownNotFromFlags |= ~AssumedClasses.getKnownFPClasses();
482 InterestedClasses &= ~KnownNotFromFlags;
485 Known.knownNot(KnownNotFromFlags);
488 Known.signBitMustBeOne();
490 Known.signBitMustBeZero();
501 const unsigned Opc =
Op->getOpcode();
503 case Instruction::FNeg: {
509 case Instruction::Select: {
510 auto ComputeForArm = [&](
Value *Arm,
bool Invert) {
520 ComputeForArm(
Op->getOperand(1),
false)
521 .intersectWith(ComputeForArm(
Op->getOperand(2),
true));
524 case Instruction::Load: {
535 case Instruction::Call: {
539 case Intrinsic::fabs: {
550 case Intrinsic::copysign: {
556 KnownSign, Q,
Depth + 1);
557 Known.copysign(KnownSign);
561 case Intrinsic::fmuladd: {
565 const bool IsFMA = IID == Intrinsic::fma;
568 if (
II->getArgOperand(0) ==
II->getArgOperand(1)) {
573 if (InterestedClasses &
fcQNan) {
580 InterestedAddend, KnownAddend, Q,
Depth + 1);
582 InterestedSquared, KnownSrc, Q,
Depth + 1);
586 II->getType()->getScalarType()->getFltSemantics();
607 for (
int I = 0;
I != 3; ++
I) {
609 InterestedClasses, KnownSrc[
I], Q,
Depth + 1);
610 if (KnownSrc[
I].isUnknown())
621 II->getType()->getScalarType()->getFltSemantics();
630 case Intrinsic::experimental_constrained_fadd:
631 case Intrinsic::experimental_constrained_fsub: {
634 IID == Intrinsic::experimental_constrained_fadd,
638 case Intrinsic::experimental_constrained_frem: {
643 case Intrinsic::sqrt:
644 case Intrinsic::experimental_constrained_sqrt: {
647 if (InterestedClasses &
fcQNan)
650 if (InterestedClasses &
fcZero)
654 KnownSrc, Q,
Depth + 1);
662 II->getType()->getScalarType()->getFltSemantics();
672 case Intrinsic::sin: {
675 KnownSrc, Q,
Depth + 1);
679 case Intrinsic::cos: {
682 KnownSrc, Q,
Depth + 1);
686 case Intrinsic::tan: {
689 KnownSrc, Q,
Depth + 1);
693 case Intrinsic::sinh: {
696 KnownSrc, Q,
Depth + 1);
700 case Intrinsic::cosh: {
703 KnownSrc, Q,
Depth + 1);
707 case Intrinsic::tanh: {
710 KnownSrc, Q,
Depth + 1);
714 case Intrinsic::asin: {
717 KnownSrc, Q,
Depth + 1);
721 case Intrinsic::acos: {
724 KnownSrc, Q,
Depth + 1);
728 case Intrinsic::atan: {
731 KnownSrc, Q,
Depth + 1);
735 case Intrinsic::atan2: {
753 KnownY, Q,
Depth + 1);
755 KnownX, Q,
Depth + 1);
759 F ?
F->getDenormalMode(
760 II->getType()->getScalarType()->getFltSemantics())
765 case Intrinsic::maxnum:
766 case Intrinsic::minnum:
767 case Intrinsic::minimum:
768 case Intrinsic::maximum:
769 case Intrinsic::minimumnum:
770 case Intrinsic::maximumnum: {
773 KnownLHS, Q,
Depth + 1);
775 KnownRHS, Q,
Depth + 1);
780 F ?
F->getDenormalMode(
781 II->getType()->getScalarType()->getFltSemantics())
788 case Intrinsic::canonicalize: {
791 KnownSrc, Q,
Depth + 1);
795 II->getType()->getScalarType()->getFltSemantics();
801 case Intrinsic::vector_reduce_fmax:
802 case Intrinsic::vector_reduce_fmin:
803 case Intrinsic::vector_reduce_fmaximum:
804 case Intrinsic::vector_reduce_fminimum:
805 case Intrinsic::vector_reduce_fmaximumnum:
806 case Intrinsic::vector_reduce_fminimumnum: {
810 InterestedClasses, Q,
Depth + 1);
812 if (!
Known.isKnownNeverNaN())
813 Known.setSignBit(std::nullopt);
817 case Intrinsic::vector_reverse:
820 II->getFastMathFlags(), InterestedClasses, Q,
Depth + 1);
822 case Intrinsic::trunc:
823 case Intrinsic::floor:
824 case Intrinsic::ceil:
825 case Intrinsic::rint:
826 case Intrinsic::nearbyint:
827 case Intrinsic::round:
828 case Intrinsic::roundeven: {
841 KnownSrc, Q,
Depth + 1);
845 F ?
F->getDenormalMode(
846 II->getType()->getScalarType()->getFltSemantics())
848 const bool IsMultiUnitFPType =
849 V->getType()->getScalarType()->isMultiUnitFPType();
852 case Intrinsic::trunc:
855 case Intrinsic::floor:
858 case Intrinsic::ceil:
869 case Intrinsic::exp2:
870 case Intrinsic::exp10:
871 case Intrinsic::amdgcn_exp2: {
874 KnownSrc, Q,
Depth + 1);
878 Type *EltTy =
II->getType()->getScalarType();
879 if (IID == Intrinsic::amdgcn_exp2 && EltTy->
isFloatTy())
884 case Intrinsic::fptrunc_round: {
893 case Intrinsic::log10:
894 case Intrinsic::log2:
895 case Intrinsic::experimental_constrained_log:
896 case Intrinsic::experimental_constrained_log10:
897 case Intrinsic::experimental_constrained_log2:
898 case Intrinsic::amdgcn_log: {
922 if (InterestedSrcs !=
fcNone)
924 KnownSrc, Q,
Depth + 1);
927 F ?
F->getDenormalMode(
928 II->getType()->getScalarType()->getFltSemantics())
930 const bool IsMultiUnitFPType =
931 V->getType()->getScalarType()->isMultiUnitFPType();
935 case Intrinsic::pow: {
936 const bool WantNaN = (InterestedClasses &
fcNan) !=
fcNone;
938 if (!WantNaN && !WantNegative)
948 InterestedRHS |=
fcNan;
959 KnownLHS, Q,
Depth + 1);
968 KnownRHS, Q,
Depth + 1);
972 case Intrinsic::powi: {
977 const Value *Exp =
II->getArgOperand(1);
982 if (InterestedClasses &
fcNan)
983 InterestedSrcs |=
fcNan;
984 if (!ExponentKnownBits.
isZero()) {
985 if (InterestedClasses &
fcInf)
992 if (InterestedSrcs !=
fcNone)
994 KnownSrc, Q,
Depth + 1);
999 case Intrinsic::ldexp: {
1002 KnownSrc, Q,
Depth + 1);
1006 const Value *ExpArg =
II->getArgOperand(1);
1010 : ConstantRange::getFull(
1014 II->getType()->getScalarType()->getFltSemantics();
1024 case Intrinsic::arithmetic_fence: {
1029 case Intrinsic::experimental_constrained_sitofp:
1030 case Intrinsic::experimental_constrained_uitofp:
1040 if (IID == Intrinsic::experimental_constrained_uitofp)
1041 Known.signBitMustBeZero();
1046 case Intrinsic::amdgcn_fract: {
1049 if (InterestedClasses &
fcNan) {
1052 InterestedClasses, KnownSrc, Q,
Depth + 1);
1062 case Intrinsic::amdgcn_rcp: {
1065 KnownSrc, Q,
Depth + 1);
1067 Known.propagateNonNaN(KnownSrc);
1069 Type *EltTy =
II->getType()->getScalarType();
1092 case Intrinsic::amdgcn_rsq: {
1098 KnownSrc, Q,
Depth + 1);
1110 Type *EltTy =
II->getType()->getScalarType();
1130 case Intrinsic::amdgcn_trig_preop: {
1135 case Intrinsic::convert_from_arbitrary_fp: {
1145 II->getType()->getScalarType()->getFltSemantics();
1180 case Instruction::FAdd:
1181 case Instruction::FSub: {
1187 case Instruction::FMul: {
1190 F ?
F->getDenormalMode(
1191 Op->getType()->getScalarType()->getFltSemantics())
1234 case Instruction::FDiv: {
1235 const bool WantNan = (InterestedClasses &
fcNan) !=
fcNone;
1239 Op->getType()->getScalarType()->getFltSemantics();
1243 if (
Op->getOperand(0) ==
Op->getOperand(1) &&
1262 if (!WantNan && !WantNegative && !WantPositive)
1269 bool KnowSomethingUseful =
1274 if (KnowSomethingUseful)
1281 case Instruction::FRem: {
1286 case Instruction::FPExt: {
1289 KnownSrc, Q,
Depth + 1);
1292 Op->getType()->getScalarType()->getFltSemantics();
1294 Op->getOperand(0)->getType()->getScalarType()->getFltSemantics();
1297 const Function *
F =
I ?
I->getFunction() :
nullptr;
1306 case Instruction::FPTrunc: {
1308 DemandedElts, InterestedClasses,
Known, Q,
1312 case Instruction::SIToFP:
1313 case Instruction::UIToFP: {
1324 if (
Op->getOpcode() == Instruction::UIToFP)
1325 Known.signBitMustBeZero();
1338 if (
Op->getOpcode() == Instruction::SIToFP) {
1343 Known.signBitMustBeZero();
1345 Known.signBitMustBeOne();
1350 if (InterestedClasses &
fcInf) {
1355 if (
Op->getOpcode() == Instruction::UIToFP)
1357 else if (
Op->getOpcode() == Instruction::SIToFP)
1362 Type *FPTy =
Op->getType()->getScalarType();
1369 case Instruction::ExtractElement: {
1372 const Value *Vec =
Op->getOperand(0);
1374 APInt DemandedVecElts;
1376 unsigned NumElts = VecTy->getNumElements();
1379 if (CIdx && CIdx->getValue().ult(NumElts))
1382 DemandedVecElts =
APInt(1, 1);
1388 case Instruction::InsertElement: {
1392 const Value *Vec =
Op->getOperand(0);
1393 const Value *Elt =
Op->getOperand(1);
1396 APInt DemandedVecElts = DemandedElts;
1397 bool NeedsElt =
true;
1399 if (CIdx && CIdx->getValue().ult(NumElts)) {
1400 DemandedVecElts.
clearBit(CIdx->getZExtValue());
1401 NeedsElt = DemandedElts[CIdx->getZExtValue()];
1408 if (
Known.isUnknown())
1415 if (!DemandedVecElts.
isZero()) {
1424 case Instruction::ShuffleVector: {
1433 APInt DemandedLHS, DemandedRHS;
1439 if (!!DemandedLHS) {
1440 const Value *
LHS = Shuf->getOperand(0);
1445 if (
Known.isUnknown())
1451 if (!!DemandedRHS) {
1453 const Value *
RHS = Shuf->getOperand(1);
1461 case Instruction::ExtractValue: {
1467 switch (
II->getIntrinsicID()) {
1468 case Intrinsic::frexp: {
1469 if (Indices[0] != 0)
1491 InterestedSrcs, KnownSrc, Q,
Depth + 1);
1495 Op->getType()->getScalarType()->getFltSemantics();
1502 case Intrinsic::sincospi: {
1506 if (InterestedClasses &
fcNan)
1507 InterestedSrcs |=
fcInf;
1511 InterestedSrcs, KnownSrc, Q,
Depth + 1);
1513 const bool IsMultiUnitFPType =
1514 V->getType()->getScalarType()->isMultiUnitFPType();
1516 if (Indices[0] == 0)
1518 else if (Indices[0] == 1)
1532 case Instruction::PHI: {
1535 if (
P->getNumIncomingValues() == 0)
1542 if (
Depth < PhiRecursionLimit) {
1549 for (
const Use &U :
P->operands()) {
1580 if (
P->getNumIncomingValues() != 2 ||
Known.cannotBeOrderedLessThanZero())
1582 for (
unsigned I = 0;
I < 2;
I++) {
1583 Value *RecurValue =
P->getIncomingValue(1 -
I);
1591 switch (
II->getIntrinsicID()) {
1592 case Intrinsic::fma:
1593 case Intrinsic::fmuladd: {
1607 case Instruction::BitCast: {
1610 !Src->getType()->isIntOrIntVectorTy())
1613 const Type *Ty =
Op->getType();
1615 Value *CastLHS, *CastRHS;
1627 Known = KnownLHS | KnownRHS;
1645 const APInt &DemandedElts,
1652 return KnownClasses;
1678 InterestedClasses &=
~fcNan;
1680 InterestedClasses &=
~fcInf;
1686 Result.setKnownFPClasses(Result.getKnownFPClasses() & ~
fcNan);
1688 Result.setKnownFPClasses(Result.getKnownFPClasses() & ~
fcInf);
1697 APInt DemandedElts =
1713 return Known.cannotBeOrderedLessThanZero();
1719 return Known.isKnownNeverInfinity();
1726 return Known.isKnownNeverNaN() &&
Known.isKnownNeverInfinity();
1735 return Known.isKnownNeverNaN();
1745 return Known.getSignBit();
1751 if (
FPOp->hasNoSignedZeros())
1755 switch (
User->getOpcode()) {
1756 case Instruction::FPToSI:
1757 case Instruction::FPToUI:
1759 case Instruction::FRem:
1761 return U.getOperandNo() == 1;
1762 case Instruction::FCmp:
1765 case Instruction::Call:
1767 switch (
II->getIntrinsicID()) {
1768 case Intrinsic::fabs:
1769 case Intrinsic::exp:
1770 case Intrinsic::exp2:
1771 case Intrinsic::exp10:
1772 case Intrinsic::log:
1773 case Intrinsic::log2:
1774 case Intrinsic::log10:
1775 case Intrinsic::cos:
1776 case Intrinsic::acos:
1777 case Intrinsic::cosh:
1778 case Intrinsic::fptosi_sat:
1779 case Intrinsic::fptoui_sat:
1780 case Intrinsic::lround:
1781 case Intrinsic::llround:
1782 case Intrinsic::lrint:
1783 case Intrinsic::llrint:
1785 case Intrinsic::copysign:
1786 return U.getOperandNo() == 0;
1787 case Intrinsic::pow:
1789 return U.getOperandNo() == 1;
1790 case Intrinsic::is_fpclass: {
1810 if (
FPOp->hasNoNaNs())
1814 switch (
User->getOpcode()) {
1815 case Instruction::FPToSI:
1816 case Instruction::FPToUI:
1819 case Instruction::FAdd:
1820 case Instruction::FSub:
1821 case Instruction::FMul:
1822 case Instruction::FDiv:
1823 case Instruction::FRem:
1824 case Instruction::FPTrunc:
1825 case Instruction::FPExt:
1826 case Instruction::FCmp:
1829 case Instruction::FNeg:
1830 case Instruction::Select:
1831 case Instruction::PHI:
1833 case Instruction::Ret:
1834 return User->getFunction()->getAttributes().getRetNoFPClass() &
1836 case Instruction::Call:
1837 case Instruction::Invoke: {
1839 switch (
II->getIntrinsicID()) {
1840 case Intrinsic::fabs:
1842 case Intrinsic::copysign:
1843 return U.getOperandNo() == 0;
1845 case Intrinsic::maxnum:
1846 case Intrinsic::minnum:
1847 case Intrinsic::maximum:
1848 case Intrinsic::minimum:
1849 case Intrinsic::maximumnum:
1850 case Intrinsic::minimumnum:
1851 case Intrinsic::canonicalize:
1852 case Intrinsic::fptrunc_round:
1853 case Intrinsic::fma:
1854 case Intrinsic::fmuladd:
1855 case Intrinsic::ldexp:
1856 case Intrinsic::frexp:
1857 case Intrinsic::modf:
1858 case Intrinsic::sqrt:
1859 case Intrinsic::exp:
1860 case Intrinsic::exp2:
1861 case Intrinsic::exp10:
1862 case Intrinsic::log:
1863 case Intrinsic::log2:
1864 case Intrinsic::log10:
1865 case Intrinsic::pow:
1866 case Intrinsic::powi:
1867 case Intrinsic::sin:
1868 case Intrinsic::cos:
1869 case Intrinsic::sincos:
1870 case Intrinsic::sincospi:
1871 case Intrinsic::tan:
1872 case Intrinsic::asin:
1873 case Intrinsic::acos:
1874 case Intrinsic::atan:
1875 case Intrinsic::atan2:
1876 case Intrinsic::sinh:
1877 case Intrinsic::cosh:
1878 case Intrinsic::tanh:
1879 case Intrinsic::trunc:
1880 case Intrinsic::floor:
1881 case Intrinsic::ceil:
1882 case Intrinsic::round:
1883 case Intrinsic::roundeven:
1884 case Intrinsic::nearbyint:
1885 case Intrinsic::rint:
1886 case Intrinsic::fptoui_sat:
1887 case Intrinsic::fptosi_sat:
1888 case Intrinsic::lround:
1889 case Intrinsic::llround:
1890 case Intrinsic::lrint:
1891 case Intrinsic::llrint:
1892 case Intrinsic::is_fpclass:
1922 switch (
I->getOpcode()) {
1923 case Instruction::SIToFP:
1924 case Instruction::UIToFP:
1932 case Instruction::Call: {
1935 case Intrinsic::trunc:
1936 case Intrinsic::floor:
1937 case Intrinsic::ceil:
1938 case Intrinsic::rint:
1939 case Intrinsic::nearbyint:
1940 case Intrinsic::round:
1941 case Intrinsic::roundeven:
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Utilities for dealing with flags related to floating point properties and mode controls.
uint64_t IntrinsicInst * II
SmallVector< MachineOperand, 4 > Cond
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")))
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
static void computeKnownFPClassForFPTrunc(const Operator *Op, RoundingMode RM, const APInt &DemandedElts, FPClassTest InterestedClasses, KnownFPClass &Known, const SimplifyQuery &Q, unsigned Depth)
static void computeKnownFPClassFromCond(const Value *V, Value *Cond, bool CondIsTrue, const Instruction *CtxI, KnownFPClass &KnownFromContext, unsigned Depth=0)
static bool isAbsoluteValueULEOne(const Value *V)
static KnownFPClass computeKnownFPClassFromContext(const Value *V, const SimplifyQuery &Q)
static constexpr KnownFPClass::MinMaxKind getMinMaxKind(Intrinsic::ID IID)
static void computeKnownFPClassForFAddSub(const Operator *Op, const APInt &DemandedElts, FPClassTest InterestedClasses, KnownFPClass &Known, const SimplifyQuery &Q, unsigned Depth, bool IsAdd, bool IsStrict)
static void computeKnownFPClassForFRem(const Operator *Op, const APInt &DemandedElts, FPClassTest InterestedClasses, KnownFPClass &Known, const SimplifyQuery &Q, unsigned Depth)
static LLVM_ABI bool semanticsHasInf(const fltSemantics &)
static LLVM_ABI bool semanticsHasSignedRepr(const fltSemantics &)
static LLVM_ABI ExponentType semanticsMaxExponent(const fltSemantics &)
static LLVM_ABI bool semanticsHasNaN(const fltSemantics &)
static LLVM_ABI bool semanticsHasZero(const fltSemantics &)
static LLVM_ABI bool isRepresentableAsNormalIn(const fltSemantics &Src, const fltSemantics &Dst)
static LLVM_ABI const fltSemantics * getArbitraryFPSemantics(StringRef Format)
Returns the fltSemantics for a given arbitrary FP format string, or nullptr if invalid.
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
unsigned getBitWidth() const
Return the number of bits in the APInt.
LLVM_ABI APInt reverseBits() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
A cache of @llvm.assume calls within a function.
MutableArrayRef< ResultElem > assumptionsFor(const Value *V)
Access the list of assumptions which affect this value.
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
This class represents a function call, abstracting a target machine's calling convention.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
Conditional Branch instruction.
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This class represents a range of values.
LLVM_ABI APInt getSignedMin() const
Return the smallest signed value contained in the ConstantRange.
LLVM_ABI APInt getSignedMax() const
Return the largest signed value contained in the ConstantRange.
This is an important base class in LLVM.
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
A parsed version of the target data layout string in and methods for querying it.
ArrayRef< CondBrInst * > conditionsFor(const Value *V) const
Access the list of branches which affect this value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
Utility class for floating point operations which can have information about relaxed accuracy require...
Convenience struct for specifying and reasoning about fast-math flags.
A wrapper class for inspecting calls to intrinsic functions.
bool isKnownNeverInfOrNaN() const
Return true if it's known this can never be an infinity or nan.
static LLVM_ABI KnownFPClass atan2(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode)
Report known values for atan2.
static LLVM_ABI KnownFPClass fma(const KnownFPClass &LHS, const KnownFPClass &RHS, const KnownFPClass &Addend, DenormalMode Mode)
Report known values for fma.
static LLVM_ABI KnownFPClass sin(const KnownFPClass &Src)
Report known values for sin.
static LLVM_ABI KnownFPClass fptrunc(const KnownFPClass &KnownSrc, const fltSemantics &DstTy, const fltSemantics &SrcTy, RoundingMode RM, DenormalMode DstMode, DenormalMode SrcMode)
Propagate known class for fptrunc and fptrunc_round.
static constexpr FPClassTest OrderedLessThanZeroMask
static LLVM_ABI KnownFPClass trunc(const KnownFPClass &Src, DenormalMode Mode)
Propagate known class for trunc.
static LLVM_ABI KnownFPClass fadd(const KnownFPClass &LHS, const KnownFPClass &RHS, RoundingMode RM, DenormalMode Mode)
Report known values for fadd.
static LLVM_ABI KnownFPClass fsub(const KnownFPClass &LHS, const KnownFPClass &RHS, RoundingMode RM, DenormalMode Mode)
Report known values for fsub.
static LLVM_ABI KnownFPClass fma_square(const KnownFPClass &Squared, const KnownFPClass &Addend, DenormalMode Mode)
Report known values for fma squared, squared, addend.
KnownFPClass unionWith(const KnownFPClass &RHS) const
static LLVM_ABI KnownFPClass fadd_self(const KnownFPClass &Src, RoundingMode RM, DenormalMode Mode)
Report known values for fadd x, x.
static LLVM_ABI KnownFPClass frem(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode)
Report known values for frem.
static LLVM_ABI KnownFPClass atan(const KnownFPClass &Src)
Report known values for atan.
static LLVM_ABI KnownFPClass ldexp(const KnownFPClass &Src, const APInt &ConstantRangeMin, const APInt &ConstantRangeMax, const fltSemantics &Flt, DenormalMode Mode)
Propagate known class for ldexp, assuming the exponent is known to be within [ConstantRangeMin,...
static LLVM_ABI KnownFPClass frexp_mant(const KnownFPClass &Src, DenormalMode Mode)
Propagate known class for mantissa component of frexp.
static LLVM_ABI KnownFPClass roundToIntegral(const KnownFPClass &Src, bool IsMultiUnitFPType, DenormalMode Mode)
Propagate known class for rounding intrinsics (rint, nearbyint, round, roundeven).
static LLVM_ABI KnownFPClass sinpi(const KnownFPClass &Src, bool IsMultiUnitFPType)
Report known values for sinpi.
static LLVM_ABI KnownFPClass fmuladd(const KnownFPClass &LHS, const KnownFPClass &RHS, const KnownFPClass &Addend, DenormalMode Mode)
Report known values for fmuladd.
static LLVM_ABI KnownFPClass ceil(const KnownFPClass &Src, bool IsMultiUnitFPType, DenormalMode Mode)
Propagate known class for ceil.
static LLVM_ABI KnownFPClass fmuladd_square(const KnownFPClass &Squared, const KnownFPClass &Addend, DenormalMode Mode)
Report known values for fmuladd squared, squared, addend.
static LLVM_ABI KnownFPClass fpext(const KnownFPClass &KnownSrc, const fltSemantics &DstTy, const fltSemantics &SrcTy, DenormalMode DstMode, DenormalMode SrcMode)
Propagate known class for fpext.
static LLVM_ABI KnownFPClass cos(const KnownFPClass &Src)
Report known values for cos.
static LLVM_ABI KnownFPClass cosh(const KnownFPClass &Src)
Report known values for cosh.
static LLVM_ABI KnownFPClass exp(const KnownFPClass &Src)
Report known values for exp, exp2 and exp10.
static LLVM_ABI KnownFPClass asin(const KnownFPClass &Src)
Report known values for asin.
bool isKnownNeverNaN() const
Return true if it's known this can never be a nan.
static LLVM_ABI KnownFPClass minMaxLike(const KnownFPClass &LHS, const KnownFPClass &RHS, MinMaxKind Kind, DenormalMode Mode)
void knownNot(FPClassMask RuleOut)
static LLVM_ABI KnownFPClass canonicalize(const KnownFPClass &Src, const fltSemantics &Flt, DenormalMode Mode)
Apply the canonicalize intrinsic to this value.
std::optional< bool > getSignBit() const
std::nullopt if the sign bit is unknown, true if the sign bit is definitely set or false if the sign ...
static LLVM_ABI KnownFPClass floor(const KnownFPClass &Src, bool IsMultiUnitFPType, DenormalMode Mode)
Propagate known class for floor.
FPClassTest getKnownFPClasses() const
Floating-point classes the value could be one of.
static KnownFPClass getEmpty()
static LLVM_ABI KnownFPClass cospi(const KnownFPClass &Src, bool IsMultiUnitFPType)
Report known values for cospi.
static LLVM_ABI KnownFPClass tan(const KnownFPClass &Src)
Report known values for tan.
bool cannotBeOrderedLessThanZero() const
Return true if we can prove that the analyzed floating-point value is either NaN or never less than -...
void signBitMustBeOne()
Assume the sign bit is one.
static LLVM_ABI KnownFPClass fdiv_self(const KnownFPClass &Src, DenormalMode Mode)
Report known values for fdiv x, x.
void signBitMustBeZero()
Assume the sign bit is zero.
static LLVM_ABI KnownFPClass sqrt(const KnownFPClass &Src, DenormalMode Mode=DenormalMode::getDynamic())
Propagate known class for sqrt.
LLVM_ABI bool isKnownNeverLogicalPosZero(DenormalMode Mode) const
Return true if it's known this can never be interpreted as a positive zero.
bool isKnownNever(FPClassMask Mask) const
Return true if it's known this can never be one of the mask entries.
bool isKnownNeverPosInfinity() const
Return true if it's known this can never be +infinity.
LLVM_ABI bool isKnownNeverLogicalNegZero(DenormalMode Mode) const
Return true if it's known this can never be interpreted as a negative zero.
static LLVM_ABI KnownFPClass bitcast(const fltSemantics &FltSemantics, const KnownBits &Bits)
Report known values for a bitcast into a float with provided semantics.
static LLVM_ABI KnownFPClass square(const KnownFPClass &Src, DenormalMode Mode)
static LLVM_ABI KnownFPClass acos(const KnownFPClass &Src)
Report known values for acos.
static LLVM_ABI KnownFPClass log(const KnownFPClass &Src, DenormalMode Mode, bool IsMultiUnitFPType)
Propagate known class for log/log2/log10.
static LLVM_ABI KnownFPClass frem_self(const KnownFPClass &Src, DenormalMode Mode)
Report known values for frem x, x. Valid for all rounding modes.
static LLVM_ABI KnownFPClass powi(const KnownFPClass &Src, const KnownBits &N)
Propagate known class for powi.
static LLVM_ABI KnownFPClass fdiv(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode)
Report known values for fdiv.
static LLVM_ABI KnownFPClass fmul(const KnownFPClass &LHS, const KnownFPClass &RHS, DenormalMode Mode)
Report known values for fmul.
static LLVM_ABI KnownFPClass pow(const KnownFPClass &LHS, const KnownFPClass &RHS)
Propagate known class for pow.
static LLVM_ABI KnownFPClass sinh(const KnownFPClass &Src)
Report known values for sinh.
static LLVM_ABI KnownFPClass tanh(const KnownFPClass &Src)
Report known values for tanh.
const MDOperand & getOperand(unsigned I) const
This is a utility class that provides an abstraction for the common functionality between Instruction...
bool contains(ConstPtrType Ptr) const
Represent a constant reference to a string, i.e.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI const fltSemantics & getFltSemantics() const
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
BinaryOp_match< SrcTy, SpecificConstantMatch, TargetOpcode::G_XOR, true > m_Not(const SrcTy &&Src)
Matches a register not-ed by a G_XOR.
CmpClass_match< LHS, RHS, FCmpInst > m_FCmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
match_deferred< Value > m_Deferred(Value *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
ap_match< APFloat > m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
auto m_Value()
Match an arbitrary value and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
CastOperator_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
auto m_c_MaxOrMin(const LHS &L, const RHS &R)
cstfp_pred_ty< custom_checkfn< APFloat > > m_CheckedFp(function_ref< bool(const APFloat &)> CheckFn)
Match a float or vector where CheckFn(ele) for each element is true.
CmpClass_match< LHS, RHS, ICmpInst > m_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
ElementWiseBitCast_match< OpTy > m_ElementWiseBitCast(const OpTy &Op)
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI KnownFPClass computeKnownFPClass(const Value *V, const APInt &DemandedElts, FPClassTest InterestedClasses, const SimplifyQuery &SQ, unsigned Depth=0)
Determine which floating-point classes are valid for V, and return them in KnownFPClass bit sets.
LLVM_ABI bool isKnownNeverInfinity(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if the floating-point scalar value is not an infinity or if the floating-point vector val...
LLVM_ABI bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS, bool &TrueIfSigned)
Given an exploded icmp instruction, return true if the comparison only checks the sign bit.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true, unsigned Depth=0)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
int ilogb(const APFloat &Arg)
Returns the exponent of the internal representation of the APFloat.
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool isa_and_nonnull(const Y &Val)
LLVM_ABI bool canIgnoreSignBitOfZero(const Use &U)
Return true if the sign bit of the FP value can be ignored by the user when the value is zero.
LLVM_ABI bool isGuaranteedNotToBeUndef(const Value *V, AssumptionCache *AC=nullptr, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, unsigned Depth=0)
Returns true if V cannot be undef, but may be poison.
std::tuple< Value *, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS, FPClassTest RHSClass, bool LookThroughSrc=true)
LLVM_ABI bool isValidAssumeForContext(const Instruction *I, const Instruction *CtxI, const DominatorTree *DT=nullptr, bool AllowEphemerals=false)
Return true if it is valid to use the assumptions provided by an assume intrinsic,...
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI bool getShuffleDemandedElts(int SrcWidth, ArrayRef< int > Mask, const APInt &DemandedElts, APInt &DemandedLHS, APInt &DemandedRHS, bool AllowUndefElts=false)
Transform a shuffle mask's output demanded element mask into demanded element masks for the 2 operand...
constexpr unsigned MaxAnalysisRecursionDepth
FPOp
The floating-point operations supported by the folding helpers.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI bool cannotBeNegativeZero(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if we can prove that the specified FP value is never equal to -0.0.
LLVM_ABI void adjustKnownFPClassForSelectArm(KnownFPClass &Known, Value *Cond, Value *Arm, bool Invert, const SimplifyQuery &Q, unsigned Depth=0)
Adjust Known for the given select Arm to include information from the select Cond.
LLVM_ABI bool matchSimpleTernaryIntrinsicRecurrence(const IntrinsicInst *I, PHINode *&P, Value *&Init, Value *&OtherOp0, Value *&OtherOp1)
Attempt to match a simple value-accumulating recurrence of the form: llvm.intrinsic....
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
DWARFExpression::Operation Op
RoundingMode
Rounding mode.
@ NearestTiesToEven
roundTiesToEven.
@ Dynamic
Denotes mode unknown at compile time.
LLVM_ABI bool isKnownNeverInfOrNaN(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if the floating-point value can never contain a NaN or infinity.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isKnownNeverNaN(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if the floating-point scalar value is not a NaN or if the floating-point vector value has...
LLVM_ABI std::optional< RoundingMode > convertStrToRoundingMode(StringRef)
Returns a valid RoundingMode enumerator when given a string that is valid as input in constrained int...
LLVM_ABI bool isKnownIntegral(const Value *V, const SimplifyQuery &SQ, FastMathFlags FMF)
Return true if the floating-point value V is known to be an integer value.
LLVM_ABI bool cannotBeOrderedLessThanZero(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return true if we can prove that the specified FP value is either NaN or never less than -0....
LLVM_ABI void breakSelfRecursivePHI(const Use *U, const PHINode *PHI, Value *&ValOut, Instruction *&CtxIOut, const PHINode **PhiOut=nullptr)
Choose the value to analyze for the incoming use U of PHI, avoiding recursion back into PHI.
LLVM_ABI std::optional< bool > computeKnownFPSignBit(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Return false if we can prove that the specified FP value's sign bit is 0.
LLVM_ABI bool canIgnoreSignBitOfNaN(const Use &U)
Return true if the sign bit of the FP value can be ignored by the user when the value is NaN.
LLVM_ABI ConstantRange computeConstantRange(const Value *V, bool ForSigned, const SimplifyQuery &SQ, unsigned Depth=0)
Determine the possible constant range of an integer or vector of integer value.
SmallPtrSet< Value *, 4 > AffectedValues
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getDynamic()
bool hasNoSignedZeros(const InstT *Op) const
unsigned countMinSignBits() const
Returns the number of times the sign bit is replicated into the other bits.
bool isNonNegative() const
Returns true if this value is known to be non-negative.
bool isZero() const
Returns true if value is all zero.
unsigned getBitWidth() const
Get the bit width of this value.
bool isNonZero() const
Returns true if this value is known to be non-zero.
bool isEven() const
Return if the value is known even (the low bit is 0).
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
bool isNegative() const
Returns true if this value is known to be negative.
SimplifyQuery getWithoutCondContext() const
SimplifyQuery getWithInstruction(const Instruction *I) const
const DomConditionCache * DC
fltNanEncoding nanEncoding