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);
2825 assert(DAG.getLibInfo().getIntSize() ==
2826 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2827 "POWI exponent should match with sizeof(int) when doing the libcall.");
2828 TargetLowering::MakeLibCallOptions CallOptions;
2830 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2831 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2832 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2833 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2835 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2840 switch (
N->getOpcode()) {
2848 case ISD::VP_REDUCE_ADD:
2849 case ISD::VP_REDUCE_MUL:
2850 case ISD::VP_REDUCE_AND:
2851 case ISD::VP_REDUCE_OR:
2852 case ISD::VP_REDUCE_XOR:
2856 case ISD::VP_REDUCE_SMAX:
2857 case ISD::VP_REDUCE_SMIN:
2861 case ISD::VP_REDUCE_UMAX:
2862 case ISD::VP_REDUCE_UMIN:
2872 return GetPromotedInteger(V);
2874 return SExtPromotedInteger(V);
2876 return ZExtPromotedInteger(V);
2882 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2884 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2885 EVT InVT =
Op.getValueType();
2887 EVT ResVT =
N->getValueType(0);
2888 unsigned Opcode =
N->getOpcode();
2905 switch (TLI.getBooleanContents(InVT)) {
2908 Op = ZExtPromotedInteger(
N->getOperand(0));
2911 Op = SExtPromotedInteger(
N->getOperand(0));
2924 switch (TLI.getBooleanContents(InVT)) {
2927 Op = ZExtPromotedInteger(
N->getOperand(0));
2930 Op = SExtPromotedInteger(
N->getOperand(0));
2936 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2940 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2944SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2951 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2952 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2955 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2957 Op = PromoteIntOpVectorReduction(
N,
Op);
2961 EVT VT =
N->getValueType(0);
2962 EVT EltVT =
Op.getValueType().getScalarType();
2965 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2977 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2978 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2981SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2984 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2985 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2988SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2991 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2992 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2997 const Function &Fn = DAG.getMachineFunction().getFunction();
2999 "cannot use llvm.write_register with illegal type", Fn,
3001 return N->getOperand(0);
3004SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3005 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3006 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3009 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3011 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3014SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3018 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3019 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3022 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3024 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3025 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3028SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3030 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3032 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3033 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3036SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3038 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3042 if (TLI.getBooleanContents(
Op.getValueType()) ==
3044 NewOp = SExtPromotedInteger(
Op);
3046 NewOp = ZExtPromotedInteger(
Op);
3048 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3051SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3053 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3054 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3055 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3058SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3061 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3062 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3065SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3067 switch (
N->getOpcode()) {
3069 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3070 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3073 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3074 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3077 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3078 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3083 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3086SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3088 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3089 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3090 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3092 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3103void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3109 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3112 switch (
N->getOpcode()) {
3115 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3116 N->dump(&DAG);
dbgs() <<
"\n";
3145 ExpandIntRes_ABS(
N,
Lo,
Hi);
3197 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3198 SplitInteger(Tmp.first,
Lo,
Hi);
3199 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3204 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3205 SDValue Tmp = DAG.getAtomicCmpSwap(
3207 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3216 SplitInteger(Tmp,
Lo,
Hi);
3295 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3300 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3306 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3310 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3314 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3319 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3329std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3330 unsigned Opc =
Node->getOpcode();
3336 EVT RetVT =
Node->getValueType(0);
3337 TargetLowering::MakeLibCallOptions CallOptions;
3340 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3341 if (LCImpl != RTLIB::Unsupported) {
3343 Ops.push_back(
Node->getOperand(1));
3346 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3347 "Unexpected atomic op or value type!");
3349 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3351 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3352 Node->getOperand(0));
3357void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3362 GetExpandedInteger(
N->getOperand(0), InL, InH);
3377 if (Amt.
uge(VTBits)) {
3378 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3379 }
else if (Amt.
ugt(NVTBits)) {
3380 Lo = DAG.getConstant(0,
DL, NVT);
3382 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3383 }
else if (Amt == NVTBits) {
3384 Lo = DAG.getConstant(0,
DL, NVT);
3388 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3390 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3392 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3397 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3399 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3406 if (Amt.
uge(VTBits)) {
3407 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3408 }
else if (Amt.
ugt(NVTBits)) {
3410 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3411 Hi = DAG.getConstant(0,
DL, NVT);
3412 }
else if (Amt == NVTBits) {
3414 Hi = DAG.getConstant(0,
DL, NVT);
3417 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3419 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3424 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3426 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3429 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3435 if (Amt.
uge(VTBits)) {
3437 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3438 }
else if (Amt.
ugt(NVTBits)) {
3440 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3442 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3443 }
else if (Amt == NVTBits) {
3446 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3449 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3451 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3456 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3458 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3461 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3469bool DAGTypeLegalizer::
3471 unsigned Opc =
N->getOpcode();
3474 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3479 "Expanded integer type size not a power of two!");
3483 KnownBits Known = DAG.computeKnownBits(Amt);
3486 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3491 GetExpandedInteger(In, InL, InH);
3498 DAG.getConstant(~HighBitMask, dl, ShTy));
3503 Lo = DAG.getConstant(0, dl, NVT);
3504 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3507 Hi = DAG.getConstant(0, dl, NVT);
3508 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3512 DAG.getConstant(NVTBits - 1, dl, ShTy));
3513 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3525 DAG.getConstant(NVTBits - 1, dl, ShTy));
3541 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3543 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3545 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3546 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3558bool DAGTypeLegalizer::
3561 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3565 "Expanded integer type size not a power of two!");
3570 GetExpandedInteger(
N->getOperand(0), InL, InH);
3572 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3575 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3578 Amt, DAG.getConstant(0, dl, ShTy),
3582 switch (
N->getOpcode()) {
3588 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3589 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3592 LoL = DAG.getConstant(0, dl, NVT);
3595 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3596 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3597 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3603 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3606 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3609 HiL = DAG.getConstant(0, dl, NVT);
3612 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3613 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3614 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3620 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3621 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3625 DAG.getConstant(NVTBits - 1, dl, ShTy));
3628 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3629 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3630 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3655 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3660 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3661 SplitInteger(Res,
Lo,
Hi);
3664void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3673 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3674 unsigned NumHalfBits = NumBits / 2;
3675 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3676 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3677 SDValue LHSL, LHSH, RHSL, RHSH;
3678 GetExpandedInteger(
LHS, LHSL, LHSH);
3679 GetExpandedInteger(
RHS, RHSL, RHSH);
3682 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3684 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3692 SDValue LHSL, LHSH, RHSL, RHSH;
3693 GetExpandedInteger(
LHS, LHSL, LHSH);
3694 GetExpandedInteger(
RHS, RHSL, RHSH);
3696 EVT CCT = getSetCCResultType(NVT);
3699 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3701 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3703 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3705 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3709 const APInt *RHSVal =
nullptr;
3711 RHSVal = &RHSConst->getAPIntValue();
3718 SDValue LHSL, LHSH, RHSL, RHSH;
3719 GetExpandedInteger(
LHS, LHSL, LHSH);
3720 GetExpandedInteger(
RHS, RHSL, RHSH);
3722 EVT CCT = getSetCCResultType(NVT);
3728 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3731 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3735 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3738 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3740 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3747 switch (
N->getOpcode()) {
3774 EVT VT =
N->getValueType(0);
3775 EVT CCT = getSetCCResultType(VT);
3778 SplitInteger(Result,
Lo,
Hi);
3782 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3783 SplitInteger(ExpandedCMP,
Lo,
Hi);
3786void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3790 SDValue LHSL, LHSH, RHSL, RHSH;
3791 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3792 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3795 SDValue LoOps[2] = { LHSL, RHSL };
3796 SDValue HiOps[3] = { LHSH, RHSH };
3798 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3800 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3802 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3806 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3812 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3825 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3827 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3830 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3844 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3846 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3850 EVT OvfVT = getSetCCResultType(NVT);
3851 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3866 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3869 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3873 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3885 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3889 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3892 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3895 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3900 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3902 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3903 DAG.getConstant(0, dl, NVT));
3906 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3915 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3920 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3922 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3923 DAG.getConstant(0, dl, NVT));
3929void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3932 SDValue LHSL, LHSH, RHSL, RHSH;
3934 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3935 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3936 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3937 SDValue LoOps[2] = { LHSL, RHSL };
3938 SDValue HiOps[3] = { LHSH, RHSH };
3952 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3955void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3958 SDValue LHSL, LHSH, RHSL, RHSH;
3960 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3961 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3962 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3964 SDValue HiOps[3] = { LHSH, RHSH };
3966 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3968 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3972 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3975void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3983 unsigned CarryOp, NoCarryOp;
3985 switch(
N->getOpcode()) {
4000 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4001 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4005 SDValue LHSL, LHSH, RHSL, RHSH;
4006 GetExpandedInteger(
LHS, LHSL, LHSH);
4007 GetExpandedInteger(
RHS, RHSL, RHSH);
4008 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4009 SDValue LoOps[2] = { LHSL, RHSL };
4010 SDValue HiOps[3] = { LHSH, RHSH };
4012 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4014 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4021 SplitInteger(Sum,
Lo,
Hi);
4027 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4028 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4032 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4037 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4043 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4049 SDValue LHSL, LHSH, RHSL, RHSH;
4051 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4052 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4053 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4057 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4059 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4063 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4066void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4069 SDValue LHSL, LHSH, RHSL, RHSH;
4071 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4072 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4073 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4078 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4079 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4083 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4086void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4088 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4091 if (
Op.getValueType().bitsLE(NVT)) {
4094 Hi = DAG.getUNDEF(NVT);
4098 assert(getTypeAction(
Op.getValueType()) ==
4100 "Only know how to promote this result!");
4103 "Operand over promoted?");
4105 SplitInteger(Res,
Lo,
Hi);
4109void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4112 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4113 EVT NVT =
Lo.getValueType();
4118 if (NVTBits < EVTBits) {
4121 EVTBits - NVTBits)));
4126 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4130void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4133 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4134 EVT NVT =
Lo.getValueType();
4139 if (NVTBits < EVTBits) {
4142 EVTBits - NVTBits)));
4146 Hi = DAG.getConstant(0, dl, NVT);
4150void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4153 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4158void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4161 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4170 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4171 EVT NVT =
Lo.getValueType();
4174 Hi = DAG.getConstant(0, dl, NVT);
4177void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4179 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4182 const APInt &Cst =
Constant->getAPIntValue();
4183 bool IsTarget =
Constant->isTargetOpcode();
4184 bool IsOpaque =
Constant->isOpaque();
4186 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4187 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4195 GetExpandedInteger(N0,
Lo,
Hi);
4196 EVT NVT =
Lo.getValueType();
4201 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4206 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4207 Hi = DAG.getConstant(0, dl, NVT);
4217 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4222 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4223 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4232 EVT VT =
N->getValueType(0);
4234 DAG.getConstant(0, dl, VT), N0);
4236 SplitInteger(Neg, NegLo, NegHi);
4238 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4240 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4241 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4244void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4248 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4249 EVT NVT =
Lo.getValueType();
4251 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4254 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4257 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4258 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4261 Hi = DAG.getConstant(0, dl, NVT);
4269 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4270 EVT NVT =
Lo.getValueType();
4273 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4274 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4277 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4280 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4282 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4284 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4285 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4287 Hi = DAG.getConstant(0, dl, NVT);
4292 SplitInteger(Result,
Lo,
Hi);
4297 EVT VT =
N->getValueType(0);
4302 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4303 "LibCall explicitly requested, but not available");
4305 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4306 TargetLowering::MakeLibCallOptions CallOptions;
4310 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4311 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4319 GetExpandedInteger(
Op,
Lo,
Hi);
4320 EVT NVT =
Lo.getValueType();
4323 Hi = DAG.getConstant(0,
DL, NVT);
4326void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4330 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4331 EVT NVT =
Lo.getValueType();
4333 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4339 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4340 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4343 Hi = DAG.getConstant(0, dl, NVT);
4349 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4356 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4360 ReplaceValueWith(
SDValue(
N, 1), Chain);
4368 Chain =
Op.getValue(1);
4377 EVT VT =
N->getValueType(0);
4381 bool IsStrict =
N->isStrictFPOpcode();
4383 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4387 Op.getValueType() == MVT::bf16) {
4393 EVT OpVT =
Op.getValueType();
4397 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4398 TargetLowering::MakeLibCallOptions CallOptions;
4403 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4404 CallOptions, dl, Chain);
4405 SplitInteger(Tmp.first,
Lo,
Hi);
4408 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4413 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4414 SplitInteger(Res,
Lo,
Hi);
4420 bool IsStrict =
N->isStrictFPOpcode();
4421 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4424 EVT VT =
Op.getValueType();
4426 if (VT == MVT::f16) {
4432 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4436 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4440 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4444 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4448 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4452 EVT RetVT =
N->getValueType(0);
4454 TargetLowering::MakeLibCallOptions CallOptions;
4456 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4457 Op, CallOptions, dl,
4459 SplitInteger(Tmp.first,
Lo,
Hi);
4461 if (
N->isStrictFPOpcode())
4462 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4465void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4467 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4470 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4476 EVT VT =
N->getValueType(0);
4477 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4482 AAMDNodes AAInfo =
N->getAAInfo();
4487 if (
N->getMemoryVT().bitsLE(NVT)) {
4488 EVT MemVT =
N->getMemoryVT();
4490 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4491 N->getBaseAlign(), MMOFlags, AAInfo);
4499 unsigned LoSize =
Lo.getValueSizeInBits();
4501 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4504 Hi = DAG.getConstant(0, dl, NVT);
4508 Hi = DAG.getUNDEF(NVT);
4510 }
else if (DAG.getDataLayout().isLittleEndian()) {
4512 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4515 unsigned ExcessBits =
4522 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4523 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4524 N->getBaseAlign(), MMOFlags, AAInfo);
4533 EVT MemVT =
N->getMemoryVT();
4536 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4539 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4542 N->getBaseAlign(), MMOFlags, AAInfo);
4548 N->getPointerInfo().getWithOffset(IncrementSize),
4550 N->getBaseAlign(), MMOFlags, AAInfo);
4562 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4566 DAG.getShiftAmountConstant(
4573 ReplaceValueWith(
SDValue(
N, 1), Ch);
4576void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4580 GetExpandedInteger(
N->getOperand(0), LL, LH);
4581 GetExpandedInteger(
N->getOperand(1), RL, RH);
4585 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4587 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4588 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4591void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4593 EVT VT =
N->getValueType(0);
4594 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4598 GetExpandedInteger(
N->getOperand(0), LL, LH);
4599 GetExpandedInteger(
N->getOperand(1), RL, RH);
4601 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4608 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4609 if (LCImpl == RTLIB::Unsupported) {
4612 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4618 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4619 TargetLowering::MakeLibCallOptions CallOptions;
4621 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4628 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4629 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4630 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4633 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4638 SplitInteger(Result,
Lo,
Hi);
4644 SplitInteger(Result,
Lo,
Hi);
4650 SplitInteger(Result,
Lo,
Hi);
4661 EVT VT =
N->getValueType(0);
4665 uint64_t Scale =
N->getConstantOperandVal(2);
4677 EVT BoolVT = getSetCCResultType(VT);
4679 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4685 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4686 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4692 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4693 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4698 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4699 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4702 SplitInteger(Result,
Lo,
Hi);
4708 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4710 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4712 GetExpandedInteger(
LHS, LL, LH);
4713 GetExpandedInteger(
RHS, RL, RH);
4717 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4724 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4725 SplitInteger(LoTmp, Result[0], Result[1]);
4726 SplitInteger(HiTmp, Result[2], Result[3]);
4728 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4731 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4732 "the size of the current value type");
4753 uint64_t Part0 = Scale / NVTSize;
4754 if (Scale % NVTSize) {
4755 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4758 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4770 if (Scale == VTSize)
4789 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4790 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4791 EVT BoolNVT = getSetCCResultType(NVT);
4794 if (Scale < NVTSize) {
4797 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4798 DAG.getShiftAmountConstant(Scale, NVT, dl));
4799 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4800 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4801 }
else if (Scale == NVTSize) {
4803 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4804 }
else if (Scale < VTSize) {
4808 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4809 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4812 "(and saturation can't happen with Scale==VTSize).");
4814 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4815 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4819 if (Scale < NVTSize) {
4824 unsigned OverflowBits = VTSize - Scale + 1;
4825 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4826 "Extent of overflow bits must start within HL");
4827 SDValue HLHiMask = DAG.getConstant(
4829 SDValue HLLoMask = DAG.getConstant(
4836 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4842 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4843 }
else if (Scale == NVTSize) {
4849 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4855 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4856 }
else if (Scale < VTSize) {
4859 unsigned OverflowBits = VTSize - Scale + 1;
4860 SDValue HHHiMask = DAG.getConstant(
4862 SDValue HHLoMask = DAG.getConstant(
4864 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4865 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4872 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4873 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4876 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4877 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4884 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4886 N->getConstantOperandVal(2), DAG);
4890 N->getConstantOperandVal(2), TLI, DAG);
4891 SplitInteger(Res,
Lo,
Hi);
4894void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4897 "Node has unexpected Opcode");
4907 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4908 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4912 SDValue LHSL, LHSH, RHSL, RHSH;
4913 GetExpandedInteger(
LHS, LHSL, LHSH);
4914 GetExpandedInteger(
RHS, RHSL, RHSH);
4915 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4918 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4927 SplitInteger(Sum,
Lo,
Hi);
4952 EVT VT =
LHS.getValueType();
4955 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4959 EVT OType =
Node->getValueType(1);
4960 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4964 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4967void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4969 EVT VT =
N->getValueType(0);
4971 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4980 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4982 TargetLowering::MakeLibCallOptions CallOptions;
4984 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4987void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4990 SDValue Shiftee =
N->getOperand(0);
4997 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4998 }
while (!TLI.isTypeLegal(LoadVT));
5003 "Shifting unit is not a a power of two!");
5005 const bool IsOneStepShift =
5006 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5011 if (!IsOneStepShift)
5012 ShAmt = DAG.getFreeze(ShAmt);
5015 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5016 unsigned VTByteWidth = VTBitWidth / 8;
5018 "Shiftee type size is not a power of two!");
5019 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5020 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5025 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5027 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5028 EVT PtrTy =
StackPtr.getValueType();
5029 SDValue Ch = DAG.getEntryNode();
5032 DAG.getMachineFunction(),
5038 unsigned WideningOpc =
5040 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5043 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5047 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5053 Flags.setExact(IsOneStepShift);
5056 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5058 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5059 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5062 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5067 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5074 if (DAG.getDataLayout().isBigEndian())
5075 WillIndexUpwards = !WillIndexUpwards;
5078 if (WillIndexUpwards) {
5081 AdjStackPtr = DAG.getMemBasePlusOffset(
5082 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5083 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5087 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5088 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5092 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5097 if (!IsOneStepShift) {
5099 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5100 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5101 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5105 SplitInteger(Res,
Lo,
Hi);
5108void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5110 EVT VT =
N->getValueType(0);
5111 unsigned Opc =
N->getOpcode();
5117 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5121 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5138 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5140 const bool LegalOrCustom =
5144 unsigned ExpansionFactor = 1;
5146 for (EVT TmpVT = NVT;;) {
5147 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5148 if (NewTMPVT == TmpVT)
5155 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5158 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5160 if (LegalOrCustom &&
5164 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5170 SDValue ShiftOp =
N->getOperand(1);
5171 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5173 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5176 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5177 Hi =
Lo.getValue(1);
5182 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5196 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5199 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5201 TargetLowering::MakeLibCallOptions CallOptions;
5204 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5209 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5213void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5215 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5218 if (
Op.getValueType().bitsLE(NVT)) {
5224 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5228 assert(getTypeAction(
Op.getValueType()) ==
5230 "Only know how to promote this result!");
5233 "Operand over promoted?");
5235 SplitInteger(Res,
Lo,
Hi);
5243void DAGTypeLegalizer::
5246 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5249 if (EVT.
bitsLE(
Lo.getValueType())) {
5257 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5258 Hi.getValueType(), dl));
5269void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5271 EVT VT =
N->getValueType(0);
5273 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5282 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5284 TargetLowering::MakeLibCallOptions CallOptions;
5286 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5289void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5291 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5301void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5303 EVT VT =
N->getValueType(0);
5322 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5323 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5324 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5326 EVT BitVT =
N->getValueType(1);
5327 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5329 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5331 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5332 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5351 SplitInteger(Three,
Lo,
Hi);
5355 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5360 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5365 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5369 if (LCImpl == RTLIB::Unsupported ||
5371 DAG.getMachineFunction().getName()) {
5374 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5375 N->getOperand(1), MulLo, MulHi);
5380 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5381 SplitInteger(MulLo,
Lo,
Hi);
5382 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5386 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5389 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5390 MachinePointerInfo());
5394 EVT ArgVT =
Op.getValueType();
5396 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5397 Entry.IsSExt =
true;
5398 Entry.IsZExt =
false;
5399 Args.push_back(Entry);
5403 TargetLowering::ArgListEntry
Entry(
5405 Entry.IsSExt =
true;
5406 Entry.IsZExt =
false;
5407 Args.push_back(Entry);
5409 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5411 TargetLowering::CallLoweringInfo CLI(DAG);
5414 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5415 Func, std::move(Args))
5418 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5420 SplitInteger(CallInfo.first,
Lo,
Hi);
5422 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5423 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5424 DAG.getConstant(0, dl, PtrVT),
5427 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5430void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5432 EVT VT =
N->getValueType(0);
5434 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5444 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5446 if (isTypeLegal(NVT)) {
5448 GetExpandedInteger(
N->getOperand(0), InL, InH);
5450 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5459 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5461 TargetLowering::MakeLibCallOptions CallOptions;
5462 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5465void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5467 EVT VT =
N->getValueType(0);
5469 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5479 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5481 if (isTypeLegal(NVT)) {
5483 GetExpandedInteger(
N->getOperand(0), InL, InH);
5485 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5494 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5496 TargetLowering::MakeLibCallOptions CallOptions;
5497 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5500void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5502 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5505 if (
Op.getValueType().bitsLE(NVT)) {
5508 Hi = DAG.getConstant(0, dl, NVT);
5512 assert(getTypeAction(
Op.getValueType()) ==
5514 "Only know how to promote this result!");
5517 "Operand over promoted?");
5519 SplitInteger(Res,
Lo,
Hi);
5521 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5527void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5531 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5533 SDValue Swap = DAG.getAtomicCmpSwap(
5542void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5546 SDValue Res = TLI.expandVecReduce(
N, DAG);
5547 SplitInteger(Res,
Lo,
Hi);
5550void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5556 N->getOperand(0),
N->getOperand(1));
5557 SplitInteger(Res,
Lo,
Hi);
5564 GetExpandedInteger(
N->getOperand(0), In3, In4);
5565 GetExpandedInteger(
N->getOperand(1), In1, In2);
5569 unsigned Opc =
N->getOpcode();
5572 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5577 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5579 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5583 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5584 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5589 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5590 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5595 SDValue Res = TLI.expandCLMUL(
N, DAG);
5596 return SplitInteger(Res,
Lo,
Hi);
5600 GetExpandedInteger(
N->getOperand(0), LL, LH);
5601 GetExpandedInteger(
N->getOperand(1), RL, RH);
5615 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5620 EVT VT =
N->getValueType(0);
5627 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5630 SplitInteger(Res,
Lo,
Hi);
5637 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5638 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5640 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5641 Lo = DAG.getPOISON(LoVT);
5642 Hi = DAG.getPOISON(HiVT);
5649 EVT VT =
N->getSimpleValueType(0);
5650 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5652 "VectorIdxTy should be smaller than type to be expanded?");
5656 SplitInteger(Res,
Lo,
Hi);
5667bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5671 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5674 switch (
N->getOpcode()) {
5677 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5678 N->dump(&DAG);
dbgs() <<
"\n";
5683 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5687 Res = ExpandOp_FAKE_USE(
N);
5691 Res = TLI.expandLoopDependenceMask(
N, DAG);
5697 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5710 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5715 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5719 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5722 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5724 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5725 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5726 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5729 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5734 if (!Res.
getNode())
return false;
5742 "Invalid operand expansion");
5744 ReplaceValueWith(
SDValue(
N, 0), Res);
5750void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5754 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5755 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5756 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5769 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5776 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5777 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5807 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5808 RHSLo, LowCC,
false, DagCombineInfo, dl);
5810 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5813 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5814 RHSHi, CCCode,
false, DagCombineInfo, dl);
5818 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5827 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5829 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5838 if (LHSHi == RHSHi) {
5847 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5848 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5851 if (HasSETCCCARRY) {
5854 bool FlipOperands =
false;
5871 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5875 DAG.getCondCode(CCCode));
5881 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5882 false, DagCombineInfo, dl);
5885 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5886 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5893 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5898 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5903 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5904 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5905 N->getOperand(4)), 0);
5911 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5916 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5921 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5922 N->getOperand(2),
N->getOperand(3),
5923 DAG.getCondCode(CCCode)), 0);
5929 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5934 "Unexpected setcc expansion!");
5940 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5948 SDLoc dl = SDLoc(
N);
5950 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5951 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5952 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5965 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5975 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5976 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5980 return TLI.expandCMP(
N, DAG);
5988 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5989 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5993 bool IsStrict =
N->isStrictFPOpcode();
5997 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5998 EVT DstVT =
N->getValueType(0);
6001 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6002 "Don't know how to expand this XINT_TO_FP!");
6003 TargetLowering::MakeLibCallOptions CallOptions;
6005 std::pair<SDValue, SDValue> Tmp =
6006 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6011 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6012 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6017 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6020 return ExpandOp_NormalStore(
N, OpNo);
6023 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6025 EVT VT =
N->getOperand(1).getValueType();
6026 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6030 AAMDNodes AAInfo =
N->getAAInfo();
6036 if (
N->getMemoryVT().bitsLE(NVT)) {
6037 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6038 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6039 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6043 if (DAG.getDataLayout().isLittleEndian()) {
6045 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6047 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6050 unsigned ExcessBits =
6057 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6058 N->getPointerInfo().getWithOffset(IncrementSize),
6059 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6065 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6067 EVT ExtVT =
N->getMemoryVT();
6070 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6078 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6082 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6086 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6087 N->getBaseAlign(), MMOFlags, AAInfo);
6092 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6093 N->getPointerInfo().getWithOffset(IncrementSize),
6095 N->getBaseAlign(), MMOFlags, AAInfo);
6101 GetExpandedInteger(
N->getOperand(0), InL, InH);
6110 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6115SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6116 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6117 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6121 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6123 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6126SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6129 "cannot use llvm.write_register with illegal type", Fn,
6132 return N->getOperand(0);
6135SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6138 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6139 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6142 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6145SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6147 unsigned Factor =
N->getNumOperands();
6150 for (
unsigned i = 0; i != Factor; i++)
6151 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6156 for (
unsigned i = 0; i != Factor; i++)
6162SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6164 EVT OutVT =
N->getValueType(0);
6165 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6166 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6170 SDValue BaseIdx =
N->getOperand(1);
6187 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6191 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6197 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6206 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6210 "Promoted operand has an element type greater than result");
6223 InOp0 = GetPromotedInteger(InOp0);
6230 Ops.reserve(OutNumElems);
6231 for (
unsigned i = 0; i != OutNumElems; ++i) {
6236 N->getOperand(0), Index);
6237 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6242 return DAG.getBuildVector(NOutVT, dl,
Ops);
6245SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6246 EVT OutVT =
N->getValueType(0);
6247 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6248 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6260 Vec = GetPromotedInteger(Vec);
6266SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6269 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6275SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6277 EVT VT =
N->getValueType(0);
6282 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6283 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6286 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6290 EVT OutVT =
N->getValueType(0);
6291 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6292 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6293 unsigned NumElems =
N->getNumOperands();
6300 Ops.reserve(NumElems);
6301 for (
unsigned i = 0; i != NumElems; ++i) {
6303 EVT OpVT =
Op.getValueType();
6308 if (OpVT.
bitsLT(NOutVTElem)) {
6314 ExtOpc = NOutExtOpc;
6315 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6320 return DAG.getBuildVector(NOutVT, dl,
Ops);
6327 assert(!
N->getOperand(0).getValueType().isVector() &&
6328 "Input must be a scalar");
6330 EVT OutVT =
N->getValueType(0);
6331 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6332 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6336 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6341 EVT OutVT =
N->getValueType(0);
6342 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6344 "Type must be promoted to a scalable vector type");
6345 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6346 return DAG.getStepVector(dl, NOutVT,
6350SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6353 EVT OutVT =
N->getValueType(0);
6354 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6355 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6357 unsigned NumOperands =
N->getNumOperands();
6362 SDUse *MaxSizedValue = std::max_element(
6364 EVT AVT = A.getValueType().getVectorElementType();
6365 EVT BVT = B.getValueType().getVectorElementType();
6366 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6372 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6374 EVT OpVT =
Op.getValueType();
6376 Op = GetPromotedInteger(
Op);
6379 "Unhandled legalization type");
6383 Op = DAG.getAnyExtOrTrunc(
6391 return DAG.getAnyExtOrTrunc(
6399 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6400 assert(NumElem * NumOperands == NumOutElem &&
6401 "Unexpected number of elements");
6405 for (
unsigned i = 0; i < NumOperands; ++i) {
6408 Op = GetPromotedInteger(
Op);
6409 EVT SclrTy =
Op.getValueType().getVectorElementType();
6410 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6411 "Unexpected number of elements");
6413 for (
unsigned j = 0;
j < NumElem; ++
j) {
6415 DAG.getVectorIdxConstant(j, dl));
6416 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6420 return DAG.getBuildVector(NOutVT, dl,
Ops);
6423SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6424 EVT VT =
N->getValueType(0);
6425 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6426 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6434 if (getTypeAction(
N->getOperand(0).getValueType())
6438 switch(
N->getOpcode()) {
6440 Promoted = SExtPromotedInteger(
N->getOperand(0));
6443 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6446 Promoted = GetPromotedInteger(
N->getOperand(0));
6458 DAG.getVectorIdxConstant(0, dl));
6460 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6464 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6467SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6468 EVT VT =
N->getValueType(0);
6469 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6473SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6474 EVT VT =
N->getValueType(0);
6475 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6479SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6481 EVT VT =
N->getValueType(0);
6482 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6483 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6484 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6488SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6489 EVT OutVT =
N->getValueType(0);
6490 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6491 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6496 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6499 NOutVTElem,
N->getOperand(1));
6501 V0, ConvElem,
N->getOperand(2));
6508 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6509 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6517 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6518 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6519 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6523 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6526 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6527 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6535 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6540SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6543 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6545 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6546 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6547 return DAG.getPOISON(NVT);
6550SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6552 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6553 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6554 TLI.getVectorIdxTy(DAG.getDataLayout()));
6561 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6564SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6569 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6574 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6576 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6588 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6589 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6592SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6594 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6602SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6605 EVT ResVT =
N->getValueType(0);
6606 unsigned NumElems =
N->getNumOperands();
6609 SDValue ResVec = DAG.getUNDEF(ResVT);
6613 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6615 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6627 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6628 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6632 for (
unsigned i=0; i<NumElem; ++i) {
6635 DAG.getVectorIdxConstant(i, dl));
6641 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6644SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6657 for (
unsigned I = 0;
I < OpNo;
I++)
6660 EVT Ty =
Op.getValueType();
6661 SDLoc
DL = SDLoc(
N);
6664 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6672 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6677 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6683SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6696 for (
unsigned I = 0;
I < OpNo;
I++)
6699 EVT Ty =
Op.getValueType();
6700 SDLoc
DL = SDLoc(
N);
6703 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6711 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6716 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)