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);
172 Res = PromoteIntRes_VECTOR_MATCH(
N);
178 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
182 case ISD::VP_SIGN_EXTEND:
184 case ISD::VP_ZERO_EXTEND:
187 case ISD::VP_FP_TO_SINT:
188 case ISD::VP_FP_TO_UINT:
196 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
200 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
203 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
207 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
222 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
232 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
242 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
246 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
250 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
254 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
256 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
258 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
274 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
276 case ISD::VP_SADDSAT:
277 case ISD::VP_UADDSAT:
278 case ISD::VP_SSUBSAT:
279 case ISD::VP_USUBSAT:
280 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
285 Res = PromoteIntRes_CMP(
N);
300 Res = PromoteIntRes_ABS(
N);
334 Res = PromoteIntRes_VECREDUCE(
N);
337 case ISD::VP_REDUCE_ADD:
338 case ISD::VP_REDUCE_MUL:
339 case ISD::VP_REDUCE_AND:
340 case ISD::VP_REDUCE_OR:
341 case ISD::VP_REDUCE_XOR:
342 case ISD::VP_REDUCE_SMAX:
343 case ISD::VP_REDUCE_SMIN:
344 case ISD::VP_REDUCE_UMAX:
345 case ISD::VP_REDUCE_UMIN:
346 Res = PromoteIntRes_VP_REDUCE(
N);
351 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
355 Res = PromoteIntRes_FREEZE(
N);
360 Res = PromoteIntRes_Rotate(
N);
365 Res = PromoteIntRes_FunnelShift(
N);
370 Res = PromoteIntRes_VPFunnelShift(
N);
376 Res = PromoteIntRes_CLMUL(
N);
380 Res = PromoteIntRes_PEXT(
N);
384 Res = PromoteIntRes_PDEP(
N);
388 Res = PromoteIntRes_IS_FPCLASS(
N);
391 Res = PromoteIntRes_FFREXP(
N);
396 Res = PromoteIntRes_XRINT(
N);
400 Res = PromoteIntRes_PATCHPOINT(
N);
403 Res = PromoteIntRes_READ_REGISTER(
N);
409 SetPromotedInteger(
SDValue(
N, ResNo), Res);
414 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
415 return GetPromotedInteger(
Op);
418SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
420 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
421 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
426 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
428 Op.getValueType(),
Op,
N->getOperand(1));
433 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
435 Op.getValueType(),
Op,
N->getOperand(1));
439 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
442 switch (TLI.getExtendForAtomicOps()) {
458 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
459 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
469 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
471 Op2 = SExtPromotedInteger(Op2);
474 Op2 = ZExtPromotedInteger(Op2);
477 Op2 = GetPromotedInteger(Op2);
482 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
484 N->getChain(),
N->getBasePtr(),
485 Op2,
N->getMemOperand());
496 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
497 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
501 if (!TLI.isTypeLegal(SVT))
504 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
505 SDValue Res = DAG.getAtomicCmpSwap(
507 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
511 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
517 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
518 switch (TLI.getExtendForAtomicCmpSwapArg()) {
520 Op2 = SExtPromotedInteger(Op2);
523 Op2 = ZExtPromotedInteger(Op2);
526 Op2 = GetPromotedInteger(Op2);
533 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
534 SDValue Res = DAG.getAtomicCmpSwap(
535 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
536 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
538 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
546 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
547 EVT OutVT =
N->getValueType(0);
548 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
551 switch (getTypeAction(InVT)) {
557 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
561 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
564 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
572 BitConvertToInteger(GetScalarizedVector(InOp)));
581 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
582 Lo = BitConvertToInteger(
Lo);
583 Hi = BitConvertToInteger(
Hi);
585 if (DAG.getDataLayout().isBigEndian())
591 JoinIntegers(
Lo,
Hi));
606 if (DAG.getDataLayout().isBigEndian()) {
610 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
625 if (isTypeLegal(WideOutVT)) {
626 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
628 DAG.getVectorIdxConstant(0, dl));
637 DAG.getDataLayout().isLittleEndian()) {
648 if (isTypeLegal(WideVecVT)) {
650 DAG.getUNDEF(WideVecVT), InOp,
651 DAG.getVectorIdxConstant(0, dl));
659 CreateStackStoreLoad(InOp, OutVT));
663 SDValue V = GetPromotedInteger(
N->getOperand(0));
665 V.getValueType(), V);
669 SDValue Op = GetPromotedInteger(
N->getOperand(0));
670 EVT OVT =
N->getValueType(0);
671 EVT NVT =
Op.getValueType();
679 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
680 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
685 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
691 return DAG.getNode(ISD::VP_SRL, dl, NVT,
692 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
697 SDValue Op = GetPromotedInteger(
N->getOperand(0));
698 EVT OVT =
N->getValueType(0);
699 EVT NVT =
Op.getValueType();
708 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
713 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
719 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
720 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
728 TLI.getTypeToTransformTo(*DAG.getContext(),
729 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
734 EVT VT =
N->getValueType(0);
741 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
748 EVT OVT =
N->getValueType(0);
749 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
755 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
756 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
758 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
764 unsigned CtlzOpcode =
N->getOpcode();
765 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
767 SDValue ExtractLeadingBits = DAG.getConstant(
770 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
774 if (!
N->isVPOpcode())
775 return DAG.getNode(
ISD::SUB, dl, NVT,
776 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
780 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
781 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
782 ExtractLeadingBits, Mask, EVL,
786 CtlzOpcode == ISD::VP_CTLZ_ZERO_POISON) {
788 SDValue Op = GetPromotedInteger(
N->getOperand(0));
792 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
793 if (!
N->isVPOpcode()) {
795 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
800 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
801 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
807 EVT OVT =
N->getValueType(0);
808 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
811 SDValue ExtractLeadingBits = DAG.getConstant(
814 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
820 EVT OVT =
N->getValueType(0);
821 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
829 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
830 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
837 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
838 if (!
N->isVPOpcode())
839 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
843 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
848 SDValue Op = GetPromotedInteger(
N->getOperand(0));
849 EVT OVT =
N->getValueType(0);
850 EVT NVT =
Op.getValueType();
857 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
858 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
862 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
868 unsigned NewOpc =
N->getOpcode();
869 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
876 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
880 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
881 N->getOperand(1),
N->getOperand(2));
882 NewOpc = ISD::VP_CTTZ_ZERO_POISON;
885 if (!
N->isVPOpcode())
886 return DAG.getNode(NewOpc, dl, NVT,
Op);
887 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
890SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
892 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
893 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
896SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
898 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
905 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
911 EVT SVT =
In.getValueType().getScalarType();
914 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
922 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
924 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
928 if (
N->isStrictFPOpcode()) {
929 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
930 {
N->getOperand(0),
N->getOperand(1)});
934 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
935 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
938 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
950 N->getOpcode() == ISD::VP_FP_TO_UINT)
954 DAG.getValueType(
N->getValueType(0).getScalarType()));
957SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
959 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
961 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
965SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
966 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
969 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
974SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
975 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
979 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
982SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
983 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
986 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
987 N->getOperand(0),
N->getOperand(1));
993 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
995 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
999 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1003 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
1012 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1015 if (getTypeAction(
N->getOperand(0).getValueType())
1017 SDValue Res = GetPromotedInteger(
N->getOperand(0));
1022 if (NVT == Res.
getValueType() &&
N->getNumOperands() == 1) {
1026 DAG.getValueType(
N->getOperand(0).getValueType()));
1028 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
1035 if (
N->getNumOperands() != 1) {
1036 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1037 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1038 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1039 N->getOperand(1),
N->getOperand(2));
1041 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1046 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1050 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1051 N->getMemoryVT(),
N->getMemOperand());
1060 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1061 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1064 :
N->getExtensionType();
1067 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1068 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1069 N->getMemOperand(),
N->isExpandingLoad());
1077 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1078 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1085 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1086 N->getOffset(),
N->getMask(), ExtPassThru,
1087 N->getMemoryVT(),
N->getMemOperand(),
1088 N->getAddressingMode(), ExtType,
1089 N->isExpandingLoad());
1097 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1098 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1100 "Gather result type and the passThru argument type should be the same");
1107 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1108 N->getIndex(),
N->getScale() };
1109 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1110 N->getMemoryVT(), dl,
Ops,
1111 N->getMemOperand(),
N->getIndexType(),
1119SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1120 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1121 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1123 N->getOperand(1), Passthru);
1130 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1131 EVT VT =
N->getValueType(0);
1132 EVT SVT = getSetCCResultType(VT);
1133 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1134 unsigned NumOps =
N->getNumOperands();
1137 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1145 ReplaceValueWith(
SDValue(
N, 0), Res);
1148 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1151template <
class MatchContextClass>
1163 MatchContextClass matcher(DAG, TLI,
N);
1165 unsigned Opcode = matcher.getRootBaseOpcode();
1171 SExtOrZExtPromotedOperands(Op1, Op2);
1177 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1179 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1180 Op1 = SExtPromotedInteger(Op1);
1181 Op2 = SExtPromotedInteger(Op2);
1182 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1185 Op1 = ZExtPromotedInteger(Op1);
1186 Op2 = ZExtPromotedInteger(Op2);
1189 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1191 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1198 Op1 = GetPromotedInteger(Op1);
1200 Op2 = ZExtPromotedInteger(Op2);
1202 Op1 = SExtPromotedInteger(Op1);
1203 Op2 = SExtPromotedInteger(Op2);
1210 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1223 "addition, subtraction or left shift");
1226 unsigned SHLAmount = NewBits - OldBits;
1228 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1233 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1234 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1240 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1241 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1242 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1243 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1244 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1251 SDValue Op1Promoted, Op2Promoted;
1257 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1258 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1260 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1261 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1263 EVT OldType =
N->getOperand(0).getValueType();
1275 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1276 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1277 Op2Promoted,
N->getOperand(2));
1279 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1280 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1282 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1287 unsigned SatW,
bool Signed,
1290 EVT VT = V.getValueType();
1317 EVT VT =
LHS.getValueType();
1333 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1339 "Tried to saturate to more than the original type?");
1348 SDValue Op1Promoted, Op2Promoted;
1354 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1355 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1357 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1358 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1361 unsigned Scale =
N->getConstantOperandVal(2);
1365 if (TLI.isTypeLegal(PromotedType)) {
1367 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1370 N->getValueType(0).getScalarSizeInBits();
1374 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1375 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1376 Op2Promoted,
N->getOperand(2));
1379 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1385 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1386 Op2Promoted, Scale, DAG)) {
1389 N->getValueType(0).getScalarSizeInBits(),
1397 N->getValueType(0).getScalarSizeInBits());
1400SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1402 return PromoteIntRes_Overflow(
N);
1406 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1407 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1408 EVT OVT =
N->getOperand(0).getValueType();
1409 EVT NVT =
LHS.getValueType();
1419 DAG.getValueType(OVT));
1421 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1424 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1430 EVT PromotedResultTy =
1431 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1432 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1433 N->getOperand(0),
N->getOperand(1));
1439 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1440 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1442 unsigned Opcode =
N->getOpcode();
1443 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1444 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1446 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1450 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1451 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1453 LHS.getValueType(),
N->getOperand(0),
1454 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1459 EVT InVT =
N->getOperand(OpNo).getValueType();
1460 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1462 EVT SVT = getSetCCResultType(InVT);
1469 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1470 SVT = getSetCCResultType(InVT);
1478 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1479 "Vector compare must return a vector result!");
1483 if (
N->isStrictFPOpcode()) {
1484 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1485 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1486 N->getOperand(2),
N->getOperand(3)};
1487 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1492 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1493 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1496 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1503 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1508 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1509 EVT VT =
N->getValueType(0);
1513 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1515 ReplaceValueWith(
SDValue(
N, 0), Res);
1520 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1523 RHS = ZExtPromotedInteger(
RHS);
1524 if (
N->getOpcode() != ISD::VP_SHL)
1525 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1533SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1534 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1536 Op.getValueType(),
Op,
N->getOperand(1));
1539SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1543 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1544 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1545 if (
N->getNumOperands() == 2)
1546 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1547 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1548 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1549 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1550 N->getOperand(2),
N->getOperand(3));
1555 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1556 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1557 if (
N->getNumOperands() == 2)
1558 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1559 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1560 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1569 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1570 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1571 if (
N->getNumOperands() == 2)
1572 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1573 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1574 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1582SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1583 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1584 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1586 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1590SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1591 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1592 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1594 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1604 SExtOrZExtPromotedOperands(
LHS,
RHS);
1606 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1612 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1615 RHS = ZExtPromotedInteger(
RHS);
1616 if (
N->getOpcode() != ISD::VP_SRA)
1617 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1628 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1630 RHS = ZExtPromotedInteger(
RHS);
1631 if (
N->getOpcode() != ISD::VP_SRL)
1632 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1642 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1644 unsigned Opcode =
N->getOpcode();
1655 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1658 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1660 Amt = ZExtPromotedInteger(Amt);
1666 DAG.getConstant(OldBits,
DL, AmtVT));
1667 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1669 SDValue Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1681 SDValue Res = TLI.expandROT(
N,
true , DAG);
1682 ReplaceValueWith(
SDValue(
N, 0), Res);
1687 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1688 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1691 Amt = ZExtPromotedInteger(Amt);
1695 EVT OldVT =
N->getOperand(0).getValueType();
1696 EVT VT =
Lo.getValueType();
1697 unsigned Opcode =
N->getOpcode();
1704 DAG.getConstant(OldBits,
DL, AmtVT));
1712 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1713 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1715 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1725 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1731 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1733 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1737SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1738 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1739 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1744 Amt = ZExtPromotedInteger(Amt);
1748 EVT OldVT =
N->getOperand(0).getValueType();
1749 EVT VT =
Lo.getValueType();
1750 unsigned Opcode =
N->getOpcode();
1751 bool IsFSHR = Opcode == ISD::VP_FSHR;
1756 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1757 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1765 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1766 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1767 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1768 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1770 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1773 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1778 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1779 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1784 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1786 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1790 unsigned Opcode =
N->getOpcode();
1793 EVT OldVT =
N->getOperand(0).getValueType();
1794 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1799 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1801 TLI.isOperationLegalOrCustom(
1802 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1803 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1806 SDValue X = GetPromotedInteger(
N->getOperand(0));
1807 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1811 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1812 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1816 if (NewBits < 2 * OldBits) {
1818 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1820 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1822 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1824 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1829 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1831 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1836 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1837 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1838 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1843 SDValue X = GetPromotedInteger(
N->getOperand(0));
1844 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1850 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1851 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1852 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1857 SDValue X = GetPromotedInteger(
N->getOperand(0));
1858 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1863 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1875 Res = GetPromotedInteger(InOp);
1882 "Dst and Src must have the same number of elements");
1884 "Promoted vector type must be a power of two");
1887 GetSplitVector(InOp, EOp1, EOp2);
1895 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1896 "Expected VP_TRUNCATE opcode");
1897 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1898 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1899 std::tie(EVLLo, EVLHi) =
1900 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1901 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1902 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1909 SDValue WideInOp = GetWidenedVector(InOp);
1914 N->getValueType(0).getScalarType(), NumElem);
1923 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1929 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1930 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1935SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1937 return PromoteIntRes_Overflow(
N);
1941 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1942 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1943 EVT OVT =
N->getOperand(0).getValueType();
1944 EVT NVT =
LHS.getValueType();
1953 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1955 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1958 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1969 return PromoteIntRes_Overflow(
N);
1981 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1982 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1984 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1987 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1998 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1999 return PromoteIntRes_Overflow(
N);
2003 EVT OVT =
N->getValueType(0);
2004 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
2010 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
2012 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
2013 if (
SDValue Res = TLI.expandABS(
N, DAG))
2017 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
2021SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
2024 return PromoteIntRes_Overflow(
N);
2028 EVT SmallVT =
LHS.getValueType();
2035 LHS = SExtPromotedInteger(
LHS);
2036 RHS = SExtPromotedInteger(
RHS);
2038 LHS = ZExtPromotedInteger(
LHS);
2039 RHS = ZExtPromotedInteger(
RHS);
2041 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
2053 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
2054 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
2055 DAG.getConstant(0,
DL,
Hi.getValueType()),
2060 Mul, DAG.getValueType(SmallVT));
2070 ReplaceValueWith(
SDValue(
N, 1), Overflow);
2075 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
2076 N->getValueType(0)));
2080 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2082 const APInt &MulImm =
N->getConstantOperandAPInt(0);
2089 EVT VT =
N->getValueType(0);
2092 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
2093 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
2097 for (
unsigned i = 0; i < NumRegs; ++i) {
2098 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2099 N->getConstantOperandVal(3));
2104 if (DAG.getDataLayout().isBigEndian())
2105 std::reverse(Parts.begin(), Parts.end());
2108 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2110 for (
unsigned i = 1; i < NumRegs; ++i) {
2115 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2121 ReplaceValueWith(
SDValue(
N, 1), Chain);
2134bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2137 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2142 switch (
N->getOpcode()) {
2145 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2146 N->dump(&DAG);
dbgs() <<
"\n";
2152 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2158 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2159 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2164 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2168 Res = PromoteIntOp_FAKE_USE(
N);
2171 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2175 Res = PromoteIntOp_ScalarOp(
N);
2178 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2181 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2183 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2184 case ISD::VP_SINT_TO_FP:
2201 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2203 case ISD::VP_TRUNCATE:
2207 case ISD::VP_UINT_TO_FP:
2210 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2215 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2226 Res = PromoteIntOp_Shift(
N);
2230 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2233 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2259 case ISD::VP_REDUCE_ADD:
2260 case ISD::VP_REDUCE_MUL:
2261 case ISD::VP_REDUCE_AND:
2262 case ISD::VP_REDUCE_OR:
2263 case ISD::VP_REDUCE_XOR:
2264 case ISD::VP_REDUCE_SMAX:
2265 case ISD::VP_REDUCE_SMIN:
2266 case ISD::VP_REDUCE_UMAX:
2267 case ISD::VP_REDUCE_UMIN:
2268 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2273 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2276 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2279 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2281 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2282 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2283 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2285 case ISD::EXPERIMENTAL_VP_SPLICE:
2286 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2289 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2294 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2297 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2300 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2306 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2311 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2315 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2320 if (!Res.
getNode())
return false;
2327 const bool IsStrictFp =
N->isStrictFPOpcode();
2329 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2330 "Invalid operand expansion");
2334 ReplaceValueWith(
SDValue(
N, 0), Res);
2348 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2352 unsigned OpLEffectiveBits =
2353 DAG.computeKnownBits(OpL).countMaxActiveBits();
2354 unsigned OpREffectiveBits =
2355 DAG.computeKnownBits(OpR).countMaxActiveBits();
2356 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2357 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2364 LHS = SExtPromotedInteger(
LHS);
2365 RHS = SExtPromotedInteger(
RHS);
2374 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2375 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2376 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2377 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2384 LHS = ZExtPromotedInteger(
LHS);
2385 RHS = ZExtPromotedInteger(
RHS);
2399 LHS = SExtPromotedInteger(
LHS);
2400 RHS = SExtPromotedInteger(
RHS);
2405 "Unknown integer comparison!");
2407 SExtOrZExtPromotedOperands(
LHS,
RHS);
2411 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2415SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2416 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2417 EVT ResVT =
N->getValueType(0);
2418 EVT OpVT =
Op.getValueType();
2421 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2426 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2427 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2428 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2432 EVT OutVT =
N->getValueType(0);
2435 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2438 switch (getTypeAction(InVT)) {
2442 DAG.getDataLayout().isLittleEndian()) {
2452 if (isTypeLegal(WideVecVT)) {
2453 SDValue Promoted = GetPromotedInteger(InOp);
2456 DAG.getVectorIdxConstant(0, dl));
2469 return CreateStackStoreLoad(InOp, OutVT);
2472SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2473 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2481 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2482 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2486SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
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,
2494 N->getOperand(2)), 0);
2497SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2498 assert(OpNo == 1 &&
"only know how to promote condition");
2501 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2504 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2509 EVT OVT =
N->getOperand(0).getValueType();
2510 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2511 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2512 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2517 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2518 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2527 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2528 "Legal vector of one illegal element?");
2533 assert(
N->getOperand(0).getValueSizeInBits() >=
2534 N->getValueType(0).getScalarSizeInBits() &&
2535 "Type of inserted value narrower than vector element type!");
2538 for (
unsigned i = 0; i < NumElts; ++i)
2539 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2541 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2544SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2551 assert(
N->getOperand(1).getValueSizeInBits() >=
2552 N->getValueType(0).getScalarSizeInBits() &&
2553 "Type of inserted value narrower than vector element type!");
2554 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2555 GetPromotedInteger(
N->getOperand(1)),
2560 assert(OpNo == 2 &&
"Different operand and result vector types?");
2563 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2564 TLI.getVectorIdxTy(DAG.getDataLayout()));
2565 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2566 N->getOperand(1), Idx), 0);
2570 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2574 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2577SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2578 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2580 EVT OpTy =
N->getOperand(1).getValueType();
2583 if (
SDValue Res = WidenVSELECTMask(
N))
2584 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2585 Res,
N->getOperand(1),
N->getOperand(2));
2589 Cond = PromoteTargetBoolean(
Cond, OpVT);
2591 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2592 N->getOperand(2)), 0);
2595SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2596 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2604 N->getOperand(3),
N->getOperand(4)), 0);
2607SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2608 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2616 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2618 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2621 N->getOperand(3),
N->getOperand(4)),
2626 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2627 ZExtPromotedInteger(
N->getOperand(1))), 0);
2635 LHS = SExtPromotedInteger(
LHS);
2636 RHS = SExtPromotedInteger(
RHS);
2638 SExtOrZExtPromotedOperands(
LHS,
RHS);
2645 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2646 ZExtPromotedInteger(
N->getOperand(2))), 0);
2650 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2654 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2657SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2659 EVT VT =
N->getValueType(0);
2660 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2662 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2666 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2668 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2670 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2675 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2676 return SDValue(DAG.UpdateNodeOperands(
N,
2677 SExtPromotedInteger(
N->getOperand(0)),
2678 N->getOperand(1),
N->getOperand(2)),
2680 return SDValue(DAG.UpdateNodeOperands(
N,
2681 SExtPromotedInteger(
N->getOperand(0))), 0);
2684SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2685 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2686 SExtPromotedInteger(
N->getOperand(1))), 0);
2691 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2694 SDValue Val = GetPromotedInteger(
N->getValue());
2697 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2698 N->getMemoryVT(),
N->getMemOperand());
2704 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2705 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2707 SDValue DataOp = GetPromotedInteger(
N->getValue());
2708 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2709 N->getMask(),
N->getVectorLength(),
2710 N->getMemoryVT(),
N->getMemOperand(),
2711 N->isCompressingStore());
2722 Mask = PromoteTargetBoolean(Mask, DataVT);
2725 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2728 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2729 DataOp = GetPromotedInteger(DataOp);
2731 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2732 N->getOffset(), Mask,
N->getMemoryVT(),
2733 N->getMemOperand(),
N->getAddressingMode(),
2734 true,
N->isCompressingStore());
2739 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2740 EVT DataVT =
N->getValueType(0);
2741 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2743 NewOps[OpNo] =
Mask;
2744 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2760 EVT DataVT =
N->getValueType(0);
2761 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2762 }
else if (OpNo == 4) {
2764 if (
N->isIndexSigned())
2766 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2768 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2770 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2772 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2784 bool TruncateStore =
N->isTruncatingStore();
2789 EVT DataVT =
N->getValue().getValueType();
2790 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2791 }
else if (OpNo == 4) {
2793 if (
N->isIndexSigned())
2795 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2797 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2799 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2800 TruncateStore =
true;
2803 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2804 SDLoc(
N), NewOps,
N->getMemOperand(),
2805 N->getIndexType(), TruncateStore);
2810 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2814 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2819 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2820 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2821 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2822 N->getOperand(1),
N->getOperand(2));
2827 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2828 return SDValue(DAG.UpdateNodeOperands(
N,
2829 ZExtPromotedInteger(
N->getOperand(0)),
2830 N->getOperand(1),
N->getOperand(2)),
2832 return SDValue(DAG.UpdateNodeOperands(
N,
2833 ZExtPromotedInteger(
N->getOperand(0))), 0);
2836SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2837 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2842SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2843 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2844 ZExtPromotedInteger(
N->getOperand(1))), 0);
2851 EVT VT =
N->getValueType(0);
2856 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2857 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2858 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2859 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2864 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2867SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2869 EVT VT =
N->getValueType(0);
2870 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2872 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2874 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2875 N->getOperand(0).getValueType());
2879 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2881 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2884SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2886 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2887 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2896 unsigned OpOffset = IsStrict ? 1 : 0;
2903 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2904 if (LCImpl == RTLIB::Unsupported) {
2910 if (IsPowI &&
N->getValueType(0).isVector())
2911 return DAG.UnrollVectorOp(
N);
2913 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2914 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2926 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2927 DAG.getLibInfo().getIntSize()) {
2928 const Function &Fn = DAG.getMachineFunction().getFunction();
2929 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2930 Twine(IsPowI ?
"powi" :
"ldexp") +
2931 " exponent does not match sizeof(int)",
2932 Fn, N->getDebugLoc()));
2934 ReplaceValueWith(SDValue(N, 1), Chain);
2935 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2939 TargetLowering::MakeLibCallOptions CallOptions;
2940 CallOptions.setIsSigned(
true);
2941 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2942 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2943 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2944 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2946 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2951 switch (
N->getOpcode()) {
2959 case ISD::VP_REDUCE_ADD:
2960 case ISD::VP_REDUCE_MUL:
2961 case ISD::VP_REDUCE_AND:
2962 case ISD::VP_REDUCE_OR:
2963 case ISD::VP_REDUCE_XOR:
2967 case ISD::VP_REDUCE_SMAX:
2968 case ISD::VP_REDUCE_SMIN:
2972 case ISD::VP_REDUCE_UMAX:
2973 case ISD::VP_REDUCE_UMIN:
2983 return GetPromotedInteger(V);
2985 return SExtPromotedInteger(V);
2987 return ZExtPromotedInteger(V);
2993 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2995 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2996 EVT InVT =
Op.getValueType();
2998 EVT ResVT =
N->getValueType(0);
2999 unsigned Opcode =
N->getOpcode();
3016 switch (TLI.getBooleanContents(InVT)) {
3019 Op = ZExtPromotedInteger(
N->getOperand(0));
3022 Op = SExtPromotedInteger(
N->getOperand(0));
3035 switch (TLI.getBooleanContents(InVT)) {
3038 Op = ZExtPromotedInteger(
N->getOperand(0));
3041 Op = SExtPromotedInteger(
N->getOperand(0));
3047 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
3051 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
3055SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
3062 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
3063 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3066 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3068 Op = PromoteIntOpVectorReduction(
N,
Op);
3072 EVT VT =
N->getValueType(0);
3073 EVT EltVT =
Op.getValueType().getScalarType();
3076 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
3088 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
3089 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
3092SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
3095 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3096 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3099SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3102 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3103 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3108 const Function &Fn = DAG.getMachineFunction().getFunction();
3110 "cannot use llvm.write_register with illegal type", Fn,
3112 return N->getOperand(0);
3115SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3116 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3117 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3120 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3121 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3131SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3135 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3136 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3139 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3141 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3142 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3145SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3147 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3149 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3150 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3153SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3155 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3159 if (TLI.getBooleanContents(
Op.getValueType()) ==
3161 NewOp = SExtPromotedInteger(
Op);
3163 NewOp = ZExtPromotedInteger(
Op);
3165 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3168SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3170 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3171 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3172 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3175SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
3176 assert(OpNo < 3 &&
"Unexpected operand for promotion");
3178 return TLI.expandVectorMatch(
N, DAG);
3181 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
3182 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3185SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3188 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3189 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3192SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3194 switch (
N->getOpcode()) {
3196 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3197 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3200 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3201 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3204 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3205 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3210 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3213SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3215 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3216 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3217 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3219 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3230void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3236 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3239 switch (
N->getOpcode()) {
3242 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3243 N->dump(&DAG);
dbgs() <<
"\n";
3272 ExpandIntRes_ABS(
N,
Lo,
Hi);
3324 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3325 SplitInteger(Tmp.first,
Lo,
Hi);
3326 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3331 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3332 SDValue Tmp = DAG.getAtomicCmpSwap(
3334 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3343 SplitInteger(Tmp,
Lo,
Hi);
3422 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3427 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3433 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3437 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3441 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3445 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3449 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3454 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3464std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3465 unsigned Opc =
Node->getOpcode();
3471 EVT RetVT =
Node->getValueType(0);
3472 TargetLowering::MakeLibCallOptions CallOptions;
3475 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3476 if (LCImpl != RTLIB::Unsupported) {
3478 Ops.push_back(
Node->getOperand(1));
3481 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3482 "Unexpected atomic op or value type!");
3484 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3486 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3487 Node->getOperand(0));
3492void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3497 GetExpandedInteger(
N->getOperand(0), InL, InH);
3512 if (Amt.
uge(VTBits)) {
3513 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3514 }
else if (Amt.
ugt(NVTBits)) {
3515 Lo = DAG.getConstant(0,
DL, NVT);
3517 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3518 }
else if (Amt == NVTBits) {
3519 Lo = DAG.getConstant(0,
DL, NVT);
3523 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3525 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3527 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3532 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3534 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3541 if (Amt.
uge(VTBits)) {
3542 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3543 }
else if (Amt.
ugt(NVTBits)) {
3545 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3546 Hi = DAG.getConstant(0,
DL, NVT);
3547 }
else if (Amt == NVTBits) {
3549 Hi = DAG.getConstant(0,
DL, NVT);
3552 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3554 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3559 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3561 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3564 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3570 if (Amt.
uge(VTBits)) {
3572 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3573 }
else if (Amt.
ugt(NVTBits)) {
3575 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3577 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3578 }
else if (Amt == NVTBits) {
3581 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3584 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3586 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3591 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3593 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3596 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3604bool DAGTypeLegalizer::
3606 unsigned Opc =
N->getOpcode();
3609 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3614 "Expanded integer type size not a power of two!");
3618 KnownBits
Known = DAG.computeKnownBits(Amt);
3621 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3626 GetExpandedInteger(In, InL, InH);
3630 if (
Known.One.intersects(HighBitMask)) {
3633 DAG.getConstant(~HighBitMask, dl, ShTy));
3638 Lo = DAG.getConstant(0, dl, NVT);
3639 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3642 Hi = DAG.getConstant(0, dl, NVT);
3643 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3647 DAG.getConstant(NVTBits - 1, dl, ShTy));
3648 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3660 DAG.getConstant(NVTBits - 1, dl, ShTy));
3676 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3678 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3680 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3681 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3693bool DAGTypeLegalizer::
3696 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3700 "Expanded integer type size not a power of two!");
3705 GetExpandedInteger(
N->getOperand(0), InL, InH);
3707 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3710 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3713 Amt, DAG.getConstant(0, dl, ShTy),
3717 switch (
N->getOpcode()) {
3723 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3724 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3727 LoL = DAG.getConstant(0, dl, NVT);
3730 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3731 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3732 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3738 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3741 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3744 HiL = DAG.getConstant(0, dl, NVT);
3747 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3748 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3749 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3755 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3756 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3760 DAG.getConstant(NVTBits - 1, dl, ShTy));
3763 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3764 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3765 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3790 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3795 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3796 SplitInteger(Res,
Lo,
Hi);
3799void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3808 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3809 unsigned NumHalfBits = NumBits / 2;
3810 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3811 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3812 SDValue LHSL, LHSH, RHSL, RHSH;
3813 GetExpandedInteger(
LHS, LHSL, LHSH);
3814 GetExpandedInteger(
RHS, RHSL, RHSH);
3817 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3819 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3827 SDValue LHSL, LHSH, RHSL, RHSH;
3828 GetExpandedInteger(
LHS, LHSL, LHSH);
3829 GetExpandedInteger(
RHS, RHSL, RHSH);
3831 EVT CCT = getSetCCResultType(NVT);
3834 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3836 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3838 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3840 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3844 const APInt *RHSVal =
nullptr;
3846 RHSVal = &RHSConst->getAPIntValue();
3853 SDValue LHSL, LHSH, RHSL, RHSH;
3854 GetExpandedInteger(
LHS, LHSL, LHSH);
3855 GetExpandedInteger(
RHS, RHSL, RHSH);
3857 EVT CCT = getSetCCResultType(NVT);
3863 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3866 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3870 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3873 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3875 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3882 switch (
N->getOpcode()) {
3909 EVT VT =
N->getValueType(0);
3910 EVT CCT = getSetCCResultType(VT);
3913 SplitInteger(Result,
Lo,
Hi);
3917 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3918 SplitInteger(ExpandedCMP,
Lo,
Hi);
3921void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3925 SDValue LHSL, LHSH, RHSL, RHSH;
3926 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3927 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3930 SDValue LoOps[2] = { LHSL, RHSL };
3931 SDValue HiOps[3] = { LHSH, RHSH };
3933 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3935 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3937 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3941 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3947 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3960 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3962 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3965 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3979 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3981 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3985 EVT OvfVT = getSetCCResultType(NVT);
3986 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
4001 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
4004 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
4008 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
4020 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4024 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4027 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
4030 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
4035 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4037 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4038 DAG.getConstant(0, dl, NVT));
4041 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
4050 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
4055 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
4057 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
4058 DAG.getConstant(0, dl, NVT));
4064void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
4067 SDValue LHSL, LHSH, RHSL, RHSH;
4069 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4070 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4071 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4072 SDValue LoOps[2] = { LHSL, RHSL };
4073 SDValue HiOps[3] = { LHSH, RHSH };
4087 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4090void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4093 SDValue LHSL, LHSH, RHSL, RHSH;
4095 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4096 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4097 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4099 SDValue HiOps[3] = { LHSH, RHSH };
4101 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4103 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4107 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4110void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4118 unsigned CarryOp, NoCarryOp;
4120 switch(
N->getOpcode()) {
4135 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4136 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4140 SDValue LHSL, LHSH, RHSL, RHSH;
4141 GetExpandedInteger(
LHS, LHSL, LHSH);
4142 GetExpandedInteger(
RHS, RHSL, RHSH);
4143 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4144 SDValue LoOps[2] = { LHSL, RHSL };
4145 SDValue HiOps[3] = { LHSH, RHSH };
4147 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4149 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4156 SplitInteger(Sum,
Lo,
Hi);
4162 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4163 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4167 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4172 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4178 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4184 SDValue LHSL, LHSH, RHSL, RHSH;
4186 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4187 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4188 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4192 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4194 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4198 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4201void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4204 SDValue LHSL, LHSH, RHSL, RHSH;
4206 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4207 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4208 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4213 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4214 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4218 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4221void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4223 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4226 if (
Op.getValueType().bitsLE(NVT)) {
4229 Hi = DAG.getUNDEF(NVT);
4233 assert(getTypeAction(
Op.getValueType()) ==
4235 "Only know how to promote this result!");
4238 "Operand over promoted?");
4240 SplitInteger(Res,
Lo,
Hi);
4244void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4247 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4248 EVT NVT =
Lo.getValueType();
4253 if (NVTBits < EVTBits) {
4256 EVTBits - NVTBits)));
4261 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4265void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4268 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4269 EVT NVT =
Lo.getValueType();
4274 if (NVTBits < EVTBits) {
4277 EVTBits - NVTBits)));
4281 Hi = DAG.getConstant(0, dl, NVT);
4285void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4288 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4293void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4296 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4305 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4306 EVT NVT =
Lo.getValueType();
4309 Hi = DAG.getConstant(0, dl, NVT);
4312void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4314 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4317 const APInt &Cst =
Constant->getAPIntValue();
4318 bool IsTarget =
Constant->isTargetOpcode();
4319 bool IsOpaque =
Constant->isOpaque();
4321 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4322 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4330 GetExpandedInteger(N0,
Lo,
Hi);
4331 EVT NVT =
Lo.getValueType();
4336 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4341 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4342 Hi = DAG.getConstant(0, dl, NVT);
4352 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4357 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4358 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4367 EVT VT =
N->getValueType(0);
4369 DAG.getConstant(0, dl, VT), N0);
4371 SplitInteger(Neg, NegLo, NegHi);
4373 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4375 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4376 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4379void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4383 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4384 EVT NVT =
Lo.getValueType();
4386 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4389 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4392 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4393 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4396 Hi = DAG.getConstant(0, dl, NVT);
4404 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4405 EVT NVT =
Lo.getValueType();
4408 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4409 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4412 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4415 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4417 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4419 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4420 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4422 Hi = DAG.getConstant(0, dl, NVT);
4427 SplitInteger(Result,
Lo,
Hi);
4432 EVT VT =
N->getValueType(0);
4437 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4438 "LibCall explicitly requested, but not available");
4440 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4441 TargetLowering::MakeLibCallOptions CallOptions;
4445 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4446 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4454 GetExpandedInteger(
Op,
Lo,
Hi);
4455 EVT NVT =
Lo.getValueType();
4458 Hi = DAG.getConstant(0,
DL, NVT);
4461void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4465 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4466 EVT NVT =
Lo.getValueType();
4468 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4474 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4475 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4478 Hi = DAG.getConstant(0, dl, NVT);
4484 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4491 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4495 ReplaceValueWith(
SDValue(
N, 1), Chain);
4503 Chain =
Op.getValue(1);
4512 EVT VT =
N->getValueType(0);
4516 bool IsStrict =
N->isStrictFPOpcode();
4518 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4522 Op.getValueType() == MVT::bf16) {
4528 EVT OpVT =
Op.getValueType();
4532 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4533 TargetLowering::MakeLibCallOptions CallOptions;
4538 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4539 CallOptions, dl, Chain);
4540 SplitInteger(Tmp.first,
Lo,
Hi);
4543 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4548 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4549 SplitInteger(Res,
Lo,
Hi);
4555 bool IsStrict =
N->isStrictFPOpcode();
4556 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4559 EVT VT =
Op.getValueType();
4561 if (VT == MVT::f16) {
4567 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4571 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4575 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4579 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4583 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4587 EVT RetVT =
N->getValueType(0);
4589 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4590 if (LCImpl == RTLIB::Unsupported) {
4591 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4592 N->getOperationName(&DAG));
4595 if (
N->isStrictFPOpcode())
4596 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
4600 TargetLowering::MakeLibCallOptions CallOptions;
4602 std::pair<SDValue, SDValue> Tmp =
4603 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4604 SplitInteger(Tmp.first,
Lo,
Hi);
4606 if (
N->isStrictFPOpcode())
4607 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4610void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4612 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4615 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4621 EVT VT =
N->getValueType(0);
4622 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4627 AAMDNodes AAInfo =
N->getAAInfo();
4632 if (
N->getMemoryVT().bitsLE(NVT)) {
4633 EVT MemVT =
N->getMemoryVT();
4635 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4636 N->getBaseAlign(), MMOFlags, AAInfo);
4644 unsigned LoSize =
Lo.getValueSizeInBits();
4646 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4649 Hi = DAG.getConstant(0, dl, NVT);
4653 Hi = DAG.getUNDEF(NVT);
4655 }
else if (DAG.getDataLayout().isLittleEndian()) {
4657 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4660 unsigned ExcessBits =
4667 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4668 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4669 N->getBaseAlign(), MMOFlags, AAInfo);
4678 EVT MemVT =
N->getMemoryVT();
4681 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4684 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4687 N->getBaseAlign(), MMOFlags, AAInfo);
4693 N->getPointerInfo().getWithOffset(IncrementSize),
4695 N->getBaseAlign(), MMOFlags, AAInfo);
4707 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4711 DAG.getShiftAmountConstant(
4718 ReplaceValueWith(
SDValue(
N, 1), Ch);
4721void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4725 GetExpandedInteger(
N->getOperand(0), LL, LH);
4726 GetExpandedInteger(
N->getOperand(1), RL, RH);
4730 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4732 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4733 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4736void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4738 EVT VT =
N->getValueType(0);
4739 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4743 GetExpandedInteger(
N->getOperand(0), LL, LH);
4744 GetExpandedInteger(
N->getOperand(1), RL, RH);
4746 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4753 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4754 if (LCImpl == RTLIB::Unsupported) {
4757 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4763 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4764 TargetLowering::MakeLibCallOptions CallOptions;
4766 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4773 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4774 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4775 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4778 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4783 SplitInteger(Result,
Lo,
Hi);
4789 SplitInteger(Result,
Lo,
Hi);
4795 SplitInteger(Result,
Lo,
Hi);
4806 EVT VT =
N->getValueType(0);
4810 uint64_t Scale =
N->getConstantOperandVal(2);
4822 EVT BoolVT = getSetCCResultType(VT);
4824 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4830 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4831 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4837 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4838 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4843 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4844 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4847 SplitInteger(Result,
Lo,
Hi);
4853 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4855 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4857 GetExpandedInteger(
LHS, LL, LH);
4858 GetExpandedInteger(
RHS, RL, RH);
4862 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4869 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4870 SplitInteger(LoTmp, Result[0], Result[1]);
4871 SplitInteger(HiTmp, Result[2], Result[3]);
4873 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4876 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4877 "the size of the current value type");
4898 uint64_t Part0 = Scale / NVTSize;
4899 if (Scale % NVTSize) {
4900 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4903 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4915 if (Scale == VTSize)
4934 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4935 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4936 EVT BoolNVT = getSetCCResultType(NVT);
4939 if (Scale < NVTSize) {
4942 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4943 DAG.getShiftAmountConstant(Scale, NVT, dl));
4944 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4945 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4946 }
else if (Scale == NVTSize) {
4948 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4949 }
else if (Scale < VTSize) {
4953 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4954 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4957 "(and saturation can't happen with Scale==VTSize).");
4959 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4960 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4964 if (Scale < NVTSize) {
4969 unsigned OverflowBits = VTSize - Scale + 1;
4970 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4971 "Extent of overflow bits must start within HL");
4972 SDValue HLHiMask = DAG.getConstant(
4974 SDValue HLLoMask = DAG.getConstant(
4981 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4987 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4988 }
else if (Scale == NVTSize) {
4994 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
5000 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
5001 }
else if (Scale < VTSize) {
5004 unsigned OverflowBits = VTSize - Scale + 1;
5005 SDValue HHHiMask = DAG.getConstant(
5007 SDValue HHLoMask = DAG.getConstant(
5009 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
5010 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
5017 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
5018 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
5021 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
5022 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
5029 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
5031 N->getConstantOperandVal(2), DAG);
5035 N->getConstantOperandVal(2), TLI, DAG);
5036 SplitInteger(Res,
Lo,
Hi);
5039void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
5042 "Node has unexpected Opcode");
5052 bool HasCarryOp = TLI.isOperationLegalOrCustom(
5053 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
5057 SDValue LHSL, LHSH, RHSL, RHSH;
5058 GetExpandedInteger(
LHS, LHSL, LHSH);
5059 GetExpandedInteger(
RHS, RHSL, RHSH);
5060 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
5063 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5072 SplitInteger(Sum,
Lo,
Hi);
5097 EVT VT =
LHS.getValueType();
5100 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5104 EVT OType =
Node->getValueType(1);
5105 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5109 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5112void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5114 EVT VT =
N->getValueType(0);
5116 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5125 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5127 TargetLowering::MakeLibCallOptions CallOptions;
5129 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5132void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5135 SDValue Shiftee =
N->getOperand(0);
5142 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5143 }
while (!TLI.isTypeLegal(LoadVT));
5148 "Shifting unit is not a a power of two!");
5150 const bool IsOneStepShift =
5151 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5156 if (!IsOneStepShift)
5157 ShAmt = DAG.getFreeze(ShAmt);
5160 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5161 unsigned VTByteWidth = VTBitWidth / 8;
5163 "Shiftee type size is not a power of two!");
5164 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5165 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5170 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5172 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5173 EVT PtrTy =
StackPtr.getValueType();
5174 SDValue Ch = DAG.getEntryNode();
5177 DAG.getMachineFunction(),
5183 unsigned WideningOpc =
5185 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5188 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5192 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5198 Flags.setExact(IsOneStepShift);
5201 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5203 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5204 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5207 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5212 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5219 if (DAG.getDataLayout().isBigEndian())
5220 WillIndexUpwards = !WillIndexUpwards;
5223 if (WillIndexUpwards) {
5226 AdjStackPtr = DAG.getMemBasePlusOffset(
5227 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5228 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5232 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5233 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5237 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5242 if (!IsOneStepShift) {
5244 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5245 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5246 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5250 SplitInteger(Res,
Lo,
Hi);
5253void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5255 EVT VT =
N->getValueType(0);
5256 unsigned Opc =
N->getOpcode();
5262 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5266 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5283 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5285 const bool LegalOrCustom =
5289 unsigned ExpansionFactor = 1;
5291 for (EVT TmpVT = NVT;;) {
5292 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5293 if (NewTMPVT == TmpVT)
5300 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5303 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5305 if (LegalOrCustom &&
5309 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5315 SDValue ShiftOp =
N->getOperand(1);
5316 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5318 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5321 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5322 Hi =
Lo.getValue(1);
5327 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5341 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5344 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5346 TargetLowering::MakeLibCallOptions CallOptions;
5349 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5354 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5358void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5360 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5363 if (
Op.getValueType().bitsLE(NVT)) {
5369 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5373 assert(getTypeAction(
Op.getValueType()) ==
5375 "Only know how to promote this result!");
5378 "Operand over promoted?");
5380 SplitInteger(Res,
Lo,
Hi);
5388void DAGTypeLegalizer::
5391 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5394 if (EVT.
bitsLE(
Lo.getValueType())) {
5402 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5403 Hi.getValueType(), dl));
5414void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5416 EVT VT =
N->getValueType(0);
5418 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5427 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5429 TargetLowering::MakeLibCallOptions CallOptions;
5431 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5434void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5436 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5446void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5448 EVT VT =
N->getValueType(0);
5467 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5468 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5469 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5471 EVT BitVT =
N->getValueType(1);
5472 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5474 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5476 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5477 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5496 SplitInteger(Three,
Lo,
Hi);
5500 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5505 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5510 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5514 if (LCImpl == RTLIB::Unsupported ||
5516 DAG.getMachineFunction().getName()) {
5519 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5520 N->getOperand(1), MulLo, MulHi);
5525 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5526 SplitInteger(MulLo,
Lo,
Hi);
5527 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5531 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5534 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5535 MachinePointerInfo());
5539 EVT ArgVT =
Op.getValueType();
5541 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5542 Entry.IsSExt =
true;
5543 Entry.IsZExt =
false;
5544 Args.push_back(Entry);
5548 TargetLowering::ArgListEntry
Entry(
5550 Entry.IsSExt =
true;
5551 Entry.IsZExt =
false;
5552 Args.push_back(Entry);
5554 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5556 TargetLowering::CallLoweringInfo CLI(DAG);
5559 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5560 Func, std::move(Args))
5563 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5565 SplitInteger(CallInfo.first,
Lo,
Hi);
5567 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5568 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5569 DAG.getConstant(0, dl, PtrVT),
5572 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5575void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5577 EVT VT =
N->getValueType(0);
5579 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5589 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5591 if (isTypeLegal(NVT)) {
5593 GetExpandedInteger(
N->getOperand(0), InL, InH);
5595 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5604 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5606 TargetLowering::MakeLibCallOptions CallOptions;
5607 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5610void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5612 EVT VT =
N->getValueType(0);
5614 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5624 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5626 if (isTypeLegal(NVT)) {
5628 GetExpandedInteger(
N->getOperand(0), InL, InH);
5630 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5639 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5641 TargetLowering::MakeLibCallOptions CallOptions;
5642 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5645void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5647 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5650 if (
Op.getValueType().bitsLE(NVT)) {
5653 Hi = DAG.getConstant(0, dl, NVT);
5657 assert(getTypeAction(
Op.getValueType()) ==
5659 "Only know how to promote this result!");
5662 "Operand over promoted?");
5664 SplitInteger(Res,
Lo,
Hi);
5666 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5672void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5676 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5678 SDValue Swap = DAG.getAtomicCmpSwap(
5687void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5691 SDValue Res = TLI.expandVecReduce(
N, DAG);
5692 SplitInteger(Res,
Lo,
Hi);
5695void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5701 N->getOperand(0),
N->getOperand(1));
5702 SplitInteger(Res,
Lo,
Hi);
5709 GetExpandedInteger(
N->getOperand(0), In3, In4);
5710 GetExpandedInteger(
N->getOperand(1), In1, In2);
5714 unsigned Opc =
N->getOpcode();
5717 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5722 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5724 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5728 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5729 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5734 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5735 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5740 SDValue Res = TLI.expandCLMUL(
N, DAG);
5741 return SplitInteger(Res,
Lo,
Hi);
5745 GetExpandedInteger(
N->getOperand(0), LL, LH);
5746 GetExpandedInteger(
N->getOperand(1), RL, RH);
5760 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5764 SDValue Res = TLI.expandPEXT(
N, DAG);
5765 SplitInteger(Res,
Lo,
Hi);
5769 SDValue Res = TLI.expandPDEP(
N, DAG);
5770 SplitInteger(Res,
Lo,
Hi);
5775 EVT VT =
N->getValueType(0);
5782 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5785 SplitInteger(Res,
Lo,
Hi);
5792 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5793 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5795 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5796 Lo = DAG.getPOISON(LoVT);
5797 Hi = DAG.getPOISON(HiVT);
5804 EVT VT =
N->getSimpleValueType(0);
5805 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5807 "VectorIdxTy should be smaller than type to be expanded?");
5811 SplitInteger(Res,
Lo,
Hi);
5822bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5826 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5829 switch (
N->getOpcode()) {
5832 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5833 N->dump(&DAG);
dbgs() <<
"\n";
5838 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5842 Res = ExpandOp_FAKE_USE(
N);
5846 Res = TLI.expandLoopDependenceMask(
N, DAG);
5852 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5865 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5870 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5874 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5877 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5879 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5880 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5881 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5884 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5889 if (!Res.
getNode())
return false;
5897 "Invalid operand expansion");
5899 ReplaceValueWith(
SDValue(
N, 0), Res);
5905void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5909 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5910 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5911 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5924 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5931 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5932 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5962 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5963 RHSLo, LowCC,
false, DagCombineInfo, dl);
5965 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5968 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5969 RHSHi, CCCode,
false, DagCombineInfo, dl);
5973 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5982 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5984 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5993 if (LHSHi == RHSHi) {
6002 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
6003 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
6006 if (HasSETCCCARRY) {
6009 bool FlipOperands =
false;
6026 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
6030 DAG.getCondCode(CCCode));
6036 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
6037 false, DagCombineInfo, dl);
6040 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
6041 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
6048 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6053 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6058 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
6059 DAG.getCondCode(CCCode), NewLHS, NewRHS,
6060 N->getOperand(4)), 0);
6066 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6071 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6076 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6077 N->getOperand(2),
N->getOperand(3),
6078 DAG.getCondCode(CCCode)), 0);
6084 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6089 "Unexpected setcc expansion!");
6095 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6103 SDLoc dl = SDLoc(
N);
6105 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6106 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6107 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6120 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6130 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6131 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6135 return TLI.expandCMP(
N, DAG);
6143 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6144 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6148 bool IsStrict =
N->isStrictFPOpcode();
6152 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6153 EVT DstVT =
N->getValueType(0);
6156 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6157 "Don't know how to expand this XINT_TO_FP!");
6158 TargetLowering::MakeLibCallOptions CallOptions;
6160 std::pair<SDValue, SDValue> Tmp =
6161 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6166 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6167 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6172 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6175 return ExpandOp_NormalStore(
N, OpNo);
6178 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6180 EVT VT =
N->getOperand(1).getValueType();
6181 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6185 AAMDNodes AAInfo =
N->getAAInfo();
6191 if (
N->getMemoryVT().bitsLE(NVT)) {
6192 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6193 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6194 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6198 if (DAG.getDataLayout().isLittleEndian()) {
6200 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6202 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6205 unsigned ExcessBits =
6212 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6213 N->getPointerInfo().getWithOffset(IncrementSize),
6214 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6220 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6222 EVT ExtVT =
N->getMemoryVT();
6225 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6233 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6237 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6241 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6242 N->getBaseAlign(), MMOFlags, AAInfo);
6247 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6248 N->getPointerInfo().getWithOffset(IncrementSize),
6250 N->getBaseAlign(), MMOFlags, AAInfo);
6256 GetExpandedInteger(
N->getOperand(0), InL, InH);
6265 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6270SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6271 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6272 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6276 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6278 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6281SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6284 "cannot use llvm.write_register with illegal type", Fn,
6287 return N->getOperand(0);
6290SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6293 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6294 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6297 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6300SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6302 unsigned Factor =
N->getNumOperands();
6305 for (
unsigned i = 0; i != Factor; i++)
6306 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6311 for (
unsigned i = 0; i != Factor; i++)
6317SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6319 EVT OutVT =
N->getValueType(0);
6320 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6321 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6325 SDValue BaseIdx =
N->getOperand(1);
6342 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6346 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6352 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6361 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6365 "Promoted operand has an element type greater than result");
6378 InOp0 = GetPromotedInteger(InOp0);
6385 Ops.reserve(OutNumElems);
6386 for (
unsigned i = 0; i != OutNumElems; ++i) {
6391 N->getOperand(0), Index);
6392 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6397 return DAG.getBuildVector(NOutVT, dl,
Ops);
6400SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6401 EVT OutVT =
N->getValueType(0);
6402 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6403 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6415 Vec = GetPromotedInteger(Vec);
6421SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6424 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6430SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6432 EVT VT =
N->getValueType(0);
6437 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6438 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6441 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6445 EVT OutVT =
N->getValueType(0);
6446 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6447 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6448 unsigned NumElems =
N->getNumOperands();
6455 Ops.reserve(NumElems);
6456 for (
unsigned i = 0; i != NumElems; ++i) {
6458 EVT OpVT =
Op.getValueType();
6463 if (OpVT.
bitsLT(NOutVTElem)) {
6469 ExtOpc = NOutExtOpc;
6470 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6475 return DAG.getBuildVector(NOutVT, dl,
Ops);
6482 assert(!
N->getOperand(0).getValueType().isVector() &&
6483 "Input must be a scalar");
6485 EVT OutVT =
N->getValueType(0);
6486 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6487 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6491 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6496 EVT OutVT =
N->getValueType(0);
6497 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6499 "Type must be promoted to a scalable vector type");
6500 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6501 return DAG.getStepVector(dl, NOutVT,
6505SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6508 EVT OutVT =
N->getValueType(0);
6509 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6510 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6512 unsigned NumOperands =
N->getNumOperands();
6517 SDUse *MaxSizedValue = std::max_element(
6519 EVT AVT = A.getValueType().getVectorElementType();
6520 EVT BVT = B.getValueType().getVectorElementType();
6521 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6527 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6529 EVT OpVT =
Op.getValueType();
6531 Op = GetPromotedInteger(
Op);
6534 "Unhandled legalization type");
6538 Op = DAG.getAnyExtOrTrunc(
6546 return DAG.getAnyExtOrTrunc(
6554 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6555 assert(NumElem * NumOperands == NumOutElem &&
6556 "Unexpected number of elements");
6560 for (
unsigned i = 0; i < NumOperands; ++i) {
6563 Op = GetPromotedInteger(
Op);
6564 EVT SclrTy =
Op.getValueType().getVectorElementType();
6565 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6566 "Unexpected number of elements");
6568 for (
unsigned j = 0;
j < NumElem; ++
j) {
6570 DAG.getVectorIdxConstant(j, dl));
6571 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6575 return DAG.getBuildVector(NOutVT, dl,
Ops);
6578SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6579 EVT VT =
N->getValueType(0);
6580 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6581 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6589 if (getTypeAction(
N->getOperand(0).getValueType())
6593 switch(
N->getOpcode()) {
6595 Promoted = SExtPromotedInteger(
N->getOperand(0));
6598 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6601 Promoted = GetPromotedInteger(
N->getOperand(0));
6613 DAG.getVectorIdxConstant(0, dl));
6615 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6619 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6622SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6623 EVT VT =
N->getValueType(0);
6624 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6628SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6629 EVT VT =
N->getValueType(0);
6630 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6635 EVT VT =
N->getValueType(0);
6636 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6638 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6642SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6644 EVT VT =
N->getValueType(0);
6645 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6646 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6647 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6651SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6652 EVT OutVT =
N->getValueType(0);
6653 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6654 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6659 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6662 NOutVTElem,
N->getOperand(1));
6664 V0, ConvElem,
N->getOperand(2));
6671 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6672 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6680 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6681 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6682 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6686 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6689 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6690 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6698 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6703SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6706 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6708 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6709 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6710 return DAG.getPOISON(NVT);
6713SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6715 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6716 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6717 TLI.getVectorIdxTy(DAG.getDataLayout()));
6724 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6727SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6732 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6735 V1.getValueType().getVectorElementType(),
6737 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6739 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6748 EVT InVT1 =
V1.getValueType();
6751 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6752 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6755SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6757 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6765SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6768 EVT ResVT =
N->getValueType(0);
6769 unsigned NumElems =
N->getNumOperands();
6772 SDValue ResVec = DAG.getUNDEF(ResVT);
6776 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6778 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6790 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6791 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6795 for (
unsigned i=0; i<NumElem; ++i) {
6798 DAG.getVectorIdxConstant(i, dl));
6804 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6807SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
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++)
6846SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6859 for (
unsigned I = 0;
I < OpNo;
I++)
6862 EVT Ty =
Op.getValueType();
6863 SDLoc
DL = SDLoc(
N);
6866 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6874 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6879 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(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
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_MATCH
VECTOR_MATCH - this corresponds to the llvm.experimental.vector.match intrinsic.
@ 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)