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);
1794 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1795 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1798 SDValue X = GetPromotedInteger(
N->getOperand(0));
1799 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1803 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1804 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1808 if (NewBits < 2 * OldBits) {
1810 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1812 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1814 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1816 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1821 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1823 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1828 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1829 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1830 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1835 SDValue X = GetPromotedInteger(
N->getOperand(0));
1836 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1842 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1843 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1844 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1849 SDValue X = GetPromotedInteger(
N->getOperand(0));
1850 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1855 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1867 Res = GetPromotedInteger(InOp);
1874 "Dst and Src must have the same number of elements");
1876 "Promoted vector type must be a power of two");
1879 GetSplitVector(InOp, EOp1, EOp2);
1887 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1888 "Expected VP_TRUNCATE opcode");
1889 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1890 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1891 std::tie(EVLLo, EVLHi) =
1892 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1893 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1894 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1901 SDValue WideInOp = GetWidenedVector(InOp);
1906 N->getValueType(0).getScalarType(), NumElem);
1915 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1921 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1922 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1927SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1929 return PromoteIntRes_Overflow(
N);
1933 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1934 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1935 EVT OVT =
N->getOperand(0).getValueType();
1936 EVT NVT =
LHS.getValueType();
1945 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1947 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1950 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1961 return PromoteIntRes_Overflow(
N);
1973 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1974 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1976 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1979 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1990 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1991 return PromoteIntRes_Overflow(
N);
1995 EVT OVT =
N->getValueType(0);
1996 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
2002 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
2004 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
2005 if (
SDValue Res = TLI.expandABS(
N, DAG))
2009 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
2013SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
2016 return PromoteIntRes_Overflow(
N);
2020 EVT SmallVT =
LHS.getValueType();
2027 LHS = SExtPromotedInteger(
LHS);
2028 RHS = SExtPromotedInteger(
RHS);
2030 LHS = ZExtPromotedInteger(
LHS);
2031 RHS = ZExtPromotedInteger(
RHS);
2033 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
2045 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
2046 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
2047 DAG.getConstant(0,
DL,
Hi.getValueType()),
2052 Mul, DAG.getValueType(SmallVT));
2062 ReplaceValueWith(
SDValue(
N, 1), Overflow);
2067 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
2068 N->getValueType(0)));
2072 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2074 const APInt &MulImm =
N->getConstantOperandAPInt(0);
2081 EVT VT =
N->getValueType(0);
2084 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
2085 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
2089 for (
unsigned i = 0; i < NumRegs; ++i) {
2090 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2091 N->getConstantOperandVal(3));
2096 if (DAG.getDataLayout().isBigEndian())
2097 std::reverse(Parts.begin(), Parts.end());
2100 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2102 for (
unsigned i = 1; i < NumRegs; ++i) {
2107 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2113 ReplaceValueWith(
SDValue(
N, 1), Chain);
2126bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2129 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2134 switch (
N->getOpcode()) {
2137 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2138 N->dump(&DAG);
dbgs() <<
"\n";
2144 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2150 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2151 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2156 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2160 Res = PromoteIntOp_FAKE_USE(
N);
2163 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2167 Res = PromoteIntOp_ScalarOp(
N);
2170 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2173 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2175 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2176 case ISD::VP_SINT_TO_FP:
2193 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2195 case ISD::VP_TRUNCATE:
2199 case ISD::VP_UINT_TO_FP:
2202 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2207 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2218 Res = PromoteIntOp_Shift(
N);
2222 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2225 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2251 case ISD::VP_REDUCE_ADD:
2252 case ISD::VP_REDUCE_MUL:
2253 case ISD::VP_REDUCE_AND:
2254 case ISD::VP_REDUCE_OR:
2255 case ISD::VP_REDUCE_XOR:
2256 case ISD::VP_REDUCE_SMAX:
2257 case ISD::VP_REDUCE_SMIN:
2258 case ISD::VP_REDUCE_UMAX:
2259 case ISD::VP_REDUCE_UMIN:
2260 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2265 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2268 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2271 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2273 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2274 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2275 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2277 case ISD::EXPERIMENTAL_VP_SPLICE:
2278 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2281 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2286 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2289 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2295 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2300 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2304 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2309 if (!Res.
getNode())
return false;
2316 const bool IsStrictFp =
N->isStrictFPOpcode();
2318 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2319 "Invalid operand expansion");
2323 ReplaceValueWith(
SDValue(
N, 0), Res);
2337 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2341 unsigned OpLEffectiveBits =
2342 DAG.computeKnownBits(OpL).countMaxActiveBits();
2343 unsigned OpREffectiveBits =
2344 DAG.computeKnownBits(OpR).countMaxActiveBits();
2345 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2346 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2353 LHS = SExtPromotedInteger(
LHS);
2354 RHS = SExtPromotedInteger(
RHS);
2363 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2364 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2365 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2366 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2373 LHS = ZExtPromotedInteger(
LHS);
2374 RHS = ZExtPromotedInteger(
RHS);
2388 LHS = SExtPromotedInteger(
LHS);
2389 RHS = SExtPromotedInteger(
RHS);
2394 "Unknown integer comparison!");
2396 SExtOrZExtPromotedOperands(
LHS,
RHS);
2400 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2404SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2405 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2406 EVT ResVT =
N->getValueType(0);
2407 EVT OpVT =
Op.getValueType();
2410 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2415 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2416 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2417 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2421 EVT OutVT =
N->getValueType(0);
2424 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2427 switch (getTypeAction(InVT)) {
2431 DAG.getDataLayout().isLittleEndian()) {
2441 if (isTypeLegal(WideVecVT)) {
2442 SDValue Promoted = GetPromotedInteger(InOp);
2445 DAG.getVectorIdxConstant(0, dl));
2458 return CreateStackStoreLoad(InOp, OutVT);
2461SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2462 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2470 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2471 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2475SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2476 assert(OpNo == 1 &&
"only know how to promote condition");
2479 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2482 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2483 N->getOperand(2)), 0);
2486SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2487 assert(OpNo == 1 &&
"only know how to promote condition");
2490 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2493 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2498 EVT OVT =
N->getOperand(0).getValueType();
2499 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2500 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2501 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2506 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2507 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2516 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2517 "Legal vector of one illegal element?");
2522 assert(
N->getOperand(0).getValueSizeInBits() >=
2523 N->getValueType(0).getScalarSizeInBits() &&
2524 "Type of inserted value narrower than vector element type!");
2527 for (
unsigned i = 0; i < NumElts; ++i)
2528 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2530 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2533SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2540 assert(
N->getOperand(1).getValueSizeInBits() >=
2541 N->getValueType(0).getScalarSizeInBits() &&
2542 "Type of inserted value narrower than vector element type!");
2543 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2544 GetPromotedInteger(
N->getOperand(1)),
2549 assert(OpNo == 2 &&
"Different operand and result vector types?");
2552 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2553 TLI.getVectorIdxTy(DAG.getDataLayout()));
2554 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2555 N->getOperand(1), Idx), 0);
2559 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2563 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2566SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2567 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2569 EVT OpTy =
N->getOperand(1).getValueType();
2572 if (
SDValue Res = WidenVSELECTMask(
N))
2573 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2574 Res,
N->getOperand(1),
N->getOperand(2));
2578 Cond = PromoteTargetBoolean(
Cond, OpVT);
2580 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2581 N->getOperand(2)), 0);
2584SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2585 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2593 N->getOperand(3),
N->getOperand(4)), 0);
2596SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2597 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2605 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2607 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2610 N->getOperand(3),
N->getOperand(4)),
2615 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2616 ZExtPromotedInteger(
N->getOperand(1))), 0);
2624 LHS = SExtPromotedInteger(
LHS);
2625 RHS = SExtPromotedInteger(
RHS);
2627 SExtOrZExtPromotedOperands(
LHS,
RHS);
2634 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2635 ZExtPromotedInteger(
N->getOperand(2))), 0);
2639 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2643 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2646SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2648 EVT VT =
N->getValueType(0);
2649 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2651 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2655 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2657 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2659 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2664 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2665 return SDValue(DAG.UpdateNodeOperands(
N,
2666 SExtPromotedInteger(
N->getOperand(0)),
2667 N->getOperand(1),
N->getOperand(2)),
2669 return SDValue(DAG.UpdateNodeOperands(
N,
2670 SExtPromotedInteger(
N->getOperand(0))), 0);
2673SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2674 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2675 SExtPromotedInteger(
N->getOperand(1))), 0);
2680 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2683 SDValue Val = GetPromotedInteger(
N->getValue());
2686 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2687 N->getMemoryVT(),
N->getMemOperand());
2693 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2694 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2696 SDValue DataOp = GetPromotedInteger(
N->getValue());
2697 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2698 N->getMask(),
N->getVectorLength(),
2699 N->getMemoryVT(),
N->getMemOperand(),
2700 N->isCompressingStore());
2711 Mask = PromoteTargetBoolean(Mask, DataVT);
2714 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2717 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2718 DataOp = GetPromotedInteger(DataOp);
2720 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2721 N->getOffset(), Mask,
N->getMemoryVT(),
2722 N->getMemOperand(),
N->getAddressingMode(),
2723 true,
N->isCompressingStore());
2728 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2729 EVT DataVT =
N->getValueType(0);
2730 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2732 NewOps[OpNo] =
Mask;
2733 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2749 EVT DataVT =
N->getValueType(0);
2750 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2751 }
else if (OpNo == 4) {
2753 if (
N->isIndexSigned())
2755 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2757 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2759 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2761 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2773 bool TruncateStore =
N->isTruncatingStore();
2778 EVT DataVT =
N->getValue().getValueType();
2779 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2780 }
else if (OpNo == 4) {
2782 if (
N->isIndexSigned())
2784 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2786 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2788 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2789 TruncateStore =
true;
2792 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2793 SDLoc(
N), NewOps,
N->getMemOperand(),
2794 N->getIndexType(), TruncateStore);
2799 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2803 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2808 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2809 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2810 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2811 N->getOperand(1),
N->getOperand(2));
2816 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2817 return SDValue(DAG.UpdateNodeOperands(
N,
2818 ZExtPromotedInteger(
N->getOperand(0)),
2819 N->getOperand(1),
N->getOperand(2)),
2821 return SDValue(DAG.UpdateNodeOperands(
N,
2822 ZExtPromotedInteger(
N->getOperand(0))), 0);
2825SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2826 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2831SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2832 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2833 ZExtPromotedInteger(
N->getOperand(1))), 0);
2840 EVT VT =
N->getValueType(0);
2845 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2846 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2847 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2848 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2853 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2856SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2858 EVT VT =
N->getValueType(0);
2859 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2861 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2863 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2864 N->getOperand(0).getValueType());
2868 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2870 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2873SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2875 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2876 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2885 unsigned OpOffset = IsStrict ? 1 : 0;
2892 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2893 if (LCImpl == RTLIB::Unsupported) {
2899 if (IsPowI &&
N->getValueType(0).isVector())
2900 return DAG.UnrollVectorOp(
N);
2902 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2903 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2915 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2916 DAG.getLibInfo().getIntSize()) {
2917 const Function &Fn = DAG.getMachineFunction().getFunction();
2918 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2919 Twine(IsPowI ?
"powi" :
"ldexp") +
2920 " exponent does not match sizeof(int)",
2921 Fn, N->getDebugLoc()));
2923 ReplaceValueWith(SDValue(N, 1), Chain);
2924 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2928 TargetLowering::MakeLibCallOptions CallOptions;
2929 CallOptions.setIsSigned(
true);
2930 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2931 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2932 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2933 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2935 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2940 switch (
N->getOpcode()) {
2948 case ISD::VP_REDUCE_ADD:
2949 case ISD::VP_REDUCE_MUL:
2950 case ISD::VP_REDUCE_AND:
2951 case ISD::VP_REDUCE_OR:
2952 case ISD::VP_REDUCE_XOR:
2956 case ISD::VP_REDUCE_SMAX:
2957 case ISD::VP_REDUCE_SMIN:
2961 case ISD::VP_REDUCE_UMAX:
2962 case ISD::VP_REDUCE_UMIN:
2972 return GetPromotedInteger(V);
2974 return SExtPromotedInteger(V);
2976 return ZExtPromotedInteger(V);
2982 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2984 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2985 EVT InVT =
Op.getValueType();
2987 EVT ResVT =
N->getValueType(0);
2988 unsigned Opcode =
N->getOpcode();
3005 switch (TLI.getBooleanContents(InVT)) {
3008 Op = ZExtPromotedInteger(
N->getOperand(0));
3011 Op = SExtPromotedInteger(
N->getOperand(0));
3024 switch (TLI.getBooleanContents(InVT)) {
3027 Op = ZExtPromotedInteger(
N->getOperand(0));
3030 Op = SExtPromotedInteger(
N->getOperand(0));
3036 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
3040 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
3044SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
3051 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
3052 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3055 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3057 Op = PromoteIntOpVectorReduction(
N,
Op);
3061 EVT VT =
N->getValueType(0);
3062 EVT EltVT =
Op.getValueType().getScalarType();
3065 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
3077 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
3078 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
3081SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
3084 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3085 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3088SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3091 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3092 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3097 const Function &Fn = DAG.getMachineFunction().getFunction();
3099 "cannot use llvm.write_register with illegal type", Fn,
3101 return N->getOperand(0);
3104SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3105 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3106 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3109 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3110 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3120SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3124 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3125 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3128 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3130 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3131 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3134SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3136 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3138 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3139 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3142SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3144 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3148 if (TLI.getBooleanContents(
Op.getValueType()) ==
3150 NewOp = SExtPromotedInteger(
Op);
3152 NewOp = ZExtPromotedInteger(
Op);
3154 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3157SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3159 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3160 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3161 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3164SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3167 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3168 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3171SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3173 switch (
N->getOpcode()) {
3175 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3176 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3179 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3180 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3183 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3184 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3189 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3192SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3194 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3195 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3196 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3198 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3209void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3215 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3218 switch (
N->getOpcode()) {
3221 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3222 N->dump(&DAG);
dbgs() <<
"\n";
3251 ExpandIntRes_ABS(
N,
Lo,
Hi);
3303 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3304 SplitInteger(Tmp.first,
Lo,
Hi);
3305 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3310 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3311 SDValue Tmp = DAG.getAtomicCmpSwap(
3313 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3322 SplitInteger(Tmp,
Lo,
Hi);
3401 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3406 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3412 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3416 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3420 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3424 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3428 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3433 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3443std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3444 unsigned Opc =
Node->getOpcode();
3450 EVT RetVT =
Node->getValueType(0);
3451 TargetLowering::MakeLibCallOptions CallOptions;
3454 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3455 if (LCImpl != RTLIB::Unsupported) {
3457 Ops.push_back(
Node->getOperand(1));
3460 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3461 "Unexpected atomic op or value type!");
3463 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3465 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3466 Node->getOperand(0));
3471void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3476 GetExpandedInteger(
N->getOperand(0), InL, InH);
3491 if (Amt.
uge(VTBits)) {
3492 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3493 }
else if (Amt.
ugt(NVTBits)) {
3494 Lo = DAG.getConstant(0,
DL, NVT);
3496 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3497 }
else if (Amt == NVTBits) {
3498 Lo = DAG.getConstant(0,
DL, NVT);
3502 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3504 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3506 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3511 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3513 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3520 if (Amt.
uge(VTBits)) {
3521 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3522 }
else if (Amt.
ugt(NVTBits)) {
3524 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3525 Hi = DAG.getConstant(0,
DL, NVT);
3526 }
else if (Amt == NVTBits) {
3528 Hi = DAG.getConstant(0,
DL, NVT);
3531 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3533 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3538 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3540 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3543 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3549 if (Amt.
uge(VTBits)) {
3551 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3552 }
else if (Amt.
ugt(NVTBits)) {
3554 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3556 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3557 }
else if (Amt == NVTBits) {
3560 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3563 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3565 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3570 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3572 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3575 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3583bool DAGTypeLegalizer::
3585 unsigned Opc =
N->getOpcode();
3588 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3593 "Expanded integer type size not a power of two!");
3597 KnownBits
Known = DAG.computeKnownBits(Amt);
3600 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3605 GetExpandedInteger(In, InL, InH);
3609 if (
Known.One.intersects(HighBitMask)) {
3612 DAG.getConstant(~HighBitMask, dl, ShTy));
3617 Lo = DAG.getConstant(0, dl, NVT);
3618 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3621 Hi = DAG.getConstant(0, dl, NVT);
3622 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3626 DAG.getConstant(NVTBits - 1, dl, ShTy));
3627 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3639 DAG.getConstant(NVTBits - 1, dl, ShTy));
3655 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3657 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3659 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3660 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3672bool DAGTypeLegalizer::
3675 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3679 "Expanded integer type size not a power of two!");
3684 GetExpandedInteger(
N->getOperand(0), InL, InH);
3686 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3689 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3692 Amt, DAG.getConstant(0, dl, ShTy),
3696 switch (
N->getOpcode()) {
3702 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3703 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3706 LoL = DAG.getConstant(0, dl, NVT);
3709 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3710 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3711 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3717 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3720 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3723 HiL = DAG.getConstant(0, dl, NVT);
3726 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3727 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3728 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3734 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3735 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3739 DAG.getConstant(NVTBits - 1, dl, ShTy));
3742 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3743 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3744 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3769 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3774 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3775 SplitInteger(Res,
Lo,
Hi);
3778void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3787 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3788 unsigned NumHalfBits = NumBits / 2;
3789 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3790 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3791 SDValue LHSL, LHSH, RHSL, RHSH;
3792 GetExpandedInteger(
LHS, LHSL, LHSH);
3793 GetExpandedInteger(
RHS, RHSL, RHSH);
3796 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3798 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3806 SDValue LHSL, LHSH, RHSL, RHSH;
3807 GetExpandedInteger(
LHS, LHSL, LHSH);
3808 GetExpandedInteger(
RHS, RHSL, RHSH);
3810 EVT CCT = getSetCCResultType(NVT);
3813 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3815 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3817 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3819 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3823 const APInt *RHSVal =
nullptr;
3825 RHSVal = &RHSConst->getAPIntValue();
3832 SDValue LHSL, LHSH, RHSL, RHSH;
3833 GetExpandedInteger(
LHS, LHSL, LHSH);
3834 GetExpandedInteger(
RHS, RHSL, RHSH);
3836 EVT CCT = getSetCCResultType(NVT);
3842 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3845 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3849 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3852 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3854 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3861 switch (
N->getOpcode()) {
3888 EVT VT =
N->getValueType(0);
3889 EVT CCT = getSetCCResultType(VT);
3892 SplitInteger(Result,
Lo,
Hi);
3896 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3897 SplitInteger(ExpandedCMP,
Lo,
Hi);
3900void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3904 SDValue LHSL, LHSH, RHSL, RHSH;
3905 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3906 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3909 SDValue LoOps[2] = { LHSL, RHSL };
3910 SDValue HiOps[3] = { LHSH, RHSH };
3912 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3914 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3916 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3920 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3926 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3939 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3941 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3944 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3958 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3960 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3964 EVT OvfVT = getSetCCResultType(NVT);
3965 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3980 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3983 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3987 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3999 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4003 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4006 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4009 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
4014 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4016 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4017 DAG.getConstant(0, dl, NVT));
4020 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
4029 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
4034 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4036 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4037 DAG.getConstant(0, dl, NVT));
4043void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
4046 SDValue LHSL, LHSH, RHSL, RHSH;
4048 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4049 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4050 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4051 SDValue LoOps[2] = { LHSL, RHSL };
4052 SDValue HiOps[3] = { LHSH, RHSH };
4066 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4069void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4072 SDValue LHSL, LHSH, RHSL, RHSH;
4074 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4075 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4076 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4078 SDValue HiOps[3] = { LHSH, RHSH };
4080 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4082 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4086 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4089void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4097 unsigned CarryOp, NoCarryOp;
4099 switch(
N->getOpcode()) {
4114 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4115 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4119 SDValue LHSL, LHSH, RHSL, RHSH;
4120 GetExpandedInteger(
LHS, LHSL, LHSH);
4121 GetExpandedInteger(
RHS, RHSL, RHSH);
4122 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4123 SDValue LoOps[2] = { LHSL, RHSL };
4124 SDValue HiOps[3] = { LHSH, RHSH };
4126 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4128 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4135 SplitInteger(Sum,
Lo,
Hi);
4141 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4142 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4146 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4151 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4157 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4163 SDValue LHSL, LHSH, RHSL, RHSH;
4165 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4166 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4167 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4171 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4173 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4177 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4180void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4183 SDValue LHSL, LHSH, RHSL, RHSH;
4185 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4186 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4187 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4192 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4193 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4197 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4200void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4202 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4205 if (
Op.getValueType().bitsLE(NVT)) {
4208 Hi = DAG.getUNDEF(NVT);
4212 assert(getTypeAction(
Op.getValueType()) ==
4214 "Only know how to promote this result!");
4217 "Operand over promoted?");
4219 SplitInteger(Res,
Lo,
Hi);
4223void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4226 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4227 EVT NVT =
Lo.getValueType();
4232 if (NVTBits < EVTBits) {
4235 EVTBits - NVTBits)));
4240 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4244void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4247 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4248 EVT NVT =
Lo.getValueType();
4253 if (NVTBits < EVTBits) {
4256 EVTBits - NVTBits)));
4260 Hi = DAG.getConstant(0, dl, NVT);
4264void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4267 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4272void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4275 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4284 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4285 EVT NVT =
Lo.getValueType();
4288 Hi = DAG.getConstant(0, dl, NVT);
4291void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4293 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4296 const APInt &Cst =
Constant->getAPIntValue();
4297 bool IsTarget =
Constant->isTargetOpcode();
4298 bool IsOpaque =
Constant->isOpaque();
4300 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4301 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4309 GetExpandedInteger(N0,
Lo,
Hi);
4310 EVT NVT =
Lo.getValueType();
4315 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4320 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4321 Hi = DAG.getConstant(0, dl, NVT);
4331 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4336 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4337 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4346 EVT VT =
N->getValueType(0);
4348 DAG.getConstant(0, dl, VT), N0);
4350 SplitInteger(Neg, NegLo, NegHi);
4352 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4354 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4355 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4358void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4362 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4363 EVT NVT =
Lo.getValueType();
4365 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4368 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4371 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4372 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4375 Hi = DAG.getConstant(0, dl, NVT);
4383 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4384 EVT NVT =
Lo.getValueType();
4387 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4388 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4391 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4394 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4396 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4398 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4399 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4401 Hi = DAG.getConstant(0, dl, NVT);
4406 SplitInteger(Result,
Lo,
Hi);
4411 EVT VT =
N->getValueType(0);
4416 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4417 "LibCall explicitly requested, but not available");
4419 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4420 TargetLowering::MakeLibCallOptions CallOptions;
4424 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4425 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4433 GetExpandedInteger(
Op,
Lo,
Hi);
4434 EVT NVT =
Lo.getValueType();
4437 Hi = DAG.getConstant(0,
DL, NVT);
4440void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4444 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4445 EVT NVT =
Lo.getValueType();
4447 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4453 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4454 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4457 Hi = DAG.getConstant(0, dl, NVT);
4463 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4470 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4474 ReplaceValueWith(
SDValue(
N, 1), Chain);
4482 Chain =
Op.getValue(1);
4491 EVT VT =
N->getValueType(0);
4495 bool IsStrict =
N->isStrictFPOpcode();
4497 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4501 Op.getValueType() == MVT::bf16) {
4507 EVT OpVT =
Op.getValueType();
4511 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4512 TargetLowering::MakeLibCallOptions CallOptions;
4517 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4518 CallOptions, dl, Chain);
4519 SplitInteger(Tmp.first,
Lo,
Hi);
4522 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4527 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4528 SplitInteger(Res,
Lo,
Hi);
4534 bool IsStrict =
N->isStrictFPOpcode();
4535 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4538 EVT VT =
Op.getValueType();
4540 if (VT == MVT::f16) {
4546 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4550 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4554 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4558 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4562 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4566 EVT RetVT =
N->getValueType(0);
4568 TargetLowering::MakeLibCallOptions CallOptions;
4570 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4571 Op, CallOptions, dl,
4573 SplitInteger(Tmp.first,
Lo,
Hi);
4575 if (
N->isStrictFPOpcode())
4576 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4579void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4581 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4584 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4590 EVT VT =
N->getValueType(0);
4591 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4596 AAMDNodes AAInfo =
N->getAAInfo();
4601 if (
N->getMemoryVT().bitsLE(NVT)) {
4602 EVT MemVT =
N->getMemoryVT();
4604 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4605 N->getBaseAlign(), MMOFlags, AAInfo);
4613 unsigned LoSize =
Lo.getValueSizeInBits();
4615 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4618 Hi = DAG.getConstant(0, dl, NVT);
4622 Hi = DAG.getUNDEF(NVT);
4624 }
else if (DAG.getDataLayout().isLittleEndian()) {
4626 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4629 unsigned ExcessBits =
4636 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4637 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4638 N->getBaseAlign(), MMOFlags, AAInfo);
4647 EVT MemVT =
N->getMemoryVT();
4650 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4653 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4656 N->getBaseAlign(), MMOFlags, AAInfo);
4662 N->getPointerInfo().getWithOffset(IncrementSize),
4664 N->getBaseAlign(), MMOFlags, AAInfo);
4676 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4680 DAG.getShiftAmountConstant(
4687 ReplaceValueWith(
SDValue(
N, 1), Ch);
4690void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4694 GetExpandedInteger(
N->getOperand(0), LL, LH);
4695 GetExpandedInteger(
N->getOperand(1), RL, RH);
4699 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4701 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4702 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4705void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4707 EVT VT =
N->getValueType(0);
4708 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4712 GetExpandedInteger(
N->getOperand(0), LL, LH);
4713 GetExpandedInteger(
N->getOperand(1), RL, RH);
4715 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4722 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4723 if (LCImpl == RTLIB::Unsupported) {
4726 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4732 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4733 TargetLowering::MakeLibCallOptions CallOptions;
4735 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4742 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4743 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4744 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4747 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4752 SplitInteger(Result,
Lo,
Hi);
4758 SplitInteger(Result,
Lo,
Hi);
4764 SplitInteger(Result,
Lo,
Hi);
4775 EVT VT =
N->getValueType(0);
4779 uint64_t Scale =
N->getConstantOperandVal(2);
4791 EVT BoolVT = getSetCCResultType(VT);
4793 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4799 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4800 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4806 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4807 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4812 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4813 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4816 SplitInteger(Result,
Lo,
Hi);
4822 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4824 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4826 GetExpandedInteger(
LHS, LL, LH);
4827 GetExpandedInteger(
RHS, RL, RH);
4831 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4838 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4839 SplitInteger(LoTmp, Result[0], Result[1]);
4840 SplitInteger(HiTmp, Result[2], Result[3]);
4842 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4845 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4846 "the size of the current value type");
4867 uint64_t Part0 = Scale / NVTSize;
4868 if (Scale % NVTSize) {
4869 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4872 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4884 if (Scale == VTSize)
4903 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4904 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4905 EVT BoolNVT = getSetCCResultType(NVT);
4908 if (Scale < NVTSize) {
4911 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4912 DAG.getShiftAmountConstant(Scale, NVT, dl));
4913 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4914 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4915 }
else if (Scale == NVTSize) {
4917 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4918 }
else if (Scale < VTSize) {
4922 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4923 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4926 "(and saturation can't happen with Scale==VTSize).");
4928 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4929 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4933 if (Scale < NVTSize) {
4938 unsigned OverflowBits = VTSize - Scale + 1;
4939 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4940 "Extent of overflow bits must start within HL");
4941 SDValue HLHiMask = DAG.getConstant(
4943 SDValue HLLoMask = DAG.getConstant(
4950 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4956 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4957 }
else if (Scale == NVTSize) {
4963 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4969 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4970 }
else if (Scale < VTSize) {
4973 unsigned OverflowBits = VTSize - Scale + 1;
4974 SDValue HHHiMask = DAG.getConstant(
4976 SDValue HHLoMask = DAG.getConstant(
4978 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4979 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4986 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4987 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4990 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4991 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4998 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
5000 N->getConstantOperandVal(2), DAG);
5004 N->getConstantOperandVal(2), TLI, DAG);
5005 SplitInteger(Res,
Lo,
Hi);
5008void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
5011 "Node has unexpected Opcode");
5021 bool HasCarryOp = TLI.isOperationLegalOrCustom(
5022 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
5026 SDValue LHSL, LHSH, RHSL, RHSH;
5027 GetExpandedInteger(
LHS, LHSL, LHSH);
5028 GetExpandedInteger(
RHS, RHSL, RHSH);
5029 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
5032 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5041 SplitInteger(Sum,
Lo,
Hi);
5066 EVT VT =
LHS.getValueType();
5069 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5073 EVT OType =
Node->getValueType(1);
5074 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5078 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5081void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5083 EVT VT =
N->getValueType(0);
5085 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5094 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5096 TargetLowering::MakeLibCallOptions CallOptions;
5098 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5101void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5104 SDValue Shiftee =
N->getOperand(0);
5111 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5112 }
while (!TLI.isTypeLegal(LoadVT));
5117 "Shifting unit is not a a power of two!");
5119 const bool IsOneStepShift =
5120 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5125 if (!IsOneStepShift)
5126 ShAmt = DAG.getFreeze(ShAmt);
5129 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5130 unsigned VTByteWidth = VTBitWidth / 8;
5132 "Shiftee type size is not a power of two!");
5133 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5134 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5139 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5141 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5142 EVT PtrTy =
StackPtr.getValueType();
5143 SDValue Ch = DAG.getEntryNode();
5146 DAG.getMachineFunction(),
5152 unsigned WideningOpc =
5154 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5157 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5161 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5167 Flags.setExact(IsOneStepShift);
5170 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5172 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5173 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5176 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5181 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5188 if (DAG.getDataLayout().isBigEndian())
5189 WillIndexUpwards = !WillIndexUpwards;
5192 if (WillIndexUpwards) {
5195 AdjStackPtr = DAG.getMemBasePlusOffset(
5196 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5197 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5201 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5202 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5206 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5211 if (!IsOneStepShift) {
5213 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5214 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5215 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5219 SplitInteger(Res,
Lo,
Hi);
5222void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5224 EVT VT =
N->getValueType(0);
5225 unsigned Opc =
N->getOpcode();
5231 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5235 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5252 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5254 const bool LegalOrCustom =
5258 unsigned ExpansionFactor = 1;
5260 for (EVT TmpVT = NVT;;) {
5261 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5262 if (NewTMPVT == TmpVT)
5269 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5272 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5274 if (LegalOrCustom &&
5278 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5284 SDValue ShiftOp =
N->getOperand(1);
5285 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5287 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5290 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5291 Hi =
Lo.getValue(1);
5296 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5310 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5313 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5315 TargetLowering::MakeLibCallOptions CallOptions;
5318 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5323 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5327void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5329 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5332 if (
Op.getValueType().bitsLE(NVT)) {
5338 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5342 assert(getTypeAction(
Op.getValueType()) ==
5344 "Only know how to promote this result!");
5347 "Operand over promoted?");
5349 SplitInteger(Res,
Lo,
Hi);
5357void DAGTypeLegalizer::
5360 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5363 if (EVT.
bitsLE(
Lo.getValueType())) {
5371 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5372 Hi.getValueType(), dl));
5383void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5385 EVT VT =
N->getValueType(0);
5387 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5396 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5398 TargetLowering::MakeLibCallOptions CallOptions;
5400 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5403void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5405 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5415void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5417 EVT VT =
N->getValueType(0);
5436 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5437 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5438 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5440 EVT BitVT =
N->getValueType(1);
5441 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5443 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5445 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5446 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5465 SplitInteger(Three,
Lo,
Hi);
5469 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5474 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5479 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5483 if (LCImpl == RTLIB::Unsupported ||
5485 DAG.getMachineFunction().getName()) {
5488 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5489 N->getOperand(1), MulLo, MulHi);
5494 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5495 SplitInteger(MulLo,
Lo,
Hi);
5496 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5500 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5503 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5504 MachinePointerInfo());
5508 EVT ArgVT =
Op.getValueType();
5510 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5511 Entry.IsSExt =
true;
5512 Entry.IsZExt =
false;
5513 Args.push_back(Entry);
5517 TargetLowering::ArgListEntry
Entry(
5519 Entry.IsSExt =
true;
5520 Entry.IsZExt =
false;
5521 Args.push_back(Entry);
5523 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5525 TargetLowering::CallLoweringInfo CLI(DAG);
5528 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5529 Func, std::move(Args))
5532 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5534 SplitInteger(CallInfo.first,
Lo,
Hi);
5536 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5537 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5538 DAG.getConstant(0, dl, PtrVT),
5541 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5544void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5546 EVT VT =
N->getValueType(0);
5548 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5558 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5560 if (isTypeLegal(NVT)) {
5562 GetExpandedInteger(
N->getOperand(0), InL, InH);
5564 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5573 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5575 TargetLowering::MakeLibCallOptions CallOptions;
5576 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5579void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5581 EVT VT =
N->getValueType(0);
5583 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5593 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5595 if (isTypeLegal(NVT)) {
5597 GetExpandedInteger(
N->getOperand(0), InL, InH);
5599 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5608 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5610 TargetLowering::MakeLibCallOptions CallOptions;
5611 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5614void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5616 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5619 if (
Op.getValueType().bitsLE(NVT)) {
5622 Hi = DAG.getConstant(0, dl, NVT);
5626 assert(getTypeAction(
Op.getValueType()) ==
5628 "Only know how to promote this result!");
5631 "Operand over promoted?");
5633 SplitInteger(Res,
Lo,
Hi);
5635 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5641void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5645 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5647 SDValue Swap = DAG.getAtomicCmpSwap(
5656void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5660 SDValue Res = TLI.expandVecReduce(
N, DAG);
5661 SplitInteger(Res,
Lo,
Hi);
5664void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5670 N->getOperand(0),
N->getOperand(1));
5671 SplitInteger(Res,
Lo,
Hi);
5678 GetExpandedInteger(
N->getOperand(0), In3, In4);
5679 GetExpandedInteger(
N->getOperand(1), In1, In2);
5683 unsigned Opc =
N->getOpcode();
5686 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5691 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5693 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5697 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5698 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5703 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5704 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5709 SDValue Res = TLI.expandCLMUL(
N, DAG);
5710 return SplitInteger(Res,
Lo,
Hi);
5714 GetExpandedInteger(
N->getOperand(0), LL, LH);
5715 GetExpandedInteger(
N->getOperand(1), RL, RH);
5729 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5733 SDValue Res = TLI.expandPEXT(
N, DAG);
5734 SplitInteger(Res,
Lo,
Hi);
5738 SDValue Res = TLI.expandPDEP(
N, DAG);
5739 SplitInteger(Res,
Lo,
Hi);
5744 EVT VT =
N->getValueType(0);
5751 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5754 SplitInteger(Res,
Lo,
Hi);
5761 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5762 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5764 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5765 Lo = DAG.getPOISON(LoVT);
5766 Hi = DAG.getPOISON(HiVT);
5773 EVT VT =
N->getSimpleValueType(0);
5774 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5776 "VectorIdxTy should be smaller than type to be expanded?");
5780 SplitInteger(Res,
Lo,
Hi);
5791bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5795 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5798 switch (
N->getOpcode()) {
5801 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5802 N->dump(&DAG);
dbgs() <<
"\n";
5807 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5811 Res = ExpandOp_FAKE_USE(
N);
5815 Res = TLI.expandLoopDependenceMask(
N, DAG);
5821 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5834 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5839 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5843 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5846 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5848 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5849 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5850 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5853 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5858 if (!Res.
getNode())
return false;
5866 "Invalid operand expansion");
5868 ReplaceValueWith(
SDValue(
N, 0), Res);
5874void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5878 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5879 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5880 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5893 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5900 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5901 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5931 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5932 RHSLo, LowCC,
false, DagCombineInfo, dl);
5934 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5937 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5938 RHSHi, CCCode,
false, DagCombineInfo, dl);
5942 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5951 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5953 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5962 if (LHSHi == RHSHi) {
5971 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5972 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5975 if (HasSETCCCARRY) {
5978 bool FlipOperands =
false;
5995 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5999 DAG.getCondCode(CCCode));
6005 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
6006 false, DagCombineInfo, dl);
6009 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
6010 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
6017 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6022 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6027 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
6028 DAG.getCondCode(CCCode), NewLHS, NewRHS,
6029 N->getOperand(4)), 0);
6035 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6040 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6045 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6046 N->getOperand(2),
N->getOperand(3),
6047 DAG.getCondCode(CCCode)), 0);
6053 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6058 "Unexpected setcc expansion!");
6064 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6072 SDLoc dl = SDLoc(
N);
6074 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6075 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6076 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6089 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6099 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6100 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6104 return TLI.expandCMP(
N, DAG);
6112 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6113 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6117 bool IsStrict =
N->isStrictFPOpcode();
6121 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6122 EVT DstVT =
N->getValueType(0);
6125 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6126 "Don't know how to expand this XINT_TO_FP!");
6127 TargetLowering::MakeLibCallOptions CallOptions;
6129 std::pair<SDValue, SDValue> Tmp =
6130 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6135 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6136 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6141 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6144 return ExpandOp_NormalStore(
N, OpNo);
6147 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6149 EVT VT =
N->getOperand(1).getValueType();
6150 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6154 AAMDNodes AAInfo =
N->getAAInfo();
6160 if (
N->getMemoryVT().bitsLE(NVT)) {
6161 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6162 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6163 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6167 if (DAG.getDataLayout().isLittleEndian()) {
6169 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6171 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6174 unsigned ExcessBits =
6181 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6182 N->getPointerInfo().getWithOffset(IncrementSize),
6183 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6189 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6191 EVT ExtVT =
N->getMemoryVT();
6194 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6202 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6206 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6210 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6211 N->getBaseAlign(), MMOFlags, AAInfo);
6216 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6217 N->getPointerInfo().getWithOffset(IncrementSize),
6219 N->getBaseAlign(), MMOFlags, AAInfo);
6225 GetExpandedInteger(
N->getOperand(0), InL, InH);
6234 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6239SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6240 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6241 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6245 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6247 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6250SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6253 "cannot use llvm.write_register with illegal type", Fn,
6256 return N->getOperand(0);
6259SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6262 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6263 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6266 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6269SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6271 unsigned Factor =
N->getNumOperands();
6274 for (
unsigned i = 0; i != Factor; i++)
6275 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6280 for (
unsigned i = 0; i != Factor; i++)
6286SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6288 EVT OutVT =
N->getValueType(0);
6289 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6290 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6294 SDValue BaseIdx =
N->getOperand(1);
6311 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6315 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6321 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6330 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6334 "Promoted operand has an element type greater than result");
6347 InOp0 = GetPromotedInteger(InOp0);
6354 Ops.reserve(OutNumElems);
6355 for (
unsigned i = 0; i != OutNumElems; ++i) {
6360 N->getOperand(0), Index);
6361 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6366 return DAG.getBuildVector(NOutVT, dl,
Ops);
6369SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6370 EVT OutVT =
N->getValueType(0);
6371 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6372 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6384 Vec = GetPromotedInteger(Vec);
6390SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6393 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6399SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6401 EVT VT =
N->getValueType(0);
6406 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6407 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6410 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6414 EVT OutVT =
N->getValueType(0);
6415 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6416 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6417 unsigned NumElems =
N->getNumOperands();
6424 Ops.reserve(NumElems);
6425 for (
unsigned i = 0; i != NumElems; ++i) {
6427 EVT OpVT =
Op.getValueType();
6432 if (OpVT.
bitsLT(NOutVTElem)) {
6438 ExtOpc = NOutExtOpc;
6439 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6444 return DAG.getBuildVector(NOutVT, dl,
Ops);
6451 assert(!
N->getOperand(0).getValueType().isVector() &&
6452 "Input must be a scalar");
6454 EVT OutVT =
N->getValueType(0);
6455 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6456 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6460 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6465 EVT OutVT =
N->getValueType(0);
6466 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6468 "Type must be promoted to a scalable vector type");
6469 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6470 return DAG.getStepVector(dl, NOutVT,
6474SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6477 EVT OutVT =
N->getValueType(0);
6478 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6479 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6481 unsigned NumOperands =
N->getNumOperands();
6486 SDUse *MaxSizedValue = std::max_element(
6488 EVT AVT = A.getValueType().getVectorElementType();
6489 EVT BVT = B.getValueType().getVectorElementType();
6490 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6496 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6498 EVT OpVT =
Op.getValueType();
6500 Op = GetPromotedInteger(
Op);
6503 "Unhandled legalization type");
6507 Op = DAG.getAnyExtOrTrunc(
6515 return DAG.getAnyExtOrTrunc(
6523 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6524 assert(NumElem * NumOperands == NumOutElem &&
6525 "Unexpected number of elements");
6529 for (
unsigned i = 0; i < NumOperands; ++i) {
6532 Op = GetPromotedInteger(
Op);
6533 EVT SclrTy =
Op.getValueType().getVectorElementType();
6534 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6535 "Unexpected number of elements");
6537 for (
unsigned j = 0;
j < NumElem; ++
j) {
6539 DAG.getVectorIdxConstant(j, dl));
6540 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6544 return DAG.getBuildVector(NOutVT, dl,
Ops);
6547SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6548 EVT VT =
N->getValueType(0);
6549 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6550 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6558 if (getTypeAction(
N->getOperand(0).getValueType())
6562 switch(
N->getOpcode()) {
6564 Promoted = SExtPromotedInteger(
N->getOperand(0));
6567 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6570 Promoted = GetPromotedInteger(
N->getOperand(0));
6582 DAG.getVectorIdxConstant(0, dl));
6584 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6588 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6591SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6592 EVT VT =
N->getValueType(0);
6593 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6597SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6598 EVT VT =
N->getValueType(0);
6599 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6603SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6605 EVT VT =
N->getValueType(0);
6606 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6607 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6608 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6612SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6613 EVT OutVT =
N->getValueType(0);
6614 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6615 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6620 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6623 NOutVTElem,
N->getOperand(1));
6625 V0, ConvElem,
N->getOperand(2));
6632 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6633 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6641 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6642 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6643 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6647 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6650 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6651 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6659 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6664SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6667 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6669 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6670 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6671 return DAG.getPOISON(NVT);
6674SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6676 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6677 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6678 TLI.getVectorIdxTy(DAG.getDataLayout()));
6685 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6688SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6693 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6696 V1.getValueType().getVectorElementType(),
6698 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6700 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6709 EVT InVT1 =
V1.getValueType();
6712 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6713 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6716SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6718 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6726SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6729 EVT ResVT =
N->getValueType(0);
6730 unsigned NumElems =
N->getNumOperands();
6733 SDValue ResVec = DAG.getUNDEF(ResVT);
6737 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6739 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6751 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6752 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6756 for (
unsigned i=0; i<NumElem; ++i) {
6759 DAG.getVectorIdxConstant(i, dl));
6765 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6768SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6781 for (
unsigned I = 0;
I < OpNo;
I++)
6784 EVT Ty =
Op.getValueType();
6785 SDLoc
DL = SDLoc(
N);
6788 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6796 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6801 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6807SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6820 for (
unsigned I = 0;
I < OpNo;
I++)
6823 EVT Ty =
Op.getValueType();
6824 SDLoc
DL = SDLoc(
N);
6827 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6835 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6840 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)