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 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1641 unsigned Opcode =
N->getOpcode();
1652 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1655 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1657 Amt = ZExtPromotedInteger(Amt);
1663 DAG.getConstant(OldBits,
DL, AmtVT));
1664 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1666 SDValue Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1678 SDValue Res = TLI.expandROT(
N,
true , DAG);
1679 ReplaceValueWith(
SDValue(
N, 0), Res);
1684 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1685 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1688 Amt = ZExtPromotedInteger(Amt);
1692 EVT OldVT =
N->getOperand(0).getValueType();
1693 EVT VT =
Lo.getValueType();
1694 unsigned Opcode =
N->getOpcode();
1701 DAG.getConstant(OldBits,
DL, AmtVT));
1709 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1710 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1712 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1722 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1728 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1730 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1734SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1735 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1736 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1741 Amt = ZExtPromotedInteger(Amt);
1745 EVT OldVT =
N->getOperand(0).getValueType();
1746 EVT VT =
Lo.getValueType();
1747 unsigned Opcode =
N->getOpcode();
1748 bool IsFSHR = Opcode == ISD::VP_FSHR;
1753 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1754 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1762 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1763 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1764 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1765 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1767 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1770 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1775 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1776 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1781 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1783 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1787 unsigned Opcode =
N->getOpcode();
1790 EVT OldVT =
N->getOperand(0).getValueType();
1791 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1796 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1798 TLI.isOperationLegalOrCustom(
1799 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1800 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1803 SDValue X = GetPromotedInteger(
N->getOperand(0));
1804 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1808 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1809 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1813 if (NewBits < 2 * OldBits) {
1815 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1817 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1819 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1821 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1826 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1828 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1833 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1834 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1835 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1840 SDValue X = GetPromotedInteger(
N->getOperand(0));
1841 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1847 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1848 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1849 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1854 SDValue X = GetPromotedInteger(
N->getOperand(0));
1855 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1860 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1872 Res = GetPromotedInteger(InOp);
1879 "Dst and Src must have the same number of elements");
1881 "Promoted vector type must be a power of two");
1884 GetSplitVector(InOp, EOp1, EOp2);
1892 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1893 "Expected VP_TRUNCATE opcode");
1894 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1895 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1896 std::tie(EVLLo, EVLHi) =
1897 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1898 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1899 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1906 SDValue WideInOp = GetWidenedVector(InOp);
1911 N->getValueType(0).getScalarType(), NumElem);
1920 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1926 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1927 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1932SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1934 return PromoteIntRes_Overflow(
N);
1938 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1939 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1940 EVT OVT =
N->getOperand(0).getValueType();
1941 EVT NVT =
LHS.getValueType();
1950 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1952 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1955 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1966 return PromoteIntRes_Overflow(
N);
1978 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1979 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1981 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1984 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1995 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1996 return PromoteIntRes_Overflow(
N);
2000 EVT OVT =
N->getValueType(0);
2001 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
2007 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
2009 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
2010 if (
SDValue Res = TLI.expandABS(
N, DAG))
2014 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
2018SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
2021 return PromoteIntRes_Overflow(
N);
2025 EVT SmallVT =
LHS.getValueType();
2032 LHS = SExtPromotedInteger(
LHS);
2033 RHS = SExtPromotedInteger(
RHS);
2035 LHS = ZExtPromotedInteger(
LHS);
2036 RHS = ZExtPromotedInteger(
RHS);
2038 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
2050 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
2051 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
2052 DAG.getConstant(0,
DL,
Hi.getValueType()),
2057 Mul, DAG.getValueType(SmallVT));
2067 ReplaceValueWith(
SDValue(
N, 1), Overflow);
2072 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
2073 N->getValueType(0)));
2077 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2079 const APInt &MulImm =
N->getConstantOperandAPInt(0);
2086 EVT VT =
N->getValueType(0);
2089 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
2090 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
2094 for (
unsigned i = 0; i < NumRegs; ++i) {
2095 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2096 N->getConstantOperandVal(3));
2101 if (DAG.getDataLayout().isBigEndian())
2102 std::reverse(Parts.begin(), Parts.end());
2105 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2107 for (
unsigned i = 1; i < NumRegs; ++i) {
2112 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2118 ReplaceValueWith(
SDValue(
N, 1), Chain);
2131bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2134 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2139 switch (
N->getOpcode()) {
2142 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2143 N->dump(&DAG);
dbgs() <<
"\n";
2149 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2155 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2156 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2161 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2165 Res = PromoteIntOp_FAKE_USE(
N);
2168 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2172 Res = PromoteIntOp_ScalarOp(
N);
2175 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2178 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2180 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2181 case ISD::VP_SINT_TO_FP:
2198 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2200 case ISD::VP_TRUNCATE:
2204 case ISD::VP_UINT_TO_FP:
2207 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2212 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2223 Res = PromoteIntOp_Shift(
N);
2227 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2230 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2256 case ISD::VP_REDUCE_ADD:
2257 case ISD::VP_REDUCE_MUL:
2258 case ISD::VP_REDUCE_AND:
2259 case ISD::VP_REDUCE_OR:
2260 case ISD::VP_REDUCE_XOR:
2261 case ISD::VP_REDUCE_SMAX:
2262 case ISD::VP_REDUCE_SMIN:
2263 case ISD::VP_REDUCE_UMAX:
2264 case ISD::VP_REDUCE_UMIN:
2265 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2270 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2273 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2276 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2278 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2279 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2280 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2282 case ISD::EXPERIMENTAL_VP_SPLICE:
2283 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2286 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2291 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2294 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2300 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2305 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2309 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2314 if (!Res.
getNode())
return false;
2321 const bool IsStrictFp =
N->isStrictFPOpcode();
2323 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2324 "Invalid operand expansion");
2328 ReplaceValueWith(
SDValue(
N, 0), Res);
2342 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2346 unsigned OpLEffectiveBits =
2347 DAG.computeKnownBits(OpL).countMaxActiveBits();
2348 unsigned OpREffectiveBits =
2349 DAG.computeKnownBits(OpR).countMaxActiveBits();
2350 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2351 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2358 LHS = SExtPromotedInteger(
LHS);
2359 RHS = SExtPromotedInteger(
RHS);
2368 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2369 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2370 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2371 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2378 LHS = ZExtPromotedInteger(
LHS);
2379 RHS = ZExtPromotedInteger(
RHS);
2393 LHS = SExtPromotedInteger(
LHS);
2394 RHS = SExtPromotedInteger(
RHS);
2399 "Unknown integer comparison!");
2401 SExtOrZExtPromotedOperands(
LHS,
RHS);
2405 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2409SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2410 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2411 EVT ResVT =
N->getValueType(0);
2412 EVT OpVT =
Op.getValueType();
2415 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2420 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2421 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2422 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2426 EVT OutVT =
N->getValueType(0);
2429 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2432 switch (getTypeAction(InVT)) {
2436 DAG.getDataLayout().isLittleEndian()) {
2446 if (isTypeLegal(WideVecVT)) {
2447 SDValue Promoted = GetPromotedInteger(InOp);
2450 DAG.getVectorIdxConstant(0, dl));
2463 return CreateStackStoreLoad(InOp, OutVT);
2466SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2467 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2475 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2476 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2480SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2481 assert(OpNo == 1 &&
"only know how to promote condition");
2484 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2487 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2488 N->getOperand(2)), 0);
2491SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2492 assert(OpNo == 1 &&
"only know how to promote condition");
2495 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2498 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2503 EVT OVT =
N->getOperand(0).getValueType();
2504 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2505 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2506 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2511 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2512 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2521 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2522 "Legal vector of one illegal element?");
2527 assert(
N->getOperand(0).getValueSizeInBits() >=
2528 N->getValueType(0).getScalarSizeInBits() &&
2529 "Type of inserted value narrower than vector element type!");
2532 for (
unsigned i = 0; i < NumElts; ++i)
2533 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2535 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2538SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2545 assert(
N->getOperand(1).getValueSizeInBits() >=
2546 N->getValueType(0).getScalarSizeInBits() &&
2547 "Type of inserted value narrower than vector element type!");
2548 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2549 GetPromotedInteger(
N->getOperand(1)),
2554 assert(OpNo == 2 &&
"Different operand and result vector types?");
2557 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2558 TLI.getVectorIdxTy(DAG.getDataLayout()));
2559 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2560 N->getOperand(1), Idx), 0);
2564 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2568 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2571SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2572 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2574 EVT OpTy =
N->getOperand(1).getValueType();
2577 if (
SDValue Res = WidenVSELECTMask(
N))
2578 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2579 Res,
N->getOperand(1),
N->getOperand(2));
2583 Cond = PromoteTargetBoolean(
Cond, OpVT);
2585 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2586 N->getOperand(2)), 0);
2589SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2590 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2598 N->getOperand(3),
N->getOperand(4)), 0);
2601SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2602 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2610 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2612 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2615 N->getOperand(3),
N->getOperand(4)),
2620 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2621 ZExtPromotedInteger(
N->getOperand(1))), 0);
2629 LHS = SExtPromotedInteger(
LHS);
2630 RHS = SExtPromotedInteger(
RHS);
2632 SExtOrZExtPromotedOperands(
LHS,
RHS);
2639 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2640 ZExtPromotedInteger(
N->getOperand(2))), 0);
2644 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2648 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2651SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2653 EVT VT =
N->getValueType(0);
2654 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2656 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2660 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2662 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2664 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2669 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2670 return SDValue(DAG.UpdateNodeOperands(
N,
2671 SExtPromotedInteger(
N->getOperand(0)),
2672 N->getOperand(1),
N->getOperand(2)),
2674 return SDValue(DAG.UpdateNodeOperands(
N,
2675 SExtPromotedInteger(
N->getOperand(0))), 0);
2678SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2679 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2680 SExtPromotedInteger(
N->getOperand(1))), 0);
2685 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2688 SDValue Val = GetPromotedInteger(
N->getValue());
2691 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2692 N->getMemoryVT(),
N->getMemOperand());
2698 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2699 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2701 SDValue DataOp = GetPromotedInteger(
N->getValue());
2702 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2703 N->getMask(),
N->getVectorLength(),
2704 N->getMemoryVT(),
N->getMemOperand(),
2705 N->isCompressingStore());
2716 Mask = PromoteTargetBoolean(Mask, DataVT);
2719 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2722 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2723 DataOp = GetPromotedInteger(DataOp);
2725 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2726 N->getOffset(), Mask,
N->getMemoryVT(),
2727 N->getMemOperand(),
N->getAddressingMode(),
2728 true,
N->isCompressingStore());
2733 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2734 EVT DataVT =
N->getValueType(0);
2735 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2737 NewOps[OpNo] =
Mask;
2738 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2754 EVT DataVT =
N->getValueType(0);
2755 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2756 }
else if (OpNo == 4) {
2758 if (
N->isIndexSigned())
2760 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2762 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2764 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2766 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2778 bool TruncateStore =
N->isTruncatingStore();
2783 EVT DataVT =
N->getValue().getValueType();
2784 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2785 }
else if (OpNo == 4) {
2787 if (
N->isIndexSigned())
2789 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2791 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2793 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2794 TruncateStore =
true;
2797 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2798 SDLoc(
N), NewOps,
N->getMemOperand(),
2799 N->getIndexType(), TruncateStore);
2804 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2808 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2813 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2814 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2815 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2816 N->getOperand(1),
N->getOperand(2));
2821 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2822 return SDValue(DAG.UpdateNodeOperands(
N,
2823 ZExtPromotedInteger(
N->getOperand(0)),
2824 N->getOperand(1),
N->getOperand(2)),
2826 return SDValue(DAG.UpdateNodeOperands(
N,
2827 ZExtPromotedInteger(
N->getOperand(0))), 0);
2830SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2831 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2836SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2837 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2838 ZExtPromotedInteger(
N->getOperand(1))), 0);
2845 EVT VT =
N->getValueType(0);
2850 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2851 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2852 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2853 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2858 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2861SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2863 EVT VT =
N->getValueType(0);
2864 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2866 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2868 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2869 N->getOperand(0).getValueType());
2873 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2875 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2878SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2880 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2881 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2890 unsigned OpOffset = IsStrict ? 1 : 0;
2897 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2898 if (LCImpl == RTLIB::Unsupported) {
2904 if (IsPowI &&
N->getValueType(0).isVector())
2905 return DAG.UnrollVectorOp(
N);
2907 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2908 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2920 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2921 DAG.getLibInfo().getIntSize()) {
2922 const Function &Fn = DAG.getMachineFunction().getFunction();
2923 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2924 Twine(IsPowI ?
"powi" :
"ldexp") +
2925 " exponent does not match sizeof(int)",
2926 Fn, N->getDebugLoc()));
2928 ReplaceValueWith(SDValue(N, 1), Chain);
2929 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2933 TargetLowering::MakeLibCallOptions CallOptions;
2934 CallOptions.setIsSigned(
true);
2935 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2936 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2937 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2938 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2940 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2945 switch (
N->getOpcode()) {
2953 case ISD::VP_REDUCE_ADD:
2954 case ISD::VP_REDUCE_MUL:
2955 case ISD::VP_REDUCE_AND:
2956 case ISD::VP_REDUCE_OR:
2957 case ISD::VP_REDUCE_XOR:
2961 case ISD::VP_REDUCE_SMAX:
2962 case ISD::VP_REDUCE_SMIN:
2966 case ISD::VP_REDUCE_UMAX:
2967 case ISD::VP_REDUCE_UMIN:
2977 return GetPromotedInteger(V);
2979 return SExtPromotedInteger(V);
2981 return ZExtPromotedInteger(V);
2987 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2989 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2990 EVT InVT =
Op.getValueType();
2992 EVT ResVT =
N->getValueType(0);
2993 unsigned Opcode =
N->getOpcode();
3010 switch (TLI.getBooleanContents(InVT)) {
3013 Op = ZExtPromotedInteger(
N->getOperand(0));
3016 Op = SExtPromotedInteger(
N->getOperand(0));
3029 switch (TLI.getBooleanContents(InVT)) {
3032 Op = ZExtPromotedInteger(
N->getOperand(0));
3035 Op = SExtPromotedInteger(
N->getOperand(0));
3041 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
3045 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
3049SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
3056 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
3057 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3060 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3062 Op = PromoteIntOpVectorReduction(
N,
Op);
3066 EVT VT =
N->getValueType(0);
3067 EVT EltVT =
Op.getValueType().getScalarType();
3070 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
3082 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
3083 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
3086SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
3089 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3090 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3093SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3096 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3097 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3102 const Function &Fn = DAG.getMachineFunction().getFunction();
3104 "cannot use llvm.write_register with illegal type", Fn,
3106 return N->getOperand(0);
3109SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3110 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3111 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3114 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3115 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3125SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3129 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3130 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3133 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3135 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3136 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3139SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3141 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3143 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3144 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3147SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3149 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3153 if (TLI.getBooleanContents(
Op.getValueType()) ==
3155 NewOp = SExtPromotedInteger(
Op);
3157 NewOp = ZExtPromotedInteger(
Op);
3159 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3162SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3164 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3165 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3166 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3169SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3172 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3173 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3176SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3178 switch (
N->getOpcode()) {
3180 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3181 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3184 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3185 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3188 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3189 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3194 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3197SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3199 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3200 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3201 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3203 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3214void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3220 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3223 switch (
N->getOpcode()) {
3226 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3227 N->dump(&DAG);
dbgs() <<
"\n";
3256 ExpandIntRes_ABS(
N,
Lo,
Hi);
3308 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3309 SplitInteger(Tmp.first,
Lo,
Hi);
3310 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3315 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3316 SDValue Tmp = DAG.getAtomicCmpSwap(
3318 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3327 SplitInteger(Tmp,
Lo,
Hi);
3406 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3411 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3417 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3421 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3425 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3429 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3433 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3438 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3448std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3449 unsigned Opc =
Node->getOpcode();
3455 EVT RetVT =
Node->getValueType(0);
3456 TargetLowering::MakeLibCallOptions CallOptions;
3459 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3460 if (LCImpl != RTLIB::Unsupported) {
3462 Ops.push_back(
Node->getOperand(1));
3465 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3466 "Unexpected atomic op or value type!");
3468 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3470 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3471 Node->getOperand(0));
3476void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3481 GetExpandedInteger(
N->getOperand(0), InL, InH);
3496 if (Amt.
uge(VTBits)) {
3497 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3498 }
else if (Amt.
ugt(NVTBits)) {
3499 Lo = DAG.getConstant(0,
DL, NVT);
3501 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3502 }
else if (Amt == NVTBits) {
3503 Lo = DAG.getConstant(0,
DL, NVT);
3507 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3509 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3511 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3516 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3518 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3525 if (Amt.
uge(VTBits)) {
3526 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3527 }
else if (Amt.
ugt(NVTBits)) {
3529 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3530 Hi = DAG.getConstant(0,
DL, NVT);
3531 }
else if (Amt == NVTBits) {
3533 Hi = DAG.getConstant(0,
DL, NVT);
3536 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3538 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3543 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3545 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3548 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3554 if (Amt.
uge(VTBits)) {
3556 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3557 }
else if (Amt.
ugt(NVTBits)) {
3559 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3561 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3562 }
else if (Amt == NVTBits) {
3565 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3568 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3570 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3575 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3577 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3580 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3588bool DAGTypeLegalizer::
3590 unsigned Opc =
N->getOpcode();
3593 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3598 "Expanded integer type size not a power of two!");
3602 KnownBits
Known = DAG.computeKnownBits(Amt);
3605 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3610 GetExpandedInteger(In, InL, InH);
3614 if (
Known.One.intersects(HighBitMask)) {
3617 DAG.getConstant(~HighBitMask, dl, ShTy));
3622 Lo = DAG.getConstant(0, dl, NVT);
3623 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3626 Hi = DAG.getConstant(0, dl, NVT);
3627 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3631 DAG.getConstant(NVTBits - 1, dl, ShTy));
3632 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3644 DAG.getConstant(NVTBits - 1, dl, ShTy));
3660 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3662 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3664 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3665 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3677bool DAGTypeLegalizer::
3680 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3684 "Expanded integer type size not a power of two!");
3689 GetExpandedInteger(
N->getOperand(0), InL, InH);
3691 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3694 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3697 Amt, DAG.getConstant(0, dl, ShTy),
3701 switch (
N->getOpcode()) {
3707 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3708 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3711 LoL = DAG.getConstant(0, dl, NVT);
3714 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3715 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3716 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3722 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3725 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3728 HiL = DAG.getConstant(0, dl, NVT);
3731 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3732 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3733 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3739 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3740 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3744 DAG.getConstant(NVTBits - 1, dl, ShTy));
3747 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3748 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3749 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3774 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3779 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3780 SplitInteger(Res,
Lo,
Hi);
3783void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3792 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3793 unsigned NumHalfBits = NumBits / 2;
3794 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3795 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3796 SDValue LHSL, LHSH, RHSL, RHSH;
3797 GetExpandedInteger(
LHS, LHSL, LHSH);
3798 GetExpandedInteger(
RHS, RHSL, RHSH);
3801 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3803 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3811 SDValue LHSL, LHSH, RHSL, RHSH;
3812 GetExpandedInteger(
LHS, LHSL, LHSH);
3813 GetExpandedInteger(
RHS, RHSL, RHSH);
3815 EVT CCT = getSetCCResultType(NVT);
3818 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3820 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3822 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3824 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3828 const APInt *RHSVal =
nullptr;
3830 RHSVal = &RHSConst->getAPIntValue();
3837 SDValue LHSL, LHSH, RHSL, RHSH;
3838 GetExpandedInteger(
LHS, LHSL, LHSH);
3839 GetExpandedInteger(
RHS, RHSL, RHSH);
3841 EVT CCT = getSetCCResultType(NVT);
3847 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3850 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3854 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3857 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3859 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3866 switch (
N->getOpcode()) {
3893 EVT VT =
N->getValueType(0);
3894 EVT CCT = getSetCCResultType(VT);
3897 SplitInteger(Result,
Lo,
Hi);
3901 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3902 SplitInteger(ExpandedCMP,
Lo,
Hi);
3905void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3909 SDValue LHSL, LHSH, RHSL, RHSH;
3910 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3911 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3914 SDValue LoOps[2] = { LHSL, RHSL };
3915 SDValue HiOps[3] = { LHSH, RHSH };
3917 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3919 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3921 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3925 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3931 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3944 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3946 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3949 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3963 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3965 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3969 EVT OvfVT = getSetCCResultType(NVT);
3970 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3985 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3988 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3992 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
4004 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4008 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4011 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4014 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
4019 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4021 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4022 DAG.getConstant(0, dl, NVT));
4025 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
4034 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
4039 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4041 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4042 DAG.getConstant(0, dl, NVT));
4048void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
4051 SDValue LHSL, LHSH, RHSL, RHSH;
4053 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4054 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4055 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4056 SDValue LoOps[2] = { LHSL, RHSL };
4057 SDValue HiOps[3] = { LHSH, RHSH };
4071 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4074void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4077 SDValue LHSL, LHSH, RHSL, RHSH;
4079 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4080 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4081 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4083 SDValue HiOps[3] = { LHSH, RHSH };
4085 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4087 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4091 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4094void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4102 unsigned CarryOp, NoCarryOp;
4104 switch(
N->getOpcode()) {
4119 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4120 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4124 SDValue LHSL, LHSH, RHSL, RHSH;
4125 GetExpandedInteger(
LHS, LHSL, LHSH);
4126 GetExpandedInteger(
RHS, RHSL, RHSH);
4127 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4128 SDValue LoOps[2] = { LHSL, RHSL };
4129 SDValue HiOps[3] = { LHSH, RHSH };
4131 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4133 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4140 SplitInteger(Sum,
Lo,
Hi);
4146 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4147 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4151 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4156 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4162 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4168 SDValue LHSL, LHSH, RHSL, RHSH;
4170 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4171 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4172 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4176 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4178 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4182 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4185void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4188 SDValue LHSL, LHSH, RHSL, RHSH;
4190 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4191 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4192 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4197 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4198 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4202 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4205void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4207 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4210 if (
Op.getValueType().bitsLE(NVT)) {
4213 Hi = DAG.getUNDEF(NVT);
4217 assert(getTypeAction(
Op.getValueType()) ==
4219 "Only know how to promote this result!");
4222 "Operand over promoted?");
4224 SplitInteger(Res,
Lo,
Hi);
4228void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4231 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4232 EVT NVT =
Lo.getValueType();
4237 if (NVTBits < EVTBits) {
4240 EVTBits - NVTBits)));
4245 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4249void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4252 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4253 EVT NVT =
Lo.getValueType();
4258 if (NVTBits < EVTBits) {
4261 EVTBits - NVTBits)));
4265 Hi = DAG.getConstant(0, dl, NVT);
4269void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4272 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4277void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4280 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4289 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4290 EVT NVT =
Lo.getValueType();
4293 Hi = DAG.getConstant(0, dl, NVT);
4296void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4298 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4301 const APInt &Cst =
Constant->getAPIntValue();
4302 bool IsTarget =
Constant->isTargetOpcode();
4303 bool IsOpaque =
Constant->isOpaque();
4305 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4306 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4314 GetExpandedInteger(N0,
Lo,
Hi);
4315 EVT NVT =
Lo.getValueType();
4320 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4325 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4326 Hi = DAG.getConstant(0, dl, NVT);
4336 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4341 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4342 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4351 EVT VT =
N->getValueType(0);
4353 DAG.getConstant(0, dl, VT), N0);
4355 SplitInteger(Neg, NegLo, NegHi);
4357 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4359 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4360 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4363void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4367 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4368 EVT NVT =
Lo.getValueType();
4370 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4373 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4376 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4377 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4380 Hi = DAG.getConstant(0, dl, NVT);
4388 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4389 EVT NVT =
Lo.getValueType();
4392 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4393 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4396 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4399 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4401 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4403 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4404 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4406 Hi = DAG.getConstant(0, dl, NVT);
4411 SplitInteger(Result,
Lo,
Hi);
4416 EVT VT =
N->getValueType(0);
4421 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4422 "LibCall explicitly requested, but not available");
4424 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4425 TargetLowering::MakeLibCallOptions CallOptions;
4429 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4430 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4438 GetExpandedInteger(
Op,
Lo,
Hi);
4439 EVT NVT =
Lo.getValueType();
4442 Hi = DAG.getConstant(0,
DL, NVT);
4445void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4449 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4450 EVT NVT =
Lo.getValueType();
4452 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4458 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4459 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4462 Hi = DAG.getConstant(0, dl, NVT);
4468 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4475 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4479 ReplaceValueWith(
SDValue(
N, 1), Chain);
4487 Chain =
Op.getValue(1);
4496 EVT VT =
N->getValueType(0);
4500 bool IsStrict =
N->isStrictFPOpcode();
4502 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4506 Op.getValueType() == MVT::bf16) {
4512 EVT OpVT =
Op.getValueType();
4516 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4517 TargetLowering::MakeLibCallOptions CallOptions;
4522 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4523 CallOptions, dl, Chain);
4524 SplitInteger(Tmp.first,
Lo,
Hi);
4527 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4532 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4533 SplitInteger(Res,
Lo,
Hi);
4539 bool IsStrict =
N->isStrictFPOpcode();
4540 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4543 EVT VT =
Op.getValueType();
4545 if (VT == MVT::f16) {
4551 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4555 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4559 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4563 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4567 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4571 EVT RetVT =
N->getValueType(0);
4573 TargetLowering::MakeLibCallOptions CallOptions;
4575 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4576 Op, CallOptions, dl,
4578 SplitInteger(Tmp.first,
Lo,
Hi);
4580 if (
N->isStrictFPOpcode())
4581 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4584void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4586 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4589 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4595 EVT VT =
N->getValueType(0);
4596 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4601 AAMDNodes AAInfo =
N->getAAInfo();
4606 if (
N->getMemoryVT().bitsLE(NVT)) {
4607 EVT MemVT =
N->getMemoryVT();
4609 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4610 N->getBaseAlign(), MMOFlags, AAInfo);
4618 unsigned LoSize =
Lo.getValueSizeInBits();
4620 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4623 Hi = DAG.getConstant(0, dl, NVT);
4627 Hi = DAG.getUNDEF(NVT);
4629 }
else if (DAG.getDataLayout().isLittleEndian()) {
4631 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4634 unsigned ExcessBits =
4641 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4642 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4643 N->getBaseAlign(), MMOFlags, AAInfo);
4652 EVT MemVT =
N->getMemoryVT();
4655 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4658 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4661 N->getBaseAlign(), MMOFlags, AAInfo);
4667 N->getPointerInfo().getWithOffset(IncrementSize),
4669 N->getBaseAlign(), MMOFlags, AAInfo);
4681 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4685 DAG.getShiftAmountConstant(
4692 ReplaceValueWith(
SDValue(
N, 1), Ch);
4695void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4699 GetExpandedInteger(
N->getOperand(0), LL, LH);
4700 GetExpandedInteger(
N->getOperand(1), RL, RH);
4704 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4706 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4707 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4710void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4712 EVT VT =
N->getValueType(0);
4713 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4717 GetExpandedInteger(
N->getOperand(0), LL, LH);
4718 GetExpandedInteger(
N->getOperand(1), RL, RH);
4720 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4727 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4728 if (LCImpl == RTLIB::Unsupported) {
4731 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4737 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4738 TargetLowering::MakeLibCallOptions CallOptions;
4740 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4747 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4748 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4749 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4752 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4757 SplitInteger(Result,
Lo,
Hi);
4763 SplitInteger(Result,
Lo,
Hi);
4769 SplitInteger(Result,
Lo,
Hi);
4780 EVT VT =
N->getValueType(0);
4784 uint64_t Scale =
N->getConstantOperandVal(2);
4796 EVT BoolVT = getSetCCResultType(VT);
4798 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4804 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4805 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4811 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4812 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4817 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4818 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4821 SplitInteger(Result,
Lo,
Hi);
4827 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4829 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4831 GetExpandedInteger(
LHS, LL, LH);
4832 GetExpandedInteger(
RHS, RL, RH);
4836 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4843 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4844 SplitInteger(LoTmp, Result[0], Result[1]);
4845 SplitInteger(HiTmp, Result[2], Result[3]);
4847 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4850 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4851 "the size of the current value type");
4872 uint64_t Part0 = Scale / NVTSize;
4873 if (Scale % NVTSize) {
4874 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4877 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4889 if (Scale == VTSize)
4908 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4909 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4910 EVT BoolNVT = getSetCCResultType(NVT);
4913 if (Scale < NVTSize) {
4916 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4917 DAG.getShiftAmountConstant(Scale, NVT, dl));
4918 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4919 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4920 }
else if (Scale == NVTSize) {
4922 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4923 }
else if (Scale < VTSize) {
4927 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4928 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4931 "(and saturation can't happen with Scale==VTSize).");
4933 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4934 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4938 if (Scale < NVTSize) {
4943 unsigned OverflowBits = VTSize - Scale + 1;
4944 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4945 "Extent of overflow bits must start within HL");
4946 SDValue HLHiMask = DAG.getConstant(
4948 SDValue HLLoMask = DAG.getConstant(
4955 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4961 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4962 }
else if (Scale == NVTSize) {
4968 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4974 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4975 }
else if (Scale < VTSize) {
4978 unsigned OverflowBits = VTSize - Scale + 1;
4979 SDValue HHHiMask = DAG.getConstant(
4981 SDValue HHLoMask = DAG.getConstant(
4983 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4984 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4991 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4992 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4995 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4996 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
5003 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
5005 N->getConstantOperandVal(2), DAG);
5009 N->getConstantOperandVal(2), TLI, DAG);
5010 SplitInteger(Res,
Lo,
Hi);
5013void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
5016 "Node has unexpected Opcode");
5026 bool HasCarryOp = TLI.isOperationLegalOrCustom(
5027 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
5031 SDValue LHSL, LHSH, RHSL, RHSH;
5032 GetExpandedInteger(
LHS, LHSL, LHSH);
5033 GetExpandedInteger(
RHS, RHSL, RHSH);
5034 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
5037 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5046 SplitInteger(Sum,
Lo,
Hi);
5071 EVT VT =
LHS.getValueType();
5074 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5078 EVT OType =
Node->getValueType(1);
5079 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5083 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5086void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5088 EVT VT =
N->getValueType(0);
5090 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5099 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5101 TargetLowering::MakeLibCallOptions CallOptions;
5103 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5106void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5109 SDValue Shiftee =
N->getOperand(0);
5116 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5117 }
while (!TLI.isTypeLegal(LoadVT));
5122 "Shifting unit is not a a power of two!");
5124 const bool IsOneStepShift =
5125 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5130 if (!IsOneStepShift)
5131 ShAmt = DAG.getFreeze(ShAmt);
5134 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5135 unsigned VTByteWidth = VTBitWidth / 8;
5137 "Shiftee type size is not a power of two!");
5138 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5139 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5144 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5146 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5147 EVT PtrTy =
StackPtr.getValueType();
5148 SDValue Ch = DAG.getEntryNode();
5151 DAG.getMachineFunction(),
5157 unsigned WideningOpc =
5159 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5162 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5166 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5172 Flags.setExact(IsOneStepShift);
5175 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5177 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5178 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5181 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5186 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5193 if (DAG.getDataLayout().isBigEndian())
5194 WillIndexUpwards = !WillIndexUpwards;
5197 if (WillIndexUpwards) {
5200 AdjStackPtr = DAG.getMemBasePlusOffset(
5201 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5202 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5206 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5207 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5211 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5216 if (!IsOneStepShift) {
5218 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5219 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5220 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5224 SplitInteger(Res,
Lo,
Hi);
5227void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5229 EVT VT =
N->getValueType(0);
5230 unsigned Opc =
N->getOpcode();
5236 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5240 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5257 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5259 const bool LegalOrCustom =
5263 unsigned ExpansionFactor = 1;
5265 for (EVT TmpVT = NVT;;) {
5266 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5267 if (NewTMPVT == TmpVT)
5274 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5277 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5279 if (LegalOrCustom &&
5283 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5289 SDValue ShiftOp =
N->getOperand(1);
5290 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5292 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5295 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5296 Hi =
Lo.getValue(1);
5301 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5315 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5318 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5320 TargetLowering::MakeLibCallOptions CallOptions;
5323 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5328 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5332void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5334 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5337 if (
Op.getValueType().bitsLE(NVT)) {
5343 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5347 assert(getTypeAction(
Op.getValueType()) ==
5349 "Only know how to promote this result!");
5352 "Operand over promoted?");
5354 SplitInteger(Res,
Lo,
Hi);
5362void DAGTypeLegalizer::
5365 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5368 if (EVT.
bitsLE(
Lo.getValueType())) {
5376 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5377 Hi.getValueType(), dl));
5388void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5390 EVT VT =
N->getValueType(0);
5392 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5401 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5403 TargetLowering::MakeLibCallOptions CallOptions;
5405 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5408void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5420void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5422 EVT VT =
N->getValueType(0);
5441 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5442 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5443 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5445 EVT BitVT =
N->getValueType(1);
5446 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5448 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5450 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5451 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5470 SplitInteger(Three,
Lo,
Hi);
5474 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5479 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5484 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5488 if (LCImpl == RTLIB::Unsupported ||
5490 DAG.getMachineFunction().getName()) {
5493 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5494 N->getOperand(1), MulLo, MulHi);
5499 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5500 SplitInteger(MulLo,
Lo,
Hi);
5501 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5505 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5508 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5509 MachinePointerInfo());
5513 EVT ArgVT =
Op.getValueType();
5515 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5516 Entry.IsSExt =
true;
5517 Entry.IsZExt =
false;
5518 Args.push_back(Entry);
5522 TargetLowering::ArgListEntry
Entry(
5524 Entry.IsSExt =
true;
5525 Entry.IsZExt =
false;
5526 Args.push_back(Entry);
5528 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5530 TargetLowering::CallLoweringInfo CLI(DAG);
5533 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5534 Func, std::move(Args))
5537 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5539 SplitInteger(CallInfo.first,
Lo,
Hi);
5541 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5542 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5543 DAG.getConstant(0, dl, PtrVT),
5546 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5549void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5551 EVT VT =
N->getValueType(0);
5553 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5563 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5565 if (isTypeLegal(NVT)) {
5567 GetExpandedInteger(
N->getOperand(0), InL, InH);
5569 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5578 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5580 TargetLowering::MakeLibCallOptions CallOptions;
5581 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5584void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5586 EVT VT =
N->getValueType(0);
5588 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5598 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5600 if (isTypeLegal(NVT)) {
5602 GetExpandedInteger(
N->getOperand(0), InL, InH);
5604 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5613 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5615 TargetLowering::MakeLibCallOptions CallOptions;
5616 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5619void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5621 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5624 if (
Op.getValueType().bitsLE(NVT)) {
5627 Hi = DAG.getConstant(0, dl, NVT);
5631 assert(getTypeAction(
Op.getValueType()) ==
5633 "Only know how to promote this result!");
5636 "Operand over promoted?");
5638 SplitInteger(Res,
Lo,
Hi);
5640 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5646void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5650 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5652 SDValue Swap = DAG.getAtomicCmpSwap(
5661void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5665 SDValue Res = TLI.expandVecReduce(
N, DAG);
5666 SplitInteger(Res,
Lo,
Hi);
5669void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5675 N->getOperand(0),
N->getOperand(1));
5676 SplitInteger(Res,
Lo,
Hi);
5683 GetExpandedInteger(
N->getOperand(0), In3, In4);
5684 GetExpandedInteger(
N->getOperand(1), In1, In2);
5688 unsigned Opc =
N->getOpcode();
5691 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5696 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5698 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5702 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5703 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5708 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5709 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5714 SDValue Res = TLI.expandCLMUL(
N, DAG);
5715 return SplitInteger(Res,
Lo,
Hi);
5719 GetExpandedInteger(
N->getOperand(0), LL, LH);
5720 GetExpandedInteger(
N->getOperand(1), RL, RH);
5734 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5738 SDValue Res = TLI.expandPEXT(
N, DAG);
5739 SplitInteger(Res,
Lo,
Hi);
5743 SDValue Res = TLI.expandPDEP(
N, DAG);
5744 SplitInteger(Res,
Lo,
Hi);
5749 EVT VT =
N->getValueType(0);
5756 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5759 SplitInteger(Res,
Lo,
Hi);
5766 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5767 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5769 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5770 Lo = DAG.getPOISON(LoVT);
5771 Hi = DAG.getPOISON(HiVT);
5778 EVT VT =
N->getSimpleValueType(0);
5779 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5781 "VectorIdxTy should be smaller than type to be expanded?");
5785 SplitInteger(Res,
Lo,
Hi);
5796bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5800 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5803 switch (
N->getOpcode()) {
5806 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5807 N->dump(&DAG);
dbgs() <<
"\n";
5812 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5816 Res = ExpandOp_FAKE_USE(
N);
5820 Res = TLI.expandLoopDependenceMask(
N, DAG);
5826 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5839 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5844 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5848 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5851 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5853 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5854 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5855 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5858 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5863 if (!Res.
getNode())
return false;
5871 "Invalid operand expansion");
5873 ReplaceValueWith(
SDValue(
N, 0), Res);
5879void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5883 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5884 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5885 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5898 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5905 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5906 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5936 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5937 RHSLo, LowCC,
false, DagCombineInfo, dl);
5939 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5942 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5943 RHSHi, CCCode,
false, DagCombineInfo, dl);
5947 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5956 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5958 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5967 if (LHSHi == RHSHi) {
5976 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5977 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5980 if (HasSETCCCARRY) {
5983 bool FlipOperands =
false;
6000 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
6004 DAG.getCondCode(CCCode));
6010 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
6011 false, DagCombineInfo, dl);
6014 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
6015 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
6022 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6027 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6032 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
6033 DAG.getCondCode(CCCode), NewLHS, NewRHS,
6034 N->getOperand(4)), 0);
6040 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6045 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6050 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6051 N->getOperand(2),
N->getOperand(3),
6052 DAG.getCondCode(CCCode)), 0);
6058 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6063 "Unexpected setcc expansion!");
6069 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6077 SDLoc dl = SDLoc(
N);
6079 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6080 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6081 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6094 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6104 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6105 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6109 return TLI.expandCMP(
N, DAG);
6117 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6118 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6122 bool IsStrict =
N->isStrictFPOpcode();
6126 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6127 EVT DstVT =
N->getValueType(0);
6130 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6131 "Don't know how to expand this XINT_TO_FP!");
6132 TargetLowering::MakeLibCallOptions CallOptions;
6134 std::pair<SDValue, SDValue> Tmp =
6135 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6140 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6141 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6146 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6149 return ExpandOp_NormalStore(
N, OpNo);
6152 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6154 EVT VT =
N->getOperand(1).getValueType();
6155 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6159 AAMDNodes AAInfo =
N->getAAInfo();
6165 if (
N->getMemoryVT().bitsLE(NVT)) {
6166 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6167 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6168 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6172 if (DAG.getDataLayout().isLittleEndian()) {
6174 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6176 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6179 unsigned ExcessBits =
6186 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6187 N->getPointerInfo().getWithOffset(IncrementSize),
6188 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6194 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6196 EVT ExtVT =
N->getMemoryVT();
6199 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6207 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6211 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6215 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6216 N->getBaseAlign(), MMOFlags, AAInfo);
6221 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6222 N->getPointerInfo().getWithOffset(IncrementSize),
6224 N->getBaseAlign(), MMOFlags, AAInfo);
6230 GetExpandedInteger(
N->getOperand(0), InL, InH);
6239 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6244SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6245 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6246 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6250 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6252 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6255SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6258 "cannot use llvm.write_register with illegal type", Fn,
6261 return N->getOperand(0);
6264SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6267 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6268 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6271 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6274SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6276 unsigned Factor =
N->getNumOperands();
6279 for (
unsigned i = 0; i != Factor; i++)
6280 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6285 for (
unsigned i = 0; i != Factor; i++)
6291SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6293 EVT OutVT =
N->getValueType(0);
6294 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6295 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6299 SDValue BaseIdx =
N->getOperand(1);
6316 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6320 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6326 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6335 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6339 "Promoted operand has an element type greater than result");
6352 InOp0 = GetPromotedInteger(InOp0);
6359 Ops.reserve(OutNumElems);
6360 for (
unsigned i = 0; i != OutNumElems; ++i) {
6365 N->getOperand(0), Index);
6366 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6371 return DAG.getBuildVector(NOutVT, dl,
Ops);
6374SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
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");
6389 Vec = GetPromotedInteger(Vec);
6395SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6398 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6404SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6406 EVT VT =
N->getValueType(0);
6411 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6412 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6415 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6419 EVT OutVT =
N->getValueType(0);
6420 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6421 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6422 unsigned NumElems =
N->getNumOperands();
6429 Ops.reserve(NumElems);
6430 for (
unsigned i = 0; i != NumElems; ++i) {
6432 EVT OpVT =
Op.getValueType();
6437 if (OpVT.
bitsLT(NOutVTElem)) {
6443 ExtOpc = NOutExtOpc;
6444 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6449 return DAG.getBuildVector(NOutVT, dl,
Ops);
6456 assert(!
N->getOperand(0).getValueType().isVector() &&
6457 "Input must be a scalar");
6459 EVT OutVT =
N->getValueType(0);
6460 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6461 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6465 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6470 EVT OutVT =
N->getValueType(0);
6471 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6473 "Type must be promoted to a scalable vector type");
6474 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6475 return DAG.getStepVector(dl, NOutVT,
6479SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6482 EVT OutVT =
N->getValueType(0);
6483 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6484 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6486 unsigned NumOperands =
N->getNumOperands();
6491 SDUse *MaxSizedValue = std::max_element(
6493 EVT AVT = A.getValueType().getVectorElementType();
6494 EVT BVT = B.getValueType().getVectorElementType();
6495 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6501 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6503 EVT OpVT =
Op.getValueType();
6505 Op = GetPromotedInteger(
Op);
6508 "Unhandled legalization type");
6512 Op = DAG.getAnyExtOrTrunc(
6520 return DAG.getAnyExtOrTrunc(
6528 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6529 assert(NumElem * NumOperands == NumOutElem &&
6530 "Unexpected number of elements");
6534 for (
unsigned i = 0; i < NumOperands; ++i) {
6537 Op = GetPromotedInteger(
Op);
6538 EVT SclrTy =
Op.getValueType().getVectorElementType();
6539 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6540 "Unexpected number of elements");
6542 for (
unsigned j = 0;
j < NumElem; ++
j) {
6544 DAG.getVectorIdxConstant(j, dl));
6545 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6549 return DAG.getBuildVector(NOutVT, dl,
Ops);
6552SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6553 EVT VT =
N->getValueType(0);
6554 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6555 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6563 if (getTypeAction(
N->getOperand(0).getValueType())
6567 switch(
N->getOpcode()) {
6569 Promoted = SExtPromotedInteger(
N->getOperand(0));
6572 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6575 Promoted = GetPromotedInteger(
N->getOperand(0));
6587 DAG.getVectorIdxConstant(0, dl));
6589 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6593 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6596SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6597 EVT VT =
N->getValueType(0);
6598 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6602SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6603 EVT VT =
N->getValueType(0);
6604 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6608SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6610 EVT VT =
N->getValueType(0);
6611 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6612 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6613 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6617SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6618 EVT OutVT =
N->getValueType(0);
6619 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6620 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6625 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6628 NOutVTElem,
N->getOperand(1));
6630 V0, ConvElem,
N->getOperand(2));
6637 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6638 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6646 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6647 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6648 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6652 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6655 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6656 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6664 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6669SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6672 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6674 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6675 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6676 return DAG.getPOISON(NVT);
6679SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6681 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6682 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6683 TLI.getVectorIdxTy(DAG.getDataLayout()));
6690 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6693SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6698 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6701 V1.getValueType().getVectorElementType(),
6703 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6705 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6714 EVT InVT1 =
V1.getValueType();
6717 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6718 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6721SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6723 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6731SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6734 EVT ResVT =
N->getValueType(0);
6735 unsigned NumElems =
N->getNumOperands();
6738 SDValue ResVec = DAG.getUNDEF(ResVT);
6742 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6744 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6756 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6757 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6761 for (
unsigned i=0; i<NumElem; ++i) {
6764 DAG.getVectorIdxConstant(i, dl));
6770 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6773SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6786 for (
unsigned I = 0;
I < OpNo;
I++)
6789 EVT Ty =
Op.getValueType();
6790 SDLoc
DL = SDLoc(
N);
6793 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6801 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6806 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6812SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6825 for (
unsigned I = 0;
I < OpNo;
I++)
6828 EVT Ty =
Op.getValueType();
6829 SDLoc
DL = SDLoc(
N);
6832 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6840 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6845 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.
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.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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)