67 if (
F.getFnAttribute(
"disable-tail-calls").getValueAsBool())
73 AttrBuilder CallerAttrs(
F.getContext(),
F.getAttributes().getRetAttrs());
74 for (
const auto &Attr : {Attribute::Alignment, Attribute::Dereferenceable,
75 Attribute::DereferenceableOrNull, Attribute::NoAlias,
76 Attribute::NonNull, Attribute::NoUndef,
77 Attribute::Range, Attribute::NoFPClass})
78 CallerAttrs.removeAttribute(Attr);
80 if (CallerAttrs.hasAttributes())
84 if (CallerAttrs.contains(Attribute::ZExt) ||
85 CallerAttrs.contains(Attribute::SExt))
96 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
113 if (
MRI.getLiveInPhysReg(ArgReg) != Reg)
121 return Call.paramHasAttr(ArgIdx, Kind);
126 return Attrs.hasParamAttr(ArgIdx, Kind);
130 return Call.getParamStackAlign(ArgIdx);
135 return Attrs.getParamStackAlignment(ArgIdx);
139 return Call.getParamAlign(ArgIdx);
143 return Attrs.getParamAlignment(ArgIdx);
148template <
typename SourceT>
150 const SourceT &Src,
unsigned ArgIdx) {
151 Entry.IsSExt =
paramHasAttr(Src, ArgIdx, Attribute::SExt);
152 Entry.IsZExt =
paramHasAttr(Src, ArgIdx, Attribute::ZExt);
153 Entry.IsNoExt =
paramHasAttr(Src, ArgIdx, Attribute::NoExt);
154 Entry.IsInReg =
paramHasAttr(Src, ArgIdx, Attribute::InReg);
155 Entry.IsSRet =
paramHasAttr(Src, ArgIdx, Attribute::StructRet);
156 Entry.IsNest =
paramHasAttr(Src, ArgIdx, Attribute::Nest);
157 Entry.IsByVal =
paramHasAttr(Src, ArgIdx, Attribute::ByVal);
158 Entry.IsPreallocated =
paramHasAttr(Src, ArgIdx, Attribute::Preallocated);
159 Entry.IsInAlloca =
paramHasAttr(Src, ArgIdx, Attribute::InAlloca);
160 Entry.IsReturned =
paramHasAttr(Src, ArgIdx, Attribute::Returned);
161 Entry.IsSwiftSelf =
paramHasAttr(Src, ArgIdx, Attribute::SwiftSelf);
162 Entry.IsSwiftAsync =
paramHasAttr(Src, ArgIdx, Attribute::SwiftAsync);
163 Entry.IsSwiftError =
paramHasAttr(Src, ArgIdx, Attribute::SwiftError);
165 Entry.IndirectType =
nullptr;
166 assert(Entry.IsByVal + Entry.IsPreallocated + Entry.IsInAlloca +
169 "multiple ABI attributes?");
171 Entry.IndirectType = Src.getParamByValType(ArgIdx);
172 if (!Entry.Alignment)
175 if (Entry.IsPreallocated)
176 Entry.IndirectType = Src.getParamPreallocatedType(ArgIdx);
177 if (Entry.IsInAlloca)
178 Entry.IndirectType = Src.getParamInAllocaType(ArgIdx);
180 Entry.IndirectType = Src.getParamStructRetType(ArgIdx);
196 if (Attr == Attribute::SExt)
198 else if (Attr == Attribute::ZExt)
200 else if (Attr == Attribute::NoExt)
213 assert(
Ops.size() == FuncTy->getNumParams() &&
214 "argument count does not match the function type");
216 Args.reserve(
Ops.size());
217 for (
unsigned I = 0, E = FuncTy->getNumParams();
I != E; ++
I) {
219 Entry.setAttributes(FuncAttrs,
I);
220 Args.push_back(Entry);
229 CallOptions, dl, Chain);
234std::pair<SDValue, SDValue>
239 if (LibcallImpl == RTLIB::Unsupported)
246 Args.reserve(
Ops.size());
249 for (
unsigned i = 0; i <
Ops.size(); ++i) {
251 Type *Ty = i < OpsTypeOverrides.
size() && OpsTypeOverrides[i]
252 ? OpsTypeOverrides[i]
261 Entry.IsZExt = !Entry.IsSExt;
265 Entry.IsSExt = Entry.IsZExt =
false;
267 Args.push_back(Entry);
274 Type *OrigRetTy = RetTy;
277 bool zeroExtend = !signExtend;
282 signExtend = zeroExtend =
false;
288 RetTy, OrigRetTy, Callee, std::move(Args))
298 LLVMContext &Context, std::vector<EVT> &MemOps,
unsigned Limit,
299 const MemOp &
Op,
unsigned DstAS,
unsigned SrcAS,
303 if (VT == MVT::Other) {
305 VT = MVT::LAST_INTEGER_VALUETYPE;
306 if (
Op.isFixedDstAlign()) {
307 bool LoadsFromSrc =
Op.isMemcpyOrMemmove() && !
Op.isMemcpyStrSrc();
308 while (VT != MVT::i8) {
311 Op.getDstAlign() >= VTSize ||
314 !LoadsFromSrc ||
Op.getSrcAlign() >= VTSize ||
324 MVT LVT = MVT::LAST_INTEGER_VALUETYPE;
335 unsigned NumMemOps = 0;
336 uint64_t
Size =
Op.size();
339 while (VTSize >
Size) {
350 else if (NewVT == MVT::i64 &&
362 if (NewVT == MVT::i8)
371 if (NumMemOps && !
Op.isVolatile() && NewVTSize <
Size &&
373 VT, DstAS,
Op.isFixedDstAlign() ?
Op.getDstAlign() :
Align(1),
383 if (++NumMemOps > Limit)
386 MemOps.push_back(VT);
411static std::pair<RTLIB::Libcall, ISD::CondCode>
413 RTLIB::Libcall TriStateLC, RTLIB::Libcall GenericLC,
418 return {TriStateLC, TriStateCC};
419 return {GenericLC, TriStateCC};
428 bool IsSignaling)
const {
433 assert((VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f128 || VT == MVT::ppcf128)
434 &&
"Unsupported setcc type!");
438 RTLIB::Libcall LC1 = RTLIB::UNKNOWN_LIBCALL, LC2 = RTLIB::UNKNOWN_LIBCALL;
440 bool ShouldInvertCC =
false;
444#define FP_CMP_LIBCALL(BASE) \
445 RTLIB::getFPLibCall(VT, RTLIB::BASE##_F32, RTLIB::BASE##_F64, \
446 RTLIB::UNKNOWN_LIBCALL, RTLIB::BASE##_F128, \
447 RTLIB::BASE##_PPCF128)
467 ShouldInvertCC =
true;
495 ShouldInvertCC =
true;
504 ShouldInvertCC =
true;
515 ShouldInvertCC =
true;
552 auto ReportNoLibcall = [&]() {
554 Twine(
"no libcall available to soften floating-point ") +
564 if (LC1Impl == RTLIB::Unsupported) {
574 if (ShouldInvertCC) {
576 CCCode = getSetCCInverse(CCCode, RetVT);
579 if (LC2 == RTLIB::UNKNOWN_LIBCALL) {
584 if (LC2Impl == RTLIB::Unsupported) {
590 "unordered call should be simple boolean");
600 auto Call2 =
makeLibCall(DAG, LC2Impl, RetVT,
Ops, CallOptions, dl, Chain);
603 CCCode = getSetCCInverse(CCCode, RetVT);
604 NewLHS = DAG.
getSetCC(dl, SetCCVT, Call2.first, NewRHS, CCCode);
657 if (!TM.shouldAssumeDSOLocal(GV))
677 const APInt &DemandedElts,
680 unsigned Opcode =
Op.getOpcode();
699 if (!Op1C || Op1C->isOpaque())
703 const APInt &
C = Op1C->getAPIntValue();
708 EVT VT =
Op.getValueType();
725 EVT VT =
Op.getValueType();
740 "ShrinkDemandedOp only supports binary operators!");
741 assert(
Op.getNode()->getNumValues() == 1 &&
742 "ShrinkDemandedOp only supports nodes with one result!");
744 EVT VT =
Op.getValueType();
753 Op.getOperand(1).getValueType().getScalarSizeInBits() ==
BitWidth &&
754 "ShrinkDemandedOp only supports operands that have the same size!");
758 if (!
Op.getNode()->hasOneUse())
774 unsigned Opcode =
Op.getOpcode();
784 assert(DemandedSize <= SmallVTBits &&
"Narrowed below demanded bits?");
808 const APInt &DemandedElts,
828 bool AssumeSingleUse)
const {
829 EVT VT =
Op.getValueType();
845 EVT VT =
Op.getValueType();
863 switch (
Op.getOpcode()) {
875 EVT SrcVT = Src.getValueType();
876 EVT DstVT =
Op.getValueType();
882 if (NumSrcEltBits == NumDstEltBits)
887 if (SrcVT.
isVector() && (NumDstEltBits % NumSrcEltBits) == 0) {
888 unsigned Scale = NumDstEltBits / NumSrcEltBits;
891 for (
unsigned i = 0; i != Scale; ++i) {
892 unsigned EltOffset = IsLE ? i : (Scale - 1 - i);
893 unsigned BitOffset = EltOffset * NumSrcEltBits;
894 DemandedSrcBits |=
DemandedBits.extractBits(NumSrcEltBits, BitOffset);
902 Src, DemandedSrcBits, DemandedSrcElts, DAG,
Depth + 1))
907 if (IsLE && (NumSrcEltBits % NumDstEltBits) == 0) {
908 unsigned Scale = NumSrcEltBits / NumDstEltBits;
912 for (
unsigned i = 0; i != NumElts; ++i)
913 if (DemandedElts[i]) {
914 unsigned Offset = (i % Scale) * NumDstEltBits;
916 DemandedSrcElts.
setBit(i / Scale);
920 Src, DemandedSrcBits, DemandedSrcElts, DAG,
Depth + 1))
939 return Op.getOperand(0);
941 return Op.getOperand(1);
952 return Op.getOperand(0);
954 return Op.getOperand(1);
964 return Op.getOperand(0);
966 return Op.getOperand(1);
976 DemandedElts, 1,
Depth + 1))
977 return Op.getOperand(0);
980 DemandedElts, 0,
Depth + 1))
981 return Op.getOperand(1);
987 if (std::optional<unsigned> MaxSA =
990 unsigned ShAmt = *MaxSA;
991 unsigned NumSignBits =
994 if (NumSignBits > ShAmt && (NumSignBits - ShAmt) >= (UpperDemandedBits))
1002 if (std::optional<unsigned> MaxSA =
1005 unsigned ShAmt = *MaxSA;
1009 unsigned NumSignBits =
1048 if (NumSignBits >= (
BitWidth - ExBits + 1))
1061 EVT SrcVT = Src.getValueType();
1062 EVT DstVT =
Op.getValueType();
1063 if (IsLE && DemandedElts == 1 &&
1079 !DemandedElts[CIdx->getZExtValue()])
1089 uint64_t Idx =
Op.getConstantOperandVal(2);
1090 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
1093 if (DemandedSubElts == 0)
1103 bool AllUndef =
true, IdentityLHS =
true, IdentityRHS =
true;
1104 for (
unsigned i = 0; i != NumElts; ++i) {
1105 int M = ShuffleMask[i];
1106 if (M < 0 || !DemandedElts[i])
1109 IdentityLHS &= (M == (int)i);
1110 IdentityRHS &= ((M - NumElts) == i);
1116 return Op.getOperand(0);
1118 return Op.getOperand(1);
1138 unsigned Depth)
const {
1139 EVT VT =
Op.getValueType();
1152 unsigned Depth)
const {
1167 return std::nullopt;
1181 "SRL or SRA node is required here!");
1184 if (!N1C || !N1C->
isOne())
1231 unsigned ShiftOpc =
Op.getOpcode();
1232 bool IsSigned =
false;
1236 unsigned NumSigned = std::min(NumSignedA, NumSignedB) - 1;
1241 unsigned NumZero = std::min(NumZeroA, NumZeroB);
1247 if (NumZero >= 2 && NumSigned < NumZero) {
1252 if (NumSigned >= 1) {
1260 if (NumZero >= 1 && NumSigned < NumZero) {
1280 EVT VT =
Op.getValueType();
1281 std::optional<EVT> NarrowVT =
1285 EVT NVT = *NarrowVT;
1286 if (TLO.
LegalTypes() && !
TLI.isOperationLegal(AVGOpc, NVT)) {
1292 Add.getOperand(1)) &&
1302 if (!IsCeil && !
TLI.isOperationLegal(AVGOpc, NVT) &&
1320 "SRL or SRA node is required here!");
1323 if (!N1C || !N1C->
isOne())
1343 unsigned NumSigned =
1347 unsigned NumZero = std::min(
1350 if (NumZero >= 1 && NumSigned < NumZero) {
1353 }
else if (NumSigned >= 1) {
1367 auto IsLegalAfterTypeLegalization = [&](
EVT VT) {
1368 EVT LegalVT =
TLI.getLegalTypeToTransformTo(Ctx, VT);
1370 TLI.isOperationLegal(AVGOpc, LegalVT);
1378 EVT VT =
Op.getValueType();
1381 if (NarrowVT && IsLegalAfterTypeLegalization(*NarrowVT))
1383 else if (!IsLegalAfterTypeLegalization(VT))
1388 if (!
TLI.isOperationLegal(AVGOpc, NVT) &&
1411 unsigned Depth,
bool AssumeSingleUse)
const {
1414 "Mask size mismatches value type size!");
1419 EVT VT =
Op.getValueType();
1421 unsigned NumElts = OriginalDemandedElts.
getBitWidth();
1423 "Unexpected vector size");
1426 APInt DemandedElts = OriginalDemandedElts;
1451 bool HasMultiUse =
false;
1452 if (!AssumeSingleUse && !
Op.getNode()->hasOneUse()) {
1461 }
else if (OriginalDemandedBits == 0 || OriginalDemandedElts == 0) {
1473 auto TryFoldToLHS = [&](
const APInt &Mask,
1490 auto TryReduceRHSDemand = [&](
const KnownBits &LHSKnown,
1502 APInt RHSDemandedBits =
1505 : LHSKnown.*KnownMask;
1518 switch (
Op.getOpcode()) {
1522 if (!DemandedElts[0])
1527 unsigned SrcBitWidth = Src.getScalarValueSizeInBits();
1534 if (DemandedElts == 1)
1570 EVT MemVT = LD->getMemoryVT();
1572 Known.Zero.setBitsFrom(MemBits);
1587 APInt DemandedVecElts(DemandedElts);
1589 unsigned Idx = CIdx->getZExtValue();
1593 if (!DemandedElts[Idx])
1610 if (!!DemandedVecElts)
1622 uint64_t Idx =
Op.getConstantOperandVal(2);
1623 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
1625 APInt DemandedSrcElts = DemandedElts;
1626 DemandedSrcElts.
clearBits(Idx, Idx + NumSubElts);
1636 Known.setAllConflict();
1637 if (!!DemandedSubElts)
1639 if (!!DemandedSrcElts)
1649 if (NewSub || NewSrc) {
1650 NewSub = NewSub ? NewSub :
Sub;
1651 NewSrc = NewSrc ? NewSrc : Src;
1664 if (Src.getValueType().isScalableVector())
1666 uint64_t Idx =
Op.getConstantOperandVal(1);
1667 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
1668 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts).
shl(Idx);
1689 Known.setAllConflict();
1690 EVT SubVT =
Op.getOperand(0).getValueType();
1691 unsigned NumSubVecs =
Op.getNumOperands();
1693 for (
unsigned i = 0; i != NumSubVecs; ++i) {
1694 APInt DemandedSubElts =
1695 DemandedElts.
extractBits(NumSubElts, i * NumSubElts);
1697 Known2, TLO,
Depth + 1))
1700 if (!!DemandedSubElts)
1710 APInt DemandedLHS, DemandedRHS;
1715 if (!!DemandedLHS || !!DemandedRHS) {
1719 Known.setAllConflict();
1720 if (!!DemandedLHS) {
1726 if (!!DemandedRHS) {
1738 if (DemandedOp0 || DemandedOp1) {
1739 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1740 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1775 LHSKnown.
One == ~RHSC->getAPIntValue()) {
1798 unsigned NumSubElts =
1819 Known2, TLO,
Depth + 1))
1847 if (DemandedOp0 || DemandedOp1) {
1848 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1849 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1871 Known2, TLO,
Depth + 1)) {
1899 if (DemandedOp0 || DemandedOp1) {
1900 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1901 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1964 if (
C->getAPIntValue() == Known2.
One) {
1973 if (!
C->isAllOnes() &&
DemandedBits.isSubsetOf(
C->getAPIntValue())) {
1985 if (ShiftC->getAPIntValue().ult(
BitWidth)) {
1986 uint64_t ShiftAmt = ShiftC->getZExtValue();
1989 : Ones.
lshr(ShiftAmt);
2006 if (!
C || !
C->isAllOnes())
2016 if (DemandedOp0 || DemandedOp1) {
2017 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
2018 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
2032 Known2, TLO,
Depth + 1))
2047 Known2, TLO,
Depth + 1))
2058 Known2, TLO,
Depth + 1))
2082 DemandedElts, KnownOp0, TLO,
Depth + 1))
2105 Known.Zero.setBitsFrom(1);
2113 if (std::optional<unsigned> KnownSA =
2115 unsigned ShAmt = *KnownSA;
2125 if (std::optional<unsigned> InnerSA =
2127 unsigned C1 = *InnerSA;
2129 int Diff = ShAmt -
C1;
2148 if (ShAmt < InnerBits &&
DemandedBits.getActiveBits() <= InnerBits &&
2166 InnerOp, DemandedElts,
Depth + 2)) {
2167 unsigned InnerShAmt = *SA2;
2168 if (InnerShAmt < ShAmt && InnerShAmt < InnerBits &&
2170 (InnerBits - InnerShAmt + ShAmt) &&
2193 Known.Zero.setLowBits(ShAmt);
2198 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
2209 Op.getNode()->hasOneUse()) {
2220 assert(DemandedSize <= SmallVTBits &&
2221 "Narrowed below demanded bits?");
2247 if (
bool IsNUW = (
Known.countMinLeadingZeros() >= HalfWidth)) {
2248 bool IsNSW =
Known.countMinSignBits() > HalfWidth;
2251 Flags.setNoUnsignedWrap(IsNUW);
2256 NewShiftAmt, Flags);
2282 if (std::optional<unsigned> MaxSA =
2284 unsigned ShAmt = *MaxSA;
2285 unsigned NumSignBits =
2288 if (NumSignBits > ShAmt && (NumSignBits - ShAmt) >= (UpperDemandedBits))
2298 if (std::optional<unsigned> KnownSA =
2300 unsigned ShAmt = *KnownSA;
2310 if (std::optional<unsigned> InnerSA =
2312 unsigned C1 = *InnerSA;
2314 int Diff = ShAmt -
C1;
2330 if (std::optional<unsigned> InnerSA =
2332 unsigned C1 = *InnerSA;
2334 unsigned Combined = std::min(
C1 + ShAmt,
BitWidth - 1);
2346 if (
Op->getFlags().hasExact())
2377 Known.Zero.setHighBits(ShAmt);
2382 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
2396 if (std::optional<unsigned> MaxSA =
2398 unsigned ShAmt = *MaxSA;
2402 unsigned NumSignBits =
2411 DemandedElts,
Depth + 1))
2414 DemandedElts,
Depth + 1))
2438 if (std::optional<unsigned> KnownSA =
2440 unsigned ShAmt = *KnownSA;
2447 if (std::optional<unsigned> InnerSA =
2449 unsigned LowBits =
BitWidth - ShAmt;
2454 if (*InnerSA == ShAmt) {
2464 unsigned NumSignBits =
2466 if (NumSignBits > ShAmt)
2476 if (
Op->getFlags().hasExact())
2508 Known.One.setHighBits(ShAmt);
2513 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
2523 DemandedElts,
Depth + 1))
2526 DemandedElts,
Depth + 1))
2539 unsigned Amt = SA->getAPIntValue().urem(
BitWidth);
2561 Known2 <<= (IsFSHL ? Amt : (
BitWidth - Amt));
2569 Op0, Demanded0, DemandedElts, TLO.
DAG,
Depth + 1);
2571 Op1, Demanded1, DemandedElts, TLO.
DAG,
Depth + 1);
2572 if (DemandedOp0 || DemandedOp1) {
2573 DemandedOp0 = DemandedOp0 ? DemandedOp0 : Op0;
2574 DemandedOp1 = DemandedOp1 ? DemandedOp1 : Op1;
2590 unsigned MaxShiftAmt =
2622 unsigned Amt = SA->getAPIntValue().urem(
BitWidth);
2638 DemandedBits.countr_zero() >= (IsROTL ? Amt : RevAmt)) {
2643 DemandedBits.countl_zero() >= (IsROTL ? RevAmt : Amt)) {
2662 unsigned Opc =
Op.getOpcode();
2669 unsigned NumSignBits =
2673 if (NumSignBits >= NumDemandedUpperBits)
2739 unsigned ShiftAmount = NLZ > NTZ ? NLZ - NTZ : NTZ - NLZ;
2786 Known.One.clearAllBits();
2799 unsigned MinSignedBits =
2801 bool AlreadySignExtended = ExVTBits >= MinSignedBits;
2804 if (!AlreadySignExtended) {
2822 InputDemandedBits.
setBit(ExVTBits - 1);
2832 if (
Known.Zero[ExVTBits - 1])
2836 if (
Known.One[ExVTBits - 1]) {
2837 Known.One.setBitsFrom(ExVTBits);
2846 EVT HalfVT =
Op.getOperand(0).getValueType();
2869 EVT SrcVT = Src.getValueType();
2878 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2889 APInt InDemandedElts = DemandedElts.
zext(InElts);
2895 assert(
Known.getBitWidth() == InBits &&
"Src width has changed?");
2900 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
2910 EVT SrcVT = Src.getValueType();
2915 APInt InDemandedElts = DemandedElts.
zext(InElts);
2920 InDemandedBits.
setBit(InBits - 1);
2926 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2944 assert(
Known.getBitWidth() == InBits &&
"Src width has changed?");
2950 if (
Known.isNonNegative()) {
2963 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
2973 EVT SrcVT = Src.getValueType();
2980 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2985 APInt InDemandedElts = DemandedElts.
zext(InElts);
2989 assert(
Known.getBitWidth() == InBits &&
"Src width has changed?");
2994 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
3003 unsigned OperandBitWidth = Src.getScalarValueSizeInBits();
3016 Src, TruncMask, DemandedElts, TLO.
DAG,
Depth + 1))
3021 switch (Src.getOpcode()) {
3032 if (Src.getNode()->hasOneUse()) {
3044 std::optional<unsigned> ShAmtC =
3046 if (!ShAmtC || *ShAmtC >=
BitWidth)
3048 unsigned ShVal = *ShAmtC;
3078 Known.Zero |= ~InMask;
3085 ElementCount SrcEltCnt = Src.getValueType().getVectorElementCount();
3086 unsigned EltBitWidth = Src.getScalarValueSizeInBits();
3095 if (CIdx->getAPIntValue().ult(NumSrcElts))
3102 DemandedSrcBits = DemandedSrcBits.
trunc(EltBitWidth);
3111 Src, DemandedSrcBits, DemandedSrcElts, TLO.
DAG,
Depth + 1)) {
3113 TLO.
DAG.
getNode(
Op.getOpcode(), dl, VT, DemandedSrc, Idx);
3127 EVT SrcVT = Src.getValueType();
3139 unsigned ShVal =
Op.getValueSizeInBits() - 1;
3149 unsigned Scale =
BitWidth / NumSrcEltBits;
3152 for (
unsigned i = 0; i != Scale; ++i) {
3153 unsigned EltOffset = IsLE ? i : (Scale - 1 - i);
3154 unsigned BitOffset = EltOffset * NumSrcEltBits;
3155 DemandedSrcBits |=
DemandedBits.extractBits(NumSrcEltBits, BitOffset);
3162 APInt KnownSrcUndef, KnownSrcZero;
3164 KnownSrcZero, TLO,
Depth + 1))
3169 KnownSrcBits, TLO,
Depth + 1))
3171 }
else if (IsLE && (NumSrcEltBits %
BitWidth) == 0) {
3173 unsigned Scale = NumSrcEltBits /
BitWidth;
3177 for (
unsigned i = 0; i != NumElts; ++i)
3178 if (DemandedElts[i]) {
3181 DemandedSrcElts.
setBit(i / Scale);
3185 APInt KnownSrcUndef, KnownSrcZero;
3187 KnownSrcZero, TLO,
Depth + 1))
3193 KnownSrcBits, TLO,
Depth + 1))
3199 Src, DemandedSrcBits, DemandedSrcElts, TLO.
DAG,
Depth + 1)) {
3221 if (
C &&
C->getAPIntValue().countr_zero() == CTZ) {
3237 if (
Op.getOperand(0).getValueType() !=
Op.getOperand(1).getValueType())
3245 SDValue Op0 =
Op.getOperand(0), Op1 =
Op.getOperand(1);
3250 auto GetDemandedBitsLHSMask = [&](
APInt Demanded,
3259 DemandedElts, KnownOp0, TLO,
Depth + 1) ||
3276 Op0, LoMask, DemandedElts, TLO.
DAG,
Depth + 1);
3278 Op1, LoMask, DemandedElts, TLO.
DAG,
Depth + 1);
3279 if (DemandedOp0 || DemandedOp1) {
3280 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
3281 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
3295 if (
C && !
C->isAllOnes() && !
C->isOne() &&
3296 (
C->getAPIntValue() | HighMask).isAllOnes()) {
3308 auto getShiftLeftAmt = [&HighMask](
SDValue Mul) ->
unsigned {
3335 if (
unsigned ShAmt = getShiftLeftAmt(Op0))
3338 if (
unsigned ShAmt = getShiftLeftAmt(Op1))
3339 return foldMul(
ISD::SUB, Op1.getOperand(0), Op0, ShAmt);
3343 if (
unsigned ShAmt = getShiftLeftAmt(Op1))
3344 return foldMul(
ISD::ADD, Op1.getOperand(0), Op0, ShAmt);
3352 Op.getOpcode() !=
ISD::SUB, Flags.hasNoSignedWrap(),
3353 Flags.hasNoUnsignedWrap(), KnownOp0, KnownOp1);
3368 if (
Known.isNonNegative())
3370 if (
Known.isNegative())
3374 Known.Zero |= SignMask;
3375 Known.One &= ~SignMask;
3406 Known.Zero &= ~SignMask0;
3407 Known.One &= ~SignMask0;
3421 if (!
Known.isSignUnknown()) {
3422 Known.Zero ^= SignMask;
3423 Known.One ^= SignMask;
3434 if (
Op.getValueType().isScalableVector())
3453 auto *C = dyn_cast<ConstantSDNode>(V);
3454 return C && C->isOpaque();
3468 if (HasMultiUse &&
Known.isUnknown() && !OriginalDemandedElts.
isAllOnes())
3475 const APInt &DemandedElts,
3481 APInt KnownUndef, KnownZero;
3495 const APInt &UndefOp0,
3496 const APInt &UndefOp1) {
3499 "Vector binop only");
3504 UndefOp1.
getBitWidth() == NumElts &&
"Bad type for undef analysis");
3506 auto getUndefOrConstantElt = [&](
SDValue V,
unsigned Index,
3507 const APInt &UndefVals) {
3508 if (UndefVals[Index])
3524 for (
unsigned i = 0; i != NumElts; ++i) {
3533 if (
C0 &&
C1 &&
C0.getValueType() == EltVT &&
C1.getValueType() == EltVT)
3543 bool AssumeSingleUse)
const {
3544 EVT VT =
Op.getValueType();
3545 unsigned Opcode =
Op.getOpcode();
3546 APInt DemandedElts = OriginalDemandedElts;
3560 "Mask size mismatches value type element count!");
3569 if (!AssumeSingleUse && !
Op.getNode()->hasOneUse())
3573 if (DemandedElts == 0) {
3591 assert(ShrunkSize % EltSizeInBits == 0 &&
3592 "Shrunk size not a multiple of element size");
3594 "Shrunk size must be < original vector size");
3596 "Shrunk size must be >= demanded size");
3611 auto SimplifyDemandedVectorEltsBinOp = [&](
SDValue Op0,
SDValue Op1) {
3616 if (NewOp0 || NewOp1) {
3619 NewOp1 ? NewOp1 : Op1,
Op->getFlags());
3623 if (TryShrinkBinOp(Op0, Op1))
3631 if (!DemandedElts[0])
3638 EVT SrcVT = Src.getValueType();
3645 for (
unsigned I = 0;
I != NumElts; ++
I) {
3646 if (DemandedElts[
I]) {
3647 unsigned Offset =
I * EltSize;
3660 if (NumSrcElts == NumElts)
3662 KnownZero, TLO,
Depth + 1);
3664 APInt SrcDemandedElts, SrcZero, SrcUndef;
3668 if ((NumElts % NumSrcElts) == 0) {
3669 unsigned Scale = NumElts / NumSrcElts;
3681 for (
unsigned i = 0; i != NumElts; ++i)
3682 if (DemandedElts[i]) {
3683 unsigned Ofs = (i % Scale) * EltSizeInBits;
3684 SrcDemandedBits.
setBits(Ofs, Ofs + EltSizeInBits);
3696 for (
unsigned SubElt = 0; SubElt != Scale; ++SubElt) {
3697 if (!
Known.Zero.extractBits(EltSizeInBits, SubElt * EltSizeInBits)
3700 for (
unsigned SrcElt = 0; SrcElt != NumSrcElts; ++SrcElt) {
3701 unsigned Elt = Scale * SrcElt + SubElt;
3704 if (DemandedElts[Elt] && !SrcUndef[SrcElt])
3712 for (
unsigned i = 0; i != NumSrcElts; ++i) {
3713 if (SrcDemandedElts[i]) {
3715 KnownZero.
setBits(i * Scale, (i + 1) * Scale);
3717 KnownUndef.
setBits(i * Scale, (i + 1) * Scale);
3725 if ((NumSrcElts % NumElts) == 0) {
3726 unsigned Scale = NumSrcElts / NumElts;
3734 for (
unsigned i = 0; i != NumElts; ++i) {
3735 if (DemandedElts[i]) {
3764 if (!IsPromotedLoad)
3775 [&](
SDValue Elt) { return Op.getOperand(0) != Elt; })) {
3777 bool Updated =
false;
3778 for (
unsigned i = 0; i != NumElts; ++i) {
3789 for (
unsigned i = 0; i != NumElts; ++i) {
3791 if (
SrcOp.isUndef()) {
3793 }
else if (EltSizeInBits ==
SrcOp.getScalarValueSizeInBits() &&
3801 EVT SubVT =
Op.getOperand(0).getValueType();
3802 unsigned NumSubVecs =
Op.getNumOperands();
3804 for (
unsigned i = 0; i != NumSubVecs; ++i) {
3807 APInt SubUndef, SubZero;
3811 KnownUndef.
insertBits(SubUndef, i * NumSubElts);
3812 KnownZero.
insertBits(SubZero, i * NumSubElts);
3817 bool FoundNewSub =
false;
3819 for (
unsigned i = 0; i != NumSubVecs; ++i) {
3823 SubOp, SubElts, TLO.
DAG,
Depth + 1);
3824 DemandedSubOps.
push_back(NewSubOp ? NewSubOp : SubOp);
3825 FoundNewSub = NewSubOp ?
true : FoundNewSub;
3840 uint64_t Idx =
Op.getConstantOperandVal(2);
3841 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
3843 APInt DemandedSrcElts = DemandedElts;
3844 DemandedSrcElts.
clearBits(Idx, Idx + NumSubElts);
3847 if (!DemandedSubElts)
3850 APInt SubUndef, SubZero;
3856 if (!DemandedSrcElts && !Src.isUndef())
3870 Src, DemandedSrcElts, TLO.
DAG,
Depth + 1);
3873 if (NewSrc || NewSub) {
3874 NewSrc = NewSrc ? NewSrc : Src;
3875 NewSub = NewSub ? NewSub :
Sub;
3877 NewSub,
Op.getOperand(2));
3886 if (Src.getValueType().isScalableVector())
3888 uint64_t Idx =
Op.getConstantOperandVal(1);
3889 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
3890 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts).
shl(Idx);
3892 APInt SrcUndef, SrcZero;
3916 if (CIdx && CIdx->getAPIntValue().ult(NumElts)) {
3917 unsigned Idx = CIdx->getZExtValue();
3918 if (!DemandedElts[Idx])
3921 APInt DemandedVecElts(DemandedElts);
3924 KnownZero, TLO,
Depth + 1))
3933 APInt VecUndef, VecZero;
3947 APInt UndefSel, ZeroSel;
3953 APInt DemandedLHS(DemandedElts);
3954 APInt DemandedRHS(DemandedElts);
3955 APInt UndefLHS, ZeroLHS;
3956 APInt UndefRHS, ZeroRHS;
3964 KnownUndef = UndefLHS & UndefRHS;
3965 KnownZero = ZeroLHS & ZeroRHS;
3969 APInt DemandedSel = DemandedElts & ~KnownZero;
3970 if (DemandedSel != DemandedElts)
3983 APInt DemandedLHS(NumElts, 0);
3984 APInt DemandedRHS(NumElts, 0);
3985 for (
unsigned i = 0; i != NumElts; ++i) {
3986 int M = ShuffleMask[i];
3987 if (M < 0 || !DemandedElts[i])
3989 assert(0 <= M && M < (
int)(2 * NumElts) &&
"Shuffle index out of range");
3990 if (M < (
int)NumElts)
3993 DemandedRHS.
setBit(M - NumElts);
3999 bool FoldLHS = !DemandedLHS && !LHS.isUndef();
4000 bool FoldRHS = !DemandedRHS && !RHS.isUndef();
4001 if (FoldLHS || FoldRHS) {
4002 LHS = FoldLHS ? TLO.
DAG.
getUNDEF(LHS.getValueType()) : LHS;
4003 RHS = FoldRHS ? TLO.
DAG.
getUNDEF(RHS.getValueType()) : RHS;
4010 APInt UndefLHS, ZeroLHS;
4011 APInt UndefRHS, ZeroRHS;
4020 bool Updated =
false;
4021 bool IdentityLHS =
true, IdentityRHS =
true;
4023 for (
unsigned i = 0; i != NumElts; ++i) {
4024 int &M = NewMask[i];
4027 if (!DemandedElts[i] || (M < (
int)NumElts && UndefLHS[M]) ||
4028 (M >= (
int)NumElts && UndefRHS[M - NumElts])) {
4032 IdentityLHS &= (M < 0) || (M == (
int)i);
4033 IdentityRHS &= (M < 0) || ((M - NumElts) == i);
4038 if (Updated && !IdentityLHS && !IdentityRHS && !TLO.
LegalOps) {
4046 for (
unsigned i = 0; i != NumElts; ++i) {
4047 int M = ShuffleMask[i];
4050 }
else if (M < (
int)NumElts) {
4056 if (UndefRHS[M - NumElts])
4058 if (ZeroRHS[M - NumElts])
4067 APInt SrcUndef, SrcZero;
4069 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
4070 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts);
4078 Op.getValueSizeInBits() == Src.getValueSizeInBits() &&
4079 DemandedSrcElts == 1) {
4092 if (IsLE && DemandedSrcElts == 1 && Src.getOpcode() ==
ISD::AND &&
4093 Op->isOnlyUserOf(Src.getNode()) &&
4094 Op.getValueSizeInBits() == Src.getValueSizeInBits()) {
4096 EVT SrcVT = Src.getValueType();
4110 ISD::AND,
DL, SrcVT, {Src.getOperand(1), Mask})) {
4124 if (Op0 == Op1 &&
Op->isOnlyUserOf(Op0.
getNode())) {
4125 APInt UndefLHS, ZeroLHS;
4151 APInt UndefRHS, ZeroRHS;
4155 APInt UndefLHS, ZeroLHS;
4160 KnownZero = ZeroLHS & ZeroRHS;
4166 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
4178 APInt UndefRHS, ZeroRHS;
4182 APInt UndefLHS, ZeroLHS;
4187 KnownZero = ZeroLHS & ~UndefRHS;
4188 KnownUndef = UndefLHS & UndefRHS;
4193 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
4204 APInt SrcUndef, SrcZero;
4218 KnownUndef &= DemandedElts;
4219 KnownZero &= DemandedElts;
4224 if (DemandedElts.
isSubsetOf(SrcZero | KnownZero | SrcUndef | KnownUndef))
4231 KnownZero |= SrcZero;
4232 KnownUndef &= SrcUndef;
4233 KnownUndef &= ~KnownZero;
4237 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
4245 KnownZero, TLO,
Depth + 1))
4250 Op.getOperand(0), DemandedElts, TLO.
DAG,
Depth + 1))
4265 KnownZero, TLO,
Depth + 1))
4272 KnownZero, TLO,
Depth))
4278 TLO,
Depth, AssumeSingleUse))
4285 assert((KnownUndef & KnownZero) == 0 &&
"Elements flagged as undef AND zero");
4299 const APInt &DemandedElts,
4301 unsigned Depth)
const {
4306 "Should use MaskedValueIsZero if you don't know whether Op"
4307 " is a target node!");
4314 unsigned Depth)
const {
4321 unsigned Depth)
const {
4334 Align Alignment)
const {
4345 unsigned NumZeroBits =
Known.countMinLeadingZeros();
4355 unsigned Depth)
const {
4364 unsigned Depth)
const {
4369 "Should use ComputeNumSignBits if you don't know whether Op"
4370 " is a target node!");
4387 "Should use SimplifyDemandedVectorElts if you don't know whether Op"
4388 " is a target node!");
4399 "Should use SimplifyDemandedBits if you don't know whether Op"
4400 " is a target node!");
4413 "Should use SimplifyMultipleUseDemandedBits if you don't know whether Op"
4414 " is a target node!");
4447 "Should use isGuaranteedNotToBeUndefOrPoison if you don't know whether Op"
4448 " is a target node!");
4455 return DAG.isGuaranteedNotToBeUndefOrPoison(V, Kind, Depth + 1);
4466 "Should use canCreateUndefOrPoison if you don't know whether Op"
4467 " is a target node!");
4474 const APInt &DemandedElts,
4476 unsigned Depth)
const {
4481 "Should use computeKnownFPClass if you don't know whether Op"
4482 " is a target node!");
4486 const APInt &DemandedElts,
4489 unsigned Depth)
const {
4494 "Should use isKnownNeverNaN if you don't know whether Op"
4495 " is a target node!");
4500 const APInt &DemandedElts,
4503 unsigned Depth)
const {
4508 "Should use isSplatValue if you don't know whether Op"
4509 " is a target node!");
4524 CVal = CN->getAPIntValue();
4525 EltWidth =
N.getValueType().getScalarSizeInBits();
4532 CVal = CVal.
trunc(EltWidth);
4538 return CVal.
isOne();
4580 return (
N->isOne() && !SExt) || (SExt && (
N->getValueType(0) != MVT::i1));
4583 return N->isAllOnes() && SExt;
4592 DAGCombinerInfo &DCI)
const {
4621 if (AndC &&
isNullConstant(N1) && AndC->getAPIntValue().isPowerOf2() &&
4624 AndC->getAPIntValue().getActiveBits());
4651 if (isXAndYEqZeroPreferableToXAndYEqY(
Cond, OpVT) &&
4659 if (DCI.isBeforeLegalizeOps() ||
4688 DAGCombinerInfo &DCI)
const {
4692 SelectionDAG &DAG = DCI.DAG;
4729SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
4731 const SDLoc &
DL)
const {
4742 ConstantSDNode *C01;
4751 APInt
I1 =
C1->getAPIntValue();
4771 auto checkConstants = [&
I1, &I01]() ->
bool {
4776 if (checkConstants()) {
4784 if (!checkConstants())
4790 const unsigned KeptBits =
I1.logBase2();
4791 const unsigned KeptBitsMinusOne = I01.
logBase2();
4794 if (KeptBits != (KeptBitsMinusOne + 1))
4799 SelectionDAG &DAG = DCI.DAG;
4808 return DAG.
getSetCC(
DL, SCCVT, SExtInReg,
X, NewCond);
4812SDValue TargetLowering::optimizeSetCCByHoistingAndByConstFromLogicalShift(
4814 DAGCombinerInfo &DCI,
const SDLoc &
DL)
const {
4816 "Should be a comparison with 0.");
4818 "Valid only for [in]equality comparisons.");
4820 unsigned NewShiftOpcode;
4823 SelectionDAG &DAG = DCI.DAG;
4826 auto Match = [&NewShiftOpcode, &
X, &
C, &
Y, &DAG,
this](
SDValue V) {
4830 unsigned OldShiftOpcode =
V.getOpcode();
4831 switch (OldShiftOpcode) {
4843 C =
V.getOperand(0);
4844 ConstantSDNode *
CC =
4848 Y =
V.getOperand(1);
4850 ConstantSDNode *XC =
4853 X, XC,
CC,
Y, OldShiftOpcode, NewShiftOpcode, DAG);
4870 EVT VT =
X.getValueType();
4885 DAGCombinerInfo &DCI)
const {
4888 "Unexpected binop");
4894 SelectionDAG &DAG = DCI.DAG;
4916 if (!DCI.isCalledByLegalizer())
4917 DCI.AddToWorklist(YShl1.
getNode());
4932 if (CTPOP.getOpcode() !=
ISD::CTPOP || !CTPOP.hasOneUse())
4935 EVT CTVT = CTPOP.getValueType();
4936 SDValue CTOp = CTPOP.getOperand(0);
4946 unsigned CostLimit =
TLI.getCustomCtpopCost(CTVT,
Cond);
4956 for (
unsigned i = 0; i <
Passes; i++) {
4967 if (
TLI.isCtpopFast(CTVT))
5002 if (!
C1 || !(
C1->isZero() ||
C1->isAllOnes()))
5005 auto getRotateSource = [](
SDValue X) {
5007 return X.getOperand(0);
5014 if (
SDValue R = getRotateSource(N0))
5047 if (!
C1 || !
C1->isZero())
5072 if (
Or.getOperand(0) ==
Other) {
5073 X =
Or.getOperand(0);
5074 Y =
Or.getOperand(1);
5077 if (
Or.getOperand(1) ==
Other) {
5078 X =
Or.getOperand(1);
5079 Y =
Or.getOperand(0);
5089 if (matchOr(F0, F1)) {
5096 if (matchOr(F1, F0)) {
5112 const SDLoc &dl)
const {
5122 bool N0ConstOrSplat =
5124 bool N1ConstOrSplat =
5132 if (N0ConstOrSplat && !N1ConstOrSplat &&
5135 return DAG.
getSetCC(dl, VT, N1, N0, SwappedCC);
5141 if (!N0ConstOrSplat && !N1ConstOrSplat &&
5146 return DAG.
getSetCC(dl, VT, N1, N0, SwappedCC);
5155 const APInt &
C1 = N1C->getAPIntValue();
5171 !Attr.hasFnAttr(Attribute::MinSize)) {
5175 return DAG.
getNode(LogicOp, dl, VT, IsXZero, IsYZero);
5221 const APInt &
C1 = N1C->getAPIntValue();
5237 if ((
C->getAPIntValue()+1).isPowerOf2()) {
5238 MinBits =
C->getAPIntValue().countr_one();
5249 MinBits = LN0->getMemoryVT().getSizeInBits();
5253 MinBits = LN0->getMemoryVT().getSizeInBits();
5259 unsigned ReqdBits =
Signed ?
C1.getSignificantBits() :
C1.getActiveBits();
5263 MinBits <
C1.getBitWidth() &&
5264 MinBits >= ReqdBits) {
5269 if (MinBits == 1 &&
C1 == 1)
5288 if (TopSetCC.
getValueType() == MVT::i1 && VT == MVT::i1 &&
5321 unsigned bestWidth = 0, bestOffset = 0;
5322 if (Lod->isSimple() && Lod->isUnindexed() &&
5323 (Lod->getMemoryVT().isByteSized() ||
5325 unsigned memWidth = Lod->getMemoryVT().getStoreSizeInBits();
5327 unsigned maskWidth = origWidth;
5331 origWidth = Lod->getMemoryVT().getSizeInBits();
5335 for (
unsigned width = 8; width < origWidth; width *= 2) {
5340 unsigned maxOffset = origWidth - width;
5341 for (
unsigned offset = 0; offset <= maxOffset; offset += 8) {
5342 if (Mask.isSubsetOf(newMask)) {
5343 unsigned ptrOffset =
5345 unsigned IsFast = 0;
5346 assert((ptrOffset % 8) == 0 &&
"Non-Bytealigned pointer offset");
5351 *DAG.
getContext(), Layout, newVT, Lod->getAddressSpace(),
5352 NewAlign, Lod->getMemOperand()->getFlags(), &IsFast) &&
5354 bestOffset = ptrOffset / 8;
5355 bestMask = Mask.lshr(offset);
5368 SDValue Ptr = Lod->getBasePtr();
5369 if (bestOffset != 0)
5372 DAG.
getLoad(newVT, dl, Lod->getChain(), Ptr,
5373 Lod->getPointerInfo().getWithOffset(bestOffset),
5375 Lod->getMMOMetadataForSubAccess());
5390 C1.getBitWidth() - InSize))) {
5450 if (
C1.getSignificantBits() > ExtSrcTyBits)
5454 ExtDstTy != ExtSrcTy &&
"Unexpected types!");
5461 return DAG.
getSetCC(dl, VT, ZextOp,
5463 }
else if ((N1C->isZero() || N1C->isOne()) &&
5510 return DAG.
getSetCC(dl, VT, Val, N1,
5513 }
else if (N1C->isOne()) {
5596 optimizeSetCCOfSignedTruncationCheck(VT, N0, N1,
Cond, DCI, dl))
5603 const APInt &
C1 = N1C->getAPIntValue();
5605 APInt MinVal, MaxVal;
5627 (!N1C->isOpaque() || (
C.getBitWidth() <= 64 &&
5647 (!N1C->isOpaque() || (
C.getBitWidth() <= 64 &&
5695 if (
SDValue CC = optimizeSetCCByHoistingAndByConstFromLogicalShift(
5696 VT, N0, N1,
Cond, DCI, dl))
5703 bool CmpZero = N1C->isZero();
5704 bool CmpNegOne = N1C->isAllOnes();
5705 if ((CmpZero || CmpNegOne) && N0.
hasOneUse()) {
5708 unsigned EltBits = V.getScalarValueSizeInBits();
5709 if (V.getOpcode() !=
ISD::OR || (EltBits % 2) != 0)
5717 RHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
5720 Hi = RHS.getOperand(0);
5725 LHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
5728 Hi = LHS.getOperand(0);
5736 unsigned HalfBits = EltBits / 2;
5747 if (IsConcat(N0,
Lo,
Hi))
5748 return MergeConcat(
Lo,
Hi);
5786 const APInt &
C1 = N1C->getAPIntValue();
5801 unsigned ShCt = AndRHS->getAPIntValue().logBase2();
5802 if (AndRHS->getAPIntValue().isPowerOf2() &&
5812 unsigned ShCt =
C1.logBase2();
5823 if (
C1.getSignificantBits() <= 64 &&
5829 const APInt &AndRHSC = AndRHS->getAPIntValue();
5835 APInt NewC =
C1.lshr(ShiftBits);
5838 APInt SignedC =
C1.ashr(ShiftBits);
5867 ShiftBits =
C1.countr_one();
5871 ShiftBits =
C1.countr_zero();
5873 APInt RangeWidth = NewC;
5882 const APInt &AddVal = AddC->getAPIntValue();
5884 APInt RangeLower = -AddVal;
5886 (void)RangeLower.
uadd_ov(RangeWidth, Overflow);
5887 if (!RangeWidth.
isZero() && !Overflow) {
5896 return DAG.
getSetCC(dl, VT, ShiftedAdd, CmpRHS, NewCond);
5905 return DAG.
getSetCC(dl, VT, Shift, CmpRHS, NewCond);
5913 assert(!CFP->getValueAPF().isNaN() &&
"Unexpected NaN value");
5934 !
isFPImmLegal(CFP->getValueAPF(), CFP->getValueType(0))) {
5953 if (CFP->getValueAPF().isInfinity()) {
5954 bool IsNegInf = CFP->getValueAPF().isNegative();
5965 return DAG.
getSetCC(dl, VT, N0, N1, NewCond);
5974 "Integer types should be handled by FoldSetCC");
5980 if (UOF ==
unsigned(EqTrue))
5985 if (NewCond !=
Cond &&
5988 return DAG.
getSetCC(dl, VT, N0, N1, NewCond);
5995 if ((isSignedIntSetCC(
Cond) || isUnsignedIntSetCC(
Cond)) &&
6032 bool LegalRHSImm =
false;
6040 DAG.
getConstant(RHSC->getAPIntValue() - LHSR->getAPIntValue(),
6048 DAG.
getConstant(LHSR->getAPIntValue() ^ RHSC->getAPIntValue(),
6058 DAG.
getConstant(SUBC->getAPIntValue() - RHSC->getAPIntValue(),
6063 if (RHSC->getValueType(0).getSizeInBits() <= 64)
6072 if (
SDValue V = foldSetCCWithBinOp(VT, N0, N1,
Cond, dl, DCI))
6078 if (
SDValue V = foldSetCCWithBinOp(VT, N1, N0,
Cond, dl, DCI))
6081 if (
SDValue V = foldSetCCWithAnd(VT, N0, N1,
Cond, dl, DCI))
6084 if (
SDValue V = foldSetCCWithOr(VT, N0, N1,
Cond, dl, DCI))
6093 if (!
isIntDivCheap(VT, Attr) && !Attr.hasFnAttr(Attribute::MinSize)) {
6111 N0 = DAG.
getNOT(dl, Temp, OpVT);
6120 Temp = DAG.
getNOT(dl, N0, OpVT);
6127 Temp = DAG.
getNOT(dl, N1, OpVT);
6134 Temp = DAG.
getNOT(dl, N0, OpVT);
6141 Temp = DAG.
getNOT(dl, N1, OpVT);
6150 N0 = DAG.
getNode(ExtendCode, dl, VT, N0);
6168 if (VT == OldCCVT) {
6196 GA = GASD->getGlobal();
6197 Offset += GASD->getOffset();
6201 if (
N->isAnyAdd()) {
6206 Offset += V->getSExtValue();
6211 Offset += V->getSExtValue();
6232 unsigned S = Constraint.
size();
6235 switch (Constraint[0]) {
6266 if (S > 1 && Constraint[0] ==
'{' && Constraint[S - 1] ==
'}') {
6267 if (S == 8 && Constraint.
substr(1, 6) ==
"memory")
6295 std::vector<SDValue> &
Ops,
6298 if (Constraint.
size() > 1)
6301 char ConstraintLetter = Constraint[0];
6302 switch (ConstraintLetter) {
6322 bool IsBool =
C->getConstantIntValue()->getBitWidth() == 1;
6332 if (ConstraintLetter !=
'n') {
6335 GA->getValueType(0),
6336 Offset + GA->getOffset()));
6341 BA->getBlockAddress(), BA->getValueType(0),
6342 Offset + BA->getOffset(), BA->getTargetFlags()));
6350 const unsigned OpCode =
Op.getOpcode();
6353 Op =
Op.getOperand(1);
6357 Op =
Op.getOperand(0);
6374std::pair<unsigned, const TargetRegisterClass *>
6380 assert(*(Constraint.
end() - 1) ==
'}' &&
"Not a brace enclosed constraint?");
6385 std::pair<unsigned, const TargetRegisterClass *> R =
6397 std::pair<unsigned, const TargetRegisterClass *> S =
6398 std::make_pair(PR, &RC);
6443 unsigned maCount = 0;
6449 unsigned LabelNo = 0;
6452 ConstraintOperands.emplace_back(std::move(CI));
6456 if (OpInfo.multipleAlternatives.size() > maCount)
6457 maCount = OpInfo.multipleAlternatives.size();
6459 OpInfo.ConstraintVT = MVT::Other;
6462 switch (OpInfo.Type) {
6465 if (OpInfo.isIndirect) {
6466 OpInfo.CallOperandVal =
Call.getArgOperand(ArgNo);
6472 assert(!
Call.getType()->isVoidTy() &&
"Bad inline asm!");
6477 assert(ResNo == 0 &&
"Asm only has one result!");
6485 OpInfo.CallOperandVal =
Call.getArgOperand(ArgNo);
6496 if (OpInfo.CallOperandVal) {
6498 if (OpInfo.isIndirect) {
6499 OpTy =
Call.getParamElementType(ArgNo);
6500 assert(
OpTy &&
"Indirect operand must have elementtype attribute");
6505 if (STy->getNumElements() == 1)
6506 OpTy = STy->getElementType(0);
6510 if (!
OpTy->isSingleValueType() &&
OpTy->isSized()) {
6511 unsigned BitSize =
DL.getTypeSizeInBits(
OpTy);
6532 if (!ConstraintOperands.empty()) {
6534 unsigned bestMAIndex = 0;
6535 int bestWeight = -1;
6541 for (maIndex = 0; maIndex < maCount; ++maIndex) {
6543 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
6544 cIndex != eIndex; ++cIndex) {
6553 if (OpInfo.hasMatchingInput()) {
6555 if (OpInfo.ConstraintVT !=
Input.ConstraintVT) {
6556 if ((OpInfo.ConstraintVT.isInteger() !=
6557 Input.ConstraintVT.isInteger()) ||
6558 (OpInfo.ConstraintVT.getSizeInBits() !=
6559 Input.ConstraintVT.getSizeInBits())) {
6570 weightSum += weight;
6573 if (weightSum > bestWeight) {
6574 bestWeight = weightSum;
6575 bestMAIndex = maIndex;
6582 cInfo.selectAlternative(bestMAIndex);
6587 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
6588 cIndex != eIndex; ++cIndex) {
6595 if (OpInfo.hasMatchingInput()) {
6598 if (OpInfo.ConstraintVT !=
Input.ConstraintVT) {
6599 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
6601 OpInfo.ConstraintVT);
6602 std::pair<unsigned, const TargetRegisterClass *> InputRC =
6604 Input.ConstraintVT);
6605 const bool OutOpIsIntOrFP = OpInfo.ConstraintVT.isInteger() ||
6606 OpInfo.ConstraintVT.isFloatingPoint();
6607 const bool InOpIsIntOrFP =
Input.ConstraintVT.isInteger() ||
6608 Input.ConstraintVT.isFloatingPoint();
6609 if ((OutOpIsIntOrFP != InOpIsIntOrFP) ||
6610 (MatchRC.second != InputRC.second)) {
6612 " with a matching output constraint of"
6613 " incompatible type!");
6619 return ConstraintOperands;
6654 if (maIndex >= (
int)
info.multipleAlternatives.size())
6655 rCodes = &
info.Codes;
6657 rCodes = &
info.multipleAlternatives[maIndex].Codes;
6661 for (
const std::string &rCode : *rCodes) {
6664 if (weight > BestWeight)
6665 BestWeight = weight;
6678 Value *CallOperandVal =
info.CallOperandVal;
6681 if (!CallOperandVal)
6684 switch (*constraint) {
6748 Ret.
reserve(OpInfo.Codes.size());
6781 "need immediate or other");
6786 std::vector<SDValue> ResultOps;
6787 TLI.LowerAsmOperandForConstraint(
Op,
P.first, ResultOps, *DAG);
6788 return !ResultOps.empty();
6796 assert(!OpInfo.Codes.empty() &&
"Must have at least one constraint");
6799 if (OpInfo.Codes.size() == 1) {
6800 OpInfo.ConstraintCode = OpInfo.Codes[0];
6807 unsigned BestIdx = 0;
6808 for (
const unsigned E =
G.size();
6815 if (BestIdx + 1 == E) {
6821 OpInfo.ConstraintCode =
G[BestIdx].first;
6822 OpInfo.ConstraintType =
G[BestIdx].second;
6826 if (OpInfo.ConstraintCode ==
"X" && OpInfo.CallOperandVal) {
6830 Value *v = OpInfo.CallOperandVal;
6836 OpInfo.ConstraintCode =
"i";
6843 OpInfo.ConstraintCode = Repl;
6857 EVT VT =
N->getValueType(0);
6861 bool UseSRA =
false;
6868 EVT CT =
C->getValueType(0);
6869 APInt Divisor =
C->getAPIntValue();
6891 "Expected matchUnaryPredicate to return one element for scalable "
6898 Factor = Factors[0];
6916 EVT VT =
N->getValueType(0);
6920 bool UseSRL =
false;
6927 EVT CT =
C->getValueType(0);
6928 APInt Divisor =
C->getAPIntValue();
6953 "Expected matchUnaryPredicate to return one element for scalable "
6960 Factor = Factors[0];
7003 EVT VT =
N->getValueType(0);
7039 bool IsAfterLegalization,
7040 bool IsAfterLegalTypes,
7045 if (
N->getFlags().hasExact())
7048 EVT VT =
N->getValueType(0);
7087 if (
isTypeLegal(VT) && !HasMULHS && !HasSMUL_LOHI && MulVT ==
EVT()) {
7099 if (!HasMULHS && !HasSMUL_LOHI && MulVT ==
EVT())
7105 if (IsAfterLegalTypes && VT.
isVector()) {
7122 APInt Divisor =
C->getAPIntValue().trunc(EltBits);
7124 int NumeratorFactor = 0;
7135 NumeratorFactor = 1;
7138 NumeratorFactor = -1;
7157 SDValue MagicFactor, Factor, Shift, ShiftMask;
7165 Shifts.
size() == 1 && ShiftMasks.
size() == 1 &&
7166 "Expected matchUnaryPredicate to return one element for scalable "
7174 MagicFactor = MagicFactors[0];
7175 Factor = Factors[0];
7177 ShiftMask = ShiftMasks[0];
7198 SDValue Q = GetMULHS(N0, MagicFactor);
7228 bool IsAfterLegalization,
7229 bool IsAfterLegalTypes,
7234 if (
N->getFlags().hasExact())
7237 EVT VT =
N->getValueType(0);
7276 if (
isTypeLegal(VT) && !HasMULHU && !HasUMUL_LOHI && MulVT ==
EVT()) {
7288 if (!HasMULHU && !HasUMUL_LOHI && MulVT ==
EVT())
7301 if (IsAfterLegalTypes && VT.
isVector()) {
7313 const EVT WideSVT = MVT::i64;
7314 const bool HasWideMULHU =
7317 const bool HasWideUMUL_LOHI =
7320 const bool AllowWiden = (HasWideMULHU || HasWideUMUL_LOHI);
7326 const bool AllowEvenToWiden = AllowWiden &&
isZExtFree(VT, WideSVT);
7328 bool UseNPQ =
false, UsePreShift =
false, UsePostShift =
false;
7329 bool UseWiden =
false;
7337 APInt Divisor =
C->getAPIntValue().trunc(EltBits);
7339 SDValue PreShift, MagicFactor, NPQFactor, PostShift;
7343 if (Divisor.
isOne()) {
7344 PreShift = PostShift = DAG.
getUNDEF(ShSVT);
7345 MagicFactor = NPQFactor = DAG.
getUNDEF(SVT);
7349 Divisor, std::min(KnownLeadingZeros, Divisor.
countl_zero()),
7361 "We shouldn't generate an undefined shift!");
7363 "We shouldn't generate an undefined shift!");
7365 "Unexpected pre-shift");
7372 UseNPQ |= magics.
IsAdd;
7373 UsePreShift |= magics.
PreShift != 0;
7389 SDValue PreShift, PostShift, MagicFactor, NPQFactor;
7397 NPQFactors.
size() == 1 && PostShifts.
size() == 1 &&
7398 "Expected matchUnaryPredicate to return one for scalable vectors");
7405 PreShift = PreShifts[0];
7406 MagicFactor = MagicFactors[0];
7407 PostShift = PostShifts[0];
7420 assert(HasWideUMUL_LOHI);
7423 WideN0, MagicFactor);
7455 Q = GetMULHU(Q, MagicFactor);
7468 NPQ = GetMULHU(NPQ, NPQFactor);
7487 return DAG.
getSelect(dl, VT, IsOne, N0, Q);
7501 if (SplatValue !=
Values.end()) {
7506 Replacement = *SplatValue;
7510 if (!AlternativeReplacement)
7513 Replacement = AlternativeReplacement;
7523SDValue TargetLowering::buildUREMEqFold(EVT SETCCVT,
SDValue REMNode,
7526 DAGCombinerInfo &DCI,
7527 const SDLoc &
DL)
const {
7531 for (SDNode *
N : Built)
7532 DCI.AddToWorklist(
N);
7540TargetLowering::prepareUREMEqFold(EVT SETCCVT,
SDValue REMNode,
7542 DAGCombinerInfo &DCI,
const SDLoc &
DL,
7543 SmallVectorImpl<SDNode *> &Created)
const {
7551 "Only applicable for (in)equality comparisons.");
7553 SelectionDAG &DAG = DCI.DAG;
7564 bool ComparingWithAllZeros =
true;
7565 bool AllComparisonsWithNonZerosAreTautological =
true;
7566 bool HadTautologicalLanes =
false;
7567 bool AllLanesAreTautological =
true;
7568 bool HadEvenDivisor =
false;
7569 bool AllDivisorsArePowerOfTwo =
true;
7570 bool HadTautologicalInvertedLanes =
false;
7573 auto BuildUREMPattern = [&](ConstantSDNode *CDiv, ConstantSDNode *CCmp) {
7579 const APInt &
Cmp = CCmp->getAPIntValue();
7581 ComparingWithAllZeros &=
Cmp.isZero();
7587 bool TautologicalInvertedLane =
D.ule(Cmp);
7588 HadTautologicalInvertedLanes |= TautologicalInvertedLane;
7593 bool TautologicalLane =
D.isOne() || TautologicalInvertedLane;
7594 HadTautologicalLanes |= TautologicalLane;
7595 AllLanesAreTautological &= TautologicalLane;
7601 AllComparisonsWithNonZerosAreTautological &= TautologicalLane;
7604 unsigned K =
D.countr_zero();
7605 assert((!
D.isOne() || (K == 0)) &&
"For divisor '1' we won't rotate.");
7606 APInt D0 =
D.lshr(K);
7609 HadEvenDivisor |= (
K != 0);
7612 AllDivisorsArePowerOfTwo &= D0.
isOne();
7616 unsigned W =
D.getBitWidth();
7618 assert((D0 *
P).isOne() &&
"Multiplicative inverse basic check failed.");
7631 "We are expecting that K is always less than all-ones for ShSVT");
7634 if (TautologicalLane) {
7658 if (AllLanesAreTautological)
7663 if (AllDivisorsArePowerOfTwo)
7668 if (HadTautologicalLanes) {
7683 "Expected matchBinaryPredicate to return one element for "
7694 if (!ComparingWithAllZeros && !AllComparisonsWithNonZerosAreTautological) {
7698 "Expecting that the types on LHS and RHS of comparisons match.");
7708 if (HadEvenDivisor) {
7721 if (!HadTautologicalInvertedLanes)
7727 assert(VT.
isVector() &&
"Can/should only get here for vectors.");
7734 SDValue TautologicalInvertedChannels =
7744 DL, SETCCVT, SETCCVT);
7746 Replacement, NewCC);
7754 TautologicalInvertedChannels);
7764SDValue TargetLowering::buildSREMEqFold(EVT SETCCVT,
SDValue REMNode,
7767 DAGCombinerInfo &DCI,
7768 const SDLoc &
DL)
const {
7772 assert(Built.
size() <= 7 &&
"Max size prediction failed.");
7773 for (SDNode *
N : Built)
7774 DCI.AddToWorklist(
N);
7782TargetLowering::prepareSREMEqFold(EVT SETCCVT,
SDValue REMNode,
7784 DAGCombinerInfo &DCI,
const SDLoc &
DL,
7785 SmallVectorImpl<SDNode *> &Created)
const {
7809 "Only applicable for (in)equality comparisons.");
7811 SelectionDAG &DAG = DCI.DAG;
7825 if (!CompTarget || !CompTarget->
isZero())
7828 bool HadOneDivisor =
false;
7829 bool AllDivisorsAreOnes =
true;
7830 bool HadEvenDivisor =
false;
7831 bool AllDivisorsArePowerOfTwo =
true;
7834 auto BuildSREMPattern = [&](ConstantSDNode *
C) {
7843 APInt
D =
C->getAPIntValue().abs();
7846 HadOneDivisor |=
D.isOne();
7847 AllDivisorsAreOnes &=
D.isOne();
7850 unsigned K =
D.countr_zero();
7851 assert((!
D.isOne() || (K == 0)) &&
"For divisor '1' we won't rotate.");
7852 APInt D0 =
D.
lshr(K);
7855 HadEvenDivisor |= (
K != 0);
7859 AllDivisorsArePowerOfTwo &= D0.
isOne();
7863 unsigned W =
D.getBitWidth();
7865 assert((D0 *
P).isOne() &&
"Multiplicative inverse basic check failed.");
7875 "We are expecting that A is always less than all-ones for SVT");
7877 "We are expecting that K is always less than all-ones for ShSVT");
7914 if (AllDivisorsAreOnes)
7919 if (AllDivisorsArePowerOfTwo)
7922 SDValue PVal, AVal, KVal, QVal;
7924 if (HadOneDivisor) {
7944 QAmts.
size() == 1 &&
7945 "Expected matchUnaryPredicate to return one element for scalable "
7973 if (HadEvenDivisor) {
7991 EVT VT =
Op.getValueType();
8016 bool LegalOps,
bool OptForSize,
8018 unsigned Depth)
const {
8022 return Op.getOperand(0);
8032 EVT VT =
Op.getValueType();
8033 unsigned Opcode =
Op.getOpcode();
8043 auto RemoveDeadNode = [&](
SDValue N) {
8044 if (
N &&
N.getNode()->use_empty())
8053 std::list<HandleSDNode> Handles;
8064 if (LegalOps && !IsOpLegal)
8093 return !N.isUndef() && !isa<ConstantFPSDNode>(N);
8101 return N.isUndef() ||
8102 isFPImmLegal(neg(cast<ConstantFPSDNode>(N)->getValueAPF()), VT,
8106 if (LegalOps && !IsOpLegal)
8123 if (!Flags.hasNoSignedZeros())
8137 Handles.emplace_back(NegX);
8148 if (NegX && (CostX <= CostY)) {
8152 RemoveDeadNode(NegY);
8161 RemoveDeadNode(NegX);
8168 if (!Flags.hasNoSignedZeros())
8193 Handles.emplace_back(NegX);
8204 if (NegX && (CostX <= CostY)) {
8208 RemoveDeadNode(NegY);
8214 if (
C->isExactlyValue(2.0) &&
Op.getOpcode() ==
ISD::FMUL)
8222 RemoveDeadNode(NegX);
8230 if (!Flags.hasNoSignedZeros())
8233 SDValue X =
Op.getOperand(0),
Y =
Op.getOperand(1), Z =
Op.getOperand(2);
8242 Handles.emplace_back(NegZ);
8250 Handles.emplace_back(NegX);
8261 if (NegX && (CostX <= CostY)) {
8262 Cost = std::min(CostX, CostZ);
8265 RemoveDeadNode(NegY);
8271 Cost = std::min(CostY, CostZ);
8274 RemoveDeadNode(NegX);
8284 return DAG.
getNode(Opcode,
DL, VT, NegV);
8300 RemoveDeadNode(NegLHS);
8305 Handles.emplace_back(NegLHS);
8318 RemoveDeadNode(NegLHS);
8319 RemoveDeadNode(NegRHS);
8323 Cost = std::min(CostLHS, CostRHS);
8324 return DAG.
getSelect(
DL, VT,
Op.getOperand(0), NegLHS, NegRHS);
8353 if (!HasMULHU && !HasMULHS && !HasUMUL_LOHI && !HasSMUL_LOHI)
8365 if ((
Signed && HasSMUL_LOHI) || (!
Signed && HasUMUL_LOHI)) {
8368 Hi =
Lo.getValue(1);
8394 if (MakeMUL_LOHI(LL, RL,
Lo,
Hi,
false)) {
8395 Result.push_back(
Lo);
8396 Result.push_back(
Hi);
8399 Result.push_back(
Zero);
8400 Result.push_back(
Zero);
8411 if (MakeMUL_LOHI(LL, RL,
Lo,
Hi,
true)) {
8412 Result.push_back(
Lo);
8413 Result.push_back(
Hi);
8418 unsigned ShiftAmount = OuterBitSize - InnerBitSize;
8433 if (!MakeMUL_LOHI(LL, RL,
Lo,
Hi,
false))
8436 Result.push_back(
Lo);
8443 Result.push_back(
Hi);
8456 if (!MakeMUL_LOHI(LL, RH,
Lo,
Hi,
false))
8463 if (!MakeMUL_LOHI(LH, RL,
Lo,
Hi,
false))
8516 N->getOperand(0),
N->getOperand(1), Result, HiLoVT,
8517 DAG, Kind, LL, LH, RL, RH);
8519 assert(Result.size() == 2);
8554bool TargetLowering::expandUDIVREMByConstantViaUREMDecomposition(
8557 unsigned Opcode =
N->getOpcode();
8558 EVT VT =
N->getValueType(0);
8566 unsigned TrailingZeros = 0;
8575 if (Divisor.
uge(HalfMaxPlus1))
8580 unsigned BestChunkWidth = 0, AltChunkWidth = 0;
8581 for (
unsigned I = HBitWidth,
E = HBitWidth / 2;
I >
E; --
I) {
8583 if (
I == HBitWidth - 1)
8595 if (
I != HBitWidth &&
Mod == Divisor - 1)
8599 bool Alternate =
false;
8600 if (!BestChunkWidth) {
8604 BestChunkWidth = AltChunkWidth;
8609 assert(!LL == !LH &&
"Expected both input halves or no input halves!");
8611 std::tie(LL, LH) = DAG.
SplitScalar(
N->getOperand(0), dl, HiLoVT, HiLoVT);
8616 assert(ShiftAmt > 0 && ShiftAmt < HBitWidth);
8634 if (ShiftAmt < HBitWidth) {
8635 Lo = GetFSHR(
Lo,
Hi, ShiftAmt);
8638 }
else if (ShiftAmt == HBitWidth) {
8651 SDValue PartialRemL, PartialRemH;
8652 if (TrailingZeros && Opcode !=
ISD::UDIV) {
8654 if (TrailingZeros < HBitWidth) {
8658 }
else if (TrailingZeros == HBitWidth) {
8673 if (BestChunkWidth == HBitWidth) {
8676 ShiftRight(LL, LH, TrailingZeros);
8682 SDVTList VTList = DAG.
getVTList(HiLoVT, SetCCType);
8705 for (
unsigned I = 0;
I <
BitWidth - TrailingZeros;
I += BestChunkWidth) {
8707 unsigned Shift =
I + TrailingZeros;
8711 else if (Shift >= HBitWidth)
8716 Chunk = GetFSHR(LL, LH, Shift);
8718 if (
I + BestChunkWidth <
BitWidth - TrailingZeros)
8724 unsigned ChunkNum =
I / BestChunkWidth;
8725 unsigned Opc = (Alternate && (ChunkNum % 2) != 0) ?
ISD::SUB : ISD::
ADD;
8726 Sum = DAG.
getNode(
Opc, dl, HiLoVT, Sum, Chunk);
8758 if (BestChunkWidth != HBitWidth)
8759 ShiftRight(LL, LH, TrailingZeros);
8776 std::tie(QuotL, QuotH) = DAG.
SplitScalar(Quotient, dl, HiLoVT, HiLoVT);
8784 if (TrailingZeros) {
8785 if (TrailingZeros < HBitWidth) {
8797 }
else if (TrailingZeros == HBitWidth) {
8819bool TargetLowering::expandUDIVREMByConstantViaUMulHiMagic(
8820 SDNode *
N,
const APInt &Divisor, SmallVectorImpl<SDValue> &Result,
8827 assert(!Divisor.
isOne() &&
"Magic algorithm does not work for division by 1");
8832 SmallVectorImpl<SDValue> &
Result) {
8836 return expandMUL_LOHI(
Opc, VT,
DL,
LHS,
RHS, Result, HiLoVT, DAG,
8846 DAG.
getVTList(HiLoVT, MVT::i1), LL, RL);
8851 DAG.
getVTList(HiLoVT, MVT::i1), LH, RH, Overflow);
8853 return std::make_pair(OutL, OutH);
8859 if (Shift < HBitWidth) {
8863 return std::make_pair(ResL, ResH);
8866 if (Shift == HBitWidth)
8867 return std::make_pair(LH,
Zero);
8868 assert(Shift - HBitWidth < HBitWidth &&
8869 "We shouldn't generate an undefined shift");
8878 Divisor, std::min(KnownLeadingZeros, Divisor.
countl_zero()));
8880 assert(!LL == !LH &&
"Expected both input halves or no input halves!");
8886 std::tie(QL, QH) = MakeSRLLong(QL, QH, Magics.
PreShift);
8896 auto [NPQL, NPQH] = MakeAddSubLong(
ISD::SUB, LL, LH, QL, QH);
8897 std::tie(NPQL, NPQH) = MakeSRLLong(NPQL, NPQH, 1);
8898 std::tie(QL, QH) = MakeAddSubLong(
ISD::ADD, NPQL, NPQH, QL, QH);
8902 std::tie(QL, QH) = MakeSRLLong(QL, QH, Magics.
PostShift);
8904 unsigned Opcode =
N->getOpcode();
8912 if (!MakeMUL_LOHIByConst(
ISD::MUL, QL, QH, Divisor, MulResult))
8918 MakeAddSubLong(
ISD::SUB, LL, LH, MulResult[0], MulResult[1]);
8931 unsigned Opcode =
N->getOpcode();
8938 "Unexpected opcode");
8944 APInt Divisor = CN->getAPIntValue();
8949 bool CanDecomposeUREMWithoutMulHi =
8952 RTLIB::Unsupported &&
8954 if (!CanDecomposeUREMWithoutMulHi &&
8967 if (expandUDIVREMByConstantViaUREMDecomposition(
N, Divisor, Result, HiLoVT,
8971 if (expandUDIVREMByConstantViaUMulHiMagic(
N, Divisor, Result, HiLoVT, DAG, LL,
8988 EVT VT =
Node->getValueType(0);
9004 EVT ShVT = Z.getValueType();
9073 EVT VT =
Node->getValueType(0);
9091 if (!AllowVectorOps && VT.
isVector() &&
9109 ShVal = DAG.
getNode(ShOpc,
DL, VT, Op0, ShAmt);
9111 HsVal = DAG.
getNode(HsOpc,
DL, VT, Op0, HsAmt);
9117 ShVal = DAG.
getNode(ShOpc,
DL, VT, Op0, ShAmt);
9138 EVT VT,
unsigned HalveDepth = 0,
9139 unsigned TotalDepth = 0) {
9144 if (!
TLI.isTypeLegal(VT))
9154 if (
TLI.isTypeLegal(HalfVT) &&
9162 if (
TLI.isTypeLegal(WideVT) &&
9171 EVT VT =
Node->getValueType(0);
9175 unsigned Opcode =
Node->getOpcode();
9190 unsigned HalfBW = BW / 2;
9275 const APInt &YVal =
C->getAPIntValue();
9279 for (
unsigned I = 1;
I <
N;
I <<= 1) {
9352 while (S < 32 &&
divideCeil(BW, S) > (1u << S))
9357 unsigned HolesCost = S * S + 3 * S + S * (S - 1) + (S - 1);
9361 unsigned NaiveCost = 0;
9362 for (
unsigned I = 0;
I < BW; ++
I) {
9380 if (HolesCost < NaiveCost &&
9390 for (
unsigned I = 0;
I < S; ++
I) {
9403 for (
unsigned I = 0;
I < S; ++
I) {
9405 for (
unsigned J = 0; J < S; ++J) {
9406 unsigned K = (
I + S - J) % S;
9423 for (
unsigned I = 0;
I < BW; ++
I) {
9491 unsigned ShAmt = Opcode ==
ISD::CLMULR ? BW - 1 : BW;
9511 if (!Flags.hasNoInfs()) {
9524 Results.push_back(ResultFrac);
9531 EVT VT =
Node->getValueType(0);
9548 for (
unsigned I = 1;
I < BW;
I *= 2) {
9570 EVT VT =
Node->getValueType(0);
9587 for (
unsigned S = 0; S < LogBW; ++S) {
9588 unsigned ShiftS = 1u << S;
9594 if (S + 1 < LogBW) {
9607 for (
int S = (
int)LogBW - 1; S >= 0; --S) {
9622 assert(
Node->getNumOperands() == 3 &&
"Not a double-shift!");
9623 EVT VT =
Node->getValueType(0);
9681 EVT VT =
Node->getValueType(0);
9684 Flags.setNoFPExcept(
true);
9696 EVT ResVT =
Node->getValueType(0);
9700 const uint64_t SemEnum =
Node->getConstantOperandVal(1);
9702 const auto RoundMode =
9704 const bool Saturate =
Node->getConstantOperandVal(3) != 0;
9717 "destination format (semantics enum " +
9718 Twine(SemEnum) +
")");
9723 switch (RoundMode) {
9732 "CONVERT_TO_ARBITRARY_FP: unsupported rounding mode (enum " +
9733 Twine(
static_cast<int>(RoundMode)) +
")");
9741 const unsigned DstMant = DstPrecision - 1;
9744 const unsigned DstExpBits = DstBits - (DstHasSign ? 1 : 0) - DstMant;
9746 const unsigned DstExpMax = (1U << DstExpBits) - 1;
9747 const uint64_t DstMantMask = (DstMant > 0) ? ((1ULL << DstMant) - 1) : 0;
9752 const unsigned DstExpMaxNormal =
9761 uint64_t DstMaxMantAtMaxExp = DstMantMask;
9764 DstMaxMantAtMaxExp = DstMantMask - 1;
9771 const unsigned SrcMant = SrcPrecision - 1;
9772 const uint64_t SrcMantMask = (1ULL << SrcMant) - 1;
9803 EVT FrexpExpScalarVT =
9823 switch (RoundMode) {
9863 if (SrcMant > DstMant) {
9864 const unsigned Shift = SrcMant - DstMant;
9894 RoundUp = ComputeRoundUp(RoundBit, StickyBits, LSB);
9909 DAG.
getSetCC(dl, SetCCVT, RoundedMant,
9944 int64_t MantDelta =
static_cast<int64_t
>(SrcMant) - DstMant;
9985 DenormRoundUp = ComputeRoundUp(DenormRoundBit, HasSticky, DenormLSB);
9990 DenormRoundUp = DAG.
getSelect(dl, IntVT, ShiftGEOne, DenormRoundUp,
Zero);
9999 DAG.
getSetCC(dl, SetCCVT, DenormRoundedMant,
10002 DAG.
getSelect(dl, IntVT, DenormMantOF,
Zero, DenormRoundedMant);
10026 DAG.
getSetCC(dl, SetCCVT, AdjMant,
10038 uint64_t MaxFinite =
10039 ((uint64_t)DstExpMaxNormal << DstMant) | DstMaxMantAtMaxExp;
10044 uint64_t InfBits = (uint64_t)DstExpMax << DstMant;
10058 DAG.
getNode(
ISD::OR, dl, IntVT, SignShifted, NormExpShifted), AdjMant);
10064 const uint64_t QNaNBit = (DstMant > 0) ? (1ULL << (DstMant - 1)) : 0;
10066 DAG.
getConstant(((uint64_t)DstExpMax << DstMant) | QNaNBit, dl, IntVT);
10070 NaNResult = DAG.
getConstant(((uint64_t)DstExpMax << DstMant) | DstMantMask,
10081 uint64_t InfBits = (uint64_t)DstExpMax << DstMant;
10084 }
else if (Saturate) {
10086 uint64_t MaxFinite =
10087 ((uint64_t)DstExpMaxNormal << DstMant) | DstMaxMantAtMaxExp;
10095 SDValue ZeroResult = SignShifted;
10099 DAG.
getSelect(dl, IntVT, ExpIsNeg, DenormResult, NormResult);
10103 SDValue Result = FiniteResult;
10104 Result = DAG.
getSelect(dl, IntVT, IsZero, ZeroResult, Result);
10105 Result = DAG.
getSelect(dl, IntVT, IsInf, InfResult, Result);
10111 if (!DstHasSign && Saturate) {
10114 Result = DAG.
getSelect(dl, IntVT, IsNegative,
Zero, Result);
10117 Result = DAG.
getSelect(dl, IntVT, IsNaN, NaNResult, Result);
10127 EVT DstVT =
Node->getValueType(0);
10131 const uint64_t SemEnum =
Node->getConstantOperandVal(1);
10145 "source format (semantics enum " +
10146 Twine(SemEnum) +
")");
10153 const unsigned SrcMant = SrcPrecision - 1;
10156 const unsigned SrcExp = SrcBits - (SrcHasSign ? 1 : 0) - SrcMant;
10164 const unsigned DstExpBits = DstBits - DstMant - 1;
10166 const int DstBias = 1 - DstMinExp;
10167 const uint64_t DstExpAllOnes = (1ULL << DstExpBits) - 1;
10171 EVT IntVT = IntScalarVT;
10183 "CONVERT_FROM_ARBITRARY_FP: the requested integer value type for its "
10184 "legalization is not supported");
10199 const uint64_t MantMask = (SrcMant > 0) ? ((1ULL << SrcMant) - 1) : 0;
10200 const uint64_t ExpMask = (1ULL << SrcExp) - 1;
10235 IsNaN = DAG.
getNode(
ISD::AND, dl, SetCCVT, IsExpAllOnes, IsMantNonZero);
10241 IsNaN = DAG.
getNode(
ISD::AND, dl, SetCCVT, IsExpAllOnes, IsMantAllOnes);
10246 IsInf = DAG.
getNode(
ISD::AND, dl, SetCCVT, IsExpAllOnes, IsMantZero);
10255 const int BiasAdjust = DstBias - SrcBias;
10262 if (DstMant > SrcMant) {
10265 NormDstMant = DAG.
getNode(
ISD::SHL, dl, IntVT, MantField, NormDstMantShift);
10267 NormDstMant = MantField;
10280 SDValue DenormResult = NormResult;
10281 if (BiasAdjust != 0) {
10286 const int DenormExpConst =
10287 (int)IntVTBits + DstBias - SrcBias - (
int)SrcMant;
10295 DAG.
getConstant(IntVTBits - 1, dl, IntVT), LeadingZeros);
10300 const unsigned ShiftSub = IntVTBits - 1 - DstMant;
10315 DAG.
getSelect(dl, IntVT, IsDenorm, DenormResult, NormResult);
10317 const uint64_t QNaNBit = (DstMant > 0) ? (1ULL << (DstMant - 1)) : 0;
10319 DAG.
getConstant((DstExpAllOnes << DstMant) | QNaNBit, dl, IntVT);
10323 DAG.
getConstant(DstExpAllOnes << DstMant, dl, IntVT));
10331 DAG.
getSetCC(dl, SetCCVT, NormDstExp,
10334 DAG.
getSelect(dl, IntVT, IsOverflow, InfResult, FiniteResult);
10337 SDValue ZeroResult = SignShifted;
10339 SDValue Result = FiniteResult;
10340 Result = DAG.
getSelect(dl, IntVT, IsZero, ZeroResult, Result);
10341 Result = DAG.
getSelect(dl, IntVT, IsInf, InfResult, Result);
10342 Result = DAG.
getSelect(dl, IntVT, IsNaN, NaNResult, Result);
10344 if (!DstVT.
bitsEq(IntVT)) {
10356 PtrInfo, IntScalarVT, Alignment);
10367 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
10369 EVT SrcVT = Src.getValueType();
10370 EVT DstVT =
Node->getValueType(0);
10374 if (SrcVT != MVT::f32 || DstVT != MVT::i64)
10377 if (
Node->isStrictFPOpcode())
10440 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
10443 EVT SrcVT = Src.getValueType();
10444 EVT DstVT =
Node->getValueType(0);
10465 if (
Node->isStrictFPOpcode()) {
10467 {
Node->getOperand(0), Src });
10468 Chain = Result.getValue(1);
10482 if (
Node->isStrictFPOpcode()) {
10484 Node->getOperand(0),
true);
10509 if (
Node->isStrictFPOpcode()) {
10511 { Chain, Src, FltOfs });
10543 if (
Node->isStrictFPOpcode())
10547 EVT SrcVT = Src.getValueType();
10548 EVT DstVT =
Node->getValueType(0);
10552 if (
Node->getFlags().hasNonNeg() &&
10600 unsigned Opcode =
Node->getOpcode();
10605 if (
Node->getFlags().hasNoNaNs()) {
10607 EVT VT =
Node->getValueType(0);
10626 EVT VT =
Node->getValueType(0);
10629 "Expanding fminnum/fmaxnum for scalable vectors is undefined.");
10639 if (!
Node->getFlags().hasNoNaNs()) {
10652 return DAG.
getNode(NewOp, dl, VT, Quiet0, Quiet1,
Node->getFlags());
10657 if (
Node->getFlags().hasNoNaNs() ||
10660 unsigned IEEE2018Op =
10663 return DAG.
getNode(IEEE2018Op, dl, VT,
Node->getOperand(0),
10664 Node->getOperand(1),
Node->getFlags());
10682 if (!
TLI.isTypeLegal(IntVT) &&
10697 unsigned Opc =
N->getOpcode();
10698 EVT VT =
N->getValueType(0);
10711 bool MinMaxMustRespectOrderedZero =
false;
10715 MinMaxMustRespectOrderedZero =
true;
10729 if (!
N->getFlags().hasNoNaNs() &&
10738 if (!MinMaxMustRespectOrderedZero && !
N->getFlags().hasNoSignedZeros() &&
10755 unsigned Opc =
Node->getOpcode();
10756 EVT VT =
Node->getValueType(0);
10765 if (!Flags.hasNoNaNs()) {
10776 return DAG.
getNode(NewOp,
DL, VT, LHS, RHS, Flags);
10781 if (Flags.hasNoNaNs() ||
10783 unsigned IEEE2019Op =
10786 return DAG.
getNode(IEEE2019Op,
DL, VT, LHS, RHS, Flags);
10791 if ((Flags.hasNoNaNs() ||
10797 return DAG.
getNode(IEEE2008Op,
DL, VT, LHS, RHS, Flags);
10842 bool IsOrdered = NanTest ==
fcNone;
10843 bool IsUnordered = NanTest ==
fcNan;
10846 if (!IsOrdered && !IsUnordered)
10847 return std::nullopt;
10849 if (OrderedMask ==
fcZero &&
10855 return std::nullopt;
10862 EVT OperandVT =
Op.getValueType();
10874 if (OperandVT == MVT::ppcf128) {
10877 OperandVT = MVT::f64;
10884 bool IsF80 = (ScalarFloatVT == MVT::f80);
10888 if (Flags.hasNoFPExcept() &&
10891 bool IsInvertedFP =
false;
10895 FPTestMask = InvertedFPCheck;
10896 IsInvertedFP =
true;
10908 OrderedFPTestMask = FPTestMask;
10910 const bool IsOrdered = FPTestMask == OrderedFPTestMask;
10912 if (std::optional<bool> IsCmp0 =
10915 *IsCmp0 ? OrderedCmpOpcode : UnorderedCmpOpcode,
10922 *IsCmp0 ? OrderedCmpOpcode : UnorderedCmpOpcode);
10925 if (FPTestMask ==
fcNan &&
10931 bool IsOrderedInf = FPTestMask ==
fcInf;
10934 : UnorderedCmpOpcode,
10945 IsOrderedInf ? OrderedCmpOpcode : UnorderedCmpOpcode);
10950 : UnorderedCmpOpcode,
10961 IsOrdered ? OrderedCmpOpcode : UnorderedCmpOpcode);
10980 return DAG.
getSetCC(
DL, ResultVT, Abs, SmallestNormal,
10981 IsOrdered ? OrderedOp : UnorderedOp);
11004 DAG.
getSetCC(
DL, ResultVT, Abs, SmallestNormal, IsNormalOp);
11006 return DAG.
getNode(LogicOp,
DL, ResultVT, IsFinite, IsNormal);
11013 bool IsInverted =
false;
11016 Test = InvertedCheck;
11030 const unsigned ExplicitIntBitInF80 = 63;
11031 APInt ExpMask = Inf;
11033 ExpMask.
clearBit(ExplicitIntBitInF80);
11035 APInt QNaNBitMask =
11047 const auto appendResult = [&](
SDValue PartialRes) {
11057 const auto getIntBitIsSet = [&]() ->
SDValue {
11058 if (!IntBitIsSetV) {
11059 APInt IntBitMask(BitSize, 0);
11060 IntBitMask.
setBit(ExplicitIntBitInF80);
11065 return IntBitIsSetV;
11086 "finite check requires IEEE-like FP");
11104 appendResult(PartialRes);
11113 appendResult(ExpIsZero);
11120 if (
unsigned PartialCheck =
Test &
fcZero) {
11123 else if (PartialCheck ==
fcZero)
11127 appendResult(PartialRes);
11140 appendResult(PartialRes);
11143 if (
unsigned PartialCheck =
Test &
fcInf) {
11146 else if (PartialCheck ==
fcInf)
11153 appendResult(PartialRes);
11156 if (
unsigned PartialCheck =
Test &
fcNan) {
11157 APInt InfWithQnanBit = Inf | QNaNBitMask;
11159 if (PartialCheck ==
fcNan) {
11172 }
else if (PartialCheck ==
fcQNan) {
11184 appendResult(PartialRes);
11189 APInt ExpLSB = ExpMask & ~(ExpMask.
shl(1));
11192 APInt ExpLimit = ExpMask - ExpLSB;
11205 appendResult(PartialRes);
11219 return TLI.isOperationLegalOrCustom(
ISD::ADD, VT) &&
11222 (Len == 8 ||
TLI.isOperationLegalOrCustom(
ISD::MUL, VT)) &&
11223 TLI.isOperationLegalOrCustomOrPromote(
ISD::AND, VT);
11228 EVT VT =
Node->getValueType(0);
11236 unsigned LZ =
Known.countMinLeadingZeros();
11237 unsigned TZ =
Known.countMinTrailingZeros();
11238 unsigned ShiftedActiveBits =
Known.getBitWidth() - (LZ + TZ);
11241 unsigned EffectiveLen = Len;
11242 if (ShiftedActiveBits > 0 && ShiftedActiveBits < Len)
11243 EffectiveLen = std::min(
alignTo(ShiftedActiveBits, 8), Len);
11248 if (!(Len <= 128 && Len % 8 == 0))
11256 if (EffectiveLen < Len && TZ > 0) {
11289 if (EffectiveLen <= 8)
11295 if (EffectiveLen == 16 && !VT.
isVector()) {
11313 for (
unsigned Shift = 8; Shift < EffectiveLen; Shift *= 2) {
11324 EVT VT =
Node->getValueType(0);
11341 return DAG.
getSelect(dl, VT, SrcIsZero,
11363 for (
unsigned i = 0; (1U << i) < NumBitsPerElt; ++i) {
11374 EVT VT =
Node->getValueType(0);
11400 :
APInt(64, 0x0218A392CD3D5DBFULL);
11413 for (
unsigned i = 0; i <
BitWidth; i++) {
11439 EVT VT =
Node->getValueType(0);
11455 return DAG.
getSelect(dl, VT, SrcIsZero,
11516 SDValue Source =
N->getOperand(0);
11519 EVT SrcVT = Source.getValueType();
11520 EVT ResVT =
N->getValueType(0);
11536 return DAG.
getNode(ISD::VP_REDUCE_UMIN,
DL, ResVT, ExtEVL,
Select, Mask, EVL);
11544static std::pair<SDValue, SDValue>
11547 EVT MaskVT = Mask.getValueType();
11556 uint64_t EltWidth =
TLI.getBitWidthForCttzElements(
11573 StepVecVT =
TLI.getTypeToTransformTo(*DAG.
getContext(), StepVecVT);
11598 return {Mask, StepVec};
11605 N->getOperand(0),
true,
DL, DAG);
11610 EVT MaskVT =
N->getOperand(0).getValueType();
11611 EVT ResVT =
N->getValueType(0);
11641 EVT StepVecVT = StepVec.getValueType();
11658 EVT VT =
N->getValueType(0);
11659 EVT OpVT = Start.getValueType();
11689 StepVector.getValueType());
11692 StepVector.getValueType());
11693 if (Mask.getValueType() != VT)
11701 EVT VT =
N->getValueType(0);
11702 SDValue SourceValue =
N->getOperand(0);
11703 SDValue SinkValue =
N->getOperand(1);
11704 SDValue EltSizeInBytes =
N->getOperand(2);
11717 SDValue SourceAheadOfOrEqualToSink =
11725 if (IsReadAfterWrite)
11726 Diff = DAG.
getSelect(
DL, AddrVT, SourceAheadOfOrEqualToSink,
11734 SDValue NoAlias = SourceAheadOfOrEqualToSink;
11735 if (IsReadAfterWrite)
11742 DL, AddrVT, NoAlias,
11751 bool IsNegative)
const {
11753 EVT VT =
N->getValueType(0);
11816 EVT VT =
N->getValueType(0);
11819 bool IsSigned =
N->getOpcode() ==
ISD::ABDS;
11899 EVT VT =
N->getValueType(0);
11903 unsigned Opc =
N->getOpcode();
11912 "Unknown AVG node");
11924 return DAG.
getNode(ShiftOpc, dl, VT, Sum,
11932 LHS = DAG.
getNode(ExtOpc, dl, ExtVT, LHS);
11933 RHS = DAG.
getNode(ExtOpc, dl, ExtVT, RHS);
11961 ISD::SHL, dl, VT, ZeroExtOverflow,
11982 EVT VT =
N->getValueType(0);
11989 SDValue Tmp1, Tmp2, Tmp3, Tmp4, Tmp5, Tmp6, Tmp7, Tmp8;
12056 EVT VT =
N->getValueType(0);
12099 for (
unsigned I = 0, J = Sz-1;
I < Sz; ++
I, --J) {
12115std::pair<SDValue, SDValue>
12119 SDValue Chain = LD->getChain();
12120 SDValue BasePTR = LD->getBasePtr();
12121 EVT SrcVT = LD->getMemoryVT();
12122 EVT DstVT = LD->getValueType(0);
12153 ISD::EXTLOAD, SL, LoadVT, Chain, BasePTR, LD->getPointerInfo(),
12154 SrcIntVT, LD->getBaseAlign(), LD->getMemOperand()->getFlags(),
12155 LD->getMMOMetadataForSubAccess());
12158 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
12159 unsigned ShiftIntoIdx =
12170 Scalar = DAG.
getNode(ExtendOp, SL, DstEltVT, Scalar);
12177 return std::make_pair(
Value,
Load.getValue(1));
12186 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
12188 ExtType, SL, DstEltVT, Chain, BasePTR,
12189 LD->getPointerInfo().getWithOffset(Idx * Stride), SrcEltVT,
12190 LD->getBaseAlign(), LD->getMemOperand()->getFlags(),
12191 LD->getMMOMetadataForSubAccess());
12202 return std::make_pair(
Value, NewChain);
12209 SDValue Chain = ST->getChain();
12210 SDValue BasePtr = ST->getBasePtr();
12212 EVT StVT = ST->getMemoryVT();
12238 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
12242 unsigned ShiftIntoIdx =
12251 return DAG.
getStore(Chain, SL, CurrVal, BasePtr, ST->getPointerInfo(),
12252 ST->getBaseAlign(), ST->getMemOperand()->getFlags(),
12253 ST->getMMOMetadataForSubAccess());
12258 assert(Stride &&
"Zero stride!");
12262 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
12270 Chain, SL, Elt, Ptr, ST->getPointerInfo().getWithOffset(Idx * Stride),
12271 MemSclVT, ST->getBaseAlign(), ST->getMemOperand()->getFlags(),
12272 ST->getMMOMetadataForSubAccess());
12280std::pair<SDValue, SDValue>
12283 "unaligned indexed loads not implemented!");
12284 SDValue Chain = LD->getChain();
12285 SDValue Ptr = LD->getBasePtr();
12286 EVT VT = LD->getValueType(0);
12287 EVT LoadedVT = LD->getMemoryVT();
12303 LD->getMemOperand());
12305 if (LoadedVT != VT)
12309 return std::make_pair(Result, newLoad.
getValue(1));
12317 unsigned NumRegs = (LoadedBytes + RegBytes - 1) / RegBytes;
12323 SDValue StackPtr = StackBase;
12327 EVT StackPtrVT = StackPtr.getValueType();
12333 for (
unsigned i = 1; i < NumRegs; i++) {
12336 RegVT, dl, Chain, Ptr, LD->getPointerInfo().getWithOffset(
Offset),
12337 LD->getBaseAlign(), LD->getMemOperand()->getFlags(),
12338 LD->getMMOMetadataForSubAccess());
12341 Load.getValue(1), dl,
Load, StackPtr,
12352 8 * (LoadedBytes -
Offset));
12355 LD->getPointerInfo().getWithOffset(
Offset), MemVT, LD->getBaseAlign(),
12356 LD->getMemOperand()->getFlags(), LD->getMMOMetadataForSubAccess());
12361 Load.getValue(1), dl,
Load, StackPtr,
12368 Load = DAG.
getExtLoad(LD->getExtensionType(), dl, VT, TF, StackBase,
12373 return std::make_pair(
Load, TF);
12377 "Unaligned load of unsupported type.");
12386 Align Alignment = LD->getBaseAlign();
12387 unsigned IncrementSize = NumBits / 8;
12398 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
12399 LD->getMMOMetadataForSubAccess());
12403 LD->getPointerInfo().getWithOffset(IncrementSize),
12404 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
12405 LD->getMMOMetadataForSubAccess());
12407 Hi = DAG.
getExtLoad(HiExtType, dl, VT, Chain, Ptr, LD->getPointerInfo(),
12408 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
12409 LD->getMMOMetadataForSubAccess());
12413 LD->getPointerInfo().getWithOffset(IncrementSize),
12414 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
12415 LD->getMMOMetadataForSubAccess());
12426 return std::make_pair(Result, TF);
12432 "unaligned indexed stores not implemented!");
12433 SDValue Chain = ST->getChain();
12434 SDValue Ptr = ST->getBasePtr();
12435 SDValue Val = ST->getValue();
12437 Align Alignment = ST->getBaseAlign();
12439 EVT StoreMemVT = ST->getMemoryVT();
12455 Result = DAG.
getStore(Chain, dl, Result, Ptr, ST->getPointerInfo(),
12456 Alignment, ST->getMemOperand()->getFlags(),
12457 ST->getMMOMetadataForSubAccess());
12468 unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes;
12476 Chain, dl, Val, StackPtr,
12479 EVT StackPtrVT = StackPtr.getValueType();
12487 for (
unsigned i = 1; i < NumRegs; i++) {
12490 RegVT, dl,
Store, StackPtr,
12495 ST->getPointerInfo().getWithOffset(
Offset), ST->getBaseAlign(),
12496 ST->getMemOperand()->getFlags(), ST->getMMOMetadataForSubAccess()));
12516 ST->getPointerInfo().getWithOffset(
Offset), LoadMemVT,
12517 ST->getBaseAlign(), ST->getMemOperand()->getFlags(),
12518 ST->getMMOMetadataForSubAccess()));
12525 "Unaligned store of unknown type.");
12529 unsigned IncrementSize = NumBits / 8;
12549 ST->getPointerInfo(), NewStoredVT, Alignment,
12550 ST->getMemOperand()->getFlags(), ST->getMMOMetadataForSubAccess());
12555 ST->getPointerInfo().getWithOffset(IncrementSize), NewStoredVT, Alignment,
12556 ST->getMemOperand()->getFlags(), ST->getMMOMetadataForSubAccess());
12567 bool IsCompressedMemory)
const {
12570 EVT MaskVT = Mask.getValueType();
12572 "Incompatible types of Data and Mask");
12573 if (IsCompressedMemory) {
12586 MaskIntVT = MVT::i32;
12605 "Cannot index a scalable vector within a fixed-width vector");
12607 EVT IdxVT = Idx.getValueType();
12629 unsigned SubOpcode =
12642 DAG, VecPtr, VecVT,
12644 Index, PtrArithFlags);
12660 "Converting bits to bytes lost precision");
12662 "Sub-vector must be a vector with matching element type");
12665 "Subvector Index must be constant!");
12673 EVT IdxVT = Index.getValueType();
12705 assert(EmuTlsVar &&
"Cannot find EmuTlsVar ");
12706 Args.emplace_back(DAG.
getGlobalAddress(EmuTlsVar, dl, PtrVT), VoidPtrType);
12713 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
12722 "Emulated TLS must have zero offset in GlobalAddressSDNode");
12723 return CallResult.first;
12734 EVT VT =
Op.getOperand(0).getValueType();
12736 if (VT.
bitsLT(MVT::i32)) {
12754 unsigned Opcode =
Node->getOpcode();
12761 return DAG.
getNode(AltOpcode,
DL, VT, Op0, Op1);
12802 {Op0, Op1, DAG.getCondCode(CC)})) {
12809 {Op0, Op1, DAG.getCondCode(CC)})) {
12837 unsigned Opcode =
Node->getOpcode();
12840 EVT VT = LHS.getValueType();
12843 assert(VT == RHS.getValueType() &&
"Expected operands to be the same type");
12873 unsigned OverflowOp;
12888 llvm_unreachable(
"Expected method to receive signed or unsigned saturation "
12889 "addition or subtraction node.");
12897 unsigned BitWidth = LHS.getScalarValueSizeInBits();
12900 SDValue SumDiff = Result.getValue(0);
12901 SDValue Overflow = Result.getValue(1);
12927 "Expected signed saturating add/sub opcode");
12943 bool RHSIsNonNegative =
12945 if (LHSIsNonNegative || RHSIsNonNegative) {
12947 return DAG.
getSelect(dl, VT, Overflow, SatMax, SumDiff);
12951 bool RHSIsNegative =
12953 if (LHSIsNegative || RHSIsNegative) {
12955 return DAG.
getSelect(dl, VT, Overflow, SatMin, SumDiff);
12963 return DAG.
getSelect(dl, VT, Overflow, Result, SumDiff);
12967 unsigned Opcode =
Node->getOpcode();
12970 EVT VT = LHS.getValueType();
12971 EVT ResVT =
Node->getValueType(0);
13003 unsigned Opcode =
Node->getOpcode();
13007 EVT VT = LHS.getValueType();
13012 "Expected a SHLSAT opcode");
13044 EVT VT = LHS.getValueType();
13045 assert(RHS.getValueType() == VT &&
"Mismatching operand types");
13047 assert((HiLHS && HiRHS) || (!HiLHS && !HiRHS));
13049 "Signed flag should only be set when HiLHS and RiRHS are null");
13057 unsigned HalfBits = Bits / 2;
13102 EVT VT = LHS.getValueType();
13103 assert(RHS.getValueType() == VT &&
"Mismatching operand types");
13107 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
13108 if (WideVT == MVT::i16)
13109 LC = RTLIB::MUL_I16;
13110 else if (WideVT == MVT::i32)
13111 LC = RTLIB::MUL_I32;
13112 else if (WideVT == MVT::i64)
13113 LC = RTLIB::MUL_I64;
13114 else if (WideVT == MVT::i128)
13115 LC = RTLIB::MUL_I128;
13118 if (LibcallImpl == RTLIB::Unsupported) {
13161 SDValue Args[] = {LHS, HiLHS, RHS, HiRHS};
13162 Ret =
makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
13164 SDValue Args[] = {HiLHS, LHS, HiRHS, RHS};
13165 Ret =
makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
13168 "Ret value is a collection of constituent nodes holding result.");
13185 "Expected a fixed point multiplication opcode");
13190 EVT VT = LHS.getValueType();
13191 unsigned Scale =
Node->getConstantOperandVal(2);
13207 SDValue Product = Result.getValue(0);
13208 SDValue Overflow = Result.getValue(1);
13219 Result = DAG.
getSelect(dl, VT, ProdNeg, SatMin, SatMax);
13220 return DAG.
getSelect(dl, VT, Overflow, Result, Product);
13224 SDValue Product = Result.getValue(0);
13225 SDValue Overflow = Result.getValue(1);
13229 return DAG.
getSelect(dl, VT, Overflow, SatMax, Product);
13234 "Expected scale to be less than the number of bits if signed or at "
13235 "most the number of bits if unsigned.");
13236 assert(LHS.getValueType() == RHS.getValueType() &&
13237 "Expected both operands to be the same type");
13256 Lo = Result.getValue(0);
13257 Hi = Result.getValue(1);
13260 Hi = DAG.
getNode(HiOp, dl, VT, LHS, RHS);
13278 if (Scale == VTSize)
13301 return getSaturatingSelect(
Hi, LowMask, DAG.
getConstant(MaxVal, dl, VT),
13321 return DAG.
getSelect(dl, VT, Overflow, ResultIfOverflow, Result);
13334 Result = getSaturatingSelect(
Hi, LowMask, SatMax, Result,
ISD::SETGT);
13335 Result = getSaturatingSelect(
Hi, HighMask, SatMin, Result,
ISD::SETLT);
13345 "Expected a fixed point division opcode");
13347 EVT VT = LHS.getValueType();
13369 if (LHSLead + RHSTrail < Scale + (
unsigned)(Saturating &&
Signed))
13372 unsigned LHSShift = std::min(LHSLead, Scale);
13373 unsigned RHSShift = Scale - LHSShift;
13437 { LHS, RHS, CarryIn });
13444 LHS.getValueType(), LHS, RHS);
13446 EVT ResultType =
Node->getValueType(1);
13457 DAG.
getSetCC(dl, SetCCType, Result,
13466 SetCC = DAG.
getSetCC(dl, SetCCType, Result, LHS,
CC);
13479 LHS.getValueType(), LHS, RHS);
13481 EVT ResultType =
Node->getValueType(1);
13488 SDValue Sat = DAG.
getNode(OpcSat, dl, LHS.getValueType(), LHS, RHS);
13504 DAG.
getNode(
ISD::XOR, dl, OType, RHSNegative, ResultLowerThanLHS), dl,
13505 ResultType, ResultType);
13512 DAG.
getNode(
ISD::XOR, dl, OType, LHSLessThanRHS, ResultNegative), dl,
13513 ResultType, ResultType);
13520 EVT VT =
Node->getValueType(0);
13528 const APInt &
C = RHSC->getAPIntValue();
13530 if (
C.isPowerOf2()) {
13532 bool UseArithShift =
isSigned && !
C.isMinSignedValue();
13535 Overflow = DAG.
getSetCC(dl, SetCCVT,
13537 dl, VT, Result, ShiftAmt),
13547 static const unsigned Ops[2][3] =
13573 Result = BottomHalf;
13580 Overflow = DAG.
getSetCC(dl, SetCCVT, TopHalf,
13585 EVT RType =
Node->getValueType(1);
13590 "Unexpected result type for S/UMULO legalization");
13596 EVT VT =
Node->getValueType(0);
13634 EVT VT =
Op.getValueType();
13639 bool WidenSrc =
false;
13640 switch (
Node->getOpcode()) {
13693 "Expanding reductions for scalable vectors is undefined.");
13702 for (
unsigned i = 1; i < NumElts; i++)
13703 Res = DAG.
getNode(BaseOpcode, dl, EltVT, Res,
Ops[i], Flags);
13706 if (EltVT !=
Node->getValueType(0))
13722 "Expanding reductions for scalable vectors is undefined.");
13732 for (
unsigned i = 0; i < NumElts; i++)
13733 Res = DAG.
getNode(BaseOpcode, dl, EltVT, Res,
Ops[i], Flags);
13740 EVT VT =
Node->getValueType(0);
13749 Result = DAG.
getNode(DivRemOpc, dl, VTs, Dividend, Divisor).
getValue(1);
13754 SDValue Divide = DAG.
getNode(DivOpc, dl, VT, Dividend, Divisor);
13769 EVT SrcVT = Src.getValueType();
13770 EVT DstVT =
Node->getValueType(0);
13775 assert(SatWidth <= DstWidth &&
13776 "Expected saturation width smaller than result width");
13780 APInt MinInt, MaxInt;
13791 if (SrcVT == MVT::f16 || SrcVT == MVT::bf16) {
13793 SrcVT = Src.getValueType();
13813 auto EmitMinMax = [&](
unsigned MinOpcode,
unsigned MaxOpcode,
13814 bool MayPropagateNaN) {
13824 Clamped = DAG.
getNode(MaxOpcode, dl, SrcVT, Clamped, MinFloatNode);
13826 Clamped = DAG.
getNode(MinOpcode, dl, SrcVT, Clamped, MaxFloatNode);
13829 dl, DstVT, Clamped);
13833 if (!MayPropagateNaN && !IsSigned)
13841 return DAG.
getSelect(dl, DstVT, IsNan, ZeroInt, FpToInt);
13843 if (AreExactFloatBounds) {
13893 EVT OperandVT =
Op.getValueType();
13919 Op.getValueType());
13923 KeepNarrow = DAG.
getNode(
ISD::OR, dl, WideSetCCVT, KeepNarrow, AlreadyOdd);
13934 SDValue Adjust = DAG.
getSelect(dl, ResultIntVT, NarrowIsRd, One, NegativeOne);
13936 Op = DAG.
getSelect(dl, ResultIntVT, KeepNarrow, NarrowBits, Adjusted);
13943 EVT VT =
Node->getValueType(0);
13946 if (
Node->getConstantOperandVal(1) == 1) {
13949 EVT OperandVT =
Op.getValueType();
13957 EVT I32 =
F32.changeTypeToInteger();
13972 if (!
Node->getFlags().hasNoNaNs() &&
14000 EVT VT =
Node->getValueType(0);
14001 unsigned Factor =
Node->getNumOperands();
14004 if (Factor > 2 && Factor % 2 == 0) {
14009 for (
unsigned I = 0;
I < Factor / 2;
I++) {
14012 {
Node->getOperand(
I),
Node->getOperand(
I + Factor / 2)});
14020 for (
unsigned I = 0;
I < Factor / 2;
I++)
14022 for (
unsigned I = 0;
I < Factor / 2;
I++)
14036 for (
unsigned I = 0;
I != Factor; ++
I)
14038 VT,
DL,
Node->getOperand(0),
Node->getOperand(1),
14044 InterleavedElts.
reserve(Factor * NumElts);
14045 for (
unsigned EltIdx = 0; EltIdx != NumElts; ++EltIdx)
14046 for (
unsigned OperandIdx = 0; OperandIdx != Factor; ++OperandIdx)
14048 DL, EltVT,
Node->getOperand(OperandIdx), EltIdx));
14050 for (
unsigned ResultIdx = 0; ResultIdx != Factor; ++ResultIdx)
14052 VT,
DL,
ArrayRef(InterleavedElts).slice(ResultIdx * NumElts, NumElts)));
14059 EVT VT =
Node->getValueType(0);
14060 unsigned Factor =
Node->getNumOperands();
14063 if (Factor > 2 && Factor % 2 == 0) {
14075 for (
unsigned I = 0;
I < Factor / 2; ++
I) {
14077 {L.getValue(
I), R.getValue(
I)});
14092 for (
unsigned I = 0;
I != Factor; ++
I)
14100 ConcatElts.
reserve(Factor * NumElts);
14101 for (
unsigned OperandIdx = 0; OperandIdx != Factor; ++OperandIdx)
14102 for (
unsigned EltIdx = 0; EltIdx != NumElts; ++EltIdx)
14104 DL, EltVT,
Node->getOperand(OperandIdx), EltIdx));
14107 DeinterleavedElts.
reserve(Factor * NumElts);
14108 for (
unsigned ResultIdx = 0; ResultIdx != Factor; ++ResultIdx) {
14109 for (
unsigned EltIdx = 0; EltIdx != NumElts; ++EltIdx)
14110 DeinterleavedElts.
push_back(ConcatElts[ResultIdx + EltIdx * Factor]);
14113 ArrayRef(DeinterleavedElts).slice(ResultIdx * NumElts, NumElts)));
14121 "Unexpected opcode!");
14122 assert((
Node->getValueType(0).isScalableVector() ||
14124 "Fixed length vector types with constant offsets expected to use "
14125 "SHUFFLE_VECTOR!");
14127 EVT VT =
Node->getValueType(0);
14148 EVT PtrVT = StackPtr.getValueType();
14160 DAG.
getStore(StoreV1,
DL, V2, StackPtr2, PtrInfo, Alignment);
14176 return DAG.
getLoad(VT,
DL, StoreV2, StackPtr,
14189 EVT MaskVT = Mask.getValueType();
14206 bool HasPassthru = !Passthru.
isUndef();
14212 Chain = DAG.
getStore(Chain,
DL, Passthru, StackPtr, PtrInfo, Alignment);
14215 APInt PassthruSplatVal;
14216 bool IsSplatPassthru =
14219 if (IsSplatPassthru) {
14223 LastWriteVal = DAG.
getConstant(PassthruSplatVal,
DL, ScalarVT);
14224 }
else if (HasPassthru) {
14240 ScalarVT,
DL, Chain, LastElmtPtr,
14246 for (
unsigned I = 0;
I < NumElms;
I++) {
14250 Chain,
DL, ValI, OutPtr,
14262 if (HasPassthru &&
I == NumElms - 1) {
14272 LastWriteVal = DAG.
getSelect(
DL, ScalarVT, AllLanesSelected, ValI,
14275 Chain,
DL, LastWriteVal, OutPtr,
14280 return DAG.
getLoad(VecVT,
DL, Chain, StackPtr, PtrInfo, Alignment);
14285 EVT VT =
Node->getValueType(0);
14297 EVT ResVT =
Node->getValueType(0);
14311 return DAG.
getSelect(
DL, ResVT, ResLoNotNumElts, ResLo, Sum);
14314 EVT StepVecVT = StepVec.getValueType();
14336 SDValue Source =
N->getOperand(0);
14337 SDValue Needle =
N->getOperand(1);
14339 EVT SourceVT = Source.getValueType();
14341 EVT ResVT =
N->getValueType(0);
14351 if (NeedleVT == SourceVT) {
14354 SourceVT,
DL, Needle, DAG.
getUNDEF(SourceVT),
14368 UseVT =
N->user_begin()->getValueType(0);
14374 if (UseVT != ResVT)
14383 SDValue MulLHS =
N->getOperand(1);
14384 SDValue MulRHS =
N->getOperand(2);
14392 unsigned ExtOpcLHS, ExtOpcRHS;
14393 switch (
N->getOpcode()) {
14413 unsigned Opc =
N->getOpcode();
14416 unsigned CountRatio =
14418 unsigned WidthRatio =
14437 DAG.
getNode(ExtOpcLHS,
DL, ProdVT, MulLHS),
14438 DAG.
getNode(ExtOpcRHS,
DL, ProdVT, MulRHS));
14443 EVT MidVT =
Lo.getValueType()
14444 .widenIntegerVectorElementType(Ctx)
14445 .getHalfNumVectorElementsVT(Ctx);
14455 if (ExtMulOpVT != MulOpVT) {
14456 MulLHS = DAG.
getNode(ExtOpcLHS,
DL, ExtMulOpVT, MulLHS);
14457 MulRHS = DAG.
getNode(ExtOpcRHS,
DL, ExtMulOpVT, MulRHS);
14473 std::deque<SDValue> Subvectors = {Acc};
14474 for (
unsigned I = 0;
I < ScaleFactor;
I++)
14477 unsigned FlatNode =
14481 while (Subvectors.size() > 1) {
14482 Subvectors.push_back(DAG.
getNode(FlatNode,
DL, AccVT,
14483 {Subvectors[0], Subvectors[1]}, Flags));
14484 Subvectors.pop_front();
14485 Subvectors.pop_front();
14488 assert(Subvectors.size() == 1 &&
14489 "There should only be one subvector after tree flattening");
14491 return Subvectors[0];
14504 if (
Op.getNode() != FPNode)
14508 while (!Worklist.
empty()) {
14542 std::optional<unsigned> CallRetResNo)
const {
14543 if (LC == RTLIB::UNKNOWN_LIBCALL)
14546 RTLIB::LibcallImpl LibcallImpl =
14548 if (LibcallImpl == RTLIB::Unsupported)
14552 EVT VT =
Node->getValueType(0);
14553 unsigned NumResults =
Node->getNumValues();
14563 SDValue StoreValue = ST->getValue();
14564 unsigned ResNo = StoreValue.
getResNo();
14566 if (CallRetResNo == ResNo)
14569 if (!ST->isSimple() || ST->getAddressSpace() != 0)
14572 if (StoresInChain && ST->getChain() != StoresInChain)
14576 if (ST->getAlign() <
14584 ResultStores[ResNo] = ST;
14585 StoresInChain = ST->getChain();
14592 EVT ArgVT =
Op.getValueType();
14594 Args.emplace_back(
Op, ArgTy);
14601 if (ResNo == CallRetResNo)
14603 EVT ResVT =
Node->getValueType(ResNo);
14605 ResultPtrs[ResNo] = ResultPtr;
14606 Args.emplace_back(ResultPtr,
PointerTy);
14618 Type *RetType = CallRetResNo.has_value()
14619 ?
Node->getValueType(*CallRetResNo).getTypeForEVT(Ctx)
14632 if (ResNo == CallRetResNo) {
14638 ResultPtr, PtrInfo);
14644 PtrInfo = ST->getPointerInfo();
14651 Results.push_back(LoadResult);
14661 bool IsSignaling)
const {
14662 MVT OpVT = LHS.getSimpleValueType();
14664 NeedInvert =
false;
14679 bool NeedSwap =
false;
14680 InvCC = getSetCCInverse(CCCode, OpVT);
14696 if (OpVT == MVT::i1) {
14711 DAG.
getNOT(dl, LHS, MVT::i1));
14716 DAG.
getNOT(dl, RHS, MVT::i1));
14721 DAG.
getNOT(dl, LHS, MVT::i1));
14726 DAG.
getNOT(dl, RHS, MVT::i1));
14749 "If SETUE is expanded, SETOEQ or SETUNE must be legal!");
14754 "If SETO is expanded, SETOEQ must be legal!");
14771 NeedInvert = ((
unsigned)CCCode & 0x8U);
14811 SetCC1 = DAG.
getSetCC(dl, VT, LHS, RHS, CC1, Chain, IsSignaling);
14812 SetCC2 = DAG.
getSetCC(dl, VT, LHS, RHS, CC2, Chain, IsSignaling);
14815 SetCC1 = DAG.
getSetCC(dl, VT, LHS, LHS, CC1, Chain, IsSignaling);
14816 SetCC2 = DAG.
getSetCC(dl, VT, RHS, RHS, CC2, Chain, IsSignaling);
14821 LHS = DAG.
getNode(
Opc, dl, VT, SetCC1, SetCC2);
14832 EVT VT =
Node->getValueType(0);
14844 unsigned Opcode =
Node->getOpcode();
14852 if (!V.getValueType().isVector()) {
14863 bool IsStrict =
Node->isStrictFPOpcode();
14900 std::optional<unsigned> ByteOffset;
14904 int Elt = ConstEltNo->getZExtValue();
14918 unsigned IsFast = 0;
14928 DAG, OriginalLoad->
getBasePtr(), InVecVT, EltNo);
14933 if (ResultVT.
bitsGT(VecEltVT)) {
14942 NewPtr, MPI, VecEltVT, Alignment,
14952 if (ResultVT.
bitsLT(VecEltVT))
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
block Block Frequency Analysis
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static std::optional< bool > isBigEndian(const SmallDenseMap< int64_t, int64_t, 8 > &MemOffset2Idx, int64_t LowestIdx)
Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds...
static bool isSigned(unsigned Opcode)
static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, const APInt &Demanded)
Check to see if the specified operand of the specified instruction is a constant integer.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool isNonZeroModBitWidthOrUndef(const MachineRegisterInfo &MRI, Register Reg, unsigned BW)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isUndef(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
Function const char * Passes
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
MachineBasicBlock * Folded
SmallVector< MachineOperand, 4 > Cond
MachineRegisterInfo & MRI
Contains matchers for matching SelectionDAG nodes and values.
static cl::opt< unsigned > MaxSteps("has-predecessor-max-steps", cl::Hidden, cl::init(8192), cl::desc("DAG combiner limit number of steps when searching DAG " "for predecessor nodes"))
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static std::pair< SDValue, SDValue > getLegalMaskAndStepVector(SDValue Mask, bool ZeroIsPoison, SDLoc DL, SelectionDAG &DAG)
Returns a type-legalized version of Mask as the first item in the pair.
static SDValue foldSetCCWithFunnelShift(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
static bool lowerImmediateIfPossible(TargetLowering::ConstraintPair &P, SDValue Op, SelectionDAG *DAG, const TargetLowering &TLI)
If we have an immediate, see if we can lower it.
#define FP_CMP_LIBCALL(BASE)
static APInt getKnownUndefForVectorBinop(SDValue BO, SelectionDAG &DAG, const APInt &UndefOp0, const APInt &UndefOp1)
Given a vector binary operation and known undefined elements for each input operand,...
static SDValue BuildExactUDIV(const TargetLowering &TLI, SDNode *N, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created)
Given an exact UDIV by a constant, create a multiplication with the multiplicative inverse of the con...
static void setArgListEntryAttributes(TargetLoweringBase::ArgListEntry &Entry, const SourceT &Src, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes.
static std::pair< RTLIB::Libcall, ISD::CondCode > selectFPCmpLibcall(const LibcallLoweringInfo &Libcalls, RTLIB::Libcall BoolLC, RTLIB::Libcall TriStateLC, RTLIB::Libcall GenericLC, ISD::CondCode TriStateCC)
Select the libcall and the condition code to test its result against 0 for an ordered floating-point ...
static SDValue isSpecificZeroAfterMaybeRounding(SelectionDAG &DAG, const TargetLowering &TLI, const SDLoc &DL, SDValue Val, FPClassTest FPClass)
static bool canNarrowCLMULToLegal(const TargetLowering &TLI, LLVMContext &Ctx, EVT VT, unsigned HalveDepth=0, unsigned TotalDepth=0)
Check if CLMUL on VT can eventually reach a type with legal CLMUL through a chain of halving decompos...
static SDValue combineShiftToAVGSUB(SDValue Op, TargetLowering::TargetLoweringOpt &TLO, const TargetLowering &TLI, const APInt &DemandedBits, const APInt &DemandedElts, unsigned Depth)
static unsigned getConstraintPiority(TargetLowering::ConstraintType CT)
Return a number indicating our preference for chosing a type of constraint over another,...
static std::optional< EVT > getNarrowAVGType(EVT VT, unsigned KnownBits, LLVMContext &Ctx)
static std::optional< bool > isFCmpEqualZero(FPClassTest Test, const fltSemantics &Semantics, const MachineFunction &MF)
Returns a true value if if this FPClassTest can be performed with an ordered fcmp to 0,...
static bool canFoldStoreIntoLibCallOutputPointers(StoreSDNode *StoreNode, SDNode *FPNode)
Given a store node StoreNode, return true if it is safe to fold that node into FPNode,...
static SDValue clampDynamicVectorIndex(SelectionDAG &DAG, SDValue Idx, EVT VecVT, const SDLoc &DL, ElementCount SubEC)
static void turnVectorIntoSplatVector(MutableArrayRef< SDValue > Values, std::function< bool(SDValue)> Predicate, SDValue AlternativeReplacement=SDValue())
If all values in Values that don't match the predicate are same 'splat' value, then replace all value...
static MaybeAlign getParamAlign(const CallBase &Call, unsigned ArgIdx)
static MaybeAlign getParamStackAlign(const CallBase &Call, unsigned ArgIdx)
static bool canExpandVectorCTPOP(const TargetLowering &TLI, EVT VT)
static SDValue foldSetCCWithRotate(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
static SDValue BuildExactSDIV(const TargetLowering &TLI, SDNode *N, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created)
Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the con...
static SDValue simplifySetCCWithCTPOP(const TargetLowering &TLI, EVT VT, SDValue N0, const APInt &C1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
static SDValue combineShiftToAVG(SDValue Op, TargetLowering::TargetLoweringOpt &TLO, const TargetLowering &TLI, const APInt &DemandedBits, const APInt &DemandedElts, unsigned Depth)
static bool paramHasAttr(const CallBase &Call, unsigned ArgIdx, Attribute::AttrKind Kind)
This file describes how to lower LLVM code to machine code.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
static SDValue scalarizeVectorStore(StoreSDNode *Store, MVT StoreVT, SelectionDAG &DAG)
Scalarize a vector store, bitcasting to TargetVT to determine the scalar type.
static LLVM_ABI const llvm::fltSemantics & EnumToSemantics(Semantics S)
static constexpr roundingMode rmTowardZero
static LLVM_ABI ExponentType semanticsMinExponent(const fltSemantics &)
static LLVM_ABI bool semanticsHasSignedRepr(const fltSemantics &)
static LLVM_ABI unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static constexpr roundingMode rmNearestTiesToEven
static LLVM_ABI ExponentType semanticsMaxExponent(const fltSemantics &)
static LLVM_ABI unsigned int semanticsPrecision(const fltSemantics &)
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
opStatus
IEEE-754R 7: Default exception handling.
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
APInt bitcastToAPInt() 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.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
Class for arbitrary precision integers.
LLVM_ABI APInt udiv(const APInt &RHS) const
Unsigned division operation.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static LLVM_ABI void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
bool isNegatedPowerOf2() const
Check if this APInt's negated value is a power of two greater than zero.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
uint64_t getZExtValue() const
Get zero extended value.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
LLVM_ABI APInt urem(const APInt &RHS) const
Unsigned remainder operation.
void setSignBit()
Set the sign bit to 1.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
bool isNegative() const
Determine sign of this APInt.
void clearAllBits()
Set every bit to 0.
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
LLVM_ABI APInt uadd_ov(const APInt &RHS, bool &Overflow) const
void negate()
Negate this APInt in place.
unsigned countr_zero() const
Count the number of trailing zero bits.
unsigned countl_zero() const
The APInt version of std::countl_zero.
static LLVM_ABI APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned getSignificantBits() const
Get the minimum bit size for this signed APInt.
unsigned countLeadingZeros() const
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
void flipAllBits()
Toggle every bit to its opposite value.
LLVM_ABI void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
void clearLowBits(unsigned loBits)
Set bottom loBits bits to 0.
unsigned logBase2() const
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
void setAllBits()
Set every bit to 1.
LLVM_ABI APInt multiplicativeInverse() const
bool isMask(unsigned numBits) const
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
APInt shl(unsigned shiftAmt) const
Left-shift function.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
void clearBits(unsigned LoBit, unsigned HiBit)
Clear the bits from LoBit (inclusive) to HiBit (exclusive) to 0.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
LLVM_ABI APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
bool isOne() const
Determine if this is a value of 1.
static APInt getBitsSetFrom(unsigned numBits, unsigned loBit)
Constructs an APInt value that has a contiguous range of bits set.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
void clearHighBits(unsigned hiBits)
Set top hiBits bits to 0.
int64_t getSExtValue() const
Get sign extended value.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
unsigned countr_one() const
Count the number of trailing one bits.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
void setBitVal(unsigned BitPosition, bool BitValue)
Set a given bit to a given value.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
A "pseudo-class" with methods for operating on BUILD_VECTORs.
LLVM_ABI ConstantSDNode * getConstantSplatNode(const APInt &DemandedElts, BitVector *UndefElements=nullptr) const
Returns the demanded splatted constant or null if this is not a constant splat.
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
This class represents a function call, abstracting a target machine's calling convention.
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
ConstantFP - Floating Point Values [float, double].
This class represents a range of values.
const APInt & getAPIntValue() const
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
bool isLittleEndian() const
Layout endianness...
LLVM_ABI Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
LLVM_ABI Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
static constexpr ElementCount getFixed(ScalarTy MinVal)
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
constexpr bool isScalar() const
Exactly one element.
constexpr bool isPowerOf2() const
Class to represent function types.
AttributeList getAttributes() const
Return the attribute list for this Function.
int64_t getOffset() const
const GlobalValue * getGlobal() const
Module * getParent()
Get the module that this global value is contained inside of...
std::vector< std::string > ConstraintCodeVector
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
Tracks which library functions to use for a particular subtarget or function.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
RTLIB::LibcallImpl getVectorLibcallImplOrMasked(RTLIB::Libcall Call) const
Return the implementation for Call, or for its masked variant if Call has no implementation.
This class is used to represent ISD::LOAD nodes.
const SDValue & getBasePtr() const
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
iterator_range< regclass_iterator > regclasses() const
Wrapper class representing physical registers. Should be passed by value.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
bool isInteger() const
Return true if this is an integer or a vector integer type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getIntegerVT(unsigned BitWidth)
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
void setAdjustsStack(bool V)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
Function & getFunction()
Return the LLVM function that this machine code represents.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.: .word LBB123.
Flags getFlags() const
Return the raw flags of the source value,.
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
unsigned getAddressSpace() const
Return the address space for the associated pointer.
bool isSimple() const
Returns true if the memory operation is neither atomic or volatile.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
MMOMetadata getMMOMetadataForSubAccess() const
Returns metadata that can be copied unchanged to an access covering all or part of this access's byte...
const MachinePointerInfo & getPointerInfo() const
const SDValue & getChain() const
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Class to represent pointers.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
ArrayRef< SDUse > ops() const
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
SDNodeFlags getFlags() const
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode * > &Visited, SmallVectorImpl< const SDNode * > &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node, in exactly one operand.
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
ISD::CondCode getOperandCondCode(unsigned i) const
bool use_empty() const
Return true if there are no nodes using value ResNo of Node.
const APInt & getConstantOperandAPInt(unsigned i) const
uint64_t getScalarValueSizeInBits() const
unsigned getResNo() const
get the index which selects a specific result in the SDNode
uint64_t getConstantOperandVal(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getElementCount(const SDLoc &DL, EVT VT, ElementCount EC)
bool willNotOverflowAdd(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the addition of 2 nodes can never overflow.
LLVM_ABI Align getReducedAlign(EVT VT, bool UseABI)
In most cases this function returns the ABI alignment for a given type, except for illegal vector typ...
LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
Test whether the given floating point SDValue (or all elements of it, if it is a vector) is known to ...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
SDValue getExtractVectorElt(const SDLoc &DL, EVT VT, SDValue Vec, unsigned Idx)
Extract element at Idx from Vec.
LLVM_ABI unsigned ComputeMaxSignificantBits(SDValue Op, unsigned Depth=0) const
Get the upper bound on bit size for this Value Op as a signed integer.
LLVM_ABI SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, const SDLoc &dl, SDNodeFlags Flags={})
Constant fold a setcc to true or false.
bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0, EVT EltVT=EVT())
Append the extracted elements from Start to Count out of the vector Op in Args.
LLVM_ABI SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
LLVM_ABI SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
LLVM_ABI SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain)
If an existing load has uses of its chain, create a token factor node with that chain and the new mem...
LLVM_ABI bool isConstantIntBuildVectorOrConstantInt(SDValue N, bool AllowOpaques=true) const
Test whether the given value is a constant int or similar node.
LLVM_ABI SDValue getJumpTableDebugInfo(int JTI, SDValue Chain, const SDLoc &DL)
LLVM_ABI std::optional< unsigned > getValidMaximumShiftAmount(SDValue V, const APInt &DemandedElts, unsigned Depth=0) const
If a SHL/SRA/SRL node V has shift amounts that are all less than the element bit-width of the shift n...
LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
LLVM_ABI SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm)
Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
static LLVM_ABI unsigned getHasPredecessorMaxSteps()
SDValue getExtractSubvector(const SDLoc &DL, EVT VT, SDValue Vec, unsigned Idx)
Return the VT typed sub-vector of Vec at Idx.
SDValue getInsertSubvector(const SDLoc &DL, SDValue Vec, SDValue SubVec, unsigned Idx)
Insert SubVec at the Idx element of Vec.
LLVM_ABI SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal)
Returns a vector of type ResVT whose elements contain the linear sequence <0, Step,...
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
bool willNotOverflowSub(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the sub of 2 nodes can never overflow.
LLVM_ABI bool shouldOptForSize() const
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const TargetLowering & getTargetLoweringInfo() const
static constexpr unsigned MaxRecursionDepth
bool isGuaranteedNotToBePoison(SDValue Op, unsigned Depth=0) const
Return true if this function can prove that Op is never poison.
LLVM_ABI std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
Compute the VTs needed for the low/hi parts of a type which is split (or expanded) into two not neces...
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
LLVM_ABI SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT)
Create negative operation as (SUB 0, Val).
LLVM_ABI std::optional< unsigned > getValidShiftAmount(SDValue V, const APInt &DemandedElts, unsigned Depth=0) const
If a SHL/SRA/SRL node V has a uniform shift amount that is less than the element bit-width of the shi...
LLVM_ABI SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
const DataLayout & getDataLayout() const
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI bool doesNodeExist(unsigned Opcode, SDVTList VTList, ArrayRef< SDValue > Ops)
Check if a node exists without modifying its flags.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
LLVM_ABI SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned TargetFlags=0)
LLVM_ABI SDValue getTypeSize(const SDLoc &DL, EVT VT, TypeSize TS)
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provided VTs and return the low/high part.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op)
LLVM_ABI bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
LLVM_ABI void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
LLVM_ABI SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V, unsigned OperandNo, unsigned Depth=0) const
Returns true if V is an identity element of Opc with Flags.
LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, UndefPoisonKind Kind=UndefPoisonKind::UndefOrPoison, unsigned Depth=0) const
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
LLVM_ABI bool isKnownNeverZero(SDValue Op, unsigned Depth=0) const
Test whether the given SDValue is known to contain non-zero value(s).
LLVM_ABI SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SDNodeFlags Flags=SDNodeFlags())
LLVM_ABI SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
const LibcallLoweringInfo & getLibcalls() const
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
LLVM_ABI bool isKnownNeverNaN(SDValue Op, const APInt &DemandedElts, bool SNaN=false, unsigned Depth=0) const
Test whether the given SDValue (or all elements of it, if it is a vector) is known to never be NaN in...
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
LLVM_ABI SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT)
Create a true or false constant of type VT using the target's BooleanContent for type OpVT.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getPOISON(EVT VT)
Return a POISON node. POISON does not have a useful SDLoc.
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVM_ABI SDValue getCondCode(ISD::CondCode Cond)
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, bool OrZero=false, unsigned Depth=0) const
Test if the given value is known to have exactly one bit set.
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
SDValue getSplat(EVT VT, const SDLoc &DL, SDValue Op)
Returns a node representing a splat of one value into all lanes of the provided vector type.
LLVM_ABI std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
LLVM_ABI SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
static void commuteMask(MutableArrayRef< int > Mask)
Change values in a shuffle permute mask assuming the two vector operands have swapped position.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Class to represent struct types.
LLVM_ABI void setExtAttribute(Attribute::AttrKind Attr)
LLVM_ABI void setAttributes(const CallBase *Call, unsigned ArgIdx)
bool isOperationExpand(unsigned Op, EVT VT) const
Return true if the specified operation is illegal on this target or unlikely to be made legal with cu...
virtual IntegerType * getCmpLibcallReturnType(LLVMContext &Ctx) const
Return the integer type returned by comparison libcalls.
virtual bool isShuffleMaskLegal(ArrayRef< int >, EVT) const
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
virtual bool shouldRemoveRedundantExtend(SDValue Op) const
Return true (the default) if it is profitable to remove a sext_inreg(x) where the sext is redundant,...
virtual bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT, std::optional< unsigned > ByteOffset=std::nullopt) const
Return true if it is profitable to reduce a load to a smaller type.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
virtual bool preferSelectsOverBooleanArithmetic(EVT VT) const
Should we prefer selects to doing arithmetic on boolean types.
virtual bool isLegalICmpImmediate(int64_t) const
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
virtual bool isSExtCheaperThanZExt(EVT FromTy, EVT ToTy) const
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.
MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
virtual bool isSafeMemOpType(MVT) const
Returns true if it's safe to use load / store of the specified type to expand memcpy / memset inline.
const TargetMachine & getTargetMachine() const
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
bool isPaddedAtMostSignificantBitsWhenStored(EVT VT) const
Indicates if any padding is guaranteed to go at the most significant bits when storing the type to me...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize=false) const
Returns true if the specified FP immediate can be materialized without a load from the constant pool.
virtual bool hasBitTest(SDValue X, SDValue Y) const
Return true if the target has a bit-test instruction: (X & (1 << Y)) ==/!= 0 This knowledge can be us...
MVT getRegisterType(LLVMContext &Context, EVT VT) const
Return the type of registers that this ValueType will eventually require.
EVT getLegalTypeToTransformTo(LLVMContext &Context, EVT VT) const
Perform getTypeToTransformTo repeatedly until a legal type is obtained.
LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const
Return how the condition code should be treated: either it is legal, needs to be expanded to some oth...
virtual bool isCommutativeBinOp(unsigned Opcode) const
Returns true if the opcode is a commutative binary operation.
virtual bool shouldTransformSignedTruncationCheck(EVT XVT, unsigned KeptBits) const
Should we tranform the IR-optimal check for whether given truncation down into KeptBits would be trun...
bool isLegalRC(const TargetRegisterInfo &TRI, const TargetRegisterClass &RC) const
Return true if the value types that can be represented by the specified register class are all legal.
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *=nullptr) const
Determine if the target supports unaligned memory accesses.
bool isOperationCustom(unsigned Op, EVT VT) const
Return true if the operation uses custom lowering, regardless of whether the type is legal or not.
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
virtual bool shouldExtendTypeInLibCall(EVT Type) const
Returns true if arguments should be extended in lib calls.
virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const
Return true if it's free to truncate a value of type FromTy to type ToTy.
virtual bool shouldAvoidTransformToShift(EVT VT, unsigned Amount) const
Return true if creating a shift of the type by the given amount is not profitable.
virtual bool isFPExtFree(EVT DestVT, EVT SrcVT) const
Return true if an fpext operation is free (for instance, because single-precision floating-point numb...
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
BooleanContent getBooleanContents(bool isVec, bool isFloat) const
For targets without i1 registers, this gives the nature of the high-bits of boolean values held in ty...
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal for a comparison of the specified types on this ...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
TargetLoweringBase(const TargetMachine &TM, const TargetSubtargetInfo &STI)
NOTE: The TargetMachine owns TLOF.
virtual bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd(SDValue X, ConstantSDNode *XC, ConstantSDNode *CC, SDValue Y, unsigned OldShiftOpcode, unsigned NewShiftOpcode, SelectionDAG &DAG) const
Given the pattern (X & (C l>>/<< Y)) ==/!= 0 return true if it should be transformed into: ((X <</l>>...
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const
Return true if integer divide is usually cheaper than a sequence of several shifts,...
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
virtual bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
Return true if the target supports a memory access of this type for the given address space and align...
virtual bool hasAndNotCompare(SDValue Y) const
Return true if the target should transform: (X & Y) == Y ---> (~X & Y) == 0 (X & Y) !...
virtual bool isNarrowingProfitable(SDNode *N, EVT SrcVT, EVT DestVT) const
Return true if it's profitable to narrow operations of type SrcVT to DestVT.
virtual bool isBinOp(unsigned Opcode) const
Return true if the node is a math/logic binary operator.
virtual bool isCtlzFast() const
Return true if ctlz instruction is fast.
virtual bool shouldUseStrictFP_TO_INT(EVT FpVT, EVT IntVT, bool IsSigned) const
Return true if it is more correct/profitable to use strict FP_TO_INT conversion operations - canonica...
NegatibleCost
Enum that specifies when a float negation is beneficial.
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
std::vector< ArgListEntry > ArgListTy
virtual EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &) const
Returns the target specific optimal type for load and store operations as a result of memset,...
virtual EVT getAsmOperandValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
bool isCondCodeLegalOrCustom(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal or custom for a comparison of the specified type...
bool isLoadLegal(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace, unsigned ExtType, bool Atomic) const
Return true if the specified load with extension is legal on this target.
virtual bool isFAbsFree(EVT VT) const
Return true if an fabs operation is free to the point where it is never worthwhile to replace it with...
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
MulExpansionKind
Enum that specifies when a multiplication should be expanded.
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US][ADD|SUB]SAT.
SDValue buildSDIVPow2WithCMov(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created) const
Build sdiv by power-of-2 with conditional move instructions Ref: "Hacker's Delight" by Henry Warren 1...
virtual ConstraintWeight getMultipleConstraintMatchWeight(AsmOperandInfo &info, int maIndex) const
Examine constraint type and operand type and determine a weight value.
void expandVectorDeinterleave(SDNode *Node, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
Expand a VECTOR_DEINTERLEAVE without introducing wider vector types.
bool expandMultipleResultFPLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, SDNode *Node, SmallVectorImpl< SDValue > &Results, std::optional< unsigned > CallRetResNo={}) const
Expands a node with multiple results to an FP or vector libcall.
bool expandMULO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]MULO.
bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL into two nodes.
SmallVector< ConstraintPair > ConstraintGroup
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase,...
virtual Align computeKnownAlignForTargetInstr(GISelValueTracking &Analysis, Register R, const MachineRegisterInfo &MRI, unsigned Depth=0) const
Determine the known alignment for the pointer value R.
bool SimplifyDemandedVectorElts(SDValue Op, const APInt &DemandedEltMask, APInt &KnownUndef, APInt &KnownZero, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Vector Op.
virtual bool isUsedByReturnOnly(SDNode *, SDValue &) const
Return true if result of the specified node is used by a return node only.
bool LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT, SDValue &LHS, SDValue &RHS, SDValue &CC, bool &NeedInvert, const SDLoc &dl, SDValue &Chain, bool IsSignaling=false) const
Legalize a SETCC with given LHS and RHS and condition code CC on the current target.
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
virtual unsigned getPreferredShrunkVectorSizeInBits(SDValue Op, const APInt &DemandedElts) const
If only low elements of a vector are demanded, shrink the operation to the returned size in bits by c...
virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
This method can be implemented by targets that want to expose additional information about sign bits ...
SDValue lowerCmpEqZeroToCtlzSrl(SDValue Op, SelectionDAG &DAG) const
void softenSetCCOperands(SelectionDAG &DAG, EVT VT, SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, const SDLoc &DL, const SDValue OldLHS, const SDValue OldRHS) const
Soften the operands of a comparison.
void forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl, bool Signed, const SDValue LHS, const SDValue RHS, SDValue &Lo, SDValue &Hi) const
Calculate full product of LHS and RHS either via a libcall or through brute force expansion of the mu...
SDValue expandVecReduceSeq(SDNode *Node, SelectionDAG &DAG) const
Expand a VECREDUCE_SEQ_* into an explicit ordered calculation.
SDValue expandFCANONICALIZE(SDNode *Node, SelectionDAG &DAG) const
Expand FCANONICALIZE to FMUL with 1.
SDValue expandCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand CTLZ/CTLZ_ZERO_POISON nodes.
SDValue expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand BITREVERSE nodes.
SDValue expandCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand CTTZ/CTTZ_ZERO_POISON nodes.
virtual SDValue expandIndirectJTBranch(const SDLoc &dl, SDValue Value, SDValue Addr, int JTI, SelectionDAG &DAG) const
Expands target specific indirect branch for the case of JumpTable expansion.
SDValue expandABD(SDNode *N, SelectionDAG &DAG) const
Expand ABDS/ABDU nodes.
virtual bool targetShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, TargetLoweringOpt &TLO) const
std::vector< AsmOperandInfo > AsmOperandInfoVector
SDValue expandGetActiveLaneMask(SDNode *N, SelectionDAG &DAG) const
Expand GET_ACTIVE_LANE_MASK nodes.
SDValue expandCLMUL(SDNode *N, SelectionDAG &DAG) const
Expand carryless multiply.
SDValue expandShlSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]SHLSAT.
SDValue expandIS_FPCLASS(EVT ResultVT, SDValue Op, FPClassTest Test, SDNodeFlags Flags, const SDLoc &DL, SelectionDAG &DAG) const
Expand check for floating point class.
virtual bool isTargetCanonicalConstantNode(SDValue Op) const
Returns true if the given Opc is considered a canonical constant for the target, which should not be ...
SDValue expandFP_TO_INT_SAT(SDNode *N, SelectionDAG &DAG) const
Expand FP_TO_[US]INT_SAT into FP_TO_[US]INT and selects or min/max.
SDValue expandCttzElts(SDNode *Node, SelectionDAG &DAG) const
Expand a CTTZ_ELTS or CTTZ_ELTS_ZERO_POISON by calculating (VL - i) for each active lane (i),...
SDValue getCheaperNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, unsigned Depth=0) const
This is the helper function to return the newly negated expression only when the cost is cheaper.
virtual unsigned computeNumSignBitsForTargetInstr(GISelValueTracking &Analysis, Register R, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const
This method can be implemented by targets that want to expose additional information about sign bits ...
SDValue SimplifyMultipleUseDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth=0) const
More limited version of SimplifyDemandedBits that can be used to "lookthrough" ops that don't contrib...
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors.
SDValue SimplifyMultipleUseDemandedVectorElts(SDValue Op, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth=0) const
Helper wrapper around SimplifyMultipleUseDemandedBits, demanding all bits from only some vector eleme...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
virtual bool findOptimalMemOpLowering(LLVMContext &Context, std::vector< EVT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes, EVT *LargestVT=nullptr) const
Determines the optimal series of memory ops to replace the memset / memcpy.
virtual SDValue unwrapAddress(SDValue N) const
void expandSADDSUBO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::S(ADD|SUB)O.
SDValue expandABS(SDNode *N, SelectionDAG &DAG, bool IsNegative=false) const
Expand ABS nodes.
SDValue expandVecReduce(SDNode *Node, SelectionDAG &DAG) const
Expand a VECREDUCE_* into an explicit calculation.
bool ShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, TargetLoweringOpt &TLO) const
Check to see if the specified operand of the specified instruction is a constant integer.
virtual bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, unsigned Depth) const
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
SDValue expandMULH(SDNode *Node, SelectionDAG &DAG) const
SDValue expandVPCTTZElements(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTTZ_ELTS/VP_CTTZ_ELTS_ZERO_POISON nodes.
SDValue BuildSDIV(SDNode *N, SelectionDAG &DAG, bool IsAfterLegalization, bool IsAfterLegalTypes, SmallVectorImpl< SDNode * > &Created) const
Given an ISD::SDIV node expressing a divide by constant, return a DAG expression to select that will ...
virtual const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
bool expandFP_TO_UINT(SDNode *N, SDValue &Result, SDValue &Chain, SelectionDAG &DAG) const
Expand float to UINT conversion.
bool parametersInCSRMatch(const MachineRegisterInfo &MRI, const uint32_t *CallerPreservedMask, const SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< SDValue > &OutVals) const
Check whether parameters to a call that are passed in callee saved registers are the same as from the...
virtual bool SimplifyDemandedVectorEltsForTargetNode(SDValue Op, const APInt &DemandedElts, APInt &KnownUndef, APInt &KnownZero, TargetLoweringOpt &TLO, unsigned Depth=0) const
Attempt to simplify any target nodes based on the demanded vector elements, returning true on success...
bool expandREM(SDNode *Node, SDValue &Result, SelectionDAG &DAG) const
Expand an SREM or UREM using SDIV/UDIV or SDIVREM/UDIVREM, if legal.
std::pair< SDValue, SDValue > expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Expands an unaligned load to 2 half-size loads for an integer, and possibly more for vectors.
SDValue expandFMINIMUMNUM_FMAXIMUMNUM(SDNode *N, SelectionDAG &DAG) const
Expand fminimumnum/fmaximumnum into multiple comparison with selects.
void expandVectorInterleave(SDNode *Node, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const
Expand a VECTOR_INTERLEAVE without introducing wider vector types.
void forceExpandMultiply(SelectionDAG &DAG, const SDLoc &dl, bool Signed, SDValue &Lo, SDValue &Hi, SDValue LHS, SDValue RHS, SDValue HiLHS=SDValue(), SDValue HiRHS=SDValue()) const
Calculate the product twice the width of LHS and RHS.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
virtual bool isTypeDesirableForOp(unsigned, EVT VT) const
Return true if the target has native support for the specified value type and it is 'desirable' to us...
SDValue expandVectorSplice(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::VECTOR_SPLICE.
SDValue getVectorSubVecPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, EVT SubVecVT, SDValue Index, const SDNodeFlags PtrArithFlags=SDNodeFlags()) const
Get a pointer to a sub-vector of type SubVecVT at index Idx located in memory for a vector of type Ve...
SDValue expandLoopDependenceMask(SDNode *N, SelectionDAG &DAG) const
Expand LOOP_DEPENDENCE_MASK nodes.
virtual const char * LowerXConstraint(EVT ConstraintVT) const
Try to replace an X constraint, which matches anything, with another that has more specific requireme...
SDValue expandCTPOP(SDNode *N, SelectionDAG &DAG) const
Expand CTPOP nodes.
virtual void computeKnownBitsForTargetInstr(GISelValueTracking &Analysis, Register R, KnownBits &Known, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
SDValue BuildUDIV(SDNode *N, SelectionDAG &DAG, bool IsAfterLegalization, bool IsAfterLegalTypes, SmallVectorImpl< SDNode * > &Created) const
Given an ISD::UDIV node expressing a divide by constant, return a DAG expression to select that will ...
SDValue expandVectorNaryOpBySplitting(SDNode *Node, SelectionDAG &DAG) const
~TargetLowering() override
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
SDValue expandBSWAP(SDNode *N, SelectionDAG &DAG) const
Expand BSWAP nodes.
SDValue expandFMINIMUM_FMAXIMUM(SDNode *N, SelectionDAG &DAG) const
Expand fminimum/fmaximum into multiple comparison with selects.
SDValue CTTZTableLookup(SDNode *N, SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Op, unsigned NumBitsPerElt) const
Expand CTTZ via Table Lookup.
bool expandDIVREMByConstant(SDNode *N, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, SDValue LL=SDValue(), SDValue LH=SDValue()) const
Attempt to expand an n-bit div/rem/divrem by constant using an n/2-bit algorithm.
virtual void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
bool isPositionIndependent() const
std::pair< StringRef, TargetLowering::ConstraintType > ConstraintPair
virtual SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, NegatibleCost &Cost, unsigned Depth=0) const
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
ConstraintGroup getConstraintPreferences(AsmOperandInfo &OpInfo) const
Given an OpInfo with list of constraints codes as strings, return a sorted Vector of pairs of constra...
bool expandFP_TO_SINT(SDNode *N, SDValue &Result, SelectionDAG &DAG) const
Expand float(f32) to SINT(i64) conversion.
virtual SDValue SimplifyMultipleUseDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth) const
More limited version of SimplifyDemandedBits that can be used to "lookthrough" ops that don't contrib...
virtual SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Glue, const SDLoc &DL, const AsmOperandInfo &OpInfo, SelectionDAG &DAG) const
SDValue buildLegalVectorShuffle(EVT VT, const SDLoc &DL, SDValue N0, SDValue N1, MutableArrayRef< int > Mask, SelectionDAG &DAG) const
Tries to build a legal vector shuffle using the provided parameters or equivalent variations.
static ArgListTy getArgListForFunctionType(FunctionType *FuncTy, const AttributeList &FuncAttrs, ArrayRef< SDValue > Ops)
Build a call argument list for FuncTy, taking the argument node values from Ops and the parameter typ...
virtual void computeKnownBitsForStackObjectPointer(KnownBits &Known, const MachineFunction &MF, Align Alignment) const
Determine known bits of a pointer to a known valid stack object.
virtual SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const
Returns relocation base for the given PIC jumptable.
std::pair< SDValue, SDValue > scalarizeVectorLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Turn load of vector type into a load of the individual elements.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Op.
virtual bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0) const
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
virtual bool isDesirableToCommuteXorWithShift(const SDNode *N) const
Return true if it is profitable to combine an XOR of a logical shift to create a logical shift of NOT...
TargetLowering(const TargetLowering &)=delete
virtual bool shouldSimplifyDemandedVectorElts(SDValue Op, const TargetLoweringOpt &TLO) const
Return true if the target supports simplifying demanded vector elements by converting them to undefs.
bool isConstFalseVal(SDValue N) const
Return if the N is a constant or constant vector equal to the false value from getBooleanContents().
SDValue IncrementMemoryAddress(SDValue Addr, SDValue Mask, const SDLoc &DL, EVT DataVT, SelectionDAG &DAG, bool IsCompressedMemory) const
Increments memory address Addr according to the type of the value DataVT that should be stored.
SDValue expandVectorMatch(SDNode *N, SelectionDAG &DAG) const
Expand VECTOR_MATCH nodes.
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
SDValue expandCONVERT_TO_ARBITRARY_FP(SDNode *Node, SelectionDAG &DAG) const
Expand CONVERT_TO_ARBITRARY_FP using bit manipulation.
virtual AsmOperandInfoVector ParseConstraints(const DataLayout &DL, const TargetRegisterInfo *TRI, const CallBase &Call) const
Split up the constraint string from the inline assembly value into the specific constraints and their...
virtual bool isSplatValueForTargetNode(SDValue Op, const APInt &DemandedElts, APInt &UndefElts, const SelectionDAG &DAG, unsigned Depth=0) const
Return true if vector Op has the same value across all DemandedElts, indicating any elements which ma...
SDValue expandRoundInexactToOdd(EVT ResultVT, SDValue Op, const SDLoc &DL, SelectionDAG &DAG) const
Truncate Op to ResultVT.
virtual bool shouldSplitFunctionArgumentsAsLittleEndian(const DataLayout &DL) const
For most targets, an LLVM type must be broken down into multiple smaller types.
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, bool foldBooleans, DAGCombinerInfo &DCI, const SDLoc &dl) const
Try to simplify a setcc built with the specified operands and cc.
SDValue expandFunnelShift(SDNode *N, SelectionDAG &DAG) const
Expand funnel shift.
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const
Return true if folding a constant offset with the given GlobalAddress is legal.
bool isExtendedTrueVal(const ConstantSDNode *N, EVT VT, bool SExt) const
Return if N is a True value when extended to VT.
bool ShrinkDemandedOp(SDValue Op, unsigned BitWidth, const APInt &DemandedBits, TargetLoweringOpt &TLO) const
Convert x+y to (VT)((SmallVT)x+(SmallVT)y) if the casts are free.
bool isConstTrueVal(SDValue N) const
Return if the N is a constant or constant vector equal to the true value from getBooleanContents().
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
SDValue expandPEXT(SDNode *N, SelectionDAG &DAG) const
Expand parallel bit extract (compress).
virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op, SelectionDAG *DAG=nullptr) const
Determines the constraint code and constraint type to use for the specific AsmOperandInfo,...
virtual void CollectTargetIntrinsicOperands(const CallInst &I, SmallVectorImpl< SDValue > &Ops, SelectionDAG &DAG) const
virtual bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const
Return true if Op can create undef or poison from non-undef & non-poison operands.
bool expandMODF(SDNode *N, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results) const
Expand MODF node into fractional and integer parts.
SDValue expandVECTOR_COMPRESS(SDNode *Node, SelectionDAG &DAG) const
Expand a vector VECTOR_COMPRESS into a sequence of extract element, store temporarily,...
virtual const Constant * getTargetConstantFromLoad(LoadSDNode *LD) const
This method returns the constant pool value that will be loaded by LD.
SDValue expandFP_ROUND(SDNode *Node, SelectionDAG &DAG) const
Expand round(fp) to fp conversion.
SDValue createSelectForFMINNUM_FMAXNUM(SDNode *Node, SelectionDAG &DAG) const
Try to convert the fminnum/fmaxnum to a compare/select sequence.
SDValue expandCONVERT_FROM_ARBITRARY_FP(SDNode *Node, SelectionDAG &DAG) const
Expand CONVERT_FROM_ARBITRARY_FP using bit manipulation.
SDValue expandROT(SDNode *N, bool AllowVectorOps, SelectionDAG &DAG) const
Expand rotations.
SDValue annotateStackObjectPointer(SDValue Ptr, SelectionDAG &DAG, const SDLoc &DL, Align Alignment) const
Annotate a stack object pointer with known-bits assertions.
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
virtual SDValue getSqrtInputTest(SDValue Operand, SelectionDAG &DAG, const DenormalMode &Mode, SDNodeFlags Flags={}) const
Return a target-dependent comparison result if the input operand is suitable for use with a square ro...
SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Index, const SDNodeFlags PtrArithFlags=SDNodeFlags()) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
SDValue expandFMINNUM_FMAXNUM(SDNode *N, SelectionDAG &DAG) const
Expand fminnum/fmaxnum into fminnum_ieee/fmaxnum_ieee with quieted inputs.
virtual bool isGAPlusOffset(SDNode *N, const GlobalValue *&GA, int64_t &Offset) const
Returns true (and the GlobalValue and the offset) if the node is a GlobalAddress + offset.
virtual void computeKnownFPClassForTargetNode(const SDValue Op, KnownFPClass &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
Determine floating-point class information for a target node.
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
virtual void computeKnownFPClassForTargetInstr(GISelValueTracking &Analysis, Register R, KnownFPClass &Known, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::LibcallImpl LibcallImpl, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
SDValue expandCMP(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]CMP.
void expandShiftParts(SDNode *N, SDValue &Lo, SDValue &Hi, SelectionDAG &DAG) const
Expand shift-by-parts.
virtual bool isKnownNeverNaNForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool SNaN=false, unsigned Depth=0) const
If SNaN is false,.
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue expandFixedPointMul(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[U|S]MULFIX[SAT].
SDValue getInboundsVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Index) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
SDValue expandIntMINMAX(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US][MIN|MAX].
SDValue expandVectorFindLastActive(SDNode *N, SelectionDAG &DAG) const
Expand VECTOR_FIND_LAST_ACTIVE nodes.
SDValue expandPartialReduceMLA(SDNode *Node, SelectionDAG &DAG) const
Expands PARTIAL_REDUCE_S/UMLA nodes to a series of simpler operations, consisting of zext/sext,...
void expandUADDSUBO(SDNode *Node, SDValue &Result, SDValue &Overflow, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::U(ADD|SUB)O.
SDValue expandPDEP(SDNode *N, SelectionDAG &DAG) const
Expand parallel bit deposit (expand).
virtual SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created) const
Targets may override this function to provide custom SDIV lowering for power-of-2 denominators.
SDValue scalarizeExtractedVectorLoad(EVT ResultVT, const SDLoc &DL, EVT InVecVT, SDValue EltNo, LoadSDNode *OriginalLoad, SelectionDAG &DAG) const
Replace an extraction of a load with a narrowed load.
virtual SDValue BuildSREMPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created) const
Targets may override this function to provide custom SREM lowering for power-of-2 denominators.
bool expandUINT_TO_FP(SDNode *N, SDValue &Result, SDValue &Chain, SelectionDAG &DAG) const
Expand UINT(i64) to double(f64) conversion.
bool expandMUL_LOHI(unsigned Opcode, EVT VT, const SDLoc &dl, SDValue LHS, SDValue RHS, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes, respectively,...
SDValue expandAVG(SDNode *N, SelectionDAG &DAG) const
Expand vector/scalar AVGCEILS/AVGCEILU/AVGFLOORS/AVGFLOORU nodes.
SDValue expandCTLS(SDNode *N, SelectionDAG &DAG) const
Expand CTLS (count leading sign bits) nodes.
void setTypeIdForCallsiteInfo(const CallBase *CB, MachineFunction &MF, MachineFunction::CallSiteInfo &CSInfo) const
Primary interface to the complete machine description for the target machine.
bool isPositionIndependent() const
const Triple & getTargetTriple() const
unsigned EmitCallSiteInfo
The flag enables call site info production.
unsigned EmitCallGraphSection
Emit section containing call graph metadata.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual StringRef getRegAsmName(MCRegister Reg) const
Return the assembly name for Reg.
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
TargetSubtargetInfo - Generic base class for all target subtargets.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_ABI const fltSemantics & getFltSemantics() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
constexpr bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS*X will result in a value whose quantity matches our ...
constexpr ScalarTy getFixedValue() const
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS*X will result in a value whose quantity matches our own.
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI APInt ScaleBitMask(const APInt &A, unsigned NewBitWidth, bool MatchAllBits=false)
Splat/Merge neighboring bits to widen/narrow the bitmask represented by.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ PTRADD
PTRADD represents pointer arithmetic semantics, for targets that opt in using shouldPreservePtrArith(...
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ LOOP_DEPENDENCE_RAW_MASK
@ FGETSIGN
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ AVGSUBFLOORS
AVGSUBFLOORS/AVGSUBFLOORU - Averaging subtract - Subtract two integers using an integer of type i[N+1...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ PSEUDO_FMIN
PSEUDO_FMIN is strictly equivalent to op0 olt op1 ?
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FMULADD
FMULADD - Performs a * b + c, with, or without, intermediate rounding.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ VECREDUCE_FADD
These reductions have relaxed evaluation order semantics, and have a single vector operand.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ SSUBO
Same for subtraction.
@ BRIND
BRIND - Indirect branch.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ FMINNUM_IEEE
FMINNUM_IEEE/FMAXNUM_IEEE - Same as FMINNUM/FMAXNUM, except that a signaling NaN operand deterministi...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ FMINNUM
FMINNUM/FMAXNUM - Same semantics as the llvm.minnum/maxnum intrinsics.
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FMINIMUM
FMINIMUM/FMAXIMUM - Same semantics as the llvm.minimum/maximum intrinsics.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ CALLSEQ_START
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence,...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - Same semantics as the llvm.minimumnum/maximumnum intrinsics.
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
LLVM_ABI NodeType getOppositeSignednessMinMaxOpcode(unsigned MinMaxOpc)
Given a MinMaxOpc of ISD::(U|S)MIN or ISD::(U|S)MAX, returns the corresponding opcode with the opposi...
LLVM_ABI bool isBuildVectorOfConstantSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantSDNode or undef.
LLVM_ABI NodeType getExtForLoadExtType(bool IsFP, LoadExtType)
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isZEXTLoad(const SDNode *N)
Returns true if the specified node is a ZEXTLOAD.
LLVM_ABI CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
unsigned getUnorderedFlavor(CondCode Cond)
This function returns 0 if the condition is always false if an operand is a NaN, 1 if the condition i...
LLVM_ABI bool matchBinaryPredicate(SDValue LHS, SDValue RHS, const APInt &DemandedElts, std::function< bool(ConstantSDNode *, ConstantSDNode *)> Match, bool AllowUndefs=false, bool AllowTypeMismatch=false)
Attempt to match a binary predicate against a pair of scalar/splat constants or every element of a pa...
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
LLVM_ABI bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef.
LLVM_ABI StringRef getCondCodeName(CondCode Operation)
Return the name of the given condition code, e.g. "setoeq".
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
LLVM_ABI bool isConstantSplatVector(const SDNode *N, APInt &SplatValue)
Node predicates.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LLVM_ABI NodeType getVecReduceBaseOpcode(unsigned VecReduceOpcode)
Get underlying scalar opcode for VECREDUCE opcode.
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool matchUnaryPredicate(SDValue Op, const APInt &DemandedElts, std::function< bool(ConstantSDNode *)> Match, bool AllowUndefs=false, bool AllowTruncation=false)
Hook for matching ConstantSDNode predicate.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
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.
auto m_Value()
Match an arbitrary value and ignore it.
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
LLVM_ABI Libcall getUREM(EVT VT)
Or< Preds... > m_AnyOf(const Preds &...preds)
TypeSize_match< ElementCount > m_ElementCount(ElementCount &V)
Match any integer constant or constant multiple of VSCALE that can be represented using ElementCount.
bool sd_match(SDValue N, Pattern &&P)
NUses_match< 1, Value_match > m_OneUse()
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
void stable_sort(R &&Range)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
RelativeUniformCounterPtr Values
LLVM_ABI bool isAllOnesOrAllOnesSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowUndefs=false)
Return true if the value is a constant -1 integer or a splatted vector of a constant -1 integer (with...
@ Known
Known to have no common set bits.
@ Undef
Value of the register doesn't matter.
LLVM_ABI SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI FPClassTest invertFPClassTestIfSimpler(FPClassTest Test, bool UseFCmp)
Evaluates if the specified FP class test is better performed as the inverse (i.e.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
LLVM_ABI bool isOneOrOneSplatFP(SDValue V, bool AllowUndefs=false)
Return true if the value is a constant floating-point value, or a splatted vector of a constant float...
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
LLVM_ABI bool isNullOrNullSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowUndefs=false)
Return true if the value is a constant 0 integer or a splatted vector of a constant 0 integer (with n...
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
constexpr int popcount(T Value) noexcept
Count the number of set bits in a value.
LLVM_ABI ConstantFPSDNode * isConstOrConstSplatFP(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant float.
constexpr bool has_single_bit(T Value) noexcept
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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...
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
LLVM_ABI bool isBitwiseNot(SDValue V, bool AllowUndefs=false)
Returns true if V is a bitwise not operation.
LLVM_ABI llvm::SmallVector< int, 16 > createStrideMask(unsigned Start, unsigned Stride, unsigned VF)
Create a stride shuffle mask.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
auto find_if_not(R &&Range, UnaryPredicate P)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
LLVM_ABI ConstantRange getVScaleRange(const Function *F, unsigned BitWidth)
Determine the possible constant range of vscale with the given bit width, based on the vscale_range f...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
LLVM_ABI bool isOneOrOneSplat(SDValue V, bool AllowUndefs=false)
Return true if the value is a constant 1 integer or a splatted vector of a constant 1 integer (with n...
@ Mod
The access may modify the value stored in memory.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
To bit_cast(const From &from) noexcept
LLVM_ABI llvm::SmallVector< int, 16 > createInterleaveMask(unsigned VF, unsigned NumVecs)
Create an interleave shuffle mask.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ Sub
Subtraction of integers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
@ Fast
Assign the register banks as fast as possible (default).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
RoundingMode
Rounding mode.
@ TowardZero
roundTowardZero.
@ NearestTiesToEven
roundTiesToEven.
@ TowardPositive
roundTowardPositive.
@ NearestTiesToAway
roundTiesToAway.
@ TowardNegative
roundTowardNegative.
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isZeroOrZeroSplat(SDValue N, bool AllowUndefs=false)
Return true if the value is a constant 0 integer or a splatted vector of a constant 0 integer (with n...
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isNullFPConstant(SDValue V)
Returns true if V is an FP constant with a value of positive zero.
APFloat neg(APFloat X)
Returns the negated value of the argument.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
unsigned Log2(Align A)
Returns the log2 of the alignment.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
@ Increment
Incrementally increasing token ID.
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
MCRegisterClass TargetRegisterClass
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
@ PositiveZero
Denormals are flushed to positive zero.
@ IEEE
IEEE-754 denormal numbers preserved.
constexpr bool inputsAreZero() const
Return true if input denormals must be implicitly treated as 0.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
EVT changeTypeToInteger() const
Return the type converted to an equivalently sized integer or vector with integer element type.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
ElementCount getVectorElementCount() const
EVT getDoubleNumVectorElementsVT(LLVMContext &Context) const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
EVT getHalfSizedIntegerVT(LLVMContext &Context) const
Finds the smallest simple value type that is greater than or equal to half the width of this EVT.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
EVT widenIntegerVectorElementType(LLVMContext &Context) const
Return a VT for an integer vector type with the size of the elements doubled.
EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
bool isScalableVT() const
Return true if the type is a scalable type.
bool isFixedLengthVector() const
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
EVT widenIntegerElementType(LLVMContext &Context) const
Return a VT for an integer element type with doubled bit width.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
bool isInteger() const
Return true if this is an integer or a vector integer type.
static KnownBits makeConstant(const APInt &C)
Create known bits from a known constant.
KnownBits anyextOrTrunc(unsigned BitWidth) const
Return known bits for an "any" extension or truncation of the value we're tracking.
static LLVM_ABI KnownBits smax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smax(LHS, RHS).
bool isNonNegative() const
Returns true if this value is known to be non-negative.
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
KnownBits trunc(unsigned BitWidth) const
Return known bits for a truncation of the value we're tracking.
KnownBits byteSwap() const
static LLVM_ABI std::optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
unsigned countMaxPopulation() const
Returns the maximum number of bits that could be one.
KnownBits reverseBits() const
KnownBits concat(const KnownBits &Lo) const
Concatenate the bits from Lo onto the bottom of *this.
static LLVM_ABI KnownBits umax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umax(LHS, RHS).
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
static LLVM_ABI KnownBits smin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for smin(LHS, RHS).
static LLVM_ABI std::optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
static LLVM_ABI std::optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
static LLVM_ABI KnownBits computeForAddSub(bool Add, bool NSW, bool NUW, const KnownBits &LHS, const KnownBits &RHS)
Compute known bits resulting from adding LHS and RHS.
static LLVM_ABI std::optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
static LLVM_ABI std::optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
bool isNegative() const
Returns true if this value is known to be negative.
static LLVM_ABI KnownBits mul(const KnownBits &LHS, const KnownBits &RHS, bool NoUndefSelfMultiply=false)
Compute known bits resulting from multiplying LHS and RHS.
static LLVM_ABI std::optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
static LLVM_ABI std::optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.
unsigned countMinPopulation() const
Returns the number of bits known to be one.
static LLVM_ABI std::optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
static LLVM_ABI KnownBits umin(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umin(LHS, RHS).
This class contains a discriminated union of information about pointers in memory operands,...
LLVM_ABI unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
MachinePointerInfo getWithOffset(int64_t O) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static bool hasVectorMaskArgument(RTLIB::LibcallImpl Impl)
Returns true if the function has a vector mask argument, which is assumed to be the last argument.
These are IR-level optimization flags that may be propagated to SDNodes.
bool hasNoUnsignedWrap() const
bool hasNoSignedWrap() const
void setNoSignedWrap(bool b)
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
Magic data for optimising signed division by a constant.
unsigned ShiftAmount
shift amount
static LLVM_ABI SignedDivisionByConstantInfo get(const APInt &D)
Calculate the magic numbers required to implement a signed integer division by a constant as a sequen...
This contains information for each constraint that we are lowering.
std::string ConstraintCode
This contains the actual string for the code, like "m".
LLVM_ABI unsigned getMatchedOperand() const
If this is an input matching constraint, this method returns the output operand it matches.
LLVM_ABI bool isMatchingInputConstraint() const
Return true of this is an input operand that is a matching constraint like "4".
This structure contains all information that is necessary for lowering calls.
CallLoweringInfo & setIsPostTypeLegalization(bool Value=true)
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
CallLoweringInfo & setDiscardResult(bool Value=true)
CallLoweringInfo & setZExtResult(bool Value=true)
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CallLoweringInfo & setSExtResult(bool Value=true)
CallLoweringInfo & setNoReturn(bool Value=true)
CallLoweringInfo & setChain(SDValue InChain)
bool isBeforeLegalizeOps() const
LLVM_ABI void AddToWorklist(SDNode *N)
bool isCalledByLegalizer() const
bool isBeforeLegalize() const
LLVM_ABI void CommitTargetLoweringOpt(const TargetLoweringOpt &TLO)
This structure is used to pass arguments to makeLibCall function.
MakeLibCallOptions & setIsPostTypeLegalization(bool Value=true)
ArrayRef< EVT > OpsVTBeforeSoften
bool IsPostTypeLegalization
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
ArrayRef< Type * > OpsTypeOverrides
MakeLibCallOptions & setIsSigned(bool Value=true)
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
bool CombineTo(SDValue O, SDValue N)
bool LegalOperations() const
Magic data for optimising unsigned division by a constant.
unsigned PreShift
pre-shift amount
unsigned PostShift
post-shift amount
static LLVM_ABI UnsignedDivisionByConstantInfo get(const APInt &D, unsigned LeadingZeros=0, bool AllowEvenDivisorOptimization=true, bool AllowWidenOptimization=false)
Calculate the magic numbers required to implement an unsigned integer division by a constant as a seq...
bool Widen
use widen optimization
fltNonfiniteBehavior nonFiniteBehavior
fltNanEncoding nanEncoding