32#define DEBUG_TYPE "legalize-types"
42void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
47 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
52 switch (
N->getOpcode()) {
55 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
56 N->dump(&DAG);
dbgs() <<
"\n";
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_POISON:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
73 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
76 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
77 case ISD::VP_CTTZ_ZERO_POISON:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
83 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
84 case ISD::VP_CTTZ_ELTS:
85 Res = PromoteIntRes_VP_CttzElements(
N);
88 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
98 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
104 Res = PromoteIntRes_Select(
N);
109 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
111 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
113 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
116 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
118 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
120 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
122 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
123 case ISD::VP_TRUNCATE:
126 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
127 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
131 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
135 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
137 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
140 Res = PromoteIntRes_VECTOR_SPLICE(
N);
144 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
147 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
149 Res = PromoteIntRes_BUILD_VECTOR(
N);
153 Res = PromoteIntRes_ScalarOp(
N);
157 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
162 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
165 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
169 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
175 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
179 case ISD::VP_SIGN_EXTEND:
181 case ISD::VP_ZERO_EXTEND:
184 case ISD::VP_FP_TO_SINT:
185 case ISD::VP_FP_TO_UINT:
193 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
197 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
200 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
204 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
219 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
229 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
239 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
243 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
247 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
251 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
253 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
255 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
271 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
273 case ISD::VP_SADDSAT:
274 case ISD::VP_UADDSAT:
275 case ISD::VP_SSUBSAT:
276 case ISD::VP_USUBSAT:
277 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
282 Res = PromoteIntRes_CMP(
N);
297 Res = PromoteIntRes_ABS(
N);
331 Res = PromoteIntRes_VECREDUCE(
N);
334 case ISD::VP_REDUCE_ADD:
335 case ISD::VP_REDUCE_MUL:
336 case ISD::VP_REDUCE_AND:
337 case ISD::VP_REDUCE_OR:
338 case ISD::VP_REDUCE_XOR:
339 case ISD::VP_REDUCE_SMAX:
340 case ISD::VP_REDUCE_SMIN:
341 case ISD::VP_REDUCE_UMAX:
342 case ISD::VP_REDUCE_UMIN:
343 Res = PromoteIntRes_VP_REDUCE(
N);
348 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
352 Res = PromoteIntRes_FREEZE(
N);
357 Res = PromoteIntRes_Rotate(
N);
362 Res = PromoteIntRes_FunnelShift(
N);
367 Res = PromoteIntRes_VPFunnelShift(
N);
373 Res = PromoteIntRes_CLMUL(
N);
377 Res = PromoteIntRes_PEXT(
N);
381 Res = PromoteIntRes_PDEP(
N);
385 Res = PromoteIntRes_IS_FPCLASS(
N);
388 Res = PromoteIntRes_FFREXP(
N);
393 Res = PromoteIntRes_XRINT(
N);
397 Res = PromoteIntRes_PATCHPOINT(
N);
400 Res = PromoteIntRes_READ_REGISTER(
N);
406 SetPromotedInteger(
SDValue(
N, ResNo), Res);
411 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
412 return GetPromotedInteger(
Op);
415SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
417 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
418 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
423 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
425 Op.getValueType(),
Op,
N->getOperand(1));
430 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
432 Op.getValueType(),
Op,
N->getOperand(1));
436 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
439 switch (TLI.getExtendForAtomicOps()) {
455 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
456 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
466 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
468 Op2 = SExtPromotedInteger(Op2);
471 Op2 = ZExtPromotedInteger(Op2);
474 Op2 = GetPromotedInteger(Op2);
479 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
481 N->getChain(),
N->getBasePtr(),
482 Op2,
N->getMemOperand());
493 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
494 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
498 if (!TLI.isTypeLegal(SVT))
501 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
502 SDValue Res = DAG.getAtomicCmpSwap(
504 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
508 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
514 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
515 switch (TLI.getExtendForAtomicCmpSwapArg()) {
517 Op2 = SExtPromotedInteger(Op2);
520 Op2 = ZExtPromotedInteger(Op2);
523 Op2 = GetPromotedInteger(Op2);
530 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
531 SDValue Res = DAG.getAtomicCmpSwap(
532 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
533 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
535 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
543 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
544 EVT OutVT =
N->getValueType(0);
545 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
548 switch (getTypeAction(InVT)) {
554 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
558 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
561 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
569 BitConvertToInteger(GetScalarizedVector(InOp)));
578 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
579 Lo = BitConvertToInteger(
Lo);
580 Hi = BitConvertToInteger(
Hi);
582 if (DAG.getDataLayout().isBigEndian())
588 JoinIntegers(
Lo,
Hi));
603 if (DAG.getDataLayout().isBigEndian()) {
607 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
622 if (isTypeLegal(WideOutVT)) {
623 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
625 DAG.getVectorIdxConstant(0, dl));
634 DAG.getDataLayout().isLittleEndian()) {
645 if (isTypeLegal(WideVecVT)) {
647 DAG.getUNDEF(WideVecVT), InOp,
648 DAG.getVectorIdxConstant(0, dl));
656 CreateStackStoreLoad(InOp, OutVT));
660 SDValue V = GetPromotedInteger(
N->getOperand(0));
662 V.getValueType(), V);
666 SDValue Op = GetPromotedInteger(
N->getOperand(0));
667 EVT OVT =
N->getValueType(0);
668 EVT NVT =
Op.getValueType();
676 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
677 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
682 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
688 return DAG.getNode(ISD::VP_SRL, dl, NVT,
689 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
694 SDValue Op = GetPromotedInteger(
N->getOperand(0));
695 EVT OVT =
N->getValueType(0);
696 EVT NVT =
Op.getValueType();
705 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
710 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
716 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
717 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
725 TLI.getTypeToTransformTo(*DAG.getContext(),
726 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
731 EVT VT =
N->getValueType(0);
738 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
745 EVT OVT =
N->getValueType(0);
746 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
752 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
753 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
755 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
761 unsigned CtlzOpcode =
N->getOpcode();
762 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
764 SDValue ExtractLeadingBits = DAG.getConstant(
767 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
771 if (!
N->isVPOpcode())
772 return DAG.getNode(
ISD::SUB, dl, NVT,
773 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
777 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
778 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
779 ExtractLeadingBits, Mask, EVL,
783 CtlzOpcode == ISD::VP_CTLZ_ZERO_POISON) {
785 SDValue Op = GetPromotedInteger(
N->getOperand(0));
789 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
790 if (!
N->isVPOpcode()) {
792 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
797 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
798 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
804 EVT OVT =
N->getValueType(0);
805 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
808 SDValue ExtractLeadingBits = DAG.getConstant(
811 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
817 EVT OVT =
N->getValueType(0);
818 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
826 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
827 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
834 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
835 if (!
N->isVPOpcode())
836 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
840 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
845 SDValue Op = GetPromotedInteger(
N->getOperand(0));
846 EVT OVT =
N->getValueType(0);
847 EVT NVT =
Op.getValueType();
854 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
855 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
859 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
865 unsigned NewOpc =
N->getOpcode();
866 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
873 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
877 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
878 N->getOperand(1),
N->getOperand(2));
879 NewOpc = ISD::VP_CTTZ_ZERO_POISON;
882 if (!
N->isVPOpcode())
883 return DAG.getNode(NewOpc, dl, NVT,
Op);
884 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
887SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
889 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
890 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
893SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
895 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
902 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
908 EVT SVT =
In.getValueType().getScalarType();
911 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
919 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
921 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
925 if (
N->isStrictFPOpcode()) {
926 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
927 {
N->getOperand(0),
N->getOperand(1)});
931 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
932 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
935 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
947 N->getOpcode() == ISD::VP_FP_TO_UINT)
951 DAG.getValueType(
N->getValueType(0).getScalarType()));
954SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
956 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
958 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
962SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
963 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
966 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
971SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
972 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
976 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
979SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
980 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
983 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
984 N->getOperand(0),
N->getOperand(1));
990 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
992 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
996 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1000 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
1009 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1012 if (getTypeAction(
N->getOperand(0).getValueType())
1014 SDValue Res = GetPromotedInteger(
N->getOperand(0));
1019 if (NVT == Res.
getValueType() &&
N->getNumOperands() == 1) {
1023 DAG.getValueType(
N->getOperand(0).getValueType()));
1025 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
1032 if (
N->getNumOperands() != 1) {
1033 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1034 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1035 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1036 N->getOperand(1),
N->getOperand(2));
1038 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1043 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1047 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1048 N->getMemoryVT(),
N->getMemOperand());
1057 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1058 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1061 :
N->getExtensionType();
1064 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1065 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1066 N->getMemOperand(),
N->isExpandingLoad());
1074 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1075 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1082 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1083 N->getOffset(),
N->getMask(), ExtPassThru,
1084 N->getMemoryVT(),
N->getMemOperand(),
1085 N->getAddressingMode(), ExtType,
1086 N->isExpandingLoad());
1094 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1095 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1097 "Gather result type and the passThru argument type should be the same");
1104 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1105 N->getIndex(),
N->getScale() };
1106 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1107 N->getMemoryVT(), dl,
Ops,
1108 N->getMemOperand(),
N->getIndexType(),
1116SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1117 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1118 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1120 N->getOperand(1), Passthru);
1127 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1128 EVT VT =
N->getValueType(0);
1129 EVT SVT = getSetCCResultType(VT);
1130 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1131 unsigned NumOps =
N->getNumOperands();
1134 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1142 ReplaceValueWith(
SDValue(
N, 0), Res);
1145 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1148template <
class MatchContextClass>
1160 MatchContextClass matcher(DAG, TLI,
N);
1162 unsigned Opcode = matcher.getRootBaseOpcode();
1168 SExtOrZExtPromotedOperands(Op1, Op2);
1174 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1176 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1177 Op1 = SExtPromotedInteger(Op1);
1178 Op2 = SExtPromotedInteger(Op2);
1179 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1182 Op1 = ZExtPromotedInteger(Op1);
1183 Op2 = ZExtPromotedInteger(Op2);
1186 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1188 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1195 Op1 = GetPromotedInteger(Op1);
1197 Op2 = ZExtPromotedInteger(Op2);
1199 Op1 = SExtPromotedInteger(Op1);
1200 Op2 = SExtPromotedInteger(Op2);
1207 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1220 "addition, subtraction or left shift");
1223 unsigned SHLAmount = NewBits - OldBits;
1225 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1230 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1231 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1237 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1238 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1239 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1240 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1241 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1248 SDValue Op1Promoted, Op2Promoted;
1254 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1255 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1257 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1258 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1260 EVT OldType =
N->getOperand(0).getValueType();
1272 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1273 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1274 Op2Promoted,
N->getOperand(2));
1276 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1277 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1279 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1284 unsigned SatW,
bool Signed,
1287 EVT VT = V.getValueType();
1314 EVT VT =
LHS.getValueType();
1330 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1336 "Tried to saturate to more than the original type?");
1345 SDValue Op1Promoted, Op2Promoted;
1351 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1352 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1354 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1355 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1358 unsigned Scale =
N->getConstantOperandVal(2);
1362 if (TLI.isTypeLegal(PromotedType)) {
1364 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1367 N->getValueType(0).getScalarSizeInBits();
1371 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1372 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1373 Op2Promoted,
N->getOperand(2));
1376 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1382 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1383 Op2Promoted, Scale, DAG)) {
1386 N->getValueType(0).getScalarSizeInBits(),
1394 N->getValueType(0).getScalarSizeInBits());
1397SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1399 return PromoteIntRes_Overflow(
N);
1403 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1404 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1405 EVT OVT =
N->getOperand(0).getValueType();
1406 EVT NVT =
LHS.getValueType();
1416 DAG.getValueType(OVT));
1418 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1421 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1427 EVT PromotedResultTy =
1428 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1429 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1430 N->getOperand(0),
N->getOperand(1));
1436 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1437 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1439 unsigned Opcode =
N->getOpcode();
1440 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1441 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1443 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1447 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1448 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1450 LHS.getValueType(),
N->getOperand(0),
1451 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1456 EVT InVT =
N->getOperand(OpNo).getValueType();
1457 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1459 EVT SVT = getSetCCResultType(InVT);
1466 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1467 SVT = getSetCCResultType(InVT);
1475 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1476 "Vector compare must return a vector result!");
1480 if (
N->isStrictFPOpcode()) {
1481 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1482 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1483 N->getOperand(2),
N->getOperand(3)};
1484 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1489 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1490 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1493 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1500 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1505 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1506 EVT VT =
N->getValueType(0);
1510 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1512 ReplaceValueWith(
SDValue(
N, 0), Res);
1517 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1520 RHS = ZExtPromotedInteger(
RHS);
1521 if (
N->getOpcode() != ISD::VP_SHL)
1522 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1530SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1531 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1533 Op.getValueType(),
Op,
N->getOperand(1));
1536SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1540 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1541 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1542 if (
N->getNumOperands() == 2)
1543 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1544 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1545 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1546 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1547 N->getOperand(2),
N->getOperand(3));
1552 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1553 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1554 if (
N->getNumOperands() == 2)
1555 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1556 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1557 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1566 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1567 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1568 if (
N->getNumOperands() == 2)
1569 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1570 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1571 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1579SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1580 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1581 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1583 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1587SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1588 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1589 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1591 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1601 SExtOrZExtPromotedOperands(
LHS,
RHS);
1603 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1609 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1612 RHS = ZExtPromotedInteger(
RHS);
1613 if (
N->getOpcode() != ISD::VP_SRA)
1614 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1625 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1627 RHS = ZExtPromotedInteger(
RHS);
1628 if (
N->getOpcode() != ISD::VP_SRL)
1629 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1639 SDValue Res = TLI.expandROT(
N,
true , DAG);
1640 ReplaceValueWith(
SDValue(
N, 0), Res);
1645 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1646 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1649 Amt = ZExtPromotedInteger(Amt);
1653 EVT OldVT =
N->getOperand(0).getValueType();
1654 EVT VT =
Lo.getValueType();
1655 unsigned Opcode =
N->getOpcode();
1662 DAG.getConstant(OldBits,
DL, AmtVT));
1670 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1671 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1673 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1683 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1689 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1691 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1695SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1696 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1697 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1702 Amt = ZExtPromotedInteger(Amt);
1706 EVT OldVT =
N->getOperand(0).getValueType();
1707 EVT VT =
Lo.getValueType();
1708 unsigned Opcode =
N->getOpcode();
1709 bool IsFSHR = Opcode == ISD::VP_FSHR;
1714 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1715 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1723 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1724 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1725 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1726 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1728 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1731 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1736 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1737 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1742 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1744 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1748 unsigned Opcode =
N->getOpcode();
1751 EVT OldVT =
N->getOperand(0).getValueType();
1752 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1755 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1756 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1759 SDValue X = GetPromotedInteger(
N->getOperand(0));
1760 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1764 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1765 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1769 if (NewBits < 2 * OldBits) {
1771 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1773 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1775 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1777 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1782 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1784 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1789 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1790 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1791 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1796 SDValue X = GetPromotedInteger(
N->getOperand(0));
1797 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1803 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1804 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1805 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1810 SDValue X = GetPromotedInteger(
N->getOperand(0));
1811 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1816 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1828 Res = GetPromotedInteger(InOp);
1835 "Dst and Src must have the same number of elements");
1837 "Promoted vector type must be a power of two");
1840 GetSplitVector(InOp, EOp1, EOp2);
1848 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1849 "Expected VP_TRUNCATE opcode");
1850 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1851 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1852 std::tie(EVLLo, EVLHi) =
1853 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1854 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1855 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1862 SDValue WideInOp = GetWidenedVector(InOp);
1867 N->getValueType(0).getScalarType(), NumElem);
1876 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1882 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1883 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1888SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1890 return PromoteIntRes_Overflow(
N);
1894 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1895 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1896 EVT OVT =
N->getOperand(0).getValueType();
1897 EVT NVT =
LHS.getValueType();
1906 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1908 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1911 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1922 return PromoteIntRes_Overflow(
N);
1934 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1935 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1937 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1940 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1951 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1952 return PromoteIntRes_Overflow(
N);
1956 EVT OVT =
N->getValueType(0);
1957 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1963 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1965 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1966 if (
SDValue Res = TLI.expandABS(
N, DAG))
1970 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1974SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1977 return PromoteIntRes_Overflow(
N);
1981 EVT SmallVT =
LHS.getValueType();
1988 LHS = SExtPromotedInteger(
LHS);
1989 RHS = SExtPromotedInteger(
RHS);
1991 LHS = ZExtPromotedInteger(
LHS);
1992 RHS = ZExtPromotedInteger(
RHS);
1994 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
2006 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
2007 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
2008 DAG.getConstant(0,
DL,
Hi.getValueType()),
2013 Mul, DAG.getValueType(SmallVT));
2023 ReplaceValueWith(
SDValue(
N, 1), Overflow);
2028 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
2029 N->getValueType(0)));
2033 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2035 const APInt &MulImm =
N->getConstantOperandAPInt(0);
2042 EVT VT =
N->getValueType(0);
2045 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
2046 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
2050 for (
unsigned i = 0; i < NumRegs; ++i) {
2051 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2052 N->getConstantOperandVal(3));
2057 if (DAG.getDataLayout().isBigEndian())
2058 std::reverse(Parts.begin(), Parts.end());
2061 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2063 for (
unsigned i = 1; i < NumRegs; ++i) {
2068 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2074 ReplaceValueWith(
SDValue(
N, 1), Chain);
2087bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2090 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2095 switch (
N->getOpcode()) {
2098 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2099 N->dump(&DAG);
dbgs() <<
"\n";
2105 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2111 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2112 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2117 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2121 Res = PromoteIntOp_FAKE_USE(
N);
2124 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2128 Res = PromoteIntOp_ScalarOp(
N);
2131 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2134 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2136 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2137 case ISD::VP_SINT_TO_FP:
2154 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2156 case ISD::VP_TRUNCATE:
2160 case ISD::VP_UINT_TO_FP:
2163 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2168 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2179 Res = PromoteIntOp_Shift(
N);
2183 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2186 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2212 case ISD::VP_REDUCE_ADD:
2213 case ISD::VP_REDUCE_MUL:
2214 case ISD::VP_REDUCE_AND:
2215 case ISD::VP_REDUCE_OR:
2216 case ISD::VP_REDUCE_XOR:
2217 case ISD::VP_REDUCE_SMAX:
2218 case ISD::VP_REDUCE_SMIN:
2219 case ISD::VP_REDUCE_UMAX:
2220 case ISD::VP_REDUCE_UMIN:
2221 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2226 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2229 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2232 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2234 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2235 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2236 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2238 case ISD::EXPERIMENTAL_VP_SPLICE:
2239 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2242 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2247 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2250 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2256 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2261 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2265 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2270 if (!Res.
getNode())
return false;
2277 const bool IsStrictFp =
N->isStrictFPOpcode();
2279 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2280 "Invalid operand expansion");
2284 ReplaceValueWith(
SDValue(
N, 0), Res);
2298 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2302 unsigned OpLEffectiveBits =
2303 DAG.computeKnownBits(OpL).countMaxActiveBits();
2304 unsigned OpREffectiveBits =
2305 DAG.computeKnownBits(OpR).countMaxActiveBits();
2306 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2307 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2314 LHS = SExtPromotedInteger(
LHS);
2315 RHS = SExtPromotedInteger(
RHS);
2324 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2325 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2326 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2327 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2334 LHS = ZExtPromotedInteger(
LHS);
2335 RHS = ZExtPromotedInteger(
RHS);
2349 LHS = SExtPromotedInteger(
LHS);
2350 RHS = SExtPromotedInteger(
RHS);
2355 "Unknown integer comparison!");
2357 SExtOrZExtPromotedOperands(
LHS,
RHS);
2361 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2365SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2366 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2367 EVT ResVT =
N->getValueType(0);
2368 EVT OpVT =
Op.getValueType();
2371 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2376 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2377 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2378 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2382 EVT OutVT =
N->getValueType(0);
2385 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2388 switch (getTypeAction(InVT)) {
2392 DAG.getDataLayout().isLittleEndian()) {
2402 if (isTypeLegal(WideVecVT)) {
2403 SDValue Promoted = GetPromotedInteger(InOp);
2406 DAG.getVectorIdxConstant(0, dl));
2419 return CreateStackStoreLoad(InOp, OutVT);
2422SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2423 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2431 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2432 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2436SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2437 assert(OpNo == 1 &&
"only know how to promote condition");
2440 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2443 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2444 N->getOperand(2)), 0);
2447SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2448 assert(OpNo == 1 &&
"only know how to promote condition");
2451 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2454 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2459 EVT OVT =
N->getOperand(0).getValueType();
2460 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2461 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2462 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2467 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2468 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2477 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2478 "Legal vector of one illegal element?");
2483 assert(
N->getOperand(0).getValueSizeInBits() >=
2484 N->getValueType(0).getScalarSizeInBits() &&
2485 "Type of inserted value narrower than vector element type!");
2488 for (
unsigned i = 0; i < NumElts; ++i)
2489 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2491 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2494SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2501 assert(
N->getOperand(1).getValueSizeInBits() >=
2502 N->getValueType(0).getScalarSizeInBits() &&
2503 "Type of inserted value narrower than vector element type!");
2504 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2505 GetPromotedInteger(
N->getOperand(1)),
2510 assert(OpNo == 2 &&
"Different operand and result vector types?");
2513 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2514 TLI.getVectorIdxTy(DAG.getDataLayout()));
2515 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2516 N->getOperand(1), Idx), 0);
2520 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2524 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2527SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2528 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2530 EVT OpTy =
N->getOperand(1).getValueType();
2533 if (
SDValue Res = WidenVSELECTMask(
N))
2534 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2535 Res,
N->getOperand(1),
N->getOperand(2));
2539 Cond = PromoteTargetBoolean(
Cond, OpVT);
2541 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2542 N->getOperand(2)), 0);
2545SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2546 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2554 N->getOperand(3),
N->getOperand(4)), 0);
2557SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2558 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2566 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2568 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2571 N->getOperand(3),
N->getOperand(4)),
2576 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2577 ZExtPromotedInteger(
N->getOperand(1))), 0);
2585 LHS = SExtPromotedInteger(
LHS);
2586 RHS = SExtPromotedInteger(
RHS);
2588 SExtOrZExtPromotedOperands(
LHS,
RHS);
2595 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2596 ZExtPromotedInteger(
N->getOperand(2))), 0);
2600 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2604 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2607SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2609 EVT VT =
N->getValueType(0);
2610 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2612 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2616 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2618 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2620 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2625 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2626 return SDValue(DAG.UpdateNodeOperands(
N,
2627 SExtPromotedInteger(
N->getOperand(0)),
2628 N->getOperand(1),
N->getOperand(2)),
2630 return SDValue(DAG.UpdateNodeOperands(
N,
2631 SExtPromotedInteger(
N->getOperand(0))), 0);
2634SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2635 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2636 SExtPromotedInteger(
N->getOperand(1))), 0);
2641 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2644 SDValue Val = GetPromotedInteger(
N->getValue());
2647 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2648 N->getMemoryVT(),
N->getMemOperand());
2654 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2655 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2657 SDValue DataOp = GetPromotedInteger(
N->getValue());
2658 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2659 N->getMask(),
N->getVectorLength(),
2660 N->getMemoryVT(),
N->getMemOperand(),
2661 N->isCompressingStore());
2672 Mask = PromoteTargetBoolean(Mask, DataVT);
2675 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2678 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2679 DataOp = GetPromotedInteger(DataOp);
2681 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2682 N->getOffset(), Mask,
N->getMemoryVT(),
2683 N->getMemOperand(),
N->getAddressingMode(),
2684 true,
N->isCompressingStore());
2689 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2690 EVT DataVT =
N->getValueType(0);
2691 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2693 NewOps[OpNo] =
Mask;
2694 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2710 EVT DataVT =
N->getValueType(0);
2711 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2712 }
else if (OpNo == 4) {
2714 if (
N->isIndexSigned())
2716 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2718 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2720 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2722 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2734 bool TruncateStore =
N->isTruncatingStore();
2739 EVT DataVT =
N->getValue().getValueType();
2740 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2741 }
else if (OpNo == 4) {
2743 if (
N->isIndexSigned())
2745 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2747 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2749 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2750 TruncateStore =
true;
2753 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2754 SDLoc(
N), NewOps,
N->getMemOperand(),
2755 N->getIndexType(), TruncateStore);
2760 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2764 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2769 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2770 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2771 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2772 N->getOperand(1),
N->getOperand(2));
2777 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2778 return SDValue(DAG.UpdateNodeOperands(
N,
2779 ZExtPromotedInteger(
N->getOperand(0)),
2780 N->getOperand(1),
N->getOperand(2)),
2782 return SDValue(DAG.UpdateNodeOperands(
N,
2783 ZExtPromotedInteger(
N->getOperand(0))), 0);
2786SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2787 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2792SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2793 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2794 ZExtPromotedInteger(
N->getOperand(1))), 0);
2801 EVT VT =
N->getValueType(0);
2806 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2807 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2808 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2809 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2814 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2817SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2819 EVT VT =
N->getValueType(0);
2820 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2822 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2824 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2825 N->getOperand(0).getValueType());
2829 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2831 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2834SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2836 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2837 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2846 unsigned OpOffset = IsStrict ? 1 : 0;
2853 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2854 if (LCImpl == RTLIB::Unsupported) {
2860 if (IsPowI &&
N->getValueType(0).isVector())
2861 return DAG.UnrollVectorOp(
N);
2863 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2864 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2876 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2877 DAG.getLibInfo().getIntSize()) {
2878 const Function &Fn = DAG.getMachineFunction().getFunction();
2879 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2880 Twine(IsPowI ?
"powi" :
"ldexp") +
2881 " exponent does not match sizeof(int)",
2882 Fn, N->getDebugLoc()));
2884 ReplaceValueWith(SDValue(N, 1), Chain);
2885 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2889 TargetLowering::MakeLibCallOptions CallOptions;
2890 CallOptions.setIsSigned(
true);
2891 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2892 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2893 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2894 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2896 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2901 switch (
N->getOpcode()) {
2909 case ISD::VP_REDUCE_ADD:
2910 case ISD::VP_REDUCE_MUL:
2911 case ISD::VP_REDUCE_AND:
2912 case ISD::VP_REDUCE_OR:
2913 case ISD::VP_REDUCE_XOR:
2917 case ISD::VP_REDUCE_SMAX:
2918 case ISD::VP_REDUCE_SMIN:
2922 case ISD::VP_REDUCE_UMAX:
2923 case ISD::VP_REDUCE_UMIN:
2933 return GetPromotedInteger(V);
2935 return SExtPromotedInteger(V);
2937 return ZExtPromotedInteger(V);
2943 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2945 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2946 EVT InVT =
Op.getValueType();
2948 EVT ResVT =
N->getValueType(0);
2949 unsigned Opcode =
N->getOpcode();
2966 switch (TLI.getBooleanContents(InVT)) {
2969 Op = ZExtPromotedInteger(
N->getOperand(0));
2972 Op = SExtPromotedInteger(
N->getOperand(0));
2985 switch (TLI.getBooleanContents(InVT)) {
2988 Op = ZExtPromotedInteger(
N->getOperand(0));
2991 Op = SExtPromotedInteger(
N->getOperand(0));
2997 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
3001 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
3005SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
3012 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
3013 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3016 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3018 Op = PromoteIntOpVectorReduction(
N,
Op);
3022 EVT VT =
N->getValueType(0);
3023 EVT EltVT =
Op.getValueType().getScalarType();
3026 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
3038 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
3039 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
3042SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
3045 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3046 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3049SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3052 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3053 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3058 const Function &Fn = DAG.getMachineFunction().getFunction();
3060 "cannot use llvm.write_register with illegal type", Fn,
3062 return N->getOperand(0);
3065SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3066 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3067 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3070 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3071 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3081SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3085 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3086 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3089 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3091 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3092 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3095SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3097 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3099 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3100 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3103SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3105 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3109 if (TLI.getBooleanContents(
Op.getValueType()) ==
3111 NewOp = SExtPromotedInteger(
Op);
3113 NewOp = ZExtPromotedInteger(
Op);
3115 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3118SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3120 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3121 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3122 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3125SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3128 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3129 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3132SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3134 switch (
N->getOpcode()) {
3136 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3137 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3140 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3141 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3144 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3145 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3150 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3153SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3155 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3156 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3157 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3159 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3170void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3176 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3179 switch (
N->getOpcode()) {
3182 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3183 N->dump(&DAG);
dbgs() <<
"\n";
3212 ExpandIntRes_ABS(
N,
Lo,
Hi);
3264 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3265 SplitInteger(Tmp.first,
Lo,
Hi);
3266 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3271 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3272 SDValue Tmp = DAG.getAtomicCmpSwap(
3274 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3283 SplitInteger(Tmp,
Lo,
Hi);
3362 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3367 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3373 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3377 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3381 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3385 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3389 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3394 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3404std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3405 unsigned Opc =
Node->getOpcode();
3411 EVT RetVT =
Node->getValueType(0);
3412 TargetLowering::MakeLibCallOptions CallOptions;
3415 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3416 if (LCImpl != RTLIB::Unsupported) {
3418 Ops.push_back(
Node->getOperand(1));
3421 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3422 "Unexpected atomic op or value type!");
3424 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3426 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3427 Node->getOperand(0));
3432void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3437 GetExpandedInteger(
N->getOperand(0), InL, InH);
3452 if (Amt.
uge(VTBits)) {
3453 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3454 }
else if (Amt.
ugt(NVTBits)) {
3455 Lo = DAG.getConstant(0,
DL, NVT);
3457 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3458 }
else if (Amt == NVTBits) {
3459 Lo = DAG.getConstant(0,
DL, NVT);
3463 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3465 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3467 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3472 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3474 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3481 if (Amt.
uge(VTBits)) {
3482 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3483 }
else if (Amt.
ugt(NVTBits)) {
3485 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3486 Hi = DAG.getConstant(0,
DL, NVT);
3487 }
else if (Amt == NVTBits) {
3489 Hi = DAG.getConstant(0,
DL, NVT);
3492 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3494 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3499 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3501 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3504 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3510 if (Amt.
uge(VTBits)) {
3512 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3513 }
else if (Amt.
ugt(NVTBits)) {
3515 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3517 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3518 }
else if (Amt == NVTBits) {
3521 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3524 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3526 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3531 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3533 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3536 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3544bool DAGTypeLegalizer::
3546 unsigned Opc =
N->getOpcode();
3549 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3554 "Expanded integer type size not a power of two!");
3558 KnownBits Known = DAG.computeKnownBits(Amt);
3561 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3566 GetExpandedInteger(In, InL, InH);
3573 DAG.getConstant(~HighBitMask, dl, ShTy));
3578 Lo = DAG.getConstant(0, dl, NVT);
3579 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3582 Hi = DAG.getConstant(0, dl, NVT);
3583 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3587 DAG.getConstant(NVTBits - 1, dl, ShTy));
3588 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3600 DAG.getConstant(NVTBits - 1, dl, ShTy));
3616 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3618 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3620 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3621 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3633bool DAGTypeLegalizer::
3636 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3640 "Expanded integer type size not a power of two!");
3645 GetExpandedInteger(
N->getOperand(0), InL, InH);
3647 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3650 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3653 Amt, DAG.getConstant(0, dl, ShTy),
3657 switch (
N->getOpcode()) {
3663 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3664 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3667 LoL = DAG.getConstant(0, dl, NVT);
3670 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3671 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3672 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3678 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3681 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3684 HiL = DAG.getConstant(0, dl, NVT);
3687 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3688 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3689 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3695 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3696 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3700 DAG.getConstant(NVTBits - 1, dl, ShTy));
3703 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3704 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3705 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3730 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3735 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3736 SplitInteger(Res,
Lo,
Hi);
3739void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3748 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3749 unsigned NumHalfBits = NumBits / 2;
3750 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3751 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3752 SDValue LHSL, LHSH, RHSL, RHSH;
3753 GetExpandedInteger(
LHS, LHSL, LHSH);
3754 GetExpandedInteger(
RHS, RHSL, RHSH);
3757 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3759 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3767 SDValue LHSL, LHSH, RHSL, RHSH;
3768 GetExpandedInteger(
LHS, LHSL, LHSH);
3769 GetExpandedInteger(
RHS, RHSL, RHSH);
3771 EVT CCT = getSetCCResultType(NVT);
3774 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3776 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3778 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3780 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3784 const APInt *RHSVal =
nullptr;
3786 RHSVal = &RHSConst->getAPIntValue();
3793 SDValue LHSL, LHSH, RHSL, RHSH;
3794 GetExpandedInteger(
LHS, LHSL, LHSH);
3795 GetExpandedInteger(
RHS, RHSL, RHSH);
3797 EVT CCT = getSetCCResultType(NVT);
3803 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3806 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3810 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3813 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3815 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3822 switch (
N->getOpcode()) {
3849 EVT VT =
N->getValueType(0);
3850 EVT CCT = getSetCCResultType(VT);
3853 SplitInteger(Result,
Lo,
Hi);
3857 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3858 SplitInteger(ExpandedCMP,
Lo,
Hi);
3861void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3865 SDValue LHSL, LHSH, RHSL, RHSH;
3866 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3867 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3870 SDValue LoOps[2] = { LHSL, RHSL };
3871 SDValue HiOps[3] = { LHSH, RHSH };
3873 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3875 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3877 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3881 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3887 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3900 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3902 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3905 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3919 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3921 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3925 EVT OvfVT = getSetCCResultType(NVT);
3926 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3941 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3944 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3948 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3960 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3964 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3967 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3970 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3975 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3977 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3978 DAG.getConstant(0, dl, NVT));
3981 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3990 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3995 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3997 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3998 DAG.getConstant(0, dl, NVT));
4004void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
4007 SDValue LHSL, LHSH, RHSL, RHSH;
4009 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4010 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4011 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4012 SDValue LoOps[2] = { LHSL, RHSL };
4013 SDValue HiOps[3] = { LHSH, RHSH };
4027 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4030void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4033 SDValue LHSL, LHSH, RHSL, RHSH;
4035 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4036 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4037 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4039 SDValue HiOps[3] = { LHSH, RHSH };
4041 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4043 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4047 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4050void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4058 unsigned CarryOp, NoCarryOp;
4060 switch(
N->getOpcode()) {
4075 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4076 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4080 SDValue LHSL, LHSH, RHSL, RHSH;
4081 GetExpandedInteger(
LHS, LHSL, LHSH);
4082 GetExpandedInteger(
RHS, RHSL, RHSH);
4083 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4084 SDValue LoOps[2] = { LHSL, RHSL };
4085 SDValue HiOps[3] = { LHSH, RHSH };
4087 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4089 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4096 SplitInteger(Sum,
Lo,
Hi);
4102 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4103 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4107 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4112 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4118 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4124 SDValue LHSL, LHSH, RHSL, RHSH;
4126 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4127 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4128 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4132 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4134 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4138 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4141void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4144 SDValue LHSL, LHSH, RHSL, RHSH;
4146 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4147 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4148 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4153 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4154 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4158 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4161void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4163 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4166 if (
Op.getValueType().bitsLE(NVT)) {
4169 Hi = DAG.getUNDEF(NVT);
4173 assert(getTypeAction(
Op.getValueType()) ==
4175 "Only know how to promote this result!");
4178 "Operand over promoted?");
4180 SplitInteger(Res,
Lo,
Hi);
4184void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4187 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4188 EVT NVT =
Lo.getValueType();
4193 if (NVTBits < EVTBits) {
4196 EVTBits - NVTBits)));
4201 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4205void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4208 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4209 EVT NVT =
Lo.getValueType();
4214 if (NVTBits < EVTBits) {
4217 EVTBits - NVTBits)));
4221 Hi = DAG.getConstant(0, dl, NVT);
4225void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4228 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4233void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4236 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4245 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4246 EVT NVT =
Lo.getValueType();
4249 Hi = DAG.getConstant(0, dl, NVT);
4252void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4254 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4257 const APInt &Cst =
Constant->getAPIntValue();
4258 bool IsTarget =
Constant->isTargetOpcode();
4259 bool IsOpaque =
Constant->isOpaque();
4261 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4262 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4270 GetExpandedInteger(N0,
Lo,
Hi);
4271 EVT NVT =
Lo.getValueType();
4276 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4281 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4282 Hi = DAG.getConstant(0, dl, NVT);
4292 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4297 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4298 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4307 EVT VT =
N->getValueType(0);
4309 DAG.getConstant(0, dl, VT), N0);
4311 SplitInteger(Neg, NegLo, NegHi);
4313 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4315 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4316 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4319void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4323 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4324 EVT NVT =
Lo.getValueType();
4326 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4329 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4332 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4333 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4336 Hi = DAG.getConstant(0, dl, NVT);
4344 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4345 EVT NVT =
Lo.getValueType();
4348 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4349 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4352 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4355 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4357 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4359 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4360 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4362 Hi = DAG.getConstant(0, dl, NVT);
4367 SplitInteger(Result,
Lo,
Hi);
4372 EVT VT =
N->getValueType(0);
4377 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4378 "LibCall explicitly requested, but not available");
4380 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4381 TargetLowering::MakeLibCallOptions CallOptions;
4385 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4386 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4394 GetExpandedInteger(
Op,
Lo,
Hi);
4395 EVT NVT =
Lo.getValueType();
4398 Hi = DAG.getConstant(0,
DL, NVT);
4401void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4405 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4406 EVT NVT =
Lo.getValueType();
4408 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4414 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4415 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4418 Hi = DAG.getConstant(0, dl, NVT);
4424 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4431 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4435 ReplaceValueWith(
SDValue(
N, 1), Chain);
4443 Chain =
Op.getValue(1);
4452 EVT VT =
N->getValueType(0);
4456 bool IsStrict =
N->isStrictFPOpcode();
4458 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4462 Op.getValueType() == MVT::bf16) {
4468 EVT OpVT =
Op.getValueType();
4472 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4473 TargetLowering::MakeLibCallOptions CallOptions;
4478 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4479 CallOptions, dl, Chain);
4480 SplitInteger(Tmp.first,
Lo,
Hi);
4483 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4488 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4489 SplitInteger(Res,
Lo,
Hi);
4495 bool IsStrict =
N->isStrictFPOpcode();
4496 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4499 EVT VT =
Op.getValueType();
4501 if (VT == MVT::f16) {
4507 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4511 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4515 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4519 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4523 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4527 EVT RetVT =
N->getValueType(0);
4529 TargetLowering::MakeLibCallOptions CallOptions;
4531 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4532 Op, CallOptions, dl,
4534 SplitInteger(Tmp.first,
Lo,
Hi);
4536 if (
N->isStrictFPOpcode())
4537 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4540void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4542 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4545 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4551 EVT VT =
N->getValueType(0);
4552 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4557 AAMDNodes AAInfo =
N->getAAInfo();
4562 if (
N->getMemoryVT().bitsLE(NVT)) {
4563 EVT MemVT =
N->getMemoryVT();
4565 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4566 N->getBaseAlign(), MMOFlags, AAInfo);
4574 unsigned LoSize =
Lo.getValueSizeInBits();
4576 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4579 Hi = DAG.getConstant(0, dl, NVT);
4583 Hi = DAG.getUNDEF(NVT);
4585 }
else if (DAG.getDataLayout().isLittleEndian()) {
4587 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4590 unsigned ExcessBits =
4597 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4598 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4599 N->getBaseAlign(), MMOFlags, AAInfo);
4608 EVT MemVT =
N->getMemoryVT();
4611 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4614 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4617 N->getBaseAlign(), MMOFlags, AAInfo);
4623 N->getPointerInfo().getWithOffset(IncrementSize),
4625 N->getBaseAlign(), MMOFlags, AAInfo);
4637 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4641 DAG.getShiftAmountConstant(
4648 ReplaceValueWith(
SDValue(
N, 1), Ch);
4651void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4655 GetExpandedInteger(
N->getOperand(0), LL, LH);
4656 GetExpandedInteger(
N->getOperand(1), RL, RH);
4660 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4662 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4663 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4666void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4668 EVT VT =
N->getValueType(0);
4669 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4673 GetExpandedInteger(
N->getOperand(0), LL, LH);
4674 GetExpandedInteger(
N->getOperand(1), RL, RH);
4676 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4683 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4684 if (LCImpl == RTLIB::Unsupported) {
4687 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4693 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4694 TargetLowering::MakeLibCallOptions CallOptions;
4696 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4703 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4704 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4705 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4708 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4713 SplitInteger(Result,
Lo,
Hi);
4719 SplitInteger(Result,
Lo,
Hi);
4725 SplitInteger(Result,
Lo,
Hi);
4736 EVT VT =
N->getValueType(0);
4740 uint64_t Scale =
N->getConstantOperandVal(2);
4752 EVT BoolVT = getSetCCResultType(VT);
4754 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4760 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4761 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4767 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4768 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4773 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4774 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4777 SplitInteger(Result,
Lo,
Hi);
4783 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4785 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4787 GetExpandedInteger(
LHS, LL, LH);
4788 GetExpandedInteger(
RHS, RL, RH);
4792 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4799 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4800 SplitInteger(LoTmp, Result[0], Result[1]);
4801 SplitInteger(HiTmp, Result[2], Result[3]);
4803 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4806 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4807 "the size of the current value type");
4828 uint64_t Part0 = Scale / NVTSize;
4829 if (Scale % NVTSize) {
4830 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4833 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4845 if (Scale == VTSize)
4864 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4865 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4866 EVT BoolNVT = getSetCCResultType(NVT);
4869 if (Scale < NVTSize) {
4872 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4873 DAG.getShiftAmountConstant(Scale, NVT, dl));
4874 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4875 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4876 }
else if (Scale == NVTSize) {
4878 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4879 }
else if (Scale < VTSize) {
4883 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4884 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4887 "(and saturation can't happen with Scale==VTSize).");
4889 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4890 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4894 if (Scale < NVTSize) {
4899 unsigned OverflowBits = VTSize - Scale + 1;
4900 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4901 "Extent of overflow bits must start within HL");
4902 SDValue HLHiMask = DAG.getConstant(
4904 SDValue HLLoMask = DAG.getConstant(
4911 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4917 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4918 }
else if (Scale == NVTSize) {
4924 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4930 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4931 }
else if (Scale < VTSize) {
4934 unsigned OverflowBits = VTSize - Scale + 1;
4935 SDValue HHHiMask = DAG.getConstant(
4937 SDValue HHLoMask = DAG.getConstant(
4939 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4940 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4947 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4948 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4951 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4952 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4959 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4961 N->getConstantOperandVal(2), DAG);
4965 N->getConstantOperandVal(2), TLI, DAG);
4966 SplitInteger(Res,
Lo,
Hi);
4969void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4972 "Node has unexpected Opcode");
4982 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4983 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4987 SDValue LHSL, LHSH, RHSL, RHSH;
4988 GetExpandedInteger(
LHS, LHSL, LHSH);
4989 GetExpandedInteger(
RHS, RHSL, RHSH);
4990 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4993 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5002 SplitInteger(Sum,
Lo,
Hi);
5027 EVT VT =
LHS.getValueType();
5030 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5034 EVT OType =
Node->getValueType(1);
5035 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5039 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5042void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5044 EVT VT =
N->getValueType(0);
5046 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5055 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5057 TargetLowering::MakeLibCallOptions CallOptions;
5059 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5062void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5065 SDValue Shiftee =
N->getOperand(0);
5072 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5073 }
while (!TLI.isTypeLegal(LoadVT));
5078 "Shifting unit is not a a power of two!");
5080 const bool IsOneStepShift =
5081 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5086 if (!IsOneStepShift)
5087 ShAmt = DAG.getFreeze(ShAmt);
5090 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5091 unsigned VTByteWidth = VTBitWidth / 8;
5093 "Shiftee type size is not a power of two!");
5094 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5095 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5100 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5102 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5103 EVT PtrTy =
StackPtr.getValueType();
5104 SDValue Ch = DAG.getEntryNode();
5107 DAG.getMachineFunction(),
5113 unsigned WideningOpc =
5115 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5118 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5122 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5128 Flags.setExact(IsOneStepShift);
5131 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5133 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5134 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5137 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5142 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5149 if (DAG.getDataLayout().isBigEndian())
5150 WillIndexUpwards = !WillIndexUpwards;
5153 if (WillIndexUpwards) {
5156 AdjStackPtr = DAG.getMemBasePlusOffset(
5157 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5158 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5162 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5163 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5167 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5172 if (!IsOneStepShift) {
5174 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5175 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5176 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5180 SplitInteger(Res,
Lo,
Hi);
5183void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5185 EVT VT =
N->getValueType(0);
5186 unsigned Opc =
N->getOpcode();
5192 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5196 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5213 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5215 const bool LegalOrCustom =
5219 unsigned ExpansionFactor = 1;
5221 for (EVT TmpVT = NVT;;) {
5222 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5223 if (NewTMPVT == TmpVT)
5230 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5233 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5235 if (LegalOrCustom &&
5239 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5245 SDValue ShiftOp =
N->getOperand(1);
5246 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5248 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5251 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5252 Hi =
Lo.getValue(1);
5257 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5271 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5274 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5276 TargetLowering::MakeLibCallOptions CallOptions;
5279 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5284 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5288void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5290 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5293 if (
Op.getValueType().bitsLE(NVT)) {
5299 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5303 assert(getTypeAction(
Op.getValueType()) ==
5305 "Only know how to promote this result!");
5308 "Operand over promoted?");
5310 SplitInteger(Res,
Lo,
Hi);
5318void DAGTypeLegalizer::
5321 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5324 if (EVT.
bitsLE(
Lo.getValueType())) {
5332 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5333 Hi.getValueType(), dl));
5344void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5346 EVT VT =
N->getValueType(0);
5348 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5357 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5359 TargetLowering::MakeLibCallOptions CallOptions;
5361 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5364void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5366 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5376void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5378 EVT VT =
N->getValueType(0);
5397 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5398 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5399 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5401 EVT BitVT =
N->getValueType(1);
5402 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5404 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5406 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5407 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5426 SplitInteger(Three,
Lo,
Hi);
5430 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5435 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5440 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5444 if (LCImpl == RTLIB::Unsupported ||
5446 DAG.getMachineFunction().getName()) {
5449 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5450 N->getOperand(1), MulLo, MulHi);
5455 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5456 SplitInteger(MulLo,
Lo,
Hi);
5457 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5461 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5464 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5465 MachinePointerInfo());
5469 EVT ArgVT =
Op.getValueType();
5471 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5472 Entry.IsSExt =
true;
5473 Entry.IsZExt =
false;
5474 Args.push_back(Entry);
5478 TargetLowering::ArgListEntry
Entry(
5480 Entry.IsSExt =
true;
5481 Entry.IsZExt =
false;
5482 Args.push_back(Entry);
5484 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5486 TargetLowering::CallLoweringInfo CLI(DAG);
5489 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5490 Func, std::move(Args))
5493 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5495 SplitInteger(CallInfo.first,
Lo,
Hi);
5497 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5498 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5499 DAG.getConstant(0, dl, PtrVT),
5502 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5505void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5507 EVT VT =
N->getValueType(0);
5509 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5519 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5521 if (isTypeLegal(NVT)) {
5523 GetExpandedInteger(
N->getOperand(0), InL, InH);
5525 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5534 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5536 TargetLowering::MakeLibCallOptions CallOptions;
5537 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5540void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5542 EVT VT =
N->getValueType(0);
5544 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5554 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5556 if (isTypeLegal(NVT)) {
5558 GetExpandedInteger(
N->getOperand(0), InL, InH);
5560 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5569 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5571 TargetLowering::MakeLibCallOptions CallOptions;
5572 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5575void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5577 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5580 if (
Op.getValueType().bitsLE(NVT)) {
5583 Hi = DAG.getConstant(0, dl, NVT);
5587 assert(getTypeAction(
Op.getValueType()) ==
5589 "Only know how to promote this result!");
5592 "Operand over promoted?");
5594 SplitInteger(Res,
Lo,
Hi);
5596 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5602void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5606 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5608 SDValue Swap = DAG.getAtomicCmpSwap(
5617void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5621 SDValue Res = TLI.expandVecReduce(
N, DAG);
5622 SplitInteger(Res,
Lo,
Hi);
5625void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5631 N->getOperand(0),
N->getOperand(1));
5632 SplitInteger(Res,
Lo,
Hi);
5639 GetExpandedInteger(
N->getOperand(0), In3, In4);
5640 GetExpandedInteger(
N->getOperand(1), In1, In2);
5644 unsigned Opc =
N->getOpcode();
5647 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5652 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5654 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5658 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5659 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5664 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5665 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5670 SDValue Res = TLI.expandCLMUL(
N, DAG);
5671 return SplitInteger(Res,
Lo,
Hi);
5675 GetExpandedInteger(
N->getOperand(0), LL, LH);
5676 GetExpandedInteger(
N->getOperand(1), RL, RH);
5690 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5694 SDValue Res = TLI.expandPEXT(
N, DAG);
5695 SplitInteger(Res,
Lo,
Hi);
5699 SDValue Res = TLI.expandPDEP(
N, DAG);
5700 SplitInteger(Res,
Lo,
Hi);
5705 EVT VT =
N->getValueType(0);
5712 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5715 SplitInteger(Res,
Lo,
Hi);
5722 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5723 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5725 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5726 Lo = DAG.getPOISON(LoVT);
5727 Hi = DAG.getPOISON(HiVT);
5734 EVT VT =
N->getSimpleValueType(0);
5735 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5737 "VectorIdxTy should be smaller than type to be expanded?");
5741 SplitInteger(Res,
Lo,
Hi);
5752bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5756 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5759 switch (
N->getOpcode()) {
5762 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5763 N->dump(&DAG);
dbgs() <<
"\n";
5768 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5772 Res = ExpandOp_FAKE_USE(
N);
5776 Res = TLI.expandLoopDependenceMask(
N, DAG);
5782 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5795 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5800 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5804 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5807 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5809 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5810 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5811 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5814 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5819 if (!Res.
getNode())
return false;
5827 "Invalid operand expansion");
5829 ReplaceValueWith(
SDValue(
N, 0), Res);
5835void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5839 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5840 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5841 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5854 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5861 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5862 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5892 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5893 RHSLo, LowCC,
false, DagCombineInfo, dl);
5895 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5898 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5899 RHSHi, CCCode,
false, DagCombineInfo, dl);
5903 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5912 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5914 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5923 if (LHSHi == RHSHi) {
5932 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5933 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5936 if (HasSETCCCARRY) {
5939 bool FlipOperands =
false;
5956 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5960 DAG.getCondCode(CCCode));
5966 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5967 false, DagCombineInfo, dl);
5970 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5971 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5978 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5983 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5988 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5989 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5990 N->getOperand(4)), 0);
5996 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6001 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6006 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6007 N->getOperand(2),
N->getOperand(3),
6008 DAG.getCondCode(CCCode)), 0);
6014 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6019 "Unexpected setcc expansion!");
6025 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6033 SDLoc dl = SDLoc(
N);
6035 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6036 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6037 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6050 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6060 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6061 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6065 return TLI.expandCMP(
N, DAG);
6073 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6074 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6078 bool IsStrict =
N->isStrictFPOpcode();
6082 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6083 EVT DstVT =
N->getValueType(0);
6086 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6087 "Don't know how to expand this XINT_TO_FP!");
6088 TargetLowering::MakeLibCallOptions CallOptions;
6090 std::pair<SDValue, SDValue> Tmp =
6091 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6096 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6097 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6102 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6105 return ExpandOp_NormalStore(
N, OpNo);
6108 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6110 EVT VT =
N->getOperand(1).getValueType();
6111 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6115 AAMDNodes AAInfo =
N->getAAInfo();
6121 if (
N->getMemoryVT().bitsLE(NVT)) {
6122 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6123 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6124 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6128 if (DAG.getDataLayout().isLittleEndian()) {
6130 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6132 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6135 unsigned ExcessBits =
6142 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6143 N->getPointerInfo().getWithOffset(IncrementSize),
6144 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6150 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6152 EVT ExtVT =
N->getMemoryVT();
6155 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6163 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6167 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6171 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6172 N->getBaseAlign(), MMOFlags, AAInfo);
6177 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6178 N->getPointerInfo().getWithOffset(IncrementSize),
6180 N->getBaseAlign(), MMOFlags, AAInfo);
6186 GetExpandedInteger(
N->getOperand(0), InL, InH);
6195 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6200SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6201 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6202 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6206 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6208 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6211SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6214 "cannot use llvm.write_register with illegal type", Fn,
6217 return N->getOperand(0);
6220SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6223 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6224 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6227 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6230SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6232 unsigned Factor =
N->getNumOperands();
6235 for (
unsigned i = 0; i != Factor; i++)
6236 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6241 for (
unsigned i = 0; i != Factor; i++)
6247SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6249 EVT OutVT =
N->getValueType(0);
6250 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6251 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6255 SDValue BaseIdx =
N->getOperand(1);
6272 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6276 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6282 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6291 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6295 "Promoted operand has an element type greater than result");
6308 InOp0 = GetPromotedInteger(InOp0);
6315 Ops.reserve(OutNumElems);
6316 for (
unsigned i = 0; i != OutNumElems; ++i) {
6321 N->getOperand(0), Index);
6322 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6327 return DAG.getBuildVector(NOutVT, dl,
Ops);
6330SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6331 EVT OutVT =
N->getValueType(0);
6332 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6333 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6345 Vec = GetPromotedInteger(Vec);
6351SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6354 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6360SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6362 EVT VT =
N->getValueType(0);
6367 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6368 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6371 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6375 EVT OutVT =
N->getValueType(0);
6376 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6377 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6378 unsigned NumElems =
N->getNumOperands();
6385 Ops.reserve(NumElems);
6386 for (
unsigned i = 0; i != NumElems; ++i) {
6388 EVT OpVT =
Op.getValueType();
6393 if (OpVT.
bitsLT(NOutVTElem)) {
6399 ExtOpc = NOutExtOpc;
6400 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6405 return DAG.getBuildVector(NOutVT, dl,
Ops);
6412 assert(!
N->getOperand(0).getValueType().isVector() &&
6413 "Input must be a scalar");
6415 EVT OutVT =
N->getValueType(0);
6416 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6417 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6421 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6426 EVT OutVT =
N->getValueType(0);
6427 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6429 "Type must be promoted to a scalable vector type");
6430 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6431 return DAG.getStepVector(dl, NOutVT,
6435SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6438 EVT OutVT =
N->getValueType(0);
6439 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6440 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6442 unsigned NumOperands =
N->getNumOperands();
6447 SDUse *MaxSizedValue = std::max_element(
6449 EVT AVT = A.getValueType().getVectorElementType();
6450 EVT BVT = B.getValueType().getVectorElementType();
6451 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6457 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6459 EVT OpVT =
Op.getValueType();
6461 Op = GetPromotedInteger(
Op);
6464 "Unhandled legalization type");
6468 Op = DAG.getAnyExtOrTrunc(
6476 return DAG.getAnyExtOrTrunc(
6484 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6485 assert(NumElem * NumOperands == NumOutElem &&
6486 "Unexpected number of elements");
6490 for (
unsigned i = 0; i < NumOperands; ++i) {
6493 Op = GetPromotedInteger(
Op);
6494 EVT SclrTy =
Op.getValueType().getVectorElementType();
6495 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6496 "Unexpected number of elements");
6498 for (
unsigned j = 0;
j < NumElem; ++
j) {
6500 DAG.getVectorIdxConstant(j, dl));
6501 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6505 return DAG.getBuildVector(NOutVT, dl,
Ops);
6508SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6509 EVT VT =
N->getValueType(0);
6510 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6511 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6519 if (getTypeAction(
N->getOperand(0).getValueType())
6523 switch(
N->getOpcode()) {
6525 Promoted = SExtPromotedInteger(
N->getOperand(0));
6528 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6531 Promoted = GetPromotedInteger(
N->getOperand(0));
6543 DAG.getVectorIdxConstant(0, dl));
6545 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6549 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6552SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6553 EVT VT =
N->getValueType(0);
6554 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6558SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6559 EVT VT =
N->getValueType(0);
6560 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6564SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6566 EVT VT =
N->getValueType(0);
6567 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6568 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6569 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6573SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6574 EVT OutVT =
N->getValueType(0);
6575 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6576 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6581 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6584 NOutVTElem,
N->getOperand(1));
6586 V0, ConvElem,
N->getOperand(2));
6593 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6594 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6602 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6603 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6604 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6608 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6611 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6612 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6620 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6625SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6628 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6630 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6631 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6632 return DAG.getPOISON(NVT);
6635SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6637 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6638 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6639 TLI.getVectorIdxTy(DAG.getDataLayout()));
6646 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6649SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6654 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6657 V1.getValueType().getVectorElementType(),
6659 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6661 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6670 EVT InVT1 =
V1.getValueType();
6673 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6674 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6677SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6679 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6687SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6690 EVT ResVT =
N->getValueType(0);
6691 unsigned NumElems =
N->getNumOperands();
6694 SDValue ResVec = DAG.getUNDEF(ResVT);
6698 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6700 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6712 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6713 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6717 for (
unsigned i=0; i<NumElem; ++i) {
6720 DAG.getVectorIdxConstant(i, dl));
6726 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6729SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6742 for (
unsigned I = 0;
I < OpNo;
I++)
6745 EVT Ty =
Op.getValueType();
6746 SDLoc
DL = SDLoc(
N);
6749 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6757 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6762 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6768SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6781 for (
unsigned I = 0;
I < OpNo;
I++)
6784 EVT Ty =
Op.getValueType();
6785 SDLoc
DL = SDLoc(
N);
6788 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6796 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6801 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool isSigned(unsigned Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V, bool LookThroughCmp=false)
Returns the "element type" of the given value/instruction V.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
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.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getValueType() const
Convenience function for get().getValueType().
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
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
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 ...
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 getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
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...
LLVMContext * getContext() const
ArrayRef< int > getMask() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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].
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
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...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ LOOP_DEPENDENCE_RAW_MASK
@ COND_LOOP
COND_LOOP is a conditional branch to self, used for implementing efficient conditional traps.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ 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...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ 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 ...
@ 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.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ 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...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ 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).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ 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.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ 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) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ 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.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ 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.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
The llvm.loop.dependence.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLRINT(EVT RetVT)
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getLLRINT(EVT RetVT)
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
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...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
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 isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
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.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
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.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
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
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 StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)