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;
575 KnownNotSrc |=
fcNan;
577 KnownNotSrc |=
fcInf;
580 if (
II->getArgOperand(0) ==
II->getArgOperand(1)) {
585 if (InterestedClasses &
fcQNan) {
592 InterestedAddend, KnownAddend, Q,
Depth + 1);
594 InterestedSquared, KnownSrc, Q,
Depth + 1);
598 II->getType()->getScalarType()->getFltSemantics();
612 for (
int I = 0;
I != 3; ++
I) {
614 InterestedClasses, KnownSrc[
I], Q,
Depth + 1);
615 if (KnownSrc[
I].isUnknown())
623 II->getType()->getScalarType()->getFltSemantics();
632 case Intrinsic::experimental_constrained_fadd:
633 case Intrinsic::experimental_constrained_fsub: {
636 IID == Intrinsic::experimental_constrained_fadd,
640 case Intrinsic::experimental_constrained_frem: {
645 case Intrinsic::sqrt:
646 case Intrinsic::experimental_constrained_sqrt: {
649 if (InterestedClasses &
fcQNan)
652 if (InterestedClasses &
fcZero)
656 KnownSrc, Q,
Depth + 1);
664 II->getType()->getScalarType()->getFltSemantics();
674 case Intrinsic::sin: {
677 KnownSrc, Q,
Depth + 1);
681 case Intrinsic::cos: {
684 KnownSrc, Q,
Depth + 1);
688 case Intrinsic::tan: {
691 KnownSrc, Q,
Depth + 1);
695 case Intrinsic::sinh: {
698 KnownSrc, Q,
Depth + 1);
702 case Intrinsic::cosh: {
705 KnownSrc, Q,
Depth + 1);
709 case Intrinsic::tanh: {
712 KnownSrc, Q,
Depth + 1);
716 case Intrinsic::asin: {
719 KnownSrc, Q,
Depth + 1);
723 case Intrinsic::acos: {
726 KnownSrc, Q,
Depth + 1);
730 case Intrinsic::atan: {
733 KnownSrc, Q,
Depth + 1);
737 case Intrinsic::atan2: {
755 KnownY, Q,
Depth + 1);
757 KnownX, Q,
Depth + 1);
761 F ?
F->getDenormalMode(
762 II->getType()->getScalarType()->getFltSemantics())
767 case Intrinsic::maxnum:
768 case Intrinsic::minnum:
769 case Intrinsic::minimum:
770 case Intrinsic::maximum:
771 case Intrinsic::minimumnum:
772 case Intrinsic::maximumnum: {
775 KnownLHS, Q,
Depth + 1);
777 KnownRHS, Q,
Depth + 1);
782 F ?
F->getDenormalMode(
783 II->getType()->getScalarType()->getFltSemantics())
790 case Intrinsic::canonicalize: {
793 KnownSrc, Q,
Depth + 1);
797 II->getType()->getScalarType()->getFltSemantics();
803 case Intrinsic::vector_reduce_fmax:
804 case Intrinsic::vector_reduce_fmin:
805 case Intrinsic::vector_reduce_fmaximum:
806 case Intrinsic::vector_reduce_fminimum:
807 case Intrinsic::vector_reduce_fmaximumnum:
808 case Intrinsic::vector_reduce_fminimumnum: {
812 InterestedClasses, Q,
Depth + 1);
814 if (!
Known.isKnownNeverNaN())
815 Known.setSignBit(std::nullopt);
819 case Intrinsic::vector_reverse:
822 II->getFastMathFlags(), InterestedClasses, Q,
Depth + 1);
824 case Intrinsic::trunc:
825 case Intrinsic::floor:
826 case Intrinsic::ceil:
827 case Intrinsic::rint:
828 case Intrinsic::nearbyint:
829 case Intrinsic::round:
830 case Intrinsic::roundeven: {
843 KnownSrc, Q,
Depth + 1);
847 F ?
F->getDenormalMode(
848 II->getType()->getScalarType()->getFltSemantics())
850 const bool IsMultiUnitFPType =
851 V->getType()->getScalarType()->isMultiUnitFPType();
854 case Intrinsic::trunc:
857 case Intrinsic::floor:
860 case Intrinsic::ceil:
871 case Intrinsic::exp2:
872 case Intrinsic::exp10:
873 case Intrinsic::amdgcn_exp2: {
876 KnownSrc, Q,
Depth + 1);
880 Type *EltTy =
II->getType()->getScalarType();
881 if (IID == Intrinsic::amdgcn_exp2 && EltTy->
isFloatTy())
886 case Intrinsic::fptrunc_round: {
895 case Intrinsic::log10:
896 case Intrinsic::log2:
897 case Intrinsic::experimental_constrained_log:
898 case Intrinsic::experimental_constrained_log10:
899 case Intrinsic::experimental_constrained_log2:
900 case Intrinsic::amdgcn_log: {
924 if (InterestedSrcs !=
fcNone)
926 KnownSrc, Q,
Depth + 1);
929 F ?
F->getDenormalMode(
930 II->getType()->getScalarType()->getFltSemantics())
932 const bool IsMultiUnitFPType =
933 V->getType()->getScalarType()->isMultiUnitFPType();
937 case Intrinsic::pow: {
938 const bool WantNaN = (InterestedClasses &
fcNan) !=
fcNone;
940 if (!WantNaN && !WantNegative)
950 InterestedRHS |=
fcNan;
961 KnownLHS, Q,
Depth + 1);
970 KnownRHS, Q,
Depth + 1);
974 case Intrinsic::powi: {
979 const Value *Exp =
II->getArgOperand(1);
984 if (InterestedClasses &
fcNan)
985 InterestedSrcs |=
fcNan;
986 if (!ExponentKnownBits.
isZero()) {
987 if (InterestedClasses &
fcInf)
994 if (InterestedSrcs !=
fcNone)
996 KnownSrc, Q,
Depth + 1);
1001 case Intrinsic::ldexp: {
1004 KnownSrc, Q,
Depth + 1);
1008 const Value *ExpArg =
II->getArgOperand(1);
1012 : ConstantRange::getFull(
1016 II->getType()->getScalarType()->getFltSemantics();
1026 case Intrinsic::arithmetic_fence: {
1031 case Intrinsic::experimental_constrained_sitofp:
1032 case Intrinsic::experimental_constrained_uitofp:
1042 if (IID == Intrinsic::experimental_constrained_uitofp)
1043 Known.signBitMustBeZero();
1048 case Intrinsic::amdgcn_fract: {
1051 if (InterestedClasses &
fcNan) {
1054 InterestedClasses, KnownSrc, Q,
Depth + 1);
1064 case Intrinsic::amdgcn_rcp: {
1067 KnownSrc, Q,
Depth + 1);
1069 Known.propagateNonNaN(KnownSrc);
1071 Type *EltTy =
II->getType()->getScalarType();
1094 case Intrinsic::amdgcn_rsq: {
1100 KnownSrc, Q,
Depth + 1);
1112 Type *EltTy =
II->getType()->getScalarType();
1132 case Intrinsic::amdgcn_trig_preop: {
1137 case Intrinsic::convert_from_arbitrary_fp: {
1147 II->getType()->getScalarType()->getFltSemantics();
1182 case Instruction::FAdd:
1183 case Instruction::FSub: {
1189 case Instruction::FMul: {
1192 F ?
F->getDenormalMode(
1193 Op->getType()->getScalarType()->getFltSemantics())
1236 case Instruction::FDiv: {
1237 const bool WantNan = (InterestedClasses &
fcNan) !=
fcNone;
1241 Op->getType()->getScalarType()->getFltSemantics();
1245 if (
Op->getOperand(0) ==
Op->getOperand(1) &&
1264 if (!WantNan && !WantNegative && !WantPositive)
1271 bool KnowSomethingUseful =
1276 if (KnowSomethingUseful)
1283 case Instruction::FRem: {
1288 case Instruction::FPExt: {
1291 KnownSrc, Q,
Depth + 1);
1294 Op->getType()->getScalarType()->getFltSemantics();
1296 Op->getOperand(0)->getType()->getScalarType()->getFltSemantics();
1299 const Function *
F =
I ?
I->getFunction() :
nullptr;
1308 case Instruction::FPTrunc: {
1310 DemandedElts, InterestedClasses,
Known, Q,
1314 case Instruction::SIToFP:
1315 case Instruction::UIToFP: {
1326 if (
Op->getOpcode() == Instruction::UIToFP)
1327 Known.signBitMustBeZero();
1340 if (
Op->getOpcode() == Instruction::SIToFP) {
1345 Known.signBitMustBeZero();
1347 Known.signBitMustBeOne();
1352 if (InterestedClasses &
fcInf) {
1357 if (
Op->getOpcode() == Instruction::UIToFP)
1359 else if (
Op->getOpcode() == Instruction::SIToFP)
1364 Type *FPTy =
Op->getType()->getScalarType();
1371 case Instruction::ExtractElement: {
1374 const Value *Vec =
Op->getOperand(0);
1376 APInt DemandedVecElts;
1378 unsigned NumElts = VecTy->getNumElements();
1381 if (CIdx && CIdx->getValue().ult(NumElts))
1384 DemandedVecElts =
APInt(1, 1);
1390 case Instruction::InsertElement: {
1394 const Value *Vec =
Op->getOperand(0);
1395 const Value *Elt =
Op->getOperand(1);
1398 APInt DemandedVecElts = DemandedElts;
1399 bool NeedsElt =
true;
1401 if (CIdx && CIdx->getValue().ult(NumElts)) {
1402 DemandedVecElts.
clearBit(CIdx->getZExtValue());
1403 NeedsElt = DemandedElts[CIdx->getZExtValue()];
1410 if (
Known.isUnknown())
1417 if (!DemandedVecElts.
isZero()) {
1426 case Instruction::ShuffleVector: {
1435 APInt DemandedLHS, DemandedRHS;
1441 if (!!DemandedLHS) {
1442 const Value *
LHS = Shuf->getOperand(0);
1447 if (
Known.isUnknown())
1453 if (!!DemandedRHS) {
1455 const Value *
RHS = Shuf->getOperand(1);
1463 case Instruction::ExtractValue: {
1469 switch (
II->getIntrinsicID()) {
1470 case Intrinsic::frexp: {
1471 if (Indices[0] != 0)
1493 InterestedSrcs, KnownSrc, Q,
Depth + 1);
1497 Op->getType()->getScalarType()->getFltSemantics();
1504 case Intrinsic::sincospi: {
1508 if (InterestedClasses &
fcNan)
1509 InterestedSrcs |=
fcInf;
1513 InterestedSrcs, KnownSrc, Q,
Depth + 1);
1515 const bool IsMultiUnitFPType =
1516 V->getType()->getScalarType()->isMultiUnitFPType();
1518 if (Indices[0] == 0)
1520 else if (Indices[0] == 1)
1534 case Instruction::PHI: {
1537 if (
P->getNumIncomingValues() == 0)
1544 if (
Depth < PhiRecursionLimit) {
1551 for (
const Use &U :
P->operands()) {
1582 if (
P->getNumIncomingValues() != 2 ||
Known.cannotBeOrderedLessThanZero())
1584 for (
unsigned I = 0;
I < 2;
I++) {
1585 Value *RecurValue =
P->getIncomingValue(1 -
I);
1593 switch (
II->getIntrinsicID()) {
1594 case Intrinsic::fma:
1595 case Intrinsic::fmuladd: {
1609 case Instruction::BitCast: {
1612 !Src->getType()->isIntOrIntVectorTy())
1615 const Type *Ty =
Op->getType();
1617 Value *CastLHS, *CastRHS;
1629 Known = KnownLHS | KnownRHS;
1647 const APInt &DemandedElts,
1654 return KnownClasses;
1680 InterestedClasses &=
~fcNan;
1682 InterestedClasses &=
~fcInf;
1688 Result.setKnownFPClasses(Result.getKnownFPClasses() & ~
fcNan);
1690 Result.setKnownFPClasses(Result.getKnownFPClasses() & ~
fcInf);
1699 APInt DemandedElts =
1715 return Known.cannotBeOrderedLessThanZero();
1721 return Known.isKnownNeverInfinity();
1728 return Known.isKnownNeverNaN() &&
Known.isKnownNeverInfinity();
1737 return Known.isKnownNeverNaN();
1747 return Known.getSignBit();
1753 if (
FPOp->hasNoSignedZeros())
1757 switch (
User->getOpcode()) {
1758 case Instruction::FPToSI:
1759 case Instruction::FPToUI:
1761 case Instruction::FRem:
1763 return U.getOperandNo() == 1;
1764 case Instruction::FCmp:
1767 case Instruction::Call:
1769 switch (
II->getIntrinsicID()) {
1770 case Intrinsic::fabs:
1771 case Intrinsic::exp:
1772 case Intrinsic::exp2:
1773 case Intrinsic::exp10:
1774 case Intrinsic::log:
1775 case Intrinsic::log2:
1776 case Intrinsic::log10:
1777 case Intrinsic::cos:
1778 case Intrinsic::acos:
1779 case Intrinsic::cosh:
1780 case Intrinsic::fptosi_sat:
1781 case Intrinsic::fptoui_sat:
1782 case Intrinsic::lround:
1783 case Intrinsic::llround:
1784 case Intrinsic::lrint:
1785 case Intrinsic::llrint:
1787 case Intrinsic::copysign:
1788 return U.getOperandNo() == 0;
1789 case Intrinsic::pow:
1791 return U.getOperandNo() == 1;
1792 case Intrinsic::is_fpclass: {
1812 if (
FPOp->hasNoNaNs())
1816 switch (
User->getOpcode()) {
1817 case Instruction::FPToSI:
1818 case Instruction::FPToUI:
1821 case Instruction::FAdd:
1822 case Instruction::FSub:
1823 case Instruction::FMul:
1824 case Instruction::FDiv:
1825 case Instruction::FRem:
1826 case Instruction::FPTrunc:
1827 case Instruction::FPExt:
1828 case Instruction::FCmp:
1831 case Instruction::FNeg:
1832 case Instruction::Select:
1833 case Instruction::PHI:
1835 case Instruction::Ret:
1836 return User->getFunction()->getAttributes().getRetNoFPClass() &
1838 case Instruction::Call:
1839 case Instruction::Invoke: {
1841 switch (
II->getIntrinsicID()) {
1842 case Intrinsic::fabs:
1844 case Intrinsic::copysign:
1845 return U.getOperandNo() == 0;
1847 case Intrinsic::maxnum:
1848 case Intrinsic::minnum:
1849 case Intrinsic::maximum:
1850 case Intrinsic::minimum:
1851 case Intrinsic::maximumnum:
1852 case Intrinsic::minimumnum:
1853 case Intrinsic::canonicalize:
1854 case Intrinsic::fptrunc_round:
1855 case Intrinsic::fma:
1856 case Intrinsic::fmuladd:
1857 case Intrinsic::ldexp:
1858 case Intrinsic::frexp:
1859 case Intrinsic::modf:
1860 case Intrinsic::sqrt:
1861 case Intrinsic::exp:
1862 case Intrinsic::exp2:
1863 case Intrinsic::exp10:
1864 case Intrinsic::log:
1865 case Intrinsic::log2:
1866 case Intrinsic::log10:
1867 case Intrinsic::pow:
1868 case Intrinsic::powi:
1869 case Intrinsic::sin:
1870 case Intrinsic::cos:
1871 case Intrinsic::sincos:
1872 case Intrinsic::sincospi:
1873 case Intrinsic::tan:
1874 case Intrinsic::asin:
1875 case Intrinsic::acos:
1876 case Intrinsic::atan:
1877 case Intrinsic::atan2:
1878 case Intrinsic::sinh:
1879 case Intrinsic::cosh:
1880 case Intrinsic::tanh:
1881 case Intrinsic::trunc:
1882 case Intrinsic::floor:
1883 case Intrinsic::ceil:
1884 case Intrinsic::round:
1885 case Intrinsic::roundeven:
1886 case Intrinsic::nearbyint:
1887 case Intrinsic::rint:
1888 case Intrinsic::fptoui_sat:
1889 case Intrinsic::fptosi_sat:
1890 case Intrinsic::lround:
1891 case Intrinsic::llround:
1892 case Intrinsic::lrint:
1893 case Intrinsic::llrint:
1894 case Intrinsic::is_fpclass:
1924 switch (
I->getOpcode()) {
1925 case Instruction::SIToFP:
1926 case Instruction::UIToFP:
1934 case Instruction::Call: {
1937 case Intrinsic::trunc:
1938 case Intrinsic::floor:
1939 case Intrinsic::ceil:
1940 case Intrinsic::rint:
1941 case Intrinsic::nearbyint:
1942 case Intrinsic::round:
1943 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