66 if (
F.getFnAttribute(
"disable-tail-calls").getValueAsBool())
72 AttrBuilder CallerAttrs(
F.getContext(),
F.getAttributes().getRetAttrs());
73 for (
const auto &Attr : {Attribute::Alignment, Attribute::Dereferenceable,
74 Attribute::DereferenceableOrNull, Attribute::NoAlias,
75 Attribute::NonNull, Attribute::NoUndef,
76 Attribute::Range, Attribute::NoFPClass})
77 CallerAttrs.removeAttribute(Attr);
79 if (CallerAttrs.hasAttributes())
83 if (CallerAttrs.contains(Attribute::ZExt) ||
84 CallerAttrs.contains(Attribute::SExt))
95 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
112 if (
MRI.getLiveInPhysReg(ArgReg) != Reg)
122 IsSExt =
Call->paramHasAttr(ArgIdx, Attribute::SExt);
123 IsZExt =
Call->paramHasAttr(ArgIdx, Attribute::ZExt);
124 IsNoExt =
Call->paramHasAttr(ArgIdx, Attribute::NoExt);
125 IsInReg =
Call->paramHasAttr(ArgIdx, Attribute::InReg);
126 IsSRet =
Call->paramHasAttr(ArgIdx, Attribute::StructRet);
127 IsNest =
Call->paramHasAttr(ArgIdx, Attribute::Nest);
128 IsByVal =
Call->paramHasAttr(ArgIdx, Attribute::ByVal);
138 "multiple ABI attributes?");
154std::pair<SDValue, SDValue>
159 if (LibcallImpl == RTLIB::Unsupported)
166 Args.reserve(
Ops.size());
169 for (
unsigned i = 0; i <
Ops.size(); ++i) {
171 Type *Ty = i < OpsTypeOverrides.
size() && OpsTypeOverrides[i]
172 ? OpsTypeOverrides[i]
181 Entry.IsZExt = !Entry.IsSExt;
185 Entry.IsSExt = Entry.IsZExt =
false;
187 Args.push_back(Entry);
194 Type *OrigRetTy = RetTy;
197 bool zeroExtend = !signExtend;
202 signExtend = zeroExtend =
false;
208 Callee, std::move(Args))
218 LLVMContext &Context, std::vector<EVT> &MemOps,
unsigned Limit,
219 const MemOp &
Op,
unsigned DstAS,
unsigned SrcAS,
220 const AttributeList &FuncAttributes)
const {
221 if (Limit != ~
unsigned(0) &&
Op.isMemcpyWithFixedDstAlign() &&
222 Op.getSrcAlign() <
Op.getDstAlign())
227 if (VT == MVT::Other) {
231 VT = MVT::LAST_INTEGER_VALUETYPE;
232 if (
Op.isFixedDstAlign())
239 MVT LVT = MVT::LAST_INTEGER_VALUETYPE;
250 unsigned NumMemOps = 0;
254 while (VTSize >
Size) {
265 else if (NewVT == MVT::i64 &&
277 if (NewVT == MVT::i8)
286 if (NumMemOps &&
Op.allowOverlap() && NewVTSize <
Size &&
288 VT, DstAS,
Op.isFixedDstAlign() ?
Op.getDstAlign() :
Align(1),
298 if (++NumMemOps > Limit)
301 MemOps.push_back(VT);
326 bool IsSignaling)
const {
331 assert((VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f128 || VT == MVT::ppcf128)
332 &&
"Unsupported setcc type!");
335 RTLIB::Libcall LC1 = RTLIB::UNKNOWN_LIBCALL, LC2 = RTLIB::UNKNOWN_LIBCALL;
336 bool ShouldInvertCC =
false;
340 LC1 = (VT == MVT::f32) ? RTLIB::OEQ_F32 :
341 (VT == MVT::f64) ? RTLIB::OEQ_F64 :
342 (VT == MVT::f128) ? RTLIB::OEQ_F128 : RTLIB::OEQ_PPCF128;
346 LC1 = (VT == MVT::f32) ? RTLIB::UNE_F32 :
347 (VT == MVT::f64) ? RTLIB::UNE_F64 :
348 (VT == MVT::f128) ? RTLIB::UNE_F128 : RTLIB::UNE_PPCF128;
352 LC1 = (VT == MVT::f32) ? RTLIB::OGE_F32 :
353 (VT == MVT::f64) ? RTLIB::OGE_F64 :
354 (VT == MVT::f128) ? RTLIB::OGE_F128 : RTLIB::OGE_PPCF128;
358 LC1 = (VT == MVT::f32) ? RTLIB::OLT_F32 :
359 (VT == MVT::f64) ? RTLIB::OLT_F64 :
360 (VT == MVT::f128) ? RTLIB::OLT_F128 : RTLIB::OLT_PPCF128;
364 LC1 = (VT == MVT::f32) ? RTLIB::OLE_F32 :
365 (VT == MVT::f64) ? RTLIB::OLE_F64 :
366 (VT == MVT::f128) ? RTLIB::OLE_F128 : RTLIB::OLE_PPCF128;
370 LC1 = (VT == MVT::f32) ? RTLIB::OGT_F32 :
371 (VT == MVT::f64) ? RTLIB::OGT_F64 :
372 (VT == MVT::f128) ? RTLIB::OGT_F128 : RTLIB::OGT_PPCF128;
375 ShouldInvertCC =
true;
378 LC1 = (VT == MVT::f32) ? RTLIB::UO_F32 :
379 (VT == MVT::f64) ? RTLIB::UO_F64 :
380 (VT == MVT::f128) ? RTLIB::UO_F128 : RTLIB::UO_PPCF128;
384 ShouldInvertCC =
true;
387 LC1 = (VT == MVT::f32) ? RTLIB::UO_F32 :
388 (VT == MVT::f64) ? RTLIB::UO_F64 :
389 (VT == MVT::f128) ? RTLIB::UO_F128 : RTLIB::UO_PPCF128;
390 LC2 = (VT == MVT::f32) ? RTLIB::OEQ_F32 :
391 (VT == MVT::f64) ? RTLIB::OEQ_F64 :
392 (VT == MVT::f128) ? RTLIB::OEQ_F128 : RTLIB::OEQ_PPCF128;
396 ShouldInvertCC =
true;
399 LC1 = (VT == MVT::f32) ? RTLIB::OGE_F32 :
400 (VT == MVT::f64) ? RTLIB::OGE_F64 :
401 (VT == MVT::f128) ? RTLIB::OGE_F128 : RTLIB::OGE_PPCF128;
404 LC1 = (VT == MVT::f32) ? RTLIB::OGT_F32 :
405 (VT == MVT::f64) ? RTLIB::OGT_F64 :
406 (VT == MVT::f128) ? RTLIB::OGT_F128 : RTLIB::OGT_PPCF128;
409 LC1 = (VT == MVT::f32) ? RTLIB::OLE_F32 :
410 (VT == MVT::f64) ? RTLIB::OLE_F64 :
411 (VT == MVT::f128) ? RTLIB::OLE_F128 : RTLIB::OLE_PPCF128;
414 LC1 = (VT == MVT::f32) ? RTLIB::OLT_F32 :
415 (VT == MVT::f64) ? RTLIB::OLT_F64 :
416 (VT == MVT::f128) ? RTLIB::OLT_F128 : RTLIB::OLT_PPCF128;
434 if (LC1Impl == RTLIB::Unsupported) {
436 "no libcall available to soften floating-point compare");
440 if (ShouldInvertCC) {
442 CCCode = getSetCCInverse(CCCode, RetVT);
445 if (LC2 == RTLIB::UNKNOWN_LIBCALL) {
450 if (LC2Impl == RTLIB::Unsupported) {
452 "no libcall available to soften floating-point compare");
456 "unordered call should be simple boolean");
466 auto Call2 =
makeLibCall(DAG, LC2, RetVT,
Ops, CallOptions, dl, Chain);
469 CCCode = getSetCCInverse(CCCode, RetVT);
470 NewLHS = DAG.
getSetCC(dl, SetCCVT, Call2.first, NewRHS, CCCode);
513 return DAG.
getNode(ISD::BRIND, dl, MVT::Other, Chain, Addr);
523 if (!TM.shouldAssumeDSOLocal(GV))
543 const APInt &DemandedElts,
546 unsigned Opcode =
Op.getOpcode();
565 if (!Op1C || Op1C->isOpaque())
569 const APInt &
C = Op1C->getAPIntValue();
574 EVT VT =
Op.getValueType();
591 EVT VT =
Op.getValueType();
606 "ShrinkDemandedOp only supports binary operators!");
607 assert(
Op.getNode()->getNumValues() == 1 &&
608 "ShrinkDemandedOp only supports nodes with one result!");
610 EVT VT =
Op.getValueType();
619 Op.getOperand(1).getValueType().getScalarSizeInBits() ==
BitWidth &&
620 "ShrinkDemandedOp only supports operands that have the same size!");
624 if (!
Op.getNode()->hasOneUse())
640 unsigned Opcode =
Op.getOpcode();
641 if (Opcode == ISD::PTRADD) {
650 assert(DemandedSize <= SmallVTBits &&
"Narrowed below demanded bits?");
674 const APInt &DemandedElts,
694 bool AssumeSingleUse)
const {
695 EVT VT =
Op.getValueType();
711 EVT VT =
Op.getValueType();
729 switch (
Op.getOpcode()) {
735 EVT SrcVT = Src.getValueType();
736 EVT DstVT =
Op.getValueType();
742 if (NumSrcEltBits == NumDstEltBits)
747 if (SrcVT.
isVector() && (NumDstEltBits % NumSrcEltBits) == 0) {
748 unsigned Scale = NumDstEltBits / NumSrcEltBits;
752 for (
unsigned i = 0; i != Scale; ++i) {
753 unsigned EltOffset = IsLE ? i : (Scale - 1 - i);
754 unsigned BitOffset = EltOffset * NumSrcEltBits;
757 DemandedSrcBits |=
Sub;
758 for (
unsigned j = 0; j != NumElts; ++j)
760 DemandedSrcElts.
setBit((j * Scale) + i);
765 Src, DemandedSrcBits, DemandedSrcElts, DAG,
Depth + 1))
770 if (IsLE && (NumSrcEltBits % NumDstEltBits) == 0) {
771 unsigned Scale = NumSrcEltBits / NumDstEltBits;
775 for (
unsigned i = 0; i != NumElts; ++i)
776 if (DemandedElts[i]) {
777 unsigned Offset = (i % Scale) * NumDstEltBits;
779 DemandedSrcElts.
setBit(i / Scale);
783 Src, DemandedSrcBits, DemandedSrcElts, DAG,
Depth + 1))
797 return Op.getOperand(0);
799 return Op.getOperand(1);
810 return Op.getOperand(0);
812 return Op.getOperand(1);
822 return Op.getOperand(0);
824 return Op.getOperand(1);
830 return Op.getOperand(0);
834 return Op.getOperand(1);
840 if (std::optional<unsigned> MaxSA =
843 unsigned ShAmt = *MaxSA;
844 unsigned NumSignBits =
847 if (NumSignBits > ShAmt && (NumSignBits - ShAmt) >= (UpperDemandedBits))
855 if (std::optional<unsigned> MaxSA =
858 unsigned ShAmt = *MaxSA;
862 unsigned NumSignBits =
901 if (NumSignBits >= (
BitWidth - ExBits + 1))
914 EVT SrcVT = Src.getValueType();
915 EVT DstVT =
Op.getValueType();
916 if (IsLE && DemandedElts == 1 &&
932 !DemandedElts[CIdx->getZExtValue()])
943 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
946 if (DemandedSubElts == 0)
956 bool AllUndef =
true, IdentityLHS =
true, IdentityRHS =
true;
957 for (
unsigned i = 0; i != NumElts; ++i) {
958 int M = ShuffleMask[i];
959 if (M < 0 || !DemandedElts[i])
962 IdentityLHS &= (M == (int)i);
963 IdentityRHS &= ((M - NumElts) == i);
969 return Op.getOperand(0);
971 return Op.getOperand(1);
991 unsigned Depth)
const {
992 EVT VT =
Op.getValueType();
1005 unsigned Depth)
const {
1019 "SRL or SRA node is required here!");
1022 if (!N1C || !N1C->
isOne())
1069 unsigned ShiftOpc =
Op.getOpcode();
1070 bool IsSigned =
false;
1074 unsigned NumSigned = std::min(NumSignedA, NumSignedB) - 1;
1079 unsigned NumZero = std::min(NumZeroA, NumZeroB);
1085 if (NumZero >= 2 && NumSigned < NumZero) {
1090 if (NumSigned >= 1) {
1098 if (NumZero >= 1 && NumSigned < NumZero) {
1118 EVT VT =
Op.getValueType();
1132 Add.getOperand(1)) &&
1163 unsigned Depth,
bool AssumeSingleUse)
const {
1166 "Mask size mismatches value type size!");
1171 EVT VT =
Op.getValueType();
1173 unsigned NumElts = OriginalDemandedElts.
getBitWidth();
1175 "Unexpected vector size");
1178 APInt DemandedElts = OriginalDemandedElts;
1203 bool HasMultiUse =
false;
1204 if (!AssumeSingleUse && !
Op.getNode()->hasOneUse()) {
1213 }
else if (OriginalDemandedBits == 0 || OriginalDemandedElts == 0) {
1222 switch (
Op.getOpcode()) {
1226 if (!DemandedElts[0])
1231 unsigned SrcBitWidth = Src.getScalarValueSizeInBits();
1238 if (DemandedElts == 1)
1267 EVT MemVT = LD->getMemoryVT();
1284 APInt DemandedVecElts(DemandedElts);
1286 unsigned Idx = CIdx->getZExtValue();
1290 if (!DemandedElts[Idx])
1307 if (!!DemandedVecElts)
1320 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
1322 APInt DemandedSrcElts = DemandedElts;
1323 DemandedSrcElts.
clearBits(Idx, Idx + NumSubElts);
1334 if (!!DemandedSubElts)
1336 if (!!DemandedSrcElts)
1346 if (NewSub || NewSrc) {
1347 NewSub = NewSub ? NewSub :
Sub;
1348 NewSrc = NewSrc ? NewSrc : Src;
1361 if (Src.getValueType().isScalableVector())
1364 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
1365 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts).
shl(Idx);
1387 EVT SubVT =
Op.getOperand(0).getValueType();
1388 unsigned NumSubVecs =
Op.getNumOperands();
1390 for (
unsigned i = 0; i != NumSubVecs; ++i) {
1391 APInt DemandedSubElts =
1392 DemandedElts.
extractBits(NumSubElts, i * NumSubElts);
1394 Known2, TLO,
Depth + 1))
1397 if (!!DemandedSubElts)
1407 APInt DemandedLHS, DemandedRHS;
1412 if (!!DemandedLHS || !!DemandedRHS) {
1417 if (!!DemandedLHS) {
1423 if (!!DemandedRHS) {
1435 if (DemandedOp0 || DemandedOp1) {
1436 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1437 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1472 LHSKnown.
One == ~RHSC->getAPIntValue()) {
1484 unsigned NumSubElts =
1505 Known2, TLO,
Depth + 1))
1531 if (DemandedOp0 || DemandedOp1) {
1532 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1533 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1552 Known2, TLO,
Depth + 1)) {
1576 if (DemandedOp0 || DemandedOp1) {
1577 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1578 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1589 for (
int I = 0;
I != 2; ++
I) {
1592 SDValue Alt =
Op.getOperand(1 -
I).getOperand(0);
1593 SDValue C2 =
Op.getOperand(1 -
I).getOperand(1);
1595 for (
int J = 0; J != 2; ++J) {
1648 if (
C->getAPIntValue() == Known2.
One) {
1657 if (!
C->isAllOnes() &&
DemandedBits.isSubsetOf(
C->getAPIntValue())) {
1669 if (ShiftC->getAPIntValue().ult(
BitWidth)) {
1670 uint64_t ShiftAmt = ShiftC->getZExtValue();
1673 : Ones.
lshr(ShiftAmt);
1690 if (!
C || !
C->isAllOnes())
1700 if (DemandedOp0 || DemandedOp1) {
1701 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
1702 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
1713 Known, TLO,
Depth + 1))
1716 Known2, TLO,
Depth + 1))
1728 Known, TLO,
Depth + 1))
1731 Known2, TLO,
Depth + 1))
1739 Known, TLO,
Depth + 1))
1742 Known2, TLO,
Depth + 1))
1785 if (std::optional<unsigned> KnownSA =
1787 unsigned ShAmt = *KnownSA;
1797 if (std::optional<unsigned> InnerSA =
1799 unsigned C1 = *InnerSA;
1801 int Diff = ShAmt - C1;
1820 if (ShAmt < InnerBits &&
DemandedBits.getActiveBits() <= InnerBits &&
1838 InnerOp, DemandedElts,
Depth + 2)) {
1839 unsigned InnerShAmt = *SA2;
1840 if (InnerShAmt < ShAmt && InnerShAmt < InnerBits &&
1842 (InnerBits - InnerShAmt + ShAmt) &&
1870 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
1881 Op.getNode()->hasOneUse()) {
1892 assert(DemandedSize <= SmallVTBits &&
1893 "Narrowed below demanded bits?");
1923 Flags.setNoUnsignedWrap(IsNUW);
1928 NewShiftAmt, Flags);
1954 if (std::optional<unsigned> MaxSA =
1956 unsigned ShAmt = *MaxSA;
1957 unsigned NumSignBits =
1960 if (NumSignBits > ShAmt && (NumSignBits - ShAmt) >= (UpperDemandedBits))
1970 if (std::optional<unsigned> KnownSA =
1972 unsigned ShAmt = *KnownSA;
1982 if (std::optional<unsigned> InnerSA =
1984 unsigned C1 = *InnerSA;
1986 int Diff = ShAmt - C1;
2002 if (std::optional<unsigned> InnerSA =
2004 unsigned C1 = *InnerSA;
2006 unsigned Combined = std::min(C1 + ShAmt,
BitWidth - 1);
2018 if (
Op->getFlags().hasExact())
2053 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
2067 if (std::optional<unsigned> MaxSA =
2069 unsigned ShAmt = *MaxSA;
2073 unsigned NumSignBits =
2082 DemandedElts,
Depth + 1))
2106 if (std::optional<unsigned> KnownSA =
2108 unsigned ShAmt = *KnownSA;
2115 if (std::optional<unsigned> InnerSA =
2117 unsigned LowBits =
BitWidth - ShAmt;
2123 if (*InnerSA == ShAmt) {
2133 unsigned NumSignBits =
2135 if (NumSignBits > ShAmt)
2145 if (
Op->getFlags().hasExact())
2182 Op0, InDemandedMask, DemandedElts, TLO.
DAG,
Depth + 1);
2192 DemandedElts,
Depth + 1))
2205 unsigned Amt = SA->getAPIntValue().urem(
BitWidth);
2211 Known, TLO,
Depth + 1))
2227 Known2 <<= (IsFSHL ? Amt : (
BitWidth - Amt));
2228 Known >>= (IsFSHL ? (
BitWidth - Amt) : Amt);
2235 Op0, Demanded0, DemandedElts, TLO.
DAG,
Depth + 1);
2237 Op1, Demanded1, DemandedElts, TLO.
DAG,
Depth + 1);
2238 if (DemandedOp0 || DemandedOp1) {
2239 DemandedOp0 = DemandedOp0 ? DemandedOp0 : Op0;
2240 DemandedOp1 = DemandedOp1 ? DemandedOp1 : Op1;
2252 Known2, TLO,
Depth + 1))
2268 unsigned Amt = SA->getAPIntValue().urem(
BitWidth);
2284 DemandedBits.countr_zero() >= (IsROTL ? Amt : RevAmt)) {
2289 DemandedBits.countl_zero() >= (IsROTL ? RevAmt : Amt)) {
2308 unsigned Opc =
Op.getOpcode();
2315 unsigned NumSignBits =
2319 if (NumSignBits >= NumDemandedUpperBits)
2385 unsigned ShiftAmount = NLZ > NTZ ? NLZ - NTZ : NTZ - NLZ;
2417 unsigned MinSignedBits =
2419 bool AlreadySignExtended = ExVTBits >= MinSignedBits;
2422 if (!AlreadySignExtended) {
2440 InputDemandedBits.
setBit(ExVTBits - 1);
2450 if (Known.
Zero[ExVTBits - 1])
2454 if (Known.
One[ExVTBits - 1]) {
2464 EVT HalfVT =
Op.getOperand(0).getValueType();
2478 Known = KnownHi.
concat(KnownLo);
2487 EVT SrcVT = Src.getValueType();
2496 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2507 APInt InDemandedElts = DemandedElts.
zext(InElts);
2518 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
2528 EVT SrcVT = Src.getValueType();
2533 APInt InDemandedElts = DemandedElts.
zext(InElts);
2538 InDemandedBits.
setBit(InBits - 1);
2544 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2581 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
2591 EVT SrcVT = Src.getValueType();
2598 if (IsLE && IsVecInReg && DemandedElts == 1 &&
2603 APInt InDemandedElts = DemandedElts.
zext(InElts);
2612 Src, InDemandedBits, InDemandedElts, TLO.
DAG,
Depth + 1))
2621 unsigned OperandBitWidth = Src.getScalarValueSizeInBits();
2634 Src, TruncMask, DemandedElts, TLO.
DAG,
Depth + 1))
2639 switch (Src.getOpcode()) {
2650 if (Src.getNode()->hasOneUse()) {
2662 std::optional<unsigned> ShAmtC =
2664 if (!ShAmtC || *ShAmtC >=
BitWidth)
2666 unsigned ShVal = *ShAmtC;
2696 Known.
Zero |= ~InMask;
2697 Known.
One &= (~Known.Zero);
2703 ElementCount SrcEltCnt = Src.getValueType().getVectorElementCount();
2704 unsigned EltBitWidth = Src.getScalarValueSizeInBits();
2713 if (CIdx->getAPIntValue().ult(NumSrcElts))
2720 DemandedSrcBits = DemandedSrcBits.
trunc(EltBitWidth);
2729 Src, DemandedSrcBits, DemandedSrcElts, TLO.
DAG,
Depth + 1)) {
2731 TLO.
DAG.
getNode(
Op.getOpcode(), dl, VT, DemandedSrc, Idx);
2741 case ISD::BITCAST: {
2745 EVT SrcVT = Src.getValueType();
2755 if ((OpVTLegal || i32Legal) && VT.
isSimple() && SrcVT != MVT::f16 &&
2756 SrcVT != MVT::f128) {
2758 EVT Ty = OpVTLegal ? VT : MVT::i32;
2762 unsigned OpVTSizeInBits =
Op.getValueSizeInBits();
2763 if (!OpVTLegal && OpVTSizeInBits > 32)
2765 unsigned ShVal =
Op.getValueSizeInBits() - 1;
2775 unsigned Scale =
BitWidth / NumSrcEltBits;
2779 for (
unsigned i = 0; i != Scale; ++i) {
2780 unsigned EltOffset = IsLE ? i : (Scale - 1 - i);
2781 unsigned BitOffset = EltOffset * NumSrcEltBits;
2783 if (!
Sub.isZero()) {
2784 DemandedSrcBits |=
Sub;
2785 for (
unsigned j = 0; j != NumElts; ++j)
2786 if (DemandedElts[j])
2787 DemandedSrcElts.
setBit((j * Scale) + i);
2791 APInt KnownSrcUndef, KnownSrcZero;
2793 KnownSrcZero, TLO,
Depth + 1))
2798 KnownSrcBits, TLO,
Depth + 1))
2800 }
else if (IsLE && (NumSrcEltBits %
BitWidth) == 0) {
2802 unsigned Scale = NumSrcEltBits /
BitWidth;
2806 for (
unsigned i = 0; i != NumElts; ++i)
2807 if (DemandedElts[i]) {
2810 DemandedSrcElts.
setBit(i / Scale);
2814 APInt KnownSrcUndef, KnownSrcZero;
2816 KnownSrcZero, TLO,
Depth + 1))
2822 KnownSrcBits, TLO,
Depth + 1))
2828 Src, DemandedSrcBits, DemandedSrcElts, TLO.
DAG,
Depth + 1)) {
2850 if (
C &&
C->getAPIntValue().countr_zero() == CTZ) {
2866 if (
Op.getOperand(0).getValueType() !=
Op.getOperand(1).getValueType())
2874 SDValue Op0 =
Op.getOperand(0), Op1 =
Op.getOperand(1);
2879 auto GetDemandedBitsLHSMask = [&](
APInt Demanded,
2888 DemandedElts, KnownOp0, TLO,
Depth + 1) ||
2905 Op0, LoMask, DemandedElts, TLO.
DAG,
Depth + 1);
2907 Op1, LoMask, DemandedElts, TLO.
DAG,
Depth + 1);
2908 if (DemandedOp0 || DemandedOp1) {
2909 Op0 = DemandedOp0 ? DemandedOp0 : Op0;
2910 Op1 = DemandedOp1 ? DemandedOp1 : Op1;
2924 if (
C && !
C->isAllOnes() && !
C->isOne() &&
2925 (
C->getAPIntValue() | HighMask).isAllOnes()) {
2937 auto getShiftLeftAmt = [&HighMask](
SDValue Mul) ->
unsigned {
2964 if (
unsigned ShAmt = getShiftLeftAmt(Op0))
2967 if (
unsigned ShAmt = getShiftLeftAmt(Op1))
2968 return foldMul(
ISD::SUB, Op1.getOperand(0), Op0, ShAmt);
2972 if (
unsigned ShAmt = getShiftLeftAmt(Op1))
2973 return foldMul(
ISD::ADD, Op1.getOperand(0), Op0, ShAmt);
2981 Op.getOpcode() !=
ISD::SUB, Flags.hasNoSignedWrap(),
2982 Flags.hasNoUnsignedWrap(), KnownOp0, KnownOp1);
3003 Known.
Zero |= SignMask;
3004 Known.
One &= ~SignMask;
3021 Known, TLO,
Depth + 1) ||
3035 Known.
Zero &= ~SignMask0;
3036 Known.
One &= ~SignMask0;
3051 Known.
Zero ^= SignMask;
3052 Known.
One ^= SignMask;
3063 if (
Op.getValueType().isScalableVector())
3082 auto *C = dyn_cast<ConstantSDNode>(V);
3083 return C && C->isOpaque();
3104 const APInt &DemandedElts,
3110 APInt KnownUndef, KnownZero;
3124 const APInt &UndefOp0,
3125 const APInt &UndefOp1) {
3128 "Vector binop only");
3133 UndefOp1.
getBitWidth() == NumElts &&
"Bad type for undef analysis");
3135 auto getUndefOrConstantElt = [&](
SDValue V,
unsigned Index,
3136 const APInt &UndefVals) {
3137 if (UndefVals[Index])
3153 for (
unsigned i = 0; i != NumElts; ++i) {
3172 bool AssumeSingleUse)
const {
3173 EVT VT =
Op.getValueType();
3174 unsigned Opcode =
Op.getOpcode();
3175 APInt DemandedElts = OriginalDemandedElts;
3189 "Mask size mismatches value type element count!");
3198 if (!AssumeSingleUse && !
Op.getNode()->hasOneUse())
3202 if (DemandedElts == 0) {
3217 auto SimplifyDemandedVectorEltsBinOp = [&](
SDValue Op0,
SDValue Op1) {
3222 if (NewOp0 || NewOp1) {
3225 NewOp1 ? NewOp1 : Op1,
Op->getFlags());
3233 if (!DemandedElts[0]) {
3240 case ISD::BITCAST: {
3242 EVT SrcVT = Src.getValueType();
3249 for (
unsigned I = 0;
I != NumElts; ++
I) {
3250 if (DemandedElts[
I]) {
3251 unsigned Offset =
I * EltSize;
3264 if (NumSrcElts == NumElts)
3266 KnownZero, TLO,
Depth + 1);
3268 APInt SrcDemandedElts, SrcZero, SrcUndef;
3272 if ((NumElts % NumSrcElts) == 0) {
3273 unsigned Scale = NumElts / NumSrcElts;
3285 for (
unsigned i = 0; i != NumElts; ++i)
3286 if (DemandedElts[i]) {
3287 unsigned Ofs = (i % Scale) * EltSizeInBits;
3288 SrcDemandedBits.
setBits(Ofs, Ofs + EltSizeInBits);
3300 for (
unsigned SubElt = 0; SubElt != Scale; ++SubElt) {
3304 for (
unsigned SrcElt = 0; SrcElt != NumSrcElts; ++SrcElt) {
3305 unsigned Elt = Scale * SrcElt + SubElt;
3306 if (DemandedElts[Elt])
3314 for (
unsigned i = 0; i != NumSrcElts; ++i) {
3315 if (SrcDemandedElts[i]) {
3317 KnownZero.
setBits(i * Scale, (i + 1) * Scale);
3319 KnownUndef.
setBits(i * Scale, (i + 1) * Scale);
3327 if ((NumSrcElts % NumElts) == 0) {
3328 unsigned Scale = NumSrcElts / NumElts;
3336 for (
unsigned i = 0; i != NumElts; ++i) {
3337 if (DemandedElts[i]) {
3367 [&](
SDValue Elt) { return Op.getOperand(0) != Elt; })) {
3369 bool Updated =
false;
3370 for (
unsigned i = 0; i != NumElts; ++i) {
3381 for (
unsigned i = 0; i != NumElts; ++i) {
3383 if (
SrcOp.isUndef()) {
3385 }
else if (EltSizeInBits ==
SrcOp.getScalarValueSizeInBits() &&
3393 EVT SubVT =
Op.getOperand(0).getValueType();
3394 unsigned NumSubVecs =
Op.getNumOperands();
3396 for (
unsigned i = 0; i != NumSubVecs; ++i) {
3399 APInt SubUndef, SubZero;
3403 KnownUndef.
insertBits(SubUndef, i * NumSubElts);
3404 KnownZero.
insertBits(SubZero, i * NumSubElts);
3409 bool FoundNewSub =
false;
3411 for (
unsigned i = 0; i != NumSubVecs; ++i) {
3415 SubOp, SubElts, TLO.
DAG,
Depth + 1);
3416 DemandedSubOps.
push_back(NewSubOp ? NewSubOp : SubOp);
3417 FoundNewSub = NewSubOp ?
true : FoundNewSub;
3433 unsigned NumSubElts =
Sub.getValueType().getVectorNumElements();
3435 APInt DemandedSrcElts = DemandedElts;
3436 DemandedSrcElts.
clearBits(Idx, Idx + NumSubElts);
3439 if (!DemandedSubElts)
3442 APInt SubUndef, SubZero;
3448 if (!DemandedSrcElts && !Src.isUndef())
3462 Src, DemandedSrcElts, TLO.
DAG,
Depth + 1);
3465 if (NewSrc || NewSub) {
3466 NewSrc = NewSrc ? NewSrc : Src;
3467 NewSub = NewSub ? NewSub :
Sub;
3469 NewSub,
Op.getOperand(2));
3478 if (Src.getValueType().isScalableVector())
3481 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
3482 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts).
shl(Idx);
3484 APInt SrcUndef, SrcZero;
3494 Src, DemandedSrcElts, TLO.
DAG,
Depth + 1);
3510 if (CIdx && CIdx->getAPIntValue().ult(NumElts)) {
3511 unsigned Idx = CIdx->getZExtValue();
3512 if (!DemandedElts[Idx])
3515 APInt DemandedVecElts(DemandedElts);
3518 KnownZero, TLO,
Depth + 1))
3527 APInt VecUndef, VecZero;
3541 APInt UndefSel, ZeroSel;
3547 APInt DemandedLHS(DemandedElts);
3548 APInt DemandedRHS(DemandedElts);
3549 APInt UndefLHS, ZeroLHS;
3550 APInt UndefRHS, ZeroRHS;
3558 KnownUndef = UndefLHS & UndefRHS;
3559 KnownZero = ZeroLHS & ZeroRHS;
3563 APInt DemandedSel = DemandedElts & ~KnownZero;
3564 if (DemandedSel != DemandedElts)
3577 APInt DemandedLHS(NumElts, 0);
3578 APInt DemandedRHS(NumElts, 0);
3579 for (
unsigned i = 0; i != NumElts; ++i) {
3580 int M = ShuffleMask[i];
3581 if (M < 0 || !DemandedElts[i])
3583 assert(0 <= M && M < (
int)(2 * NumElts) &&
"Shuffle index out of range");
3584 if (M < (
int)NumElts)
3587 DemandedRHS.
setBit(M - NumElts);
3593 bool FoldLHS = !DemandedLHS && !LHS.isUndef();
3594 bool FoldRHS = !DemandedRHS && !RHS.isUndef();
3595 if (FoldLHS || FoldRHS) {
3596 LHS = FoldLHS ? TLO.
DAG.
getUNDEF(LHS.getValueType()) : LHS;
3597 RHS = FoldRHS ? TLO.
DAG.
getUNDEF(RHS.getValueType()) : RHS;
3604 APInt UndefLHS, ZeroLHS;
3605 APInt UndefRHS, ZeroRHS;
3614 bool Updated =
false;
3615 bool IdentityLHS =
true, IdentityRHS =
true;
3617 for (
unsigned i = 0; i != NumElts; ++i) {
3618 int &M = NewMask[i];
3621 if (!DemandedElts[i] || (M < (
int)NumElts && UndefLHS[M]) ||
3622 (M >= (
int)NumElts && UndefRHS[M - NumElts])) {
3626 IdentityLHS &= (M < 0) || (M == (
int)i);
3627 IdentityRHS &= (M < 0) || ((M - NumElts) == i);
3632 if (Updated && !IdentityLHS && !IdentityRHS && !TLO.
LegalOps) {
3640 for (
unsigned i = 0; i != NumElts; ++i) {
3641 int M = ShuffleMask[i];
3644 }
else if (M < (
int)NumElts) {
3650 if (UndefRHS[M - NumElts])
3652 if (ZeroRHS[M - NumElts])
3661 APInt SrcUndef, SrcZero;
3663 unsigned NumSrcElts = Src.getValueType().getVectorNumElements();
3664 APInt DemandedSrcElts = DemandedElts.
zext(NumSrcElts);
3672 Op.getValueSizeInBits() == Src.getValueSizeInBits() &&
3673 DemandedSrcElts == 1) {
3686 if (IsLE && DemandedSrcElts == 1 && Src.getOpcode() ==
ISD::AND &&
3687 Op->isOnlyUserOf(Src.getNode()) &&
3688 Op.getValueSizeInBits() == Src.getValueSizeInBits()) {
3690 EVT SrcVT = Src.getValueType();
3697 ISD::AND,
DL, SrcVT, {Src.getOperand(1), Mask})) {
3711 if (Op0 == Op1 &&
Op->isOnlyUserOf(Op0.
getNode())) {
3712 APInt UndefLHS, ZeroLHS;
3734 APInt UndefRHS, ZeroRHS;
3738 APInt UndefLHS, ZeroLHS;
3743 KnownZero = ZeroLHS & ZeroRHS;
3749 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
3761 APInt UndefRHS, ZeroRHS;
3765 APInt UndefLHS, ZeroLHS;
3770 KnownZero = ZeroLHS;
3771 KnownUndef = UndefLHS & UndefRHS;
3776 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
3787 APInt SrcUndef, SrcZero;
3793 APInt DemandedElts0 = DemandedElts & ~SrcZero;
3798 KnownUndef &= DemandedElts0;
3799 KnownZero &= DemandedElts0;
3804 if (DemandedElts.
isSubsetOf(SrcZero | KnownZero | SrcUndef | KnownUndef))
3811 KnownZero |= SrcZero;
3812 KnownUndef &= SrcUndef;
3813 KnownUndef &= ~KnownZero;
3817 if (SimplifyDemandedVectorEltsBinOp(Op0, Op1))
3825 KnownZero, TLO,
Depth + 1))
3830 Op.getOperand(0), DemandedElts, TLO.
DAG,
Depth + 1))
3845 KnownZero, TLO,
Depth + 1))
3852 KnownZero, TLO,
Depth))
3858 TLO,
Depth, AssumeSingleUse))
3864 assert((KnownUndef & KnownZero) == 0 &&
"Elements flagged as undef AND zero");
3878 const APInt &DemandedElts,
3880 unsigned Depth)
const {
3885 "Should use MaskedValueIsZero if you don't know whether Op"
3886 " is a target node!");
3893 unsigned Depth)
const {
3900 unsigned Depth)
const {
3912 unsigned Depth)
const {
3921 unsigned Depth)
const {
3926 "Should use ComputeNumSignBits if you don't know whether Op"
3927 " is a target node!");
3944 "Should use SimplifyDemandedVectorElts if you don't know whether Op"
3945 " is a target node!");
3956 "Should use SimplifyDemandedBits if you don't know whether Op"
3957 " is a target node!");
3970 "Should use SimplifyMultipleUseDemandedBits if you don't know whether Op"
3971 " is a target node!");
4004 "Should use isGuaranteedNotToBeUndefOrPoison if you don't know whether Op"
4005 " is a target node!");
4012 return DAG.isGuaranteedNotToBeUndefOrPoison(V, PoisonOnly,
4024 "Should use canCreateUndefOrPoison if you don't know whether Op"
4025 " is a target node!");
4031 const APInt &DemandedElts,
4034 unsigned Depth)
const {
4039 "Should use isKnownNeverNaN if you don't know whether Op"
4040 " is a target node!");
4045 const APInt &DemandedElts,
4048 unsigned Depth)
const {
4053 "Should use isSplatValue if you don't know whether Op"
4054 " is a target node!");
4069 CVal = CN->getAPIntValue();
4070 EltWidth =
N.getValueType().getScalarSizeInBits();
4077 CVal = CVal.
trunc(EltWidth);
4083 return CVal.
isOne();
4125 return (
N->isOne() && !SExt) || (SExt && (
N->getValueType(0) != MVT::i1));
4128 return N->isAllOnes() && SExt;
4137 DAGCombinerInfo &DCI)
const {
4166 if (AndC &&
isNullConstant(N1) && AndC->getAPIntValue().isPowerOf2() &&
4169 AndC->getAPIntValue().getActiveBits());
4196 if (isXAndYEqZeroPreferableToXAndYEqY(
Cond, OpVT) &&
4204 if (DCI.isBeforeLegalizeOps() ||
4233 DAGCombinerInfo &DCI)
const {
4237 SelectionDAG &DAG = DCI.DAG;
4274SDValue TargetLowering::optimizeSetCCOfSignedTruncationCheck(
4276 const SDLoc &
DL)
const {
4287 ConstantSDNode *C01;
4316 auto checkConstants = [&
I1, &I01]() ->
bool {
4321 if (checkConstants()) {
4329 if (!checkConstants())
4335 const unsigned KeptBits =
I1.logBase2();
4336 const unsigned KeptBitsMinusOne = I01.
logBase2();
4339 if (KeptBits != (KeptBitsMinusOne + 1))
4344 SelectionDAG &DAG = DCI.DAG;
4353 return DAG.
getSetCC(
DL, SCCVT, SExtInReg,
X, NewCond);
4357SDValue TargetLowering::optimizeSetCCByHoistingAndByConstFromLogicalShift(
4359 DAGCombinerInfo &DCI,
const SDLoc &
DL)
const {
4361 "Should be a comparison with 0.");
4363 "Valid only for [in]equality comparisons.");
4365 unsigned NewShiftOpcode;
4368 SelectionDAG &DAG = DCI.DAG;
4371 auto Match = [&NewShiftOpcode, &
X, &
C, &
Y, &DAG,
this](
SDValue V) {
4375 unsigned OldShiftOpcode =
V.getOpcode();
4376 switch (OldShiftOpcode) {
4388 C =
V.getOperand(0);
4389 ConstantSDNode *CC =
4393 Y =
V.getOperand(1);
4395 ConstantSDNode *XC =
4398 X, XC, CC,
Y, OldShiftOpcode, NewShiftOpcode, DAG);
4415 EVT VT =
X.getValueType();
4430 DAGCombinerInfo &DCI)
const {
4433 "Unexpected binop");
4439 SelectionDAG &DAG = DCI.DAG;
4461 if (!DCI.isCalledByLegalizer())
4462 DCI.AddToWorklist(YShl1.
getNode());
4477 if (CTPOP.getOpcode() !=
ISD::CTPOP || !CTPOP.hasOneUse())
4480 EVT CTVT = CTPOP.getValueType();
4481 SDValue CTOp = CTPOP.getOperand(0);
4501 for (
unsigned i = 0; i <
Passes; i++) {
4550 auto getRotateSource = [](
SDValue X) {
4552 return X.getOperand(0);
4559 if (
SDValue R = getRotateSource(N0))
4592 if (!C1 || !C1->
isZero())
4617 if (
Or.getOperand(0) ==
Other) {
4618 X =
Or.getOperand(0);
4619 Y =
Or.getOperand(1);
4622 if (
Or.getOperand(1) ==
Other) {
4623 X =
Or.getOperand(1);
4624 Y =
Or.getOperand(0);
4634 if (matchOr(F0, F1)) {
4641 if (matchOr(F1, F0)) {
4657 const SDLoc &dl)
const {
4667 bool N0ConstOrSplat =
4669 bool N1ConstOrSplat =
4677 if (N0ConstOrSplat && !N1ConstOrSplat &&
4680 return DAG.
getSetCC(dl, VT, N1, N0, SwappedCC);
4686 if (!N0ConstOrSplat && !N1ConstOrSplat &&
4691 return DAG.
getSetCC(dl, VT, N1, N0, SwappedCC);
4700 const APInt &C1 = N1C->getAPIntValue();
4716 !Attr.hasFnAttr(Attribute::MinSize)) {
4720 return DAG.
getNode(LogicOp, dl, VT, IsXZero, IsYZero);
4751 const APInt &C1 = N1C->getAPIntValue();
4767 if ((
C->getAPIntValue()+1).isPowerOf2()) {
4768 MinBits =
C->getAPIntValue().countr_one();
4779 MinBits = LN0->getMemoryVT().getSizeInBits();
4783 MinBits = LN0->getMemoryVT().getSizeInBits();
4794 MinBits >= ReqdBits) {
4799 if (MinBits == 1 && C1 == 1)
4818 if (TopSetCC.
getValueType() == MVT::i1 && VT == MVT::i1 &&
4852 unsigned bestWidth = 0, bestOffset = 0;
4853 if (Lod->isSimple() && Lod->isUnindexed() &&
4854 (Lod->getMemoryVT().isByteSized() ||
4856 unsigned memWidth = Lod->getMemoryVT().getStoreSizeInBits();
4858 unsigned maskWidth = origWidth;
4862 origWidth = Lod->getMemoryVT().getSizeInBits();
4866 for (
unsigned width = 8; width < origWidth; width *= 2) {
4871 unsigned maxOffset = origWidth - width;
4872 for (
unsigned offset = 0; offset <= maxOffset; offset += 8) {
4873 if (Mask.isSubsetOf(newMask)) {
4874 unsigned ptrOffset =
4876 unsigned IsFast = 0;
4877 assert((ptrOffset % 8) == 0 &&
"Non-Bytealigned pointer offset");
4882 *DAG.
getContext(), Layout, newVT, Lod->getAddressSpace(),
4883 NewAlign, Lod->getMemOperand()->getFlags(), &IsFast) &&
4885 bestOffset = ptrOffset / 8;
4886 bestMask = Mask.lshr(offset);
4899 SDValue Ptr = Lod->getBasePtr();
4900 if (bestOffset != 0)
4903 DAG.
getLoad(newVT, dl, Lod->getChain(), Ptr,
4904 Lod->getPointerInfo().getWithOffset(bestOffset),
4905 Lod->getBaseAlign());
4984 ExtDstTy != ExtSrcTy &&
"Unexpected types!");
4991 return DAG.
getSetCC(dl, VT, ZextOp,
4993 }
else if ((N1C->isZero() || N1C->isOne()) &&
5040 return DAG.
getSetCC(dl, VT, Val, N1,
5043 }
else if (N1C->isOne()) {
5126 optimizeSetCCOfSignedTruncationCheck(VT, N0, N1,
Cond, DCI, dl))
5133 const APInt &C1 = N1C->getAPIntValue();
5135 APInt MinVal, MaxVal;
5157 (!N1C->isOpaque() || (
C.getBitWidth() <= 64 &&
5177 (!N1C->isOpaque() || (
C.getBitWidth() <= 64 &&
5225 if (
SDValue CC = optimizeSetCCByHoistingAndByConstFromLogicalShift(
5226 VT, N0, N1,
Cond, DCI, dl))
5233 bool CmpZero = N1C->isZero();
5234 bool CmpNegOne = N1C->isAllOnes();
5235 if ((CmpZero || CmpNegOne) && N0.
hasOneUse()) {
5238 unsigned EltBits = V.getScalarValueSizeInBits();
5239 if (V.getOpcode() !=
ISD::OR || (EltBits % 2) != 0)
5247 RHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
5250 Hi = RHS.getOperand(0);
5255 LHS.getConstantOperandAPInt(1) == (EltBits / 2) &&
5258 Hi = LHS.getOperand(0);
5266 unsigned HalfBits = EltBits / 2;
5277 if (IsConcat(N0,
Lo,
Hi))
5278 return MergeConcat(
Lo,
Hi);
5316 const APInt &C1 = N1C->getAPIntValue();
5331 unsigned ShCt = AndRHS->getAPIntValue().logBase2();
5332 if (AndRHS->getAPIntValue().isPowerOf2() &&
5339 }
else if (
Cond ==
ISD::SETEQ && C1 == AndRHS->getAPIntValue()) {
5359 const APInt &AndRHSC = AndRHS->getAPIntValue();
5411 return DAG.
getSetCC(dl, VT, Shift, CmpRHS, NewCond);
5419 assert(!CFP->getValueAPF().isNaN() &&
"Unexpected NaN value");
5440 !
isFPImmLegal(CFP->getValueAPF(), CFP->getValueType(0))) {
5441 bool IsFabs = N0.
getOpcode() == ISD::FABS;
5459 if (CFP->getValueAPF().isInfinity()) {
5460 bool IsNegInf = CFP->getValueAPF().isNegative();
5471 return DAG.
getSetCC(dl, VT, N0, N1, NewCond);
5480 "Integer types should be handled by FoldSetCC");
5486 if (UOF ==
unsigned(EqTrue))
5491 if (NewCond !=
Cond &&
5494 return DAG.
getSetCC(dl, VT, N0, N1, NewCond);
5501 if ((isSignedIntSetCC(
Cond) || isUnsignedIntSetCC(
Cond)) &&
5538 bool LegalRHSImm =
false;
5546 DAG.
getConstant(RHSC->getAPIntValue() - LHSR->getAPIntValue(),
5554 DAG.
getConstant(LHSR->getAPIntValue() ^ RHSC->getAPIntValue(),
5564 DAG.
getConstant(SUBC->getAPIntValue() - RHSC->getAPIntValue(),
5569 if (RHSC->getValueType(0).getSizeInBits() <= 64)
5578 if (
SDValue V = foldSetCCWithBinOp(VT, N0, N1,
Cond, dl, DCI))
5584 if (
SDValue V = foldSetCCWithBinOp(VT, N1, N0,
Cond, dl, DCI))
5587 if (
SDValue V = foldSetCCWithAnd(VT, N0, N1,
Cond, dl, DCI))
5590 if (
SDValue V = foldSetCCWithOr(VT, N0, N1,
Cond, dl, DCI))
5599 if (!
isIntDivCheap(VT, Attr) && !Attr.hasFnAttr(Attribute::MinSize)) {
5601 if (
SDValue Folded = buildUREMEqFold(VT, N0, N1,
Cond, DCI, dl))
5604 if (
SDValue Folded = buildSREMEqFold(VT, N0, N1,
Cond, DCI, dl))
5617 N0 = DAG.
getNOT(dl, Temp, OpVT);
5626 Temp = DAG.
getNOT(dl, N0, OpVT);
5633 Temp = DAG.
getNOT(dl, N1, OpVT);
5640 Temp = DAG.
getNOT(dl, N0, OpVT);
5647 Temp = DAG.
getNOT(dl, N1, OpVT);
5656 N0 = DAG.
getNode(ExtendCode, dl, VT, N0);
5684 GA = GASD->getGlobal();
5685 Offset += GASD->getOffset();
5689 if (
N->isAnyAdd()) {
5694 Offset += V->getSExtValue();
5699 Offset += V->getSExtValue();
5720 unsigned S = Constraint.
size();
5723 switch (Constraint[0]) {
5754 if (S > 1 && Constraint[0] ==
'{' && Constraint[S - 1] ==
'}') {
5755 if (S == 8 && Constraint.
substr(1, 6) ==
"memory")
5783 std::vector<SDValue> &
Ops,
5786 if (Constraint.
size() > 1)
5789 char ConstraintLetter = Constraint[0];
5790 switch (ConstraintLetter) {
5810 bool IsBool =
C->getConstantIntValue()->getBitWidth() == 1;
5820 if (ConstraintLetter !=
'n') {
5823 GA->getValueType(0),
5824 Offset + GA->getOffset()));
5829 BA->getBlockAddress(), BA->getValueType(0),
5830 Offset + BA->getOffset(), BA->getTargetFlags()));
5838 const unsigned OpCode =
Op.getOpcode();
5841 Op =
Op.getOperand(1);
5845 Op =
Op.getOperand(0);
5862std::pair<unsigned, const TargetRegisterClass *>
5868 assert(*(Constraint.
end() - 1) ==
'}' &&
"Not a brace enclosed constraint?");
5873 std::pair<unsigned, const TargetRegisterClass *> R =
5885 std::pair<unsigned, const TargetRegisterClass *> S =
5886 std::make_pair(PR, RC);
5931 unsigned maCount = 0;
5937 unsigned LabelNo = 0;
5940 ConstraintOperands.emplace_back(std::move(CI));
5944 if (OpInfo.multipleAlternatives.size() > maCount)
5945 maCount = OpInfo.multipleAlternatives.size();
5947 OpInfo.ConstraintVT = MVT::Other;
5950 switch (OpInfo.Type) {
5953 if (OpInfo.isIndirect) {
5954 OpInfo.CallOperandVal =
Call.getArgOperand(ArgNo);
5960 assert(!
Call.getType()->isVoidTy() &&
"Bad inline asm!");
5962 OpInfo.ConstraintVT =
5966 assert(ResNo == 0 &&
"Asm only has one result!");
5967 OpInfo.ConstraintVT =
5973 OpInfo.CallOperandVal =
Call.getArgOperand(ArgNo);
5984 if (OpInfo.CallOperandVal) {
5985 llvm::Type *OpTy = OpInfo.CallOperandVal->getType();
5986 if (OpInfo.isIndirect) {
5987 OpTy =
Call.getParamElementType(ArgNo);
5988 assert(OpTy &&
"Indirect operand must have elementtype attribute");
5993 if (STy->getNumElements() == 1)
5994 OpTy = STy->getElementType(0);
5999 unsigned BitSize =
DL.getTypeSizeInBits(OpTy);
6020 if (!ConstraintOperands.empty()) {
6022 unsigned bestMAIndex = 0;
6023 int bestWeight = -1;
6029 for (maIndex = 0; maIndex < maCount; ++maIndex) {
6031 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
6032 cIndex != eIndex; ++cIndex) {
6041 if (OpInfo.hasMatchingInput()) {
6043 if (OpInfo.ConstraintVT !=
Input.ConstraintVT) {
6044 if ((OpInfo.ConstraintVT.isInteger() !=
6045 Input.ConstraintVT.isInteger()) ||
6046 (OpInfo.ConstraintVT.getSizeInBits() !=
6047 Input.ConstraintVT.getSizeInBits())) {
6058 weightSum += weight;
6061 if (weightSum > bestWeight) {
6062 bestWeight = weightSum;
6063 bestMAIndex = maIndex;
6070 cInfo.selectAlternative(bestMAIndex);
6075 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
6076 cIndex != eIndex; ++cIndex) {
6083 if (OpInfo.hasMatchingInput()) {
6086 if (OpInfo.ConstraintVT !=
Input.ConstraintVT) {
6087 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
6089 OpInfo.ConstraintVT);
6090 std::pair<unsigned, const TargetRegisterClass *> InputRC =
6092 Input.ConstraintVT);
6093 const bool OutOpIsIntOrFP = OpInfo.ConstraintVT.isInteger() ||
6094 OpInfo.ConstraintVT.isFloatingPoint();
6095 const bool InOpIsIntOrFP =
Input.ConstraintVT.isInteger() ||
6096 Input.ConstraintVT.isFloatingPoint();
6097 if ((OutOpIsIntOrFP != InOpIsIntOrFP) ||
6098 (MatchRC.second != InputRC.second)) {
6100 " with a matching output constraint of"
6101 " incompatible type!");
6107 return ConstraintOperands;
6142 if (maIndex >= (
int)
info.multipleAlternatives.size())
6143 rCodes = &
info.Codes;
6145 rCodes = &
info.multipleAlternatives[maIndex].Codes;
6149 for (
const std::string &rCode : *rCodes) {
6152 if (weight > BestWeight)
6153 BestWeight = weight;
6166 Value *CallOperandVal =
info.CallOperandVal;
6169 if (!CallOperandVal)
6172 switch (*constraint) {
6236 Ret.
reserve(OpInfo.Codes.size());
6269 "need immediate or other");
6274 std::vector<SDValue> ResultOps;
6276 return !ResultOps.empty();
6284 assert(!OpInfo.Codes.empty() &&
"Must have at least one constraint");
6287 if (OpInfo.Codes.size() == 1) {
6288 OpInfo.ConstraintCode = OpInfo.Codes[0];
6295 unsigned BestIdx = 0;
6296 for (
const unsigned E =
G.size();
6303 if (BestIdx + 1 == E) {
6309 OpInfo.ConstraintCode =
G[BestIdx].first;
6310 OpInfo.ConstraintType =
G[BestIdx].second;
6314 if (OpInfo.ConstraintCode ==
"X" && OpInfo.CallOperandVal) {
6318 Value *v = OpInfo.CallOperandVal;
6324 OpInfo.ConstraintCode =
"i";
6331 OpInfo.ConstraintCode = Repl;
6345 EVT VT =
N->getValueType(0);
6349 bool UseSRA =
false;
6356 EVT CT =
C->getValueType(0);
6357 APInt Divisor =
C->getAPIntValue();
6380 "Expected matchUnaryPredicate to return one element for scalable "
6387 Factor = Factors[0];
6405 EVT VT =
N->getValueType(0);
6409 bool UseSRL =
false;
6416 EVT CT =
C->getValueType(0);
6417 APInt Divisor =
C->getAPIntValue();
6443 "Expected matchUnaryPredicate to return one element for scalable "
6450 Factor = Factors[0];
6493 EVT VT =
N->getValueType(0);
6529 bool IsAfterLegalization,
6530 bool IsAfterLegalTypes,
6533 EVT VT =
N->getValueType(0);
6559 if (
N->getFlags().hasExact())
6569 APInt Divisor =
C->getAPIntValue().trunc(EltBits);
6571 int NumeratorFactor = 0;
6582 NumeratorFactor = 1;
6585 NumeratorFactor = -1;
6603 SDValue MagicFactor, Factor, Shift, ShiftMask;
6611 Shifts.
size() == 1 && ShiftMasks.
size() == 1 &&
6612 "Expected matchUnaryPredicate to return one element for scalable "
6620 MagicFactor = MagicFactors[0];
6621 Factor = Factors[0];
6623 ShiftMask = ShiftMasks[0];
6669 SDValue Q = GetMULHS(N0, MagicFactor);
6699 bool IsAfterLegalization,
6700 bool IsAfterLegalTypes,
6703 EVT VT =
N->getValueType(0);
6729 if (
N->getFlags().hasExact())
6739 bool UseNPQ =
false, UsePreShift =
false, UsePostShift =
false;
6747 APInt Divisor =
C->getAPIntValue().trunc(EltBits);
6749 SDValue PreShift, MagicFactor, NPQFactor, PostShift;
6753 if (Divisor.
isOne()) {
6754 PreShift = PostShift = DAG.
getUNDEF(ShSVT);
6755 MagicFactor = NPQFactor = DAG.
getUNDEF(SVT);
6759 Divisor, std::min(KnownLeadingZeros, Divisor.
countl_zero()));
6764 "We shouldn't generate an undefined shift!");
6766 "We shouldn't generate an undefined shift!");
6768 "Unexpected pre-shift");
6775 UseNPQ |= magics.
IsAdd;
6776 UsePreShift |= magics.
PreShift != 0;
6792 SDValue PreShift, PostShift, MagicFactor, NPQFactor;
6800 NPQFactors.
size() == 1 && PostShifts.
size() == 1 &&
6801 "Expected matchUnaryPredicate to return one for scalable vectors");
6808 PreShift = PreShifts[0];
6809 MagicFactor = MagicFactors[0];
6810 PostShift = PostShifts[0];
6862 Q = GetMULHU(Q, MagicFactor);
6875 NPQ = GetMULHU(NPQ, NPQFactor);
6894 return DAG.
getSelect(dl, VT, IsOne, N0, Q);
6908 if (SplatValue != Values.
end()) {
6913 Replacement = *SplatValue;
6917 if (!AlternativeReplacement)
6920 Replacement = AlternativeReplacement;
6930SDValue TargetLowering::buildUREMEqFold(EVT SETCCVT,
SDValue REMNode,
6933 DAGCombinerInfo &DCI,
6934 const SDLoc &
DL)
const {
6936 if (
SDValue Folded = prepareUREMEqFold(SETCCVT, REMNode, CompTargetNode,
Cond,
6938 for (SDNode *
N : Built)
6939 DCI.AddToWorklist(
N);
6947TargetLowering::prepareUREMEqFold(EVT SETCCVT,
SDValue REMNode,
6949 DAGCombinerInfo &DCI,
const SDLoc &
DL,
6950 SmallVectorImpl<SDNode *> &Created)
const {
6957 "Only applicable for (in)equality comparisons.");
6959 SelectionDAG &DAG = DCI.DAG;
6970 bool ComparingWithAllZeros =
true;
6971 bool AllComparisonsWithNonZerosAreTautological =
true;
6972 bool HadTautologicalLanes =
false;
6973 bool AllLanesAreTautological =
true;
6974 bool HadEvenDivisor =
false;
6975 bool AllDivisorsArePowerOfTwo =
true;
6976 bool HadTautologicalInvertedLanes =
false;
6979 auto BuildUREMPattern = [&](ConstantSDNode *CDiv, ConstantSDNode *CCmp) {
6985 const APInt &
Cmp = CCmp->getAPIntValue();
6987 ComparingWithAllZeros &=
Cmp.isZero();
6993 bool TautologicalInvertedLane =
D.ule(Cmp);
6994 HadTautologicalInvertedLanes |= TautologicalInvertedLane;
6999 bool TautologicalLane =
D.isOne() || TautologicalInvertedLane;
7000 HadTautologicalLanes |= TautologicalLane;
7001 AllLanesAreTautological &= TautologicalLane;
7007 AllComparisonsWithNonZerosAreTautological &= TautologicalLane;
7010 unsigned K =
D.countr_zero();
7011 assert((!
D.isOne() || (K == 0)) &&
"For divisor '1' we won't rotate.");
7012 APInt D0 =
D.lshr(K);
7015 HadEvenDivisor |= (
K != 0);
7018 AllDivisorsArePowerOfTwo &= D0.
isOne();
7022 unsigned W =
D.getBitWidth();
7024 assert((D0 *
P).isOne() &&
"Multiplicative inverse basic check failed.");
7037 "We are expecting that K is always less than all-ones for ShSVT");
7040 if (TautologicalLane) {
7066 if (AllLanesAreTautological)
7071 if (AllDivisorsArePowerOfTwo)
7076 if (HadTautologicalLanes) {
7091 "Expected matchBinaryPredicate to return one element for "
7102 if (!ComparingWithAllZeros && !AllComparisonsWithNonZerosAreTautological) {
7106 "Expecting that the types on LHS and RHS of comparisons match.");
7116 if (HadEvenDivisor) {
7129 if (!HadTautologicalInvertedLanes)
7135 assert(VT.
isVector() &&
"Can/should only get here for vectors.");
7142 SDValue TautologicalInvertedChannels =
7152 DL, SETCCVT, SETCCVT);
7154 Replacement, NewCC);
7162 TautologicalInvertedChannels);
7172SDValue TargetLowering::buildSREMEqFold(EVT SETCCVT,
SDValue REMNode,
7175 DAGCombinerInfo &DCI,
7176 const SDLoc &
DL)
const {
7178 if (
SDValue Folded = prepareSREMEqFold(SETCCVT, REMNode, CompTargetNode,
Cond,
7180 assert(Built.
size() <= 7 &&
"Max size prediction failed.");
7181 for (SDNode *
N : Built)
7182 DCI.AddToWorklist(
N);
7190TargetLowering::prepareSREMEqFold(EVT SETCCVT,
SDValue REMNode,
7192 DAGCombinerInfo &DCI,
const SDLoc &
DL,
7193 SmallVectorImpl<SDNode *> &Created)
const {
7217 "Only applicable for (in)equality comparisons.");
7219 SelectionDAG &DAG = DCI.DAG;
7233 if (!CompTarget || !CompTarget->
isZero())
7236 bool HadIntMinDivisor =
false;
7237 bool HadOneDivisor =
false;
7238 bool AllDivisorsAreOnes =
true;
7239 bool HadEvenDivisor =
false;
7240 bool NeedToApplyOffset =
false;
7241 bool AllDivisorsArePowerOfTwo =
true;
7244 auto BuildSREMPattern = [&](ConstantSDNode *
C) {
7252 APInt
D =
C->getAPIntValue();
7256 HadIntMinDivisor |=
D.isMinSignedValue();
7259 HadOneDivisor |=
D.isOne();
7260 AllDivisorsAreOnes &=
D.isOne();
7263 unsigned K =
D.countr_zero();
7264 assert((!
D.isOne() || (K == 0)) &&
"For divisor '1' we won't rotate.");
7265 APInt D0 =
D.
lshr(K);
7267 if (!
D.isMinSignedValue()) {
7270 HadEvenDivisor |= (
K != 0);
7275 AllDivisorsArePowerOfTwo &= D0.
isOne();
7279 unsigned W =
D.getBitWidth();
7281 assert((D0 *
P).isOne() &&
"Multiplicative inverse basic check failed.");
7287 if (!
D.isMinSignedValue()) {
7290 NeedToApplyOffset |=
A != 0;
7297 "We are expecting that A is always less than all-ones for SVT");
7299 "We are expecting that K is always less than all-ones for ShSVT");
7339 if (AllDivisorsAreOnes)
7344 if (AllDivisorsArePowerOfTwo)
7347 SDValue PVal, AVal, KVal, QVal;
7349 if (HadOneDivisor) {
7369 QAmts.
size() == 1 &&
7370 "Expected matchUnaryPredicate to return one element for scalable "
7388 if (NeedToApplyOffset) {
7400 if (HadEvenDivisor) {
7415 if (!HadIntMinDivisor)
7421 assert(VT.
isVector() &&
"Can/should only get here for vectors.");
7456 MaskedIsZero, Fold);
7464 EVT VT =
Op.getValueType();
7487 bool LegalOps,
bool OptForSize,
7489 unsigned Depth)
const {
7491 if (
Op.getOpcode() == ISD::FNEG ||
Op.getOpcode() == ISD::VP_FNEG) {
7493 return Op.getOperand(0);
7503 EVT VT =
Op.getValueType();
7504 unsigned Opcode =
Op.getOpcode();
7508 bool IsFreeExtend = Opcode == ISD::FP_EXTEND &&
7514 auto RemoveDeadNode = [&](
SDValue N) {
7515 if (
N &&
N.getNode()->use_empty())
7524 std::list<HandleSDNode> Handles;
7535 if (LegalOps && !IsOpLegal)
7552 return !N.isUndef() && !isa<ConstantFPSDNode>(N);
7560 return N.isUndef() ||
7561 isFPImmLegal(neg(cast<ConstantFPSDNode>(N)->getValueAPF()), VT,
7565 if (LegalOps && !IsOpLegal)
7582 if (!Flags.hasNoSignedZeros())
7596 Handles.emplace_back(NegX);
7607 if (NegX && (CostX <= CostY)) {
7611 RemoveDeadNode(NegY);
7620 RemoveDeadNode(NegX);
7627 if (!Flags.hasNoSignedZeros())
7652 Handles.emplace_back(NegX);
7663 if (NegX && (CostX <= CostY)) {
7667 RemoveDeadNode(NegY);
7673 if (
C->isExactlyValue(2.0) &&
Op.getOpcode() ==
ISD::FMUL)
7681 RemoveDeadNode(NegX);
7689 if (!Flags.hasNoSignedZeros())
7692 SDValue X =
Op.getOperand(0),
Y =
Op.getOperand(1), Z =
Op.getOperand(2);
7701 Handles.emplace_back(NegZ);
7709 Handles.emplace_back(NegX);
7720 if (NegX && (CostX <= CostY)) {
7721 Cost = std::min(CostX, CostZ);
7724 RemoveDeadNode(NegY);
7730 Cost = std::min(CostY, CostZ);
7733 RemoveDeadNode(NegX);
7739 case ISD::FP_EXTEND:
7743 return DAG.
getNode(Opcode,
DL, VT, NegV);
7759 RemoveDeadNode(NegLHS);
7764 Handles.emplace_back(NegLHS);
7777 RemoveDeadNode(NegLHS);
7778 RemoveDeadNode(NegRHS);
7782 Cost = std::min(CostLHS, CostRHS);
7783 return DAG.
getSelect(
DL, VT,
Op.getOperand(0), NegLHS, NegRHS);
7812 if (!HasMULHU && !HasMULHS && !HasUMUL_LOHI && !HasSMUL_LOHI)
7825 if ((
Signed && HasSMUL_LOHI) || (!
Signed && HasUMUL_LOHI)) {
7853 if (MakeMUL_LOHI(LL, RL,
Lo,
Hi,
false)) {
7854 Result.push_back(
Lo);
7855 Result.push_back(
Hi);
7858 Result.push_back(Zero);
7859 Result.push_back(Zero);
7870 if (MakeMUL_LOHI(LL, RL,
Lo,
Hi,
true)) {
7871 Result.push_back(
Lo);
7872 Result.push_back(
Hi);
7877 unsigned ShiftAmount = OuterBitSize - InnerBitSize;
7892 if (!MakeMUL_LOHI(LL, RL,
Lo,
Hi,
false))
7895 Result.push_back(
Lo);
7902 Result.push_back(
Hi);
7915 if (!MakeMUL_LOHI(LL, RH,
Lo,
Hi,
false))
7922 if (!MakeMUL_LOHI(LH, RL,
Lo,
Hi,
false))
7975 N->getOperand(0),
N->getOperand(1), Result, HiLoVT,
7976 DAG, Kind, LL, LH, RL, RH);
7978 assert(Result.size() == 2);
8010 unsigned Opcode =
N->getOpcode();
8011 EVT VT =
N->getValueType(0);
8018 "Unexpected opcode");
8024 APInt Divisor = CN->getAPIntValue();
8032 if (Divisor.
uge(HalfMaxPlus1))
8050 unsigned TrailingZeros = 0;
8064 if (HalfMaxPlus1.
urem(Divisor).
isOne()) {
8065 assert(!LL == !LH &&
"Expected both input halves or no input halves!");
8067 std::tie(LL, LH) = DAG.
SplitScalar(
N->getOperand(0), dl, HiLoVT, HiLoVT);
8071 if (TrailingZeros) {
8139 std::tie(QuotL, QuotH) = DAG.
SplitScalar(Quotient, dl, HiLoVT, HiLoVT);
8140 Result.push_back(QuotL);
8141 Result.push_back(QuotH);
8147 if (TrailingZeros) {
8152 Result.push_back(RemL);
8168 EVT VT =
Node->getValueType(0);
8178 bool IsFSHL =
Node->getOpcode() == ISD::VP_FSHL;
8181 EVT ShVT = Z.getValueType();
8187 ShAmt = DAG.
getNode(ISD::VP_UREM,
DL, ShVT, Z, BitWidthC, Mask, VL);
8188 InvShAmt = DAG.
getNode(ISD::VP_SUB,
DL, ShVT, BitWidthC, ShAmt, Mask, VL);
8189 ShX = DAG.
getNode(ISD::VP_SHL,
DL, VT,
X, IsFSHL ? ShAmt : InvShAmt, Mask,
8191 ShY = DAG.
getNode(ISD::VP_SRL,
DL, VT,
Y, IsFSHL ? InvShAmt : ShAmt, Mask,
8199 ShAmt = DAG.
getNode(ISD::VP_AND,
DL, ShVT, Z, BitMask, Mask, VL);
8203 InvShAmt = DAG.
getNode(ISD::VP_AND,
DL, ShVT, NotZ, BitMask, Mask, VL);
8206 ShAmt = DAG.
getNode(ISD::VP_UREM,
DL, ShVT, Z, BitWidthC, Mask, VL);
8207 InvShAmt = DAG.
getNode(ISD::VP_SUB,
DL, ShVT, BitMask, ShAmt, Mask, VL);
8212 ShX = DAG.
getNode(ISD::VP_SHL,
DL, VT,
X, ShAmt, Mask, VL);
8214 ShY = DAG.
getNode(ISD::VP_SRL,
DL, VT, ShY1, InvShAmt, Mask, VL);
8217 ShX = DAG.
getNode(ISD::VP_SHL,
DL, VT, ShX1, InvShAmt, Mask, VL);
8218 ShY = DAG.
getNode(ISD::VP_SRL,
DL, VT,
Y, ShAmt, Mask, VL);
8221 return DAG.
getNode(ISD::VP_OR,
DL, VT, ShX, ShY, Mask, VL);
8226 if (
Node->isVPOpcode())
8229 EVT VT =
Node->getValueType(0);
8245 EVT ShVT = Z.getValueType();
8315 EVT VT =
Node->getValueType(0);
8333 if (!AllowVectorOps && VT.
isVector() &&
8351 ShVal = DAG.
getNode(ShOpc,
DL, VT, Op0, ShAmt);
8353 HsVal = DAG.
getNode(HsOpc,
DL, VT, Op0, HsAmt);
8359 ShVal = DAG.
getNode(ShOpc,
DL, VT, Op0, ShAmt);
8370 assert(
Node->getNumOperands() == 3 &&
"Not a double-shift!");
8371 EVT VT =
Node->getValueType(0);
8422 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
8424 EVT SrcVT = Src.getValueType();
8425 EVT DstVT =
Node->getValueType(0);
8429 if (SrcVT != MVT::f32 || DstVT != MVT::i64)
8432 if (
Node->isStrictFPOpcode())
8495 unsigned OpNo =
Node->isStrictFPOpcode() ? 1 : 0;
8498 EVT SrcVT = Src.getValueType();
8499 EVT DstVT =
Node->getValueType(0);
8520 if (
Node->isStrictFPOpcode()) {
8522 {
Node->getOperand(0), Src });
8523 Chain = Result.getValue(1);
8537 if (
Node->isStrictFPOpcode()) {
8539 Node->getOperand(0),
true);
8545 bool Strict =
Node->isStrictFPOpcode() ||
8564 if (
Node->isStrictFPOpcode()) {
8566 { Chain, Src, FltOfs });
8588 Result = DAG.
getSelect(dl, DstVT, Sel, True, False);
8598 if (
Node->isStrictFPOpcode())
8602 EVT SrcVT = Src.getValueType();
8603 EVT DstVT =
Node->getValueType(0);
8607 if (
Node->getFlags().hasNonNeg() &&
8655 unsigned Opcode =
Node->getOpcode();
8656 assert((Opcode == ISD::FMINNUM || Opcode == ISD::FMAXNUM ||
8660 if (
Node->getFlags().hasNoNaNs()) {
8662 EVT VT =
Node->getValueType(0);
8681 EVT VT =
Node->getValueType(0);
8684 "Expanding fminnum/fmaxnum for scalable vectors is undefined.");
8688 Node->getOpcode() == ISD::FMINNUM ? ISD::FMINNUM_IEEE : ISD::FMAXNUM_IEEE;
8694 if (!
Node->getFlags().hasNoNaNs()) {
8707 return DAG.
getNode(NewOp, dl, VT, Quiet0, Quiet1,
Node->getFlags());
8713 if ((
Node->getFlags().hasNoNaNs() ||
8716 (
Node->getFlags().hasNoSignedZeros() ||
8719 unsigned IEEE2018Op =
8720 Node->getOpcode() == ISD::FMINNUM ? ISD::FMINIMUM : ISD::FMAXIMUM;
8722 return DAG.
getNode(IEEE2018Op, dl, VT,
Node->getOperand(0),
8723 Node->getOperand(1),
Node->getFlags());
8740 unsigned Opc =
N->getOpcode();
8741 EVT VT =
N->getValueType(0);
8743 bool IsMax =
Opc == ISD::FMAXIMUM;
8749 unsigned CompOpcIeee = IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE;
8750 unsigned CompOpc = IsMax ? ISD::FMAXNUM : ISD::FMINNUM;
8754 bool MinMaxMustRespectOrderedZero =
false;
8758 MinMaxMustRespectOrderedZero =
true;
8772 if (!
N->getFlags().hasNoNaNs() &&
8781 if (!MinMaxMustRespectOrderedZero && !
N->getFlags().hasNoSignedZeros() &&
8804 unsigned Opc =
Node->getOpcode();
8805 EVT VT =
Node->getValueType(0);
8807 bool IsMax =
Opc == ISD::FMAXIMUMNUM;
8811 Opc == ISD::FMINIMUMNUM ? ISD::FMINNUM_IEEE : ISD::FMAXNUM_IEEE;
8814 if (!Flags.hasNoNaNs()) {
8825 return DAG.
getNode(NewOp,
DL, VT, LHS, RHS, Flags);
8830 if (Flags.hasNoNaNs() ||
8832 unsigned IEEE2019Op =
8833 Opc == ISD::FMINIMUMNUM ? ISD::FMINIMUM : ISD::FMAXIMUM;
8835 return DAG.
getNode(IEEE2019Op,
DL, VT, LHS, RHS, Flags);
8840 if ((Flags.hasNoNaNs() ||
8844 unsigned IEEE2008Op =
Opc == ISD::FMINIMUMNUM ? ISD::FMINNUM : ISD::FMAXNUM;
8846 return DAG.
getNode(IEEE2008Op,
DL, VT, LHS, RHS, Flags);
8900 bool IsOrdered = NanTest ==
fcNone;
8901 bool IsUnordered = NanTest ==
fcNan;
8904 if (!IsOrdered && !IsUnordered)
8905 return std::nullopt;
8907 if (OrderedMask ==
fcZero &&
8913 return std::nullopt;
8920 EVT OperandVT =
Op.getValueType();
8932 if (OperandVT == MVT::ppcf128) {
8935 OperandVT = MVT::f64;
8942 bool IsF80 = (ScalarFloatVT == MVT::f80);
8946 if (Flags.hasNoFPExcept() &&
8949 bool IsInvertedFP =
false;
8953 FPTestMask = InvertedFPCheck;
8954 IsInvertedFP =
true;
8966 OrderedFPTestMask = FPTestMask;
8968 const bool IsOrdered = FPTestMask == OrderedFPTestMask;
8970 if (std::optional<bool> IsCmp0 =
8973 *IsCmp0 ? OrderedCmpOpcode : UnorderedCmpOpcode,
8980 *IsCmp0 ? OrderedCmpOpcode : UnorderedCmpOpcode);
8983 if (FPTestMask ==
fcNan &&
8989 bool IsOrderedInf = FPTestMask ==
fcInf;
8992 : UnorderedCmpOpcode,
9003 IsOrderedInf ? OrderedCmpOpcode : UnorderedCmpOpcode);
9008 : UnorderedCmpOpcode,
9019 IsOrdered ? OrderedCmpOpcode : UnorderedCmpOpcode);
9038 return DAG.
getSetCC(
DL, ResultVT, Abs, SmallestNormal,
9039 IsOrdered ? OrderedOp : UnorderedOp);
9062 DAG.
getSetCC(
DL, ResultVT, Abs, SmallestNormal, IsNormalOp);
9064 return DAG.
getNode(LogicOp,
DL, ResultVT, IsFinite, IsNormal);
9071 bool IsInverted =
false;
9074 Test = InvertedCheck;
9090 const unsigned ExplicitIntBitInF80 = 63;
9091 APInt ExpMask = Inf;
9093 ExpMask.
clearBit(ExplicitIntBitInF80);
9107 const auto appendResult = [&](
SDValue PartialRes) {
9117 const auto getIntBitIsSet = [&]() ->
SDValue {
9118 if (!IntBitIsSetV) {
9119 APInt IntBitMask(BitSize, 0);
9120 IntBitMask.
setBit(ExplicitIntBitInF80);
9125 return IntBitIsSetV;
9153 appendResult(PartialRes);
9162 appendResult(ExpIsZero);
9172 else if (PartialCheck ==
fcZero)
9176 appendResult(PartialRes);
9189 appendResult(PartialRes);
9192 if (
unsigned PartialCheck =
Test &
fcInf) {
9195 else if (PartialCheck ==
fcInf)
9202 appendResult(PartialRes);
9205 if (
unsigned PartialCheck =
Test &
fcNan) {
9206 APInt InfWithQnanBit = Inf | QNaNBitMask;
9208 if (PartialCheck ==
fcNan) {
9221 }
else if (PartialCheck ==
fcQNan) {
9233 appendResult(PartialRes);
9238 APInt ExpLSB = ExpMask & ~(ExpMask.
shl(1));
9241 APInt ExpLimit = ExpMask - ExpLSB;
9254 appendResult(PartialRes);
9277 EVT VT =
Node->getValueType(0);
9284 if (!(Len <= 128 && Len % 8 == 0))
9343 for (
unsigned Shift = 8; Shift < Len; Shift *= 2) {
9354 EVT VT =
Node->getValueType(0);
9363 if (!(Len <= 128 && Len % 8 == 0))
9375 SDValue Tmp1, Tmp2, Tmp3, Tmp4, Tmp5;
9378 Tmp1 = DAG.
getNode(ISD::VP_AND, dl, VT,
9382 Op = DAG.
getNode(ISD::VP_SUB, dl, VT,
Op, Tmp1, Mask, VL);
9385 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT,
Op, Mask33, Mask, VL);
9386 Tmp3 = DAG.
getNode(ISD::VP_AND, dl, VT,
9390 Op = DAG.
getNode(ISD::VP_ADD, dl, VT, Tmp2, Tmp3, Mask, VL);
9395 Tmp5 = DAG.
getNode(ISD::VP_ADD, dl, VT,
Op, Tmp4, Mask, VL);
9396 Op = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp5, Mask0F, Mask, VL);
9407 V = DAG.
getNode(ISD::VP_MUL, dl, VT,
Op, Mask01, Mask, VL);
9410 for (
unsigned Shift = 8; Shift < Len; Shift *= 2) {
9412 V = DAG.
getNode(ISD::VP_ADD, dl, VT, V,
9413 DAG.
getNode(ISD::VP_SHL, dl, VT, V, ShiftC, Mask, VL),
9423 EVT VT =
Node->getValueType(0);
9462 for (
unsigned i = 0; (1U << i) < NumBitsPerElt; ++i) {
9473 EVT VT =
Node->getValueType(0);
9487 for (
unsigned i = 0; (1U << i) < NumBitsPerElt; ++i) {
9490 DAG.
getNode(ISD::VP_SRL, dl, VT,
Op, Tmp, Mask, VL), Mask,
9495 return DAG.
getNode(ISD::VP_CTPOP, dl, VT,
Op, Mask, VL);
9504 :
APInt(64, 0x0218A392CD3D5DBFULL);
9518 for (
unsigned i = 0; i <
BitWidth; i++) {
9544 EVT VT =
Node->getValueType(0);
9604 EVT VT =
Node->getValueType(0);
9612 return DAG.
getNode(ISD::VP_CTPOP, dl, VT, Tmp, Mask, VL);
9626 EVT SrcVT = Source.getValueType();
9627 EVT ResVT =
N->getValueType(0);
9636 Source = DAG.
getNode(ISD::VP_SETCC,
DL, SrcVT, Source, AllZero,
9644 DAG.
getNode(ISD::VP_SELECT,
DL, ResVecVT, Source, StepVec,
Splat, EVL);
9645 return DAG.
getNode(ISD::VP_REDUCE_UMIN,
DL, ResVT, ExtEVL,
Select, Mask, EVL);
9652 EVT MaskVT = Mask.getValueType();
9662 true, &VScaleRange);
9681 SDValue HighestIdx = DAG.
getNode(ISD::VECREDUCE_UMAX,
DL, StepVT, ActiveElts);
9686 bool IsNegative)
const {
9688 EVT VT =
N->getValueType(0);
9742 EVT VT =
N->getValueType(0);
9820 EVT VT =
N->getValueType(0);
9824 unsigned Opc =
N->getOpcode();
9833 "Unknown AVG node");
9845 return DAG.
getNode(ShiftOpc, dl, VT, Sum,
9854 LHS = DAG.
getNode(ExtOpc, dl, ExtVT, LHS);
9855 RHS = DAG.
getNode(ExtOpc, dl, ExtVT, RHS);
9897 return DAG.
getNode(SumOpc, dl, VT, Sign, Shift);
9902 EVT VT =
N->getValueType(0);
9909 SDValue Tmp1, Tmp2, Tmp3, Tmp4, Tmp5, Tmp6, Tmp7, Tmp8;
9972 EVT VT =
N->getValueType(0);
9981 SDValue Tmp1, Tmp2, Tmp3, Tmp4, Tmp5, Tmp6, Tmp7, Tmp8;
9990 return DAG.
getNode(ISD::VP_OR, dl, VT, Tmp1, Tmp2, Mask, EVL);
10000 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp2,
10004 Tmp4 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp4, Tmp3, Mask, EVL);
10005 Tmp2 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp2, Tmp1, Mask, EVL);
10006 return DAG.
getNode(ISD::VP_OR, dl, VT, Tmp4, Tmp2, Mask, EVL);
10010 Tmp7 = DAG.
getNode(ISD::VP_AND, dl, VT,
Op,
10011 DAG.
getConstant(255ULL << 8, dl, VT), Mask, EVL);
10014 Tmp6 = DAG.
getNode(ISD::VP_AND, dl, VT,
Op,
10015 DAG.
getConstant(255ULL << 16, dl, VT), Mask, EVL);
10018 Tmp5 = DAG.
getNode(ISD::VP_AND, dl, VT,
Op,
10019 DAG.
getConstant(255ULL << 24, dl, VT), Mask, EVL);
10024 Tmp4 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp4,
10025 DAG.
getConstant(255ULL << 24, dl, VT), Mask, EVL);
10028 Tmp3 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp3,
10029 DAG.
getConstant(255ULL << 16, dl, VT), Mask, EVL);
10032 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp2,
10033 DAG.
getConstant(255ULL << 8, dl, VT), Mask, EVL);
10036 Tmp8 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp8, Tmp7, Mask, EVL);
10037 Tmp6 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp6, Tmp5, Mask, EVL);
10038 Tmp4 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp4, Tmp3, Mask, EVL);
10039 Tmp2 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp2, Tmp1, Mask, EVL);
10040 Tmp8 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp8, Tmp6, Mask, EVL);
10041 Tmp4 = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp4, Tmp2, Mask, EVL);
10042 return DAG.
getNode(ISD::VP_OR, dl, VT, Tmp8, Tmp4, Mask, EVL);
10048 EVT VT =
N->getValueType(0);
10091 for (
unsigned I = 0, J = Sz-1;
I < Sz; ++
I, --J) {
10108 assert(
N->getOpcode() == ISD::VP_BITREVERSE);
10111 EVT VT =
N->getValueType(0);
10130 Tmp = (Sz > 8 ? DAG.
getNode(ISD::VP_BSWAP, dl, VT,
Op, Mask, EVL) :
Op);
10135 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp2,
10141 Tmp = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp2, Tmp3, Mask, EVL);
10146 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp2,
10152 Tmp = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp2, Tmp3, Mask, EVL);
10157 Tmp2 = DAG.
getNode(ISD::VP_AND, dl, VT, Tmp2,
10163 Tmp = DAG.
getNode(ISD::VP_OR, dl, VT, Tmp2, Tmp3, Mask, EVL);
10169std::pair<SDValue, SDValue>
10173 SDValue Chain = LD->getChain();
10174 SDValue BasePTR = LD->getBasePtr();
10175 EVT SrcVT = LD->getMemoryVT();
10176 EVT DstVT = LD->getValueType(0);
10208 LD->getPointerInfo(), SrcIntVT, LD->getBaseAlign(),
10209 LD->getMemOperand()->getFlags(), LD->getAAInfo());
10212 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
10213 unsigned ShiftIntoIdx =
10224 Scalar = DAG.
getNode(ExtendOp, SL, DstEltVT, Scalar);
10231 return std::make_pair(
Value, Load.getValue(1));
10240 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
10242 ExtType, SL, DstEltVT, Chain, BasePTR,
10243 LD->getPointerInfo().getWithOffset(Idx * Stride), SrcEltVT,
10244 LD->getBaseAlign(), LD->getMemOperand()->getFlags(), LD->getAAInfo());
10255 return std::make_pair(
Value, NewChain);
10262 SDValue Chain = ST->getChain();
10263 SDValue BasePtr = ST->getBasePtr();
10265 EVT StVT = ST->getMemoryVT();
10291 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
10295 unsigned ShiftIntoIdx =
10304 return DAG.
getStore(Chain, SL, CurrVal, BasePtr, ST->getPointerInfo(),
10305 ST->getBaseAlign(), ST->getMemOperand()->getFlags(),
10311 assert(Stride &&
"Zero stride!");
10315 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
10323 Chain, SL, Elt, Ptr, ST->getPointerInfo().getWithOffset(Idx * Stride),
10324 MemSclVT, ST->getBaseAlign(), ST->getMemOperand()->getFlags(),
10333std::pair<SDValue, SDValue>
10336 "unaligned indexed loads not implemented!");
10337 SDValue Chain = LD->getChain();
10338 SDValue Ptr = LD->getBasePtr();
10339 EVT VT = LD->getValueType(0);
10340 EVT LoadedVT = LD->getMemoryVT();
10356 LD->getMemOperand());
10357 SDValue Result = DAG.
getNode(ISD::BITCAST, dl, LoadedVT, newLoad);
10358 if (LoadedVT != VT)
10362 return std::make_pair(Result, newLoad.
getValue(1));
10370 unsigned NumRegs = (LoadedBytes + RegBytes - 1) / RegBytes;
10376 SDValue StackPtr = StackBase;
10380 EVT StackPtrVT = StackPtr.getValueType();
10386 for (
unsigned i = 1; i < NumRegs; i++) {
10389 RegVT, dl, Chain, Ptr, LD->getPointerInfo().getWithOffset(
Offset),
10390 LD->getBaseAlign(), LD->getMemOperand()->getFlags(), LD->getAAInfo());
10393 Load.getValue(1), dl, Load, StackPtr,
10404 8 * (LoadedBytes -
Offset));
10407 LD->getPointerInfo().getWithOffset(
Offset), MemVT, LD->getBaseAlign(),
10408 LD->getMemOperand()->getFlags(), LD->getAAInfo());
10413 Load.getValue(1), dl, Load, StackPtr,
10420 Load = DAG.
getExtLoad(LD->getExtensionType(), dl, VT, TF, StackBase,
10425 return std::make_pair(Load, TF);
10429 "Unaligned load of unsupported type.");
10438 Align Alignment = LD->getBaseAlign();
10439 unsigned IncrementSize = NumBits / 8;
10450 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
10455 LD->getPointerInfo().getWithOffset(IncrementSize),
10456 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
10459 Hi = DAG.
getExtLoad(HiExtType, dl, VT, Chain, Ptr, LD->getPointerInfo(),
10460 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
10465 LD->getPointerInfo().getWithOffset(IncrementSize),
10466 NewLoadedVT, Alignment, LD->getMemOperand()->getFlags(),
10478 return std::make_pair(Result, TF);
10484 "unaligned indexed stores not implemented!");
10485 SDValue Chain = ST->getChain();
10486 SDValue Ptr = ST->getBasePtr();
10487 SDValue Val = ST->getValue();
10489 Align Alignment = ST->getBaseAlign();
10491 EVT StoreMemVT = ST->getMemoryVT();
10507 Result = DAG.
getStore(Chain, dl, Result, Ptr, ST->getPointerInfo(),
10508 Alignment, ST->getMemOperand()->getFlags());
10519 unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes;
10527 Chain, dl, Val, StackPtr,
10530 EVT StackPtrVT = StackPtr.getValueType();
10538 for (
unsigned i = 1; i < NumRegs; i++) {
10541 RegVT, dl, Store, StackPtr,
10545 ST->getPointerInfo().getWithOffset(
Offset),
10546 ST->getBaseAlign(),
10547 ST->getMemOperand()->getFlags()));
10566 Load.getValue(1), dl, Load, Ptr,
10567 ST->getPointerInfo().getWithOffset(
Offset), LoadMemVT,
10568 ST->getBaseAlign(), ST->getMemOperand()->getFlags(), ST->getAAInfo()));
10575 "Unaligned store of unknown type.");
10579 unsigned IncrementSize = NumBits / 8;
10599 Ptr, ST->getPointerInfo(), NewStoredVT, Alignment,
10600 ST->getMemOperand()->getFlags());
10605 ST->getPointerInfo().getWithOffset(IncrementSize), NewStoredVT, Alignment,
10606 ST->getMemOperand()->getFlags(), ST->getAAInfo());
10617 bool IsCompressedMemory)
const {
10620 EVT MaskVT = Mask.getValueType();
10622 "Incompatible types of Data and Mask");
10623 if (IsCompressedMemory) {
10636 MaskIntVT = MVT::i32;
10655 "Cannot index a scalable vector within a fixed-width vector");
10666 if (IdxCst->getZExtValue() + (NumSubElts - 1) < NElts)
10680 unsigned MaxIndex = NumSubElts < NElts ? NElts - NumSubElts : 0;
10690 DAG, VecPtr, VecVT,
10692 Index, PtrArithFlags);
10708 "Converting bits to bytes lost precision");
10710 "Sub-vector must be a vector with matching element type");
10714 EVT IdxVT = Index.getValueType();
10745 assert(EmuTlsVar &&
"Cannot find EmuTlsVar ");
10746 Args.emplace_back(DAG.
getGlobalAddress(EmuTlsVar, dl, PtrVT), VoidPtrType);
10753 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
10762 "Emulated TLS must have zero offset in GlobalAddressSDNode");
10763 return CallResult.first;
10774 EVT VT =
Op.getOperand(0).getValueType();
10776 if (VT.
bitsLT(MVT::i32)) {
10794 unsigned Opcode =
Node->getOpcode();
10836 {Op0, Op1, DAG.getCondCode(CC)})) {
10843 {Op0, Op1, DAG.getCondCode(CC)})) {
10871 unsigned Opcode =
Node->getOpcode();
10874 EVT VT = LHS.getValueType();
10877 assert(VT == RHS.getValueType() &&
"Expected operands to be the same type");
10893 unsigned OverflowOp;
10908 llvm_unreachable(
"Expected method to receive signed or unsigned saturation "
10909 "addition or subtraction node.");
10917 unsigned BitWidth = LHS.getScalarValueSizeInBits();
10920 SDValue SumDiff = Result.getValue(0);
10921 SDValue Overflow = Result.getValue(1);
10943 return DAG.
getSelect(dl, VT, Overflow, Zero, SumDiff);
10963 if (LHSIsNonNegative || RHSIsNonNegative) {
10965 return DAG.
getSelect(dl, VT, Overflow, SatMax, SumDiff);
10971 if (LHSIsNegative || RHSIsNegative) {
10973 return DAG.
getSelect(dl, VT, Overflow, SatMin, SumDiff);
10983 return DAG.
getSelect(dl, VT, Overflow, Result, SumDiff);
10987 unsigned Opcode =
Node->getOpcode();
10990 EVT VT = LHS.getValueType();
10991 EVT ResVT =
Node->getValueType(0);
11023 unsigned Opcode =
Node->getOpcode();
11027 EVT VT = LHS.getValueType();
11032 "Expected a SHLSAT opcode");
11033 assert(VT == RHS.getValueType() &&
"Expected operands to be the same type");
11065 EVT VT = LHS.getValueType();
11066 assert(RHS.getValueType() == VT &&
"Mismatching operand types");
11068 assert((HiLHS && HiRHS) || (!HiLHS && !HiRHS));
11070 "Signed flag should only be set when HiLHS and RiRHS are null");
11078 unsigned HalfBits = Bits / 2;
11123 EVT VT = LHS.getValueType();
11124 assert(RHS.getValueType() == VT &&
"Mismatching operand types");
11128 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
11129 if (WideVT == MVT::i16)
11130 LC = RTLIB::MUL_I16;
11131 else if (WideVT == MVT::i32)
11132 LC = RTLIB::MUL_I32;
11133 else if (WideVT == MVT::i64)
11134 LC = RTLIB::MUL_I64;
11135 else if (WideVT == MVT::i128)
11136 LC = RTLIB::MUL_I128;
11139 if (LibcallImpl == RTLIB::Unsupported) {
11167 SDValue Args[] = {LHS, HiLHS, RHS, HiRHS};
11168 Ret =
makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
11170 SDValue Args[] = {HiLHS, LHS, HiRHS, RHS};
11171 Ret =
makeLibCall(DAG, LC, WideVT, Args, CallOptions, dl).first;
11174 "Ret value is a collection of constituent nodes holding result.");
11191 "Expected a fixed point multiplication opcode");
11196 EVT VT = LHS.getValueType();
11197 unsigned Scale =
Node->getConstantOperandVal(2);
11213 SDValue Product = Result.getValue(0);
11214 SDValue Overflow = Result.getValue(1);
11225 Result = DAG.
getSelect(dl, VT, ProdNeg, SatMin, SatMax);
11226 return DAG.
getSelect(dl, VT, Overflow, Result, Product);
11230 SDValue Product = Result.getValue(0);
11231 SDValue Overflow = Result.getValue(1);
11235 return DAG.
getSelect(dl, VT, Overflow, SatMax, Product);
11240 "Expected scale to be less than the number of bits if signed or at "
11241 "most the number of bits if unsigned.");
11242 assert(LHS.getValueType() == RHS.getValueType() &&
11243 "Expected both operands to be the same type");
11255 Lo = Result.getValue(0);
11256 Hi = Result.getValue(1);
11259 Hi = DAG.
getNode(HiOp, dl, VT, LHS, RHS);
11277 if (Scale == VTSize)
11323 return DAG.
getSelect(dl, VT, Overflow, ResultIfOverflow, Result);
11348 "Expected a fixed point division opcode");
11350 EVT VT = LHS.getValueType();
11372 if (LHSLead + RHSTrail < Scale + (
unsigned)(Saturating &&
Signed))
11375 unsigned LHSShift = std::min(LHSLead, Scale);
11376 unsigned RHSShift = Scale - LHSShift;
11440 { LHS, RHS, CarryIn });
11447 LHS.getValueType(), LHS, RHS);
11449 EVT ResultType =
Node->getValueType(1);
11460 DAG.
getSetCC(dl, SetCCType, Result,
11469 SetCC = DAG.
getSetCC(dl, SetCCType, Result, LHS, CC);
11482 LHS.getValueType(), LHS, RHS);
11484 EVT ResultType =
Node->getValueType(1);
11491 SDValue Sat = DAG.
getNode(OpcSat, dl, LHS.getValueType(), LHS, RHS);
11510 DAG.
getNode(
ISD::XOR, dl, OType, ConditionRHS, ResultLowerThanLHS), dl,
11511 ResultType, ResultType);
11517 EVT VT =
Node->getValueType(0);
11525 const APInt &
C = RHSC->getAPIntValue();
11527 if (
C.isPowerOf2()) {
11529 bool UseArithShift =
isSigned && !
C.isMinSignedValue();
11532 Overflow = DAG.
getSetCC(dl, SetCCVT,
11534 dl, VT, Result, ShiftAmt),
11547 static const unsigned Ops[2][3] =
11573 Result = BottomHalf;
11580 Overflow = DAG.
getSetCC(dl, SetCCVT, TopHalf,
11585 EVT RType =
Node->getValueType(1);
11590 "Unexpected result type for S/UMULO legalization");
11598 EVT VT =
Op.getValueType();
11621 "Expanding reductions for scalable vectors is undefined.");
11630 for (
unsigned i = 1; i < NumElts; i++)
11631 Res = DAG.
getNode(BaseOpcode, dl, EltVT, Res,
Ops[i],
Node->getFlags());
11634 if (EltVT !=
Node->getValueType(0))
11650 "Expanding reductions for scalable vectors is undefined.");
11660 for (
unsigned i = 0; i < NumElts; i++)
11661 Res = DAG.
getNode(BaseOpcode, dl, EltVT, Res,
Ops[i], Flags);
11668 EVT VT =
Node->getValueType(0);
11677 Result = DAG.
getNode(DivRemOpc, dl, VTs, Dividend, Divisor).
getValue(1);
11682 SDValue Divide = DAG.
getNode(DivOpc, dl, VT, Dividend, Divisor);
11697 EVT SrcVT = Src.getValueType();
11698 EVT DstVT =
Node->getValueType(0);
11703 assert(SatWidth <= DstWidth &&
11704 "Expected saturation width smaller than result width");
11708 APInt MinInt, MaxInt;
11719 if (SrcVT == MVT::f16 || SrcVT == MVT::bf16) {
11720 Src = DAG.
getNode(ISD::FP_EXTEND, dl, MVT::f32, Src);
11721 SrcVT = Src.getValueType();
11743 if (AreExactFloatBounds && MinMaxLegal) {
11747 Clamped = DAG.
getNode(ISD::FMAXNUM, dl, SrcVT, Clamped, MinFloatNode);
11749 Clamped = DAG.
getNode(ISD::FMINNUM, dl, SrcVT, Clamped, MaxFloatNode);
11752 dl, DstVT, Clamped);
11764 return DAG.
getSelect(dl, DstVT, IsNan, ZeroInt, FpToInt);
11803 EVT OperandVT =
Op.getValueType();
11818 SDValue NarrowBits = DAG.
getNode(ISD::BITCAST, dl, ResultIntVT, Narrow);
11829 Op.getValueType());
11833 KeepNarrow = DAG.
getNode(
ISD::OR, dl, WideSetCCVT, KeepNarrow, AlreadyOdd);
11837 SDValue AbsNarrowAsWide = DAG.
getNode(ISD::FABS, dl, OperandVT, NarrowAsWide);
11844 SDValue Adjust = DAG.
getSelect(dl, ResultIntVT, NarrowIsRd, One, NegativeOne);
11846 Op = DAG.
getSelect(dl, ResultIntVT, KeepNarrow, NarrowBits, Adjusted);
11847 return DAG.
getNode(ISD::BITCAST, dl, ResultVT,
Op);
11853 EVT VT =
Node->getValueType(0);
11856 if (
Node->getConstantOperandVal(1) == 1) {
11857 return DAG.
getNode(ISD::FP_TO_BF16, dl, VT,
Node->getOperand(0));
11859 EVT OperandVT =
Op.getValueType();
11871 EVT I32 =
F32.changeTypeToInteger();
11897 EVT I16 = I32.
isVector() ? I32.changeVectorElementType(MVT::i16) : MVT::i16;
11899 return DAG.
getNode(ISD::BITCAST, dl, VT,
Op);
11907 assert(
Node->getValueType(0).isScalableVector() &&
11908 "Fixed length vector types expected to use SHUFFLE_VECTOR!");
11910 EVT VT =
Node->getValueType(0);
11932 EVT PtrVT = StackPtr.getValueType();
11949 return DAG.
getLoad(VT,
DL, StoreV2, StackPtr,
11967 return DAG.
getLoad(VT,
DL, StoreV2, StackPtr2,
11980 EVT MaskVT = Mask.getValueType();
11997 bool HasPassthru = !Passthru.
isUndef();
12003 Chain = DAG.
getStore(Chain,
DL, Passthru, StackPtr, PtrInfo);
12006 APInt PassthruSplatVal;
12007 bool IsSplatPassthru =
12010 if (IsSplatPassthru) {
12014 LastWriteVal = DAG.
getConstant(PassthruSplatVal,
DL, ScalarVT);
12015 }
else if (HasPassthru) {
12025 Popcount = DAG.
getNode(ISD::VECREDUCE_ADD,
DL, PopcountVT, Popcount);
12029 ScalarVT,
DL, Chain, LastElmtPtr,
12035 for (
unsigned I = 0;
I < NumElms;
I++) {
12039 Chain,
DL, ValI, OutPtr,
12051 if (HasPassthru &&
I == NumElms - 1) {
12061 LastWriteVal = DAG.
getSelect(
DL, ScalarVT, AllLanesSelected, ValI,
12064 Chain,
DL, LastWriteVal, OutPtr,
12069 return DAG.
getLoad(VecVT,
DL, Chain, StackPtr, PtrInfo);
12076 SDValue MulLHS =
N->getOperand(1);
12077 SDValue MulRHS =
N->getOperand(2);
12085 unsigned ExtOpcLHS, ExtOpcRHS;
12086 switch (
N->getOpcode()) {
12089 case ISD::PARTIAL_REDUCE_UMLA:
12092 case ISD::PARTIAL_REDUCE_SMLA:
12095 case ISD::PARTIAL_REDUCE_FMLA:
12096 ExtOpcLHS = ExtOpcRHS = ISD::FP_EXTEND;
12100 if (ExtMulOpVT != MulOpVT) {
12101 MulLHS = DAG.
getNode(ExtOpcLHS,
DL, ExtMulOpVT, MulLHS);
12102 MulRHS = DAG.
getNode(ExtOpcRHS,
DL, ExtMulOpVT, MulRHS);
12105 if (
N->getOpcode() == ISD::PARTIAL_REDUCE_FMLA) {
12116 std::deque<SDValue> Subvectors = {Acc};
12117 for (
unsigned I = 0;
I < ScaleFactor;
I++)
12120 unsigned FlatNode =
12124 while (Subvectors.size() > 1) {
12125 Subvectors.push_back(
12126 DAG.
getNode(FlatNode,
DL, AccVT, {Subvectors[0], Subvectors[1]}));
12127 Subvectors.pop_front();
12128 Subvectors.pop_front();
12131 assert(Subvectors.size() == 1 &&
12132 "There should only be one subvector after tree flattening");
12134 return Subvectors[0];
12147 if (
Op.getNode() != FPNode)
12151 while (!Worklist.
empty()) {
12162 if (
Node == FPNode ||
Node->getOpcode() == ISD::CALLSEQ_START)
12165 if (
Node->getOpcode() == ISD::CALLSEQ_END) {
12185 std::optional<unsigned> CallRetResNo)
const {
12186 if (LC == RTLIB::UNKNOWN_LIBCALL)
12190 if (LibcallImpl == RTLIB::Unsupported)
12194 EVT VT =
Node->getValueType(0);
12195 unsigned NumResults =
Node->getNumValues();
12205 SDValue StoreValue = ST->getValue();
12206 unsigned ResNo = StoreValue.
getResNo();
12208 if (CallRetResNo == ResNo)
12211 if (!ST->isSimple() || ST->getAddressSpace() != 0)
12214 if (StoresInChain && ST->getChain() != StoresInChain)
12218 if (ST->getAlign() <
12226 ResultStores[ResNo] = ST;
12227 StoresInChain = ST->getChain();
12234 EVT ArgVT =
Op.getValueType();
12236 Args.emplace_back(
Op, ArgTy);
12243 if (ResNo == CallRetResNo)
12245 EVT ResVT =
Node->getValueType(ResNo);
12247 ResultPtrs[ResNo] = ResultPtr;
12248 Args.emplace_back(ResultPtr,
PointerTy);
12260 Type *RetType = CallRetResNo.has_value()
12261 ?
Node->getValueType(*CallRetResNo).getTypeForEVT(Ctx)
12273 if (ResNo == CallRetResNo) {
12279 ResultPtr, PtrInfo);
12285 PtrInfo = ST->getPointerInfo();
12292 Results.push_back(LoadResult);
12301 SDValue EVL,
bool &NeedInvert,
12303 bool IsSignaling)
const {
12304 MVT OpVT = LHS.getSimpleValueType();
12306 NeedInvert =
false;
12307 assert(!EVL == !Mask &&
"VP Mask and EVL must either both be set or unset");
12308 bool IsNonVP = !EVL;
12323 bool NeedSwap =
false;
12324 InvCC = getSetCCInverse(CCCode, OpVT);
12340 if (OpVT == MVT::i1) {
12355 DAG.
getNOT(dl, LHS, MVT::i1));
12360 DAG.
getNOT(dl, RHS, MVT::i1));
12365 DAG.
getNOT(dl, LHS, MVT::i1));
12370 DAG.
getNOT(dl, RHS, MVT::i1));
12393 "If SETUE is expanded, SETOEQ or SETUNE must be legal!");
12398 "If SETO is expanded, SETOEQ must be legal!");
12415 NeedInvert = ((
unsigned)CCCode & 0x8U);
12456 SetCC1 = DAG.
getSetCC(dl, VT, LHS, RHS, CC1, Chain, IsSignaling);
12457 SetCC2 = DAG.
getSetCC(dl, VT, LHS, RHS, CC2, Chain, IsSignaling);
12459 SetCC1 = DAG.
getSetCCVP(dl, VT, LHS, RHS, CC1, Mask, EVL);
12460 SetCC2 = DAG.
getSetCCVP(dl, VT, LHS, RHS, CC2, Mask, EVL);
12465 SetCC1 = DAG.
getSetCC(dl, VT, LHS, LHS, CC1, Chain, IsSignaling);
12466 SetCC2 = DAG.
getSetCC(dl, VT, RHS, RHS, CC2, Chain, IsSignaling);
12468 SetCC1 = DAG.
getSetCCVP(dl, VT, LHS, LHS, CC1, Mask, EVL);
12469 SetCC2 = DAG.
getSetCCVP(dl, VT, RHS, RHS, CC2, Mask, EVL);
12476 LHS = DAG.
getNode(
Opc, dl, VT, SetCC1, SetCC2);
12481 LHS = DAG.
getNode(
Opc, dl, VT, SetCC1, SetCC2, Mask, EVL);
12493 EVT VT =
Node->getValueType(0);
12505 unsigned Opcode =
Node->getOpcode();
12543 std::optional<unsigned> ByteOffset;
12547 int Elt = ConstEltNo->getZExtValue();
12561 unsigned IsFast = 0;
12571 DAG, OriginalLoad->
getBasePtr(), InVecVT, EltNo);
12576 if (ResultVT.
bitsGT(VecEltVT)) {
12583 NewPtr, MPI, VecEltVT, Alignment,
12593 if (ResultVT.
bitsLT(VecEltVT))
unsigned const MachineRegisterInfo * MRI
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< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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 int 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
const SmallVectorImpl< MachineOperand > & Cond
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 TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
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.
static SDValue expandVPFunnelShift(SDNode *Node, SelectionDAG &DAG)
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 SDValue clampDynamicVectorIndex(SelectionDAG &DAG, SDValue Idx, EVT VecVT, const SDLoc &dl, ElementCount SubEC)
static unsigned getConstraintPiority(TargetLowering::ConstraintType CT)
Return a number indicating our preference for chosing a type of constraint over another,...
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 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 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)
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 constexpr roundingMode rmTowardZero
static constexpr roundingMode rmNearestTiesToEven
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.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
uint64_t getZExtValue() const
Get zero extended value.
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
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.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
void clearAllBits()
Set every bit to 0.
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
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.
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.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
void setAllBits()
Set every bit to 1.
LLVM_ABI APInt multiplicativeInverse() const
bool isMaxSignedValue() const
Determine if this is the largest signed value.
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
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...
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.
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.
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.
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)
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
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.
@ 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.
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
bool isSimple() const
Returns true if the memory operation is neither atomic or volatile.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
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.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Class to represent pointers.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type 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.
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
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...
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 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 AAMDNodes &AAInfo=AAMDNodes())
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.
bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
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 FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, const SDLoc &dl)
Constant fold a setcc to true or false.
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)
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
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.
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
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,...
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
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 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 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 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 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI SDValue getTypeSize(const SDLoc &DL, EVT VT, TypeSize TS)
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 bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, bool PoisonOnly=false, unsigned Depth=0) const
Return true if this function can prove that Op is never poison and, if PoisonOnly is false,...
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
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 bool isKnownToBeAPowerOfTwo(SDValue Val, unsigned Depth=0) const
Test if the given value is known to have exactly one bit set.
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
LLVM_ABI bool isKnownNeverZeroFloat(SDValue Op) const
Test whether the given floating point SDValue is known to never be positive or negative zero.
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 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
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
SDValue getSetCCVP(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Mask, SDValue EVL)
Helper function to make it easier to build VP_SETCCs if you just have an ISD::CondCode instead of an ...
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.
StringRef - 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
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Class to represent struct types.
LLVM_ABI void setAttributes(const CallBase *Call, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes.
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 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 isCtpopFast(EVT VT) const
Return true if ctpop instruction is fast.
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...
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...
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall implementation.
virtual bool isCommutativeBinOp(unsigned Opcode) const
Returns true if the opcode is a commutative binary operation.
virtual bool isFPImmLegal(const APFloat &, EVT, bool ForCodeSize=false) const
Returns true if the target can instruction select the specified FP immediate natively.
virtual MVT::SimpleValueType getCmpLibcallReturnType() const
Return the ValueType for comparison libcalls.
unsigned getBitWidthForCttzElements(Type *RetTy, ElementCount EC, bool ZeroIsPoison, const ConstantRange *VScaleRange) const
Return the minimum number of bits required to hold the maximum possible number of trailing zero vecto...
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...
ISD::CondCode getSoftFloatCmpLibcallPredicate(RTLIB::LibcallImpl Call) const
Get the comparison predicate that's to be used to test the result of the comparison libcall against z...
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 unsigned getCustomCtpopCost(EVT VT, ISD::CondCode Cond) const
Return the maximum number of "x & (x - 1)" operations that can be done instead of deferring to a cust...
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.
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal on this target.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Get the libcall impl routine name for the specified libcall.
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...
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
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.
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.
SDValue expandVPCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTLZ/VP_CTLZ_ZERO_UNDEF nodes.
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.
virtual void computeKnownBitsForFrameIndex(int FIOp, KnownBits &Known, const MachineFunction &MF) const
Determine which of the bits of FrameIndex FIOp are known to be 0.
virtual bool findOptimalMemOpLowering(LLVMContext &Context, std::vector< EVT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes) const
Determines the optimal series of memory ops to replace the memset / memcpy.
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
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
SDValue expandVPBSWAP(SDNode *N, SelectionDAG &DAG) const
Expand VP_BSWAP nodes.
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 expandCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand CTLZ/CTLZ_ZERO_UNDEF nodes.
SDValue expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand BITREVERSE nodes.
SDValue expandCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand CTTZ/CTTZ_ZERO_UNDEF 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 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.
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 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 expandVPBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand VP_BITREVERSE nodes.
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.
SDValue expandVPCTTZElements(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTTZ_ELTS/VP_CTTZ_ELTS_ZERO_UNDEF 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 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...
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 a n/2-bit urem by constant and other arit...
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.
virtual SDValue getSqrtInputTest(SDValue Operand, SelectionDAG &DAG, const DenormalMode &Mode) const
Return a target-dependent comparison result if the input operand is suitable for use with a square ro...
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.
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.
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
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 LegalizeSetCCCondCode(SelectionDAG &DAG, EVT VT, SDValue &LHS, SDValue &RHS, SDValue &CC, SDValue Mask, SDValue EVL, bool &NeedInvert, const SDLoc &dl, SDValue &Chain, bool IsSignaling=false) const
Legalize a SETCC or VP_SETCC with given LHS and RHS and condition code CC on the current target.
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 expandVPCTPOP(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTPOP nodes.
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].
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
SDValue expandVPCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand VP_CTTZ/VP_CTTZ_ZERO_UNDEF nodes.
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 expandROT(SDNode *N, bool AllowVectorOps, SelectionDAG &DAG) const
Expand rotations.
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
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 bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool PoisonOnly, unsigned Depth) const
Return true if this function can prove that Op is never poison and, if PoisonOnly is false,...
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...
virtual bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const
Return true if Op can create undef or poison from non-undef & non-poison operands.
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.
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.
Primary interface to the complete machine description for the target machine.
bool isPositionIndependent() const
const Triple & getTargetTriple() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
iterator_range< regclass_iterator > regclasses() const
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.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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 ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#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.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ 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...
@ 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...
@ 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.
@ 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.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ 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.
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ 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...
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ SSUBO
Same for subtraction.
@ 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.
@ 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.
@ 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.
@ 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) ...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ 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...
@ 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.
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ 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],...
@ 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.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ 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)...
@ 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...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
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 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.
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.
LLVM_ABI bool matchBinaryPredicate(SDValue LHS, SDValue RHS, 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...
bool matchUnaryPredicate(SDValue Op, std::function< bool(ConstantSDNode *)> Match, bool AllowUndefs=false, bool AllowTruncation=false)
Hook for matching ConstantSDNode predicate.
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...
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
bool sd_match(SDNode *N, const SelectionDAG *DAG, Pattern &&P)
This is an optimization pass for GlobalISel generic memory operations.
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.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
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.
FPClassTest invertFPClassTestIfSimpler(FPClassTest Test, bool UseFCmp)
Evaluates if the specified FP class test is better performed as the inverse (i.e.
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.
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.
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.
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)
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...
To bit_cast(const From &from) noexcept
@ 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...
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
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 isOneConstant(SDValue V)
Returns true if V is a constant integer one.
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.
unsigned Log2(Align A)
Returns the log2 of the alignment.
@ Increment
Incrementally increasing token ID.
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.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
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
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.
EVT changeElementType(EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
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.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
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.
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.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
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.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
EVT changeVectorElementType(EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
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.
unsigned countMinSignBits() const
Returns the number of times the sign bit is replicated into the other bits.
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.
bool isZero() const
Returns true if value is all zero.
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
bool isUnknown() const
Returns true if we don't know any bits.
void setAllConflict()
Make all bits known to be both zero and one.
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.
unsigned getBitWidth() const
Get the bit width of this value.
static LLVM_ABI KnownBits umax(const KnownBits &LHS, const KnownBits &RHS)
Compute known bits for umax(LHS, RHS).
KnownBits zext(unsigned BitWidth) const
Return known bits for a zero extension of the value we're tracking.
void resetAll()
Resets the known state of all bits.
KnownBits unionWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for either this or RHS or both.
bool isSignUnknown() const
Returns true if we don't know the sign bit.
KnownBits intersectWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for both this and RHS.
KnownBits sext(unsigned BitWidth) const
Return known bits for a sign extension of the value we're tracking.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
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.
KnownBits anyext(unsigned BitWidth) const
Return known bits for an "any" extension of the value we're tracking, where we don't know anything ab...
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.
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
static LLVM_ABI UnsignedDivisionByConstantInfo get(const APInt &D, unsigned LeadingZeros=0, bool AllowEvenDivisorOptimization=true)
Calculate the magic numbers required to implement an unsigned integer division by a constant as a seq...
unsigned PostShift
post-shift amount