32#define DEBUG_TYPE "legalize-types"
42void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
47 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
52 switch (
N->getOpcode()) {
55 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
56 N->dump(&DAG);
dbgs() <<
"\n";
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_POISON:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
73 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
76 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
77 case ISD::VP_CTTZ_ZERO_POISON:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
83 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
84 case ISD::VP_CTTZ_ELTS:
85 Res = PromoteIntRes_VP_CttzElements(
N);
88 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
98 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
104 Res = PromoteIntRes_Select(
N);
109 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
111 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
113 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
116 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
118 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
120 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
122 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
123 case ISD::VP_TRUNCATE:
126 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
127 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
131 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
135 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
137 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
140 Res = PromoteIntRes_VECTOR_SPLICE(
N);
144 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
147 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
149 Res = PromoteIntRes_BUILD_VECTOR(
N);
153 Res = PromoteIntRes_ScalarOp(
N);
157 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
162 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
165 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
169 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
175 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
179 case ISD::VP_SIGN_EXTEND:
181 case ISD::VP_ZERO_EXTEND:
184 case ISD::VP_FP_TO_SINT:
185 case ISD::VP_FP_TO_UINT:
193 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
197 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
201 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
216 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
226 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
236 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
240 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
244 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
248 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
250 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
252 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
268 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
270 case ISD::VP_SADDSAT:
271 case ISD::VP_UADDSAT:
272 case ISD::VP_SSUBSAT:
273 case ISD::VP_USUBSAT:
274 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
279 Res = PromoteIntRes_CMP(
N);
294 Res = PromoteIntRes_ABS(
N);
328 Res = PromoteIntRes_VECREDUCE(
N);
331 case ISD::VP_REDUCE_ADD:
332 case ISD::VP_REDUCE_MUL:
333 case ISD::VP_REDUCE_AND:
334 case ISD::VP_REDUCE_OR:
335 case ISD::VP_REDUCE_XOR:
336 case ISD::VP_REDUCE_SMAX:
337 case ISD::VP_REDUCE_SMIN:
338 case ISD::VP_REDUCE_UMAX:
339 case ISD::VP_REDUCE_UMIN:
340 Res = PromoteIntRes_VP_REDUCE(
N);
345 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
349 Res = PromoteIntRes_FREEZE(
N);
354 Res = PromoteIntRes_Rotate(
N);
359 Res = PromoteIntRes_FunnelShift(
N);
364 Res = PromoteIntRes_VPFunnelShift(
N);
370 Res = PromoteIntRes_CLMUL(
N);
374 Res = PromoteIntRes_IS_FPCLASS(
N);
377 Res = PromoteIntRes_FFREXP(
N);
382 Res = PromoteIntRes_XRINT(
N);
386 Res = PromoteIntRes_PATCHPOINT(
N);
389 Res = PromoteIntRes_READ_REGISTER(
N);
395 SetPromotedInteger(
SDValue(
N, ResNo), Res);
400 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
401 return GetPromotedInteger(
Op);
404SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
406 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
407 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
412 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
414 Op.getValueType(),
Op,
N->getOperand(1));
419 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
421 Op.getValueType(),
Op,
N->getOperand(1));
425 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
428 switch (TLI.getExtendForAtomicOps()) {
444 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
445 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
455 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
457 Op2 = SExtPromotedInteger(Op2);
460 Op2 = ZExtPromotedInteger(Op2);
463 Op2 = GetPromotedInteger(Op2);
468 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
470 N->getChain(),
N->getBasePtr(),
471 Op2,
N->getMemOperand());
482 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
483 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
487 if (!TLI.isTypeLegal(SVT))
490 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
491 SDValue Res = DAG.getAtomicCmpSwap(
493 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
497 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
503 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
504 switch (TLI.getExtendForAtomicCmpSwapArg()) {
506 Op2 = SExtPromotedInteger(Op2);
509 Op2 = ZExtPromotedInteger(Op2);
512 Op2 = GetPromotedInteger(Op2);
519 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
520 SDValue Res = DAG.getAtomicCmpSwap(
521 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
522 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
524 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
532 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
533 EVT OutVT =
N->getValueType(0);
534 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
537 switch (getTypeAction(InVT)) {
543 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
547 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
550 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
558 BitConvertToInteger(GetScalarizedVector(InOp)));
567 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
568 Lo = BitConvertToInteger(
Lo);
569 Hi = BitConvertToInteger(
Hi);
571 if (DAG.getDataLayout().isBigEndian())
577 JoinIntegers(
Lo,
Hi));
592 if (DAG.getDataLayout().isBigEndian()) {
596 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
611 if (isTypeLegal(WideOutVT)) {
612 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
614 DAG.getVectorIdxConstant(0, dl));
623 DAG.getDataLayout().isLittleEndian()) {
634 if (isTypeLegal(WideVecVT)) {
636 DAG.getUNDEF(WideVecVT), InOp,
637 DAG.getVectorIdxConstant(0, dl));
645 CreateStackStoreLoad(InOp, OutVT));
649 SDValue V = GetPromotedInteger(
N->getOperand(0));
651 V.getValueType(), V);
655 SDValue Op = GetPromotedInteger(
N->getOperand(0));
656 EVT OVT =
N->getValueType(0);
657 EVT NVT =
Op.getValueType();
665 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
666 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
671 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
677 return DAG.getNode(ISD::VP_SRL, dl, NVT,
678 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
683 SDValue Op = GetPromotedInteger(
N->getOperand(0));
684 EVT OVT =
N->getValueType(0);
685 EVT NVT =
Op.getValueType();
694 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
699 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
705 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
706 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
714 TLI.getTypeToTransformTo(*DAG.getContext(),
715 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
720 EVT VT =
N->getValueType(0);
727 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
734 EVT OVT =
N->getValueType(0);
735 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
741 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
742 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
744 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
750 unsigned CtlzOpcode =
N->getOpcode();
751 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
753 SDValue ExtractLeadingBits = DAG.getConstant(
756 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
760 if (!
N->isVPOpcode())
761 return DAG.getNode(
ISD::SUB, dl, NVT,
762 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
766 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
767 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
768 ExtractLeadingBits, Mask, EVL,
772 CtlzOpcode == ISD::VP_CTLZ_ZERO_POISON) {
774 SDValue Op = GetPromotedInteger(
N->getOperand(0));
778 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
779 if (!
N->isVPOpcode()) {
781 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
786 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
787 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
793 EVT OVT =
N->getValueType(0);
794 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
797 SDValue ExtractLeadingBits = DAG.getConstant(
800 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
806 EVT OVT =
N->getValueType(0);
807 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
815 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
816 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
823 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
824 if (!
N->isVPOpcode())
825 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
829 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
834 SDValue Op = GetPromotedInteger(
N->getOperand(0));
835 EVT OVT =
N->getValueType(0);
836 EVT NVT =
Op.getValueType();
843 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
844 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
848 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
854 unsigned NewOpc =
N->getOpcode();
855 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
862 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
866 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
867 N->getOperand(1),
N->getOperand(2));
868 NewOpc = ISD::VP_CTTZ_ZERO_POISON;
871 if (!
N->isVPOpcode())
872 return DAG.getNode(NewOpc, dl, NVT,
Op);
873 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
876SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
878 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
879 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
882SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
884 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
891 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
897 EVT SVT =
In.getValueType().getScalarType();
900 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
908 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
910 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
914 if (
N->isStrictFPOpcode()) {
915 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
916 {
N->getOperand(0),
N->getOperand(1)});
920 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
921 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
924 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
936 N->getOpcode() == ISD::VP_FP_TO_UINT)
940 DAG.getValueType(
N->getValueType(0).getScalarType()));
943SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
945 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
947 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
951SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
952 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
955 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
958SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
959 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
962 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
963 N->getOperand(0),
N->getOperand(1));
969 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
971 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
975 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
979 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
988 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
991 if (getTypeAction(
N->getOperand(0).getValueType())
993 SDValue Res = GetPromotedInteger(
N->getOperand(0));
1002 DAG.getValueType(
N->getOperand(0).getValueType()));
1004 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
1011 if (
N->getNumOperands() != 1) {
1012 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1013 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1014 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1015 N->getOperand(1),
N->getOperand(2));
1017 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1022 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1026 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1027 N->getMemoryVT(),
N->getMemOperand());
1036 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1037 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1040 :
N->getExtensionType();
1043 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1044 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1045 N->getMemOperand(),
N->isExpandingLoad());
1053 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1054 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1061 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1062 N->getOffset(),
N->getMask(), ExtPassThru,
1063 N->getMemoryVT(),
N->getMemOperand(),
1064 N->getAddressingMode(), ExtType,
1065 N->isExpandingLoad());
1073 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1074 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1076 "Gather result type and the passThru argument type should be the same");
1083 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1084 N->getIndex(),
N->getScale() };
1085 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1086 N->getMemoryVT(), dl,
Ops,
1087 N->getMemOperand(),
N->getIndexType(),
1095SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1096 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1097 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1099 N->getOperand(1), Passthru);
1106 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1107 EVT VT =
N->getValueType(0);
1108 EVT SVT = getSetCCResultType(VT);
1109 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1110 unsigned NumOps =
N->getNumOperands();
1113 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1121 ReplaceValueWith(
SDValue(
N, 0), Res);
1124 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1127template <
class MatchContextClass>
1139 MatchContextClass matcher(DAG, TLI,
N);
1141 unsigned Opcode = matcher.getRootBaseOpcode();
1147 SExtOrZExtPromotedOperands(Op1, Op2);
1153 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1155 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1156 Op1 = SExtPromotedInteger(Op1);
1157 Op2 = SExtPromotedInteger(Op2);
1158 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1161 Op1 = ZExtPromotedInteger(Op1);
1162 Op2 = ZExtPromotedInteger(Op2);
1165 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1167 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1174 Op1 = GetPromotedInteger(Op1);
1176 Op2 = ZExtPromotedInteger(Op2);
1178 Op1 = SExtPromotedInteger(Op1);
1179 Op2 = SExtPromotedInteger(Op2);
1186 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1199 "addition, subtraction or left shift");
1202 unsigned SHLAmount = NewBits - OldBits;
1204 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1209 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1210 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1216 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1217 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1218 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1219 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1220 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1227 SDValue Op1Promoted, Op2Promoted;
1233 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1234 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1236 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1237 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1239 EVT OldType =
N->getOperand(0).getValueType();
1251 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1252 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1253 Op2Promoted,
N->getOperand(2));
1255 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1256 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1258 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1263 unsigned SatW,
bool Signed,
1266 EVT VT = V.getValueType();
1293 EVT VT =
LHS.getValueType();
1309 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1315 "Tried to saturate to more than the original type?");
1324 SDValue Op1Promoted, Op2Promoted;
1330 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1331 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1333 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1334 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1337 unsigned Scale =
N->getConstantOperandVal(2);
1341 if (TLI.isTypeLegal(PromotedType)) {
1343 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1346 N->getValueType(0).getScalarSizeInBits();
1350 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1351 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1352 Op2Promoted,
N->getOperand(2));
1355 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1361 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1362 Op2Promoted, Scale, DAG)) {
1365 N->getValueType(0).getScalarSizeInBits(),
1373 N->getValueType(0).getScalarSizeInBits());
1376SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1378 return PromoteIntRes_Overflow(
N);
1382 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1383 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1384 EVT OVT =
N->getOperand(0).getValueType();
1385 EVT NVT =
LHS.getValueType();
1395 DAG.getValueType(OVT));
1397 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1400 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1406 EVT PromotedResultTy =
1407 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1408 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1409 N->getOperand(0),
N->getOperand(1));
1415 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1416 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1418 unsigned Opcode =
N->getOpcode();
1419 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1420 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1422 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1426 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1427 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1429 LHS.getValueType(),
N->getOperand(0),
1430 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1435 EVT InVT =
N->getOperand(OpNo).getValueType();
1436 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1438 EVT SVT = getSetCCResultType(InVT);
1445 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1446 SVT = getSetCCResultType(InVT);
1454 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1455 "Vector compare must return a vector result!");
1459 if (
N->isStrictFPOpcode()) {
1460 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1461 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1462 N->getOperand(2),
N->getOperand(3)};
1463 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1468 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1469 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1472 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1479 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1484 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1485 EVT VT =
N->getValueType(0);
1489 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1491 ReplaceValueWith(
SDValue(
N, 0), Res);
1496 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1499 RHS = ZExtPromotedInteger(
RHS);
1500 if (
N->getOpcode() != ISD::VP_SHL)
1501 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1509SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1510 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1512 Op.getValueType(),
Op,
N->getOperand(1));
1515SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1519 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1520 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1521 if (
N->getNumOperands() == 2)
1522 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1523 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1524 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1525 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1526 N->getOperand(2),
N->getOperand(3));
1531 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1532 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1533 if (
N->getNumOperands() == 2)
1534 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1535 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1536 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1545 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1546 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1547 if (
N->getNumOperands() == 2)
1548 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1549 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1550 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1558SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1559 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1560 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1562 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1566SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1567 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1568 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1570 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1580 SExtOrZExtPromotedOperands(
LHS,
RHS);
1582 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1588 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1591 RHS = ZExtPromotedInteger(
RHS);
1592 if (
N->getOpcode() != ISD::VP_SRA)
1593 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1604 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1606 RHS = ZExtPromotedInteger(
RHS);
1607 if (
N->getOpcode() != ISD::VP_SRL)
1608 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1618 SDValue Res = TLI.expandROT(
N,
true , DAG);
1619 ReplaceValueWith(
SDValue(
N, 0), Res);
1624 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1625 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1628 Amt = ZExtPromotedInteger(Amt);
1632 EVT OldVT =
N->getOperand(0).getValueType();
1633 EVT VT =
Lo.getValueType();
1634 unsigned Opcode =
N->getOpcode();
1641 DAG.getConstant(OldBits,
DL, AmtVT));
1649 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1650 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1652 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1662 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1668 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1670 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1674SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1675 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1676 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1681 Amt = ZExtPromotedInteger(Amt);
1685 EVT OldVT =
N->getOperand(0).getValueType();
1686 EVT VT =
Lo.getValueType();
1687 unsigned Opcode =
N->getOpcode();
1688 bool IsFSHR = Opcode == ISD::VP_FSHR;
1693 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1694 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1702 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1703 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1704 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1705 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1707 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1710 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1715 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1716 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1721 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1723 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1727 unsigned Opcode =
N->getOpcode();
1730 EVT OldVT =
N->getOperand(0).getValueType();
1731 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1734 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1735 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1738 SDValue X = GetPromotedInteger(
N->getOperand(0));
1739 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1743 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1744 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1748 if (NewBits < 2 * OldBits) {
1750 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1752 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1754 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1756 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1761 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1763 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1767 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1779 Res = GetPromotedInteger(InOp);
1786 "Dst and Src must have the same number of elements");
1788 "Promoted vector type must be a power of two");
1791 GetSplitVector(InOp, EOp1, EOp2);
1799 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1800 "Expected VP_TRUNCATE opcode");
1801 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1802 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1803 std::tie(EVLLo, EVLHi) =
1804 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1805 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1806 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1813 SDValue WideInOp = GetWidenedVector(InOp);
1818 N->getValueType(0).getScalarType(), NumElem);
1827 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1833 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1834 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1839SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1841 return PromoteIntRes_Overflow(
N);
1845 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1846 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1847 EVT OVT =
N->getOperand(0).getValueType();
1848 EVT NVT =
LHS.getValueType();
1857 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1859 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1862 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1873 return PromoteIntRes_Overflow(
N);
1885 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1886 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1888 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1891 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1902 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1903 return PromoteIntRes_Overflow(
N);
1907 EVT OVT =
N->getValueType(0);
1908 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1914 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1916 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1917 if (
SDValue Res = TLI.expandABS(
N, DAG))
1921 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1925SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1928 return PromoteIntRes_Overflow(
N);
1932 EVT SmallVT =
LHS.getValueType();
1939 LHS = SExtPromotedInteger(
LHS);
1940 RHS = SExtPromotedInteger(
RHS);
1942 LHS = ZExtPromotedInteger(
LHS);
1943 RHS = ZExtPromotedInteger(
RHS);
1945 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1957 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1958 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1959 DAG.getConstant(0,
DL,
Hi.getValueType()),
1964 Mul, DAG.getValueType(SmallVT));
1974 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1979 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1980 N->getValueType(0)));
1984 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1986 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1993 EVT VT =
N->getValueType(0);
1996 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1997 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
2001 for (
unsigned i = 0; i < NumRegs; ++i) {
2002 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2003 N->getConstantOperandVal(3));
2008 if (DAG.getDataLayout().isBigEndian())
2009 std::reverse(Parts.begin(), Parts.end());
2012 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2014 for (
unsigned i = 1; i < NumRegs; ++i) {
2019 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2025 ReplaceValueWith(
SDValue(
N, 1), Chain);
2038bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2041 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2046 switch (
N->getOpcode()) {
2049 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2050 N->dump(&DAG);
dbgs() <<
"\n";
2056 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2062 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2063 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2068 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2072 Res = PromoteIntOp_FAKE_USE(
N);
2075 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2079 Res = PromoteIntOp_ScalarOp(
N);
2082 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2085 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2087 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2088 case ISD::VP_SINT_TO_FP:
2105 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2107 case ISD::VP_TRUNCATE:
2111 case ISD::VP_UINT_TO_FP:
2114 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2119 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2130 Res = PromoteIntOp_Shift(
N);
2134 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2137 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2163 case ISD::VP_REDUCE_ADD:
2164 case ISD::VP_REDUCE_MUL:
2165 case ISD::VP_REDUCE_AND:
2166 case ISD::VP_REDUCE_OR:
2167 case ISD::VP_REDUCE_XOR:
2168 case ISD::VP_REDUCE_SMAX:
2169 case ISD::VP_REDUCE_SMIN:
2170 case ISD::VP_REDUCE_UMAX:
2171 case ISD::VP_REDUCE_UMIN:
2172 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2177 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2180 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2183 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2185 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2186 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2187 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2189 case ISD::EXPERIMENTAL_VP_SPLICE:
2190 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2193 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2198 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2201 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2207 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2212 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2216 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2221 if (!Res.
getNode())
return false;
2228 const bool IsStrictFp =
N->isStrictFPOpcode();
2230 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2231 "Invalid operand expansion");
2235 ReplaceValueWith(
SDValue(
N, 0), Res);
2249 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2253 unsigned OpLEffectiveBits =
2254 DAG.computeKnownBits(OpL).countMaxActiveBits();
2255 unsigned OpREffectiveBits =
2256 DAG.computeKnownBits(OpR).countMaxActiveBits();
2257 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2258 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2265 LHS = SExtPromotedInteger(
LHS);
2266 RHS = SExtPromotedInteger(
RHS);
2275 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2276 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2277 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2278 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2285 LHS = ZExtPromotedInteger(
LHS);
2286 RHS = ZExtPromotedInteger(
RHS);
2300 LHS = SExtPromotedInteger(
LHS);
2301 RHS = SExtPromotedInteger(
RHS);
2306 "Unknown integer comparison!");
2308 SExtOrZExtPromotedOperands(
LHS,
RHS);
2312 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2316SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2317 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2318 EVT ResVT =
N->getValueType(0);
2319 EVT OpVT =
Op.getValueType();
2322 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2327 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2328 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2329 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2333 EVT OutVT =
N->getValueType(0);
2336 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2339 switch (getTypeAction(InVT)) {
2343 DAG.getDataLayout().isLittleEndian()) {
2353 if (isTypeLegal(WideVecVT)) {
2354 SDValue Promoted = GetPromotedInteger(InOp);
2357 DAG.getVectorIdxConstant(0, dl));
2370 return CreateStackStoreLoad(InOp, OutVT);
2373SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2374 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2382 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2383 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2387SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2388 assert(OpNo == 1 &&
"only know how to promote condition");
2391 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2394 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2395 N->getOperand(2)), 0);
2398SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2399 assert(OpNo == 1 &&
"only know how to promote condition");
2402 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2405 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2410 EVT OVT =
N->getOperand(0).getValueType();
2411 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2412 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2413 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2418 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2419 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2428 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2429 "Legal vector of one illegal element?");
2434 assert(
N->getOperand(0).getValueSizeInBits() >=
2435 N->getValueType(0).getScalarSizeInBits() &&
2436 "Type of inserted value narrower than vector element type!");
2439 for (
unsigned i = 0; i < NumElts; ++i)
2440 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2442 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2445SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2452 assert(
N->getOperand(1).getValueSizeInBits() >=
2453 N->getValueType(0).getScalarSizeInBits() &&
2454 "Type of inserted value narrower than vector element type!");
2455 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2456 GetPromotedInteger(
N->getOperand(1)),
2461 assert(OpNo == 2 &&
"Different operand and result vector types?");
2464 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2465 TLI.getVectorIdxTy(DAG.getDataLayout()));
2466 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2467 N->getOperand(1), Idx), 0);
2471 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2475 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2478SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2479 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2481 EVT OpTy =
N->getOperand(1).getValueType();
2484 if (
SDValue Res = WidenVSELECTMask(
N))
2485 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2486 Res,
N->getOperand(1),
N->getOperand(2));
2490 Cond = PromoteTargetBoolean(
Cond, OpVT);
2492 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2493 N->getOperand(2)), 0);
2496SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2497 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2505 N->getOperand(3),
N->getOperand(4)), 0);
2508SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2509 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2517 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2519 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2522 N->getOperand(3),
N->getOperand(4)),
2527 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2528 ZExtPromotedInteger(
N->getOperand(1))), 0);
2536 LHS = SExtPromotedInteger(
LHS);
2537 RHS = SExtPromotedInteger(
RHS);
2539 SExtOrZExtPromotedOperands(
LHS,
RHS);
2546 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2547 ZExtPromotedInteger(
N->getOperand(2))), 0);
2551 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2555 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2558SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2560 EVT VT =
N->getValueType(0);
2561 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2563 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2567 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2569 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2571 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2576 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2577 return SDValue(DAG.UpdateNodeOperands(
N,
2578 SExtPromotedInteger(
N->getOperand(0)),
2579 N->getOperand(1),
N->getOperand(2)),
2581 return SDValue(DAG.UpdateNodeOperands(
N,
2582 SExtPromotedInteger(
N->getOperand(0))), 0);
2585SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2586 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2587 SExtPromotedInteger(
N->getOperand(1))), 0);
2592 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2595 SDValue Val = GetPromotedInteger(
N->getValue());
2598 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2599 N->getMemoryVT(),
N->getMemOperand());
2605 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2606 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2608 SDValue DataOp = GetPromotedInteger(
N->getValue());
2609 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2610 N->getMask(),
N->getVectorLength(),
2611 N->getMemoryVT(),
N->getMemOperand(),
2612 N->isCompressingStore());
2623 Mask = PromoteTargetBoolean(Mask, DataVT);
2626 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2629 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2630 DataOp = GetPromotedInteger(DataOp);
2632 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2633 N->getOffset(), Mask,
N->getMemoryVT(),
2634 N->getMemOperand(),
N->getAddressingMode(),
2635 true,
N->isCompressingStore());
2640 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2641 EVT DataVT =
N->getValueType(0);
2642 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2644 NewOps[OpNo] =
Mask;
2645 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2661 EVT DataVT =
N->getValueType(0);
2662 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2663 }
else if (OpNo == 4) {
2665 if (
N->isIndexSigned())
2667 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2669 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2671 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2673 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2685 bool TruncateStore =
N->isTruncatingStore();
2690 EVT DataVT =
N->getValue().getValueType();
2691 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2692 }
else if (OpNo == 4) {
2694 if (
N->isIndexSigned())
2696 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2698 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2700 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2701 TruncateStore =
true;
2704 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2705 SDLoc(
N), NewOps,
N->getMemOperand(),
2706 N->getIndexType(), TruncateStore);
2711 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2715 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2720 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2721 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2722 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2723 N->getOperand(1),
N->getOperand(2));
2728 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2729 return SDValue(DAG.UpdateNodeOperands(
N,
2730 ZExtPromotedInteger(
N->getOperand(0)),
2731 N->getOperand(1),
N->getOperand(2)),
2733 return SDValue(DAG.UpdateNodeOperands(
N,
2734 ZExtPromotedInteger(
N->getOperand(0))), 0);
2737SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2738 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2743SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2744 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2745 ZExtPromotedInteger(
N->getOperand(1))), 0);
2752 EVT VT =
N->getValueType(0);
2757 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2758 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2759 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2760 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2765 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2768SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2770 EVT VT =
N->getValueType(0);
2771 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2773 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2775 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2776 N->getOperand(0).getValueType());
2780 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2782 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2785SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2787 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2788 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2797 unsigned OpOffset = IsStrict ? 1 : 0;
2804 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2805 if (LCImpl == RTLIB::Unsupported) {
2811 if (IsPowI &&
N->getValueType(0).isVector())
2812 return DAG.UnrollVectorOp(
N);
2814 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2815 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2827 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2828 DAG.getLibInfo().getIntSize()) {
2829 const Function &Fn = DAG.getMachineFunction().getFunction();
2830 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2831 Twine(IsPowI ?
"powi" :
"ldexp") +
2832 " exponent does not match sizeof(int)",
2833 Fn, N->getDebugLoc()));
2835 ReplaceValueWith(SDValue(N, 1), Chain);
2836 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2840 TargetLowering::MakeLibCallOptions CallOptions;
2841 CallOptions.setIsSigned(
true);
2842 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2843 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2844 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2845 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2847 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2852 switch (
N->getOpcode()) {
2860 case ISD::VP_REDUCE_ADD:
2861 case ISD::VP_REDUCE_MUL:
2862 case ISD::VP_REDUCE_AND:
2863 case ISD::VP_REDUCE_OR:
2864 case ISD::VP_REDUCE_XOR:
2868 case ISD::VP_REDUCE_SMAX:
2869 case ISD::VP_REDUCE_SMIN:
2873 case ISD::VP_REDUCE_UMAX:
2874 case ISD::VP_REDUCE_UMIN:
2884 return GetPromotedInteger(V);
2886 return SExtPromotedInteger(V);
2888 return ZExtPromotedInteger(V);
2894 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2896 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2897 EVT InVT =
Op.getValueType();
2899 EVT ResVT =
N->getValueType(0);
2900 unsigned Opcode =
N->getOpcode();
2917 switch (TLI.getBooleanContents(InVT)) {
2920 Op = ZExtPromotedInteger(
N->getOperand(0));
2923 Op = SExtPromotedInteger(
N->getOperand(0));
2936 switch (TLI.getBooleanContents(InVT)) {
2939 Op = ZExtPromotedInteger(
N->getOperand(0));
2942 Op = SExtPromotedInteger(
N->getOperand(0));
2948 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2952 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2956SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2963 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2964 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2967 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2969 Op = PromoteIntOpVectorReduction(
N,
Op);
2973 EVT VT =
N->getValueType(0);
2974 EVT EltVT =
Op.getValueType().getScalarType();
2977 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2989 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2990 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2993SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2996 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2997 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3000SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3003 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3004 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3009 const Function &Fn = DAG.getMachineFunction().getFunction();
3011 "cannot use llvm.write_register with illegal type", Fn,
3013 return N->getOperand(0);
3016SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3017 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3018 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3021 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3022 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3032SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3036 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3037 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3040 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3042 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3043 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3046SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3048 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3050 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3051 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3054SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3056 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3060 if (TLI.getBooleanContents(
Op.getValueType()) ==
3062 NewOp = SExtPromotedInteger(
Op);
3064 NewOp = ZExtPromotedInteger(
Op);
3066 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3069SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3071 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3072 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3073 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3076SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3079 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3080 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3083SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3085 switch (
N->getOpcode()) {
3087 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3088 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3091 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3092 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3095 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3096 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3101 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3104SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3106 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3107 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3108 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3110 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3121void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3127 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3130 switch (
N->getOpcode()) {
3133 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3134 N->dump(&DAG);
dbgs() <<
"\n";
3163 ExpandIntRes_ABS(
N,
Lo,
Hi);
3215 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3216 SplitInteger(Tmp.first,
Lo,
Hi);
3217 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3222 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3223 SDValue Tmp = DAG.getAtomicCmpSwap(
3225 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3234 SplitInteger(Tmp,
Lo,
Hi);
3313 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3318 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3324 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3328 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3332 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3337 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3347std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3348 unsigned Opc =
Node->getOpcode();
3354 EVT RetVT =
Node->getValueType(0);
3355 TargetLowering::MakeLibCallOptions CallOptions;
3358 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3359 if (LCImpl != RTLIB::Unsupported) {
3361 Ops.push_back(
Node->getOperand(1));
3364 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3365 "Unexpected atomic op or value type!");
3367 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3369 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3370 Node->getOperand(0));
3375void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3380 GetExpandedInteger(
N->getOperand(0), InL, InH);
3395 if (Amt.
uge(VTBits)) {
3396 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3397 }
else if (Amt.
ugt(NVTBits)) {
3398 Lo = DAG.getConstant(0,
DL, NVT);
3400 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3401 }
else if (Amt == NVTBits) {
3402 Lo = DAG.getConstant(0,
DL, NVT);
3406 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3408 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3410 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3415 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3417 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3424 if (Amt.
uge(VTBits)) {
3425 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3426 }
else if (Amt.
ugt(NVTBits)) {
3428 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3429 Hi = DAG.getConstant(0,
DL, NVT);
3430 }
else if (Amt == NVTBits) {
3432 Hi = DAG.getConstant(0,
DL, NVT);
3435 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3437 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3442 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3444 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3447 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3453 if (Amt.
uge(VTBits)) {
3455 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3456 }
else if (Amt.
ugt(NVTBits)) {
3458 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3460 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3461 }
else if (Amt == NVTBits) {
3464 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3467 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3469 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3474 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3476 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3479 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3487bool DAGTypeLegalizer::
3489 unsigned Opc =
N->getOpcode();
3492 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3497 "Expanded integer type size not a power of two!");
3501 KnownBits Known = DAG.computeKnownBits(Amt);
3504 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3509 GetExpandedInteger(In, InL, InH);
3516 DAG.getConstant(~HighBitMask, dl, ShTy));
3521 Lo = DAG.getConstant(0, dl, NVT);
3522 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3525 Hi = DAG.getConstant(0, dl, NVT);
3526 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3530 DAG.getConstant(NVTBits - 1, dl, ShTy));
3531 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3543 DAG.getConstant(NVTBits - 1, dl, ShTy));
3559 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3561 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3563 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3564 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3576bool DAGTypeLegalizer::
3579 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3583 "Expanded integer type size not a power of two!");
3588 GetExpandedInteger(
N->getOperand(0), InL, InH);
3590 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3593 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3596 Amt, DAG.getConstant(0, dl, ShTy),
3600 switch (
N->getOpcode()) {
3606 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3607 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3610 LoL = DAG.getConstant(0, dl, NVT);
3613 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3614 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3615 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3621 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3624 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3627 HiL = DAG.getConstant(0, dl, NVT);
3630 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3631 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3632 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3638 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3639 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3643 DAG.getConstant(NVTBits - 1, dl, ShTy));
3646 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3647 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3648 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3673 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3678 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3679 SplitInteger(Res,
Lo,
Hi);
3682void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3691 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3692 unsigned NumHalfBits = NumBits / 2;
3693 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3694 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3695 SDValue LHSL, LHSH, RHSL, RHSH;
3696 GetExpandedInteger(
LHS, LHSL, LHSH);
3697 GetExpandedInteger(
RHS, RHSL, RHSH);
3700 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3702 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3710 SDValue LHSL, LHSH, RHSL, RHSH;
3711 GetExpandedInteger(
LHS, LHSL, LHSH);
3712 GetExpandedInteger(
RHS, RHSL, RHSH);
3714 EVT CCT = getSetCCResultType(NVT);
3717 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3719 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3721 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3723 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3727 const APInt *RHSVal =
nullptr;
3729 RHSVal = &RHSConst->getAPIntValue();
3736 SDValue LHSL, LHSH, RHSL, RHSH;
3737 GetExpandedInteger(
LHS, LHSL, LHSH);
3738 GetExpandedInteger(
RHS, RHSL, RHSH);
3740 EVT CCT = getSetCCResultType(NVT);
3746 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3749 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3753 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3756 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3758 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3765 switch (
N->getOpcode()) {
3792 EVT VT =
N->getValueType(0);
3793 EVT CCT = getSetCCResultType(VT);
3796 SplitInteger(Result,
Lo,
Hi);
3800 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3801 SplitInteger(ExpandedCMP,
Lo,
Hi);
3804void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3808 SDValue LHSL, LHSH, RHSL, RHSH;
3809 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3810 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3813 SDValue LoOps[2] = { LHSL, RHSL };
3814 SDValue HiOps[3] = { LHSH, RHSH };
3816 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3818 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3820 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3824 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3830 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3843 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3845 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3848 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3862 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3864 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3868 EVT OvfVT = getSetCCResultType(NVT);
3869 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3884 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3887 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3891 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3903 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3907 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3910 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3913 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3918 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3920 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3921 DAG.getConstant(0, dl, NVT));
3924 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3933 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3938 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3940 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3941 DAG.getConstant(0, dl, NVT));
3947void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3950 SDValue LHSL, LHSH, RHSL, RHSH;
3952 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3953 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3954 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3955 SDValue LoOps[2] = { LHSL, RHSL };
3956 SDValue HiOps[3] = { LHSH, RHSH };
3970 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3973void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3976 SDValue LHSL, LHSH, RHSL, RHSH;
3978 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3979 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3980 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3982 SDValue HiOps[3] = { LHSH, RHSH };
3984 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3986 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3990 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3993void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4001 unsigned CarryOp, NoCarryOp;
4003 switch(
N->getOpcode()) {
4018 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4019 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4023 SDValue LHSL, LHSH, RHSL, RHSH;
4024 GetExpandedInteger(
LHS, LHSL, LHSH);
4025 GetExpandedInteger(
RHS, RHSL, RHSH);
4026 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4027 SDValue LoOps[2] = { LHSL, RHSL };
4028 SDValue HiOps[3] = { LHSH, RHSH };
4030 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4032 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4039 SplitInteger(Sum,
Lo,
Hi);
4045 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4046 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4050 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4055 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4061 ReplaceValueWith(
SDValue(
N, 1), Ovf);
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(),
N->getValueType(1));
4075 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4077 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4081 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4084void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4087 SDValue LHSL, LHSH, RHSL, RHSH;
4089 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4090 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4091 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4096 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4097 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4101 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4104void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4106 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4109 if (
Op.getValueType().bitsLE(NVT)) {
4112 Hi = DAG.getUNDEF(NVT);
4116 assert(getTypeAction(
Op.getValueType()) ==
4118 "Only know how to promote this result!");
4121 "Operand over promoted?");
4123 SplitInteger(Res,
Lo,
Hi);
4127void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4130 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4131 EVT NVT =
Lo.getValueType();
4136 if (NVTBits < EVTBits) {
4139 EVTBits - NVTBits)));
4144 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4148void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4151 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4152 EVT NVT =
Lo.getValueType();
4157 if (NVTBits < EVTBits) {
4160 EVTBits - NVTBits)));
4164 Hi = DAG.getConstant(0, dl, NVT);
4168void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4171 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4176void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4179 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4188 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4189 EVT NVT =
Lo.getValueType();
4192 Hi = DAG.getConstant(0, dl, NVT);
4195void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4197 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4200 const APInt &Cst =
Constant->getAPIntValue();
4201 bool IsTarget =
Constant->isTargetOpcode();
4202 bool IsOpaque =
Constant->isOpaque();
4204 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4205 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4213 GetExpandedInteger(N0,
Lo,
Hi);
4214 EVT NVT =
Lo.getValueType();
4219 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4224 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4225 Hi = DAG.getConstant(0, dl, NVT);
4235 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4240 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4241 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4250 EVT VT =
N->getValueType(0);
4252 DAG.getConstant(0, dl, VT), N0);
4254 SplitInteger(Neg, NegLo, NegHi);
4256 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4258 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4259 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4262void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4266 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4267 EVT NVT =
Lo.getValueType();
4269 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4272 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4275 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4276 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4279 Hi = DAG.getConstant(0, dl, NVT);
4287 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4288 EVT NVT =
Lo.getValueType();
4291 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4292 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4295 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4298 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4300 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4302 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4303 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4305 Hi = DAG.getConstant(0, dl, NVT);
4310 SplitInteger(Result,
Lo,
Hi);
4315 EVT VT =
N->getValueType(0);
4320 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4321 "LibCall explicitly requested, but not available");
4323 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4324 TargetLowering::MakeLibCallOptions CallOptions;
4328 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4329 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4337 GetExpandedInteger(
Op,
Lo,
Hi);
4338 EVT NVT =
Lo.getValueType();
4341 Hi = DAG.getConstant(0,
DL, NVT);
4344void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4348 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4349 EVT NVT =
Lo.getValueType();
4351 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4357 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4358 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4361 Hi = DAG.getConstant(0, dl, NVT);
4367 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4374 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4378 ReplaceValueWith(
SDValue(
N, 1), Chain);
4386 Chain =
Op.getValue(1);
4395 EVT VT =
N->getValueType(0);
4399 bool IsStrict =
N->isStrictFPOpcode();
4401 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4405 Op.getValueType() == MVT::bf16) {
4411 EVT OpVT =
Op.getValueType();
4415 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4416 TargetLowering::MakeLibCallOptions CallOptions;
4421 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4422 CallOptions, dl, Chain);
4423 SplitInteger(Tmp.first,
Lo,
Hi);
4426 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4431 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4432 SplitInteger(Res,
Lo,
Hi);
4438 bool IsStrict =
N->isStrictFPOpcode();
4439 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4442 EVT VT =
Op.getValueType();
4444 if (VT == MVT::f16) {
4450 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4454 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4458 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4462 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4466 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4470 EVT RetVT =
N->getValueType(0);
4472 TargetLowering::MakeLibCallOptions CallOptions;
4474 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4475 Op, CallOptions, dl,
4477 SplitInteger(Tmp.first,
Lo,
Hi);
4479 if (
N->isStrictFPOpcode())
4480 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4483void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4485 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4488 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4494 EVT VT =
N->getValueType(0);
4495 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4500 AAMDNodes AAInfo =
N->getAAInfo();
4505 if (
N->getMemoryVT().bitsLE(NVT)) {
4506 EVT MemVT =
N->getMemoryVT();
4508 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4509 N->getBaseAlign(), MMOFlags, AAInfo);
4517 unsigned LoSize =
Lo.getValueSizeInBits();
4519 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4522 Hi = DAG.getConstant(0, dl, NVT);
4526 Hi = DAG.getUNDEF(NVT);
4528 }
else if (DAG.getDataLayout().isLittleEndian()) {
4530 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4533 unsigned ExcessBits =
4540 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4541 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4542 N->getBaseAlign(), MMOFlags, AAInfo);
4551 EVT MemVT =
N->getMemoryVT();
4554 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4557 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4560 N->getBaseAlign(), MMOFlags, AAInfo);
4566 N->getPointerInfo().getWithOffset(IncrementSize),
4568 N->getBaseAlign(), MMOFlags, AAInfo);
4580 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4584 DAG.getShiftAmountConstant(
4591 ReplaceValueWith(
SDValue(
N, 1), Ch);
4594void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4598 GetExpandedInteger(
N->getOperand(0), LL, LH);
4599 GetExpandedInteger(
N->getOperand(1), RL, RH);
4603 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4605 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4606 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4609void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4611 EVT VT =
N->getValueType(0);
4612 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4616 GetExpandedInteger(
N->getOperand(0), LL, LH);
4617 GetExpandedInteger(
N->getOperand(1), RL, RH);
4619 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4626 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4627 if (LCImpl == RTLIB::Unsupported) {
4630 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4636 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4637 TargetLowering::MakeLibCallOptions CallOptions;
4639 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4646 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4647 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4648 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4651 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4656 SplitInteger(Result,
Lo,
Hi);
4662 SplitInteger(Result,
Lo,
Hi);
4668 SplitInteger(Result,
Lo,
Hi);
4679 EVT VT =
N->getValueType(0);
4683 uint64_t Scale =
N->getConstantOperandVal(2);
4695 EVT BoolVT = getSetCCResultType(VT);
4697 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4703 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4704 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4710 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4711 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4716 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4717 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4720 SplitInteger(Result,
Lo,
Hi);
4726 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4728 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4730 GetExpandedInteger(
LHS, LL, LH);
4731 GetExpandedInteger(
RHS, RL, RH);
4735 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4742 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4743 SplitInteger(LoTmp, Result[0], Result[1]);
4744 SplitInteger(HiTmp, Result[2], Result[3]);
4746 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4749 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4750 "the size of the current value type");
4771 uint64_t Part0 = Scale / NVTSize;
4772 if (Scale % NVTSize) {
4773 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4776 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4788 if (Scale == VTSize)
4807 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4808 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4809 EVT BoolNVT = getSetCCResultType(NVT);
4812 if (Scale < NVTSize) {
4815 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4816 DAG.getShiftAmountConstant(Scale, NVT, dl));
4817 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4818 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4819 }
else if (Scale == NVTSize) {
4821 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4822 }
else if (Scale < VTSize) {
4826 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4827 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4830 "(and saturation can't happen with Scale==VTSize).");
4832 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4833 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4837 if (Scale < NVTSize) {
4842 unsigned OverflowBits = VTSize - Scale + 1;
4843 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4844 "Extent of overflow bits must start within HL");
4845 SDValue HLHiMask = DAG.getConstant(
4847 SDValue HLLoMask = DAG.getConstant(
4854 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4860 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4861 }
else if (Scale == NVTSize) {
4867 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4873 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4874 }
else if (Scale < VTSize) {
4877 unsigned OverflowBits = VTSize - Scale + 1;
4878 SDValue HHHiMask = DAG.getConstant(
4880 SDValue HHLoMask = DAG.getConstant(
4882 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4883 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4890 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4891 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4894 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4895 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4902 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4904 N->getConstantOperandVal(2), DAG);
4908 N->getConstantOperandVal(2), TLI, DAG);
4909 SplitInteger(Res,
Lo,
Hi);
4912void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4915 "Node has unexpected Opcode");
4925 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4926 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4930 SDValue LHSL, LHSH, RHSL, RHSH;
4931 GetExpandedInteger(
LHS, LHSL, LHSH);
4932 GetExpandedInteger(
RHS, RHSL, RHSH);
4933 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4936 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4945 SplitInteger(Sum,
Lo,
Hi);
4970 EVT VT =
LHS.getValueType();
4973 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4977 EVT OType =
Node->getValueType(1);
4978 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4982 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4985void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4987 EVT VT =
N->getValueType(0);
4989 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4998 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5000 TargetLowering::MakeLibCallOptions CallOptions;
5002 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5005void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5008 SDValue Shiftee =
N->getOperand(0);
5015 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5016 }
while (!TLI.isTypeLegal(LoadVT));
5021 "Shifting unit is not a a power of two!");
5023 const bool IsOneStepShift =
5024 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5029 if (!IsOneStepShift)
5030 ShAmt = DAG.getFreeze(ShAmt);
5033 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5034 unsigned VTByteWidth = VTBitWidth / 8;
5036 "Shiftee type size is not a power of two!");
5037 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5038 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5043 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5045 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5046 EVT PtrTy =
StackPtr.getValueType();
5047 SDValue Ch = DAG.getEntryNode();
5050 DAG.getMachineFunction(),
5056 unsigned WideningOpc =
5058 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5061 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5065 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5071 Flags.setExact(IsOneStepShift);
5074 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5076 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5077 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5080 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5085 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5092 if (DAG.getDataLayout().isBigEndian())
5093 WillIndexUpwards = !WillIndexUpwards;
5096 if (WillIndexUpwards) {
5099 AdjStackPtr = DAG.getMemBasePlusOffset(
5100 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5101 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5105 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5106 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5110 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5115 if (!IsOneStepShift) {
5117 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5118 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5119 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5123 SplitInteger(Res,
Lo,
Hi);
5126void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5128 EVT VT =
N->getValueType(0);
5129 unsigned Opc =
N->getOpcode();
5135 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5139 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5156 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5158 const bool LegalOrCustom =
5162 unsigned ExpansionFactor = 1;
5164 for (EVT TmpVT = NVT;;) {
5165 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5166 if (NewTMPVT == TmpVT)
5173 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5176 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5178 if (LegalOrCustom &&
5182 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5188 SDValue ShiftOp =
N->getOperand(1);
5189 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5191 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5194 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5195 Hi =
Lo.getValue(1);
5200 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5214 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5217 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5219 TargetLowering::MakeLibCallOptions CallOptions;
5222 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5227 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5231void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5233 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5236 if (
Op.getValueType().bitsLE(NVT)) {
5242 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5246 assert(getTypeAction(
Op.getValueType()) ==
5248 "Only know how to promote this result!");
5251 "Operand over promoted?");
5253 SplitInteger(Res,
Lo,
Hi);
5261void DAGTypeLegalizer::
5264 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5267 if (EVT.
bitsLE(
Lo.getValueType())) {
5275 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5276 Hi.getValueType(), dl));
5287void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5289 EVT VT =
N->getValueType(0);
5291 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5300 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5302 TargetLowering::MakeLibCallOptions CallOptions;
5304 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5307void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5309 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5319void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5321 EVT VT =
N->getValueType(0);
5340 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5341 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5342 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5344 EVT BitVT =
N->getValueType(1);
5345 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5347 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5349 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5350 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5369 SplitInteger(Three,
Lo,
Hi);
5373 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5378 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5383 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5387 if (LCImpl == RTLIB::Unsupported ||
5389 DAG.getMachineFunction().getName()) {
5392 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5393 N->getOperand(1), MulLo, MulHi);
5398 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5399 SplitInteger(MulLo,
Lo,
Hi);
5400 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5404 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5407 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5408 MachinePointerInfo());
5412 EVT ArgVT =
Op.getValueType();
5414 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5415 Entry.IsSExt =
true;
5416 Entry.IsZExt =
false;
5417 Args.push_back(Entry);
5421 TargetLowering::ArgListEntry
Entry(
5423 Entry.IsSExt =
true;
5424 Entry.IsZExt =
false;
5425 Args.push_back(Entry);
5427 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5429 TargetLowering::CallLoweringInfo CLI(DAG);
5432 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5433 Func, std::move(Args))
5436 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5438 SplitInteger(CallInfo.first,
Lo,
Hi);
5440 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5441 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5442 DAG.getConstant(0, dl, PtrVT),
5445 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5448void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5450 EVT VT =
N->getValueType(0);
5452 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5462 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5464 if (isTypeLegal(NVT)) {
5466 GetExpandedInteger(
N->getOperand(0), InL, InH);
5468 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5477 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5479 TargetLowering::MakeLibCallOptions CallOptions;
5480 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5483void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5485 EVT VT =
N->getValueType(0);
5487 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5497 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5499 if (isTypeLegal(NVT)) {
5501 GetExpandedInteger(
N->getOperand(0), InL, InH);
5503 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5512 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5514 TargetLowering::MakeLibCallOptions CallOptions;
5515 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5518void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5520 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5523 if (
Op.getValueType().bitsLE(NVT)) {
5526 Hi = DAG.getConstant(0, dl, NVT);
5530 assert(getTypeAction(
Op.getValueType()) ==
5532 "Only know how to promote this result!");
5535 "Operand over promoted?");
5537 SplitInteger(Res,
Lo,
Hi);
5539 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5545void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5549 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5551 SDValue Swap = DAG.getAtomicCmpSwap(
5560void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5564 SDValue Res = TLI.expandVecReduce(
N, DAG);
5565 SplitInteger(Res,
Lo,
Hi);
5568void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5574 N->getOperand(0),
N->getOperand(1));
5575 SplitInteger(Res,
Lo,
Hi);
5582 GetExpandedInteger(
N->getOperand(0), In3, In4);
5583 GetExpandedInteger(
N->getOperand(1), In1, In2);
5587 unsigned Opc =
N->getOpcode();
5590 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5595 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5597 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5601 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5602 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5607 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5608 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5613 SDValue Res = TLI.expandCLMUL(
N, DAG);
5614 return SplitInteger(Res,
Lo,
Hi);
5618 GetExpandedInteger(
N->getOperand(0), LL, LH);
5619 GetExpandedInteger(
N->getOperand(1), RL, RH);
5633 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5638 EVT VT =
N->getValueType(0);
5645 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5648 SplitInteger(Res,
Lo,
Hi);
5655 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5656 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5658 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5659 Lo = DAG.getPOISON(LoVT);
5660 Hi = DAG.getPOISON(HiVT);
5667 EVT VT =
N->getSimpleValueType(0);
5668 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5670 "VectorIdxTy should be smaller than type to be expanded?");
5674 SplitInteger(Res,
Lo,
Hi);
5685bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5689 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5692 switch (
N->getOpcode()) {
5695 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5696 N->dump(&DAG);
dbgs() <<
"\n";
5701 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5705 Res = ExpandOp_FAKE_USE(
N);
5709 Res = TLI.expandLoopDependenceMask(
N, DAG);
5715 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5728 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5733 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5737 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5740 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5742 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5743 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5744 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5747 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5752 if (!Res.
getNode())
return false;
5760 "Invalid operand expansion");
5762 ReplaceValueWith(
SDValue(
N, 0), Res);
5768void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5772 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5773 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5774 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5787 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5794 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5795 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5825 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5826 RHSLo, LowCC,
false, DagCombineInfo, dl);
5828 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5831 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5832 RHSHi, CCCode,
false, DagCombineInfo, dl);
5836 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5845 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5847 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5856 if (LHSHi == RHSHi) {
5865 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5866 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5869 if (HasSETCCCARRY) {
5872 bool FlipOperands =
false;
5889 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5893 DAG.getCondCode(CCCode));
5899 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5900 false, DagCombineInfo, dl);
5903 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5904 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5911 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5916 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5921 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5922 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5923 N->getOperand(4)), 0);
5929 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5934 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5939 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5940 N->getOperand(2),
N->getOperand(3),
5941 DAG.getCondCode(CCCode)), 0);
5947 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5952 "Unexpected setcc expansion!");
5958 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5966 SDLoc dl = SDLoc(
N);
5968 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5969 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5970 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5983 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5993 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5994 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5998 return TLI.expandCMP(
N, DAG);
6006 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6007 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6011 bool IsStrict =
N->isStrictFPOpcode();
6015 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6016 EVT DstVT =
N->getValueType(0);
6019 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6020 "Don't know how to expand this XINT_TO_FP!");
6021 TargetLowering::MakeLibCallOptions CallOptions;
6023 std::pair<SDValue, SDValue> Tmp =
6024 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6029 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6030 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6035 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6038 return ExpandOp_NormalStore(
N, OpNo);
6041 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6043 EVT VT =
N->getOperand(1).getValueType();
6044 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6048 AAMDNodes AAInfo =
N->getAAInfo();
6054 if (
N->getMemoryVT().bitsLE(NVT)) {
6055 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6056 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6057 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6061 if (DAG.getDataLayout().isLittleEndian()) {
6063 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6065 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6068 unsigned ExcessBits =
6075 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6076 N->getPointerInfo().getWithOffset(IncrementSize),
6077 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6083 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6085 EVT ExtVT =
N->getMemoryVT();
6088 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6096 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6100 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6104 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6105 N->getBaseAlign(), MMOFlags, AAInfo);
6110 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6111 N->getPointerInfo().getWithOffset(IncrementSize),
6113 N->getBaseAlign(), MMOFlags, AAInfo);
6119 GetExpandedInteger(
N->getOperand(0), InL, InH);
6128 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6133SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6134 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6135 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6139 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6141 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6144SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6147 "cannot use llvm.write_register with illegal type", Fn,
6150 return N->getOperand(0);
6153SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6156 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6157 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6160 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6163SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6165 unsigned Factor =
N->getNumOperands();
6168 for (
unsigned i = 0; i != Factor; i++)
6169 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6174 for (
unsigned i = 0; i != Factor; i++)
6180SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6182 EVT OutVT =
N->getValueType(0);
6183 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6184 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6188 SDValue BaseIdx =
N->getOperand(1);
6205 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6209 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6215 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6224 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6228 "Promoted operand has an element type greater than result");
6241 InOp0 = GetPromotedInteger(InOp0);
6248 Ops.reserve(OutNumElems);
6249 for (
unsigned i = 0; i != OutNumElems; ++i) {
6254 N->getOperand(0), Index);
6255 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6260 return DAG.getBuildVector(NOutVT, dl,
Ops);
6263SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6264 EVT OutVT =
N->getValueType(0);
6265 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6266 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6278 Vec = GetPromotedInteger(Vec);
6284SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6287 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6293SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6295 EVT VT =
N->getValueType(0);
6300 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6301 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6304 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6308 EVT OutVT =
N->getValueType(0);
6309 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6310 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6311 unsigned NumElems =
N->getNumOperands();
6318 Ops.reserve(NumElems);
6319 for (
unsigned i = 0; i != NumElems; ++i) {
6321 EVT OpVT =
Op.getValueType();
6326 if (OpVT.
bitsLT(NOutVTElem)) {
6332 ExtOpc = NOutExtOpc;
6333 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6338 return DAG.getBuildVector(NOutVT, dl,
Ops);
6345 assert(!
N->getOperand(0).getValueType().isVector() &&
6346 "Input must be a scalar");
6348 EVT OutVT =
N->getValueType(0);
6349 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6350 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6354 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6359 EVT OutVT =
N->getValueType(0);
6360 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6362 "Type must be promoted to a scalable vector type");
6363 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6364 return DAG.getStepVector(dl, NOutVT,
6368SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6371 EVT OutVT =
N->getValueType(0);
6372 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6373 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6375 unsigned NumOperands =
N->getNumOperands();
6380 SDUse *MaxSizedValue = std::max_element(
6382 EVT AVT = A.getValueType().getVectorElementType();
6383 EVT BVT = B.getValueType().getVectorElementType();
6384 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6390 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6392 EVT OpVT =
Op.getValueType();
6394 Op = GetPromotedInteger(
Op);
6397 "Unhandled legalization type");
6401 Op = DAG.getAnyExtOrTrunc(
6409 return DAG.getAnyExtOrTrunc(
6417 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6418 assert(NumElem * NumOperands == NumOutElem &&
6419 "Unexpected number of elements");
6423 for (
unsigned i = 0; i < NumOperands; ++i) {
6426 Op = GetPromotedInteger(
Op);
6427 EVT SclrTy =
Op.getValueType().getVectorElementType();
6428 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6429 "Unexpected number of elements");
6431 for (
unsigned j = 0;
j < NumElem; ++
j) {
6433 DAG.getVectorIdxConstant(j, dl));
6434 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6438 return DAG.getBuildVector(NOutVT, dl,
Ops);
6441SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6442 EVT VT =
N->getValueType(0);
6443 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6444 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6452 if (getTypeAction(
N->getOperand(0).getValueType())
6456 switch(
N->getOpcode()) {
6458 Promoted = SExtPromotedInteger(
N->getOperand(0));
6461 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6464 Promoted = GetPromotedInteger(
N->getOperand(0));
6476 DAG.getVectorIdxConstant(0, dl));
6478 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6482 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6485SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6486 EVT VT =
N->getValueType(0);
6487 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6491SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6492 EVT VT =
N->getValueType(0);
6493 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6497SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6499 EVT VT =
N->getValueType(0);
6500 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6501 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6502 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6506SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6507 EVT OutVT =
N->getValueType(0);
6508 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6509 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6514 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6517 NOutVTElem,
N->getOperand(1));
6519 V0, ConvElem,
N->getOperand(2));
6526 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6527 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6535 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6536 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6537 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6541 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6544 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6545 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6553 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6558SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6561 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6563 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6564 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6565 return DAG.getPOISON(NVT);
6568SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6570 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6571 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6572 TLI.getVectorIdxTy(DAG.getDataLayout()));
6579 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6582SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6587 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6590 V1.getValueType().getVectorElementType(),
6592 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6594 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6603 EVT InVT1 =
V1.getValueType();
6606 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6607 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6610SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6612 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6620SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6623 EVT ResVT =
N->getValueType(0);
6624 unsigned NumElems =
N->getNumOperands();
6627 SDValue ResVec = DAG.getUNDEF(ResVT);
6631 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6633 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6645 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6646 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6650 for (
unsigned i=0; i<NumElem; ++i) {
6653 DAG.getVectorIdxConstant(i, dl));
6659 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6662SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6675 for (
unsigned I = 0;
I < OpNo;
I++)
6678 EVT Ty =
Op.getValueType();
6679 SDLoc
DL = SDLoc(
N);
6682 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6690 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6695 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6701SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6714 for (
unsigned I = 0;
I < OpNo;
I++)
6717 EVT Ty =
Op.getValueType();
6718 SDLoc
DL = SDLoc(
N);
6721 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6729 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6734 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool isSigned(unsigned Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V, bool LookThroughCmp=false)
Returns the "element type" of the given value/instruction V.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getValueType() const
Convenience function for get().getValueType().
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
ArrayRef< int > getMask() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ LOOP_DEPENDENCE_RAW_MASK
@ COND_LOOP
COND_LOOP is a conditional branch to self, used for implementing efficient conditional traps.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
The llvm.loop.dependence.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLRINT(EVT RetVT)
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getLLRINT(EVT RetVT)
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)