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));
3010 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3020SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3024 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3025 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3028 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3030 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3031 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3034SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3036 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3038 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3039 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3042SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3044 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3048 if (TLI.getBooleanContents(
Op.getValueType()) ==
3050 NewOp = SExtPromotedInteger(
Op);
3052 NewOp = ZExtPromotedInteger(
Op);
3054 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3057SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3059 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3060 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3061 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3064SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3067 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3068 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3071SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3073 switch (
N->getOpcode()) {
3075 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3076 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3079 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3080 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3083 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3084 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3089 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3092SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3094 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3095 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3096 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3098 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3109void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3115 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3118 switch (
N->getOpcode()) {
3121 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3122 N->dump(&DAG);
dbgs() <<
"\n";
3151 ExpandIntRes_ABS(
N,
Lo,
Hi);
3203 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3204 SplitInteger(Tmp.first,
Lo,
Hi);
3205 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3210 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3211 SDValue Tmp = DAG.getAtomicCmpSwap(
3213 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3222 SplitInteger(Tmp,
Lo,
Hi);
3301 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3306 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3312 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3316 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3320 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3325 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3335std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3336 unsigned Opc =
Node->getOpcode();
3342 EVT RetVT =
Node->getValueType(0);
3343 TargetLowering::MakeLibCallOptions CallOptions;
3346 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3347 if (LCImpl != RTLIB::Unsupported) {
3349 Ops.push_back(
Node->getOperand(1));
3352 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3353 "Unexpected atomic op or value type!");
3355 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3357 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3358 Node->getOperand(0));
3363void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3368 GetExpandedInteger(
N->getOperand(0), InL, InH);
3383 if (Amt.
uge(VTBits)) {
3384 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3385 }
else if (Amt.
ugt(NVTBits)) {
3386 Lo = DAG.getConstant(0,
DL, NVT);
3388 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3389 }
else if (Amt == NVTBits) {
3390 Lo = DAG.getConstant(0,
DL, NVT);
3394 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3396 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3398 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3403 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3405 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3412 if (Amt.
uge(VTBits)) {
3413 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3414 }
else if (Amt.
ugt(NVTBits)) {
3416 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3417 Hi = DAG.getConstant(0,
DL, NVT);
3418 }
else if (Amt == NVTBits) {
3420 Hi = DAG.getConstant(0,
DL, NVT);
3423 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3425 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3430 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3432 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3435 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3441 if (Amt.
uge(VTBits)) {
3443 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3444 }
else if (Amt.
ugt(NVTBits)) {
3446 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3448 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3449 }
else if (Amt == NVTBits) {
3452 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3455 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3457 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3462 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3464 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3467 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3475bool DAGTypeLegalizer::
3477 unsigned Opc =
N->getOpcode();
3480 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3485 "Expanded integer type size not a power of two!");
3489 KnownBits Known = DAG.computeKnownBits(Amt);
3492 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3497 GetExpandedInteger(In, InL, InH);
3504 DAG.getConstant(~HighBitMask, dl, ShTy));
3509 Lo = DAG.getConstant(0, dl, NVT);
3510 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3513 Hi = DAG.getConstant(0, dl, NVT);
3514 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3518 DAG.getConstant(NVTBits - 1, dl, ShTy));
3519 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3531 DAG.getConstant(NVTBits - 1, dl, ShTy));
3547 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3549 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3551 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3552 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3564bool DAGTypeLegalizer::
3567 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3571 "Expanded integer type size not a power of two!");
3576 GetExpandedInteger(
N->getOperand(0), InL, InH);
3578 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3581 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3584 Amt, DAG.getConstant(0, dl, ShTy),
3588 switch (
N->getOpcode()) {
3594 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3595 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3598 LoL = DAG.getConstant(0, dl, NVT);
3601 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3602 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3603 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3609 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3612 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3615 HiL = DAG.getConstant(0, dl, NVT);
3618 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3619 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3620 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3626 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3627 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3631 DAG.getConstant(NVTBits - 1, dl, ShTy));
3634 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3635 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3636 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3661 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3666 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3667 SplitInteger(Res,
Lo,
Hi);
3670void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3679 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3680 unsigned NumHalfBits = NumBits / 2;
3681 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3682 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3683 SDValue LHSL, LHSH, RHSL, RHSH;
3684 GetExpandedInteger(
LHS, LHSL, LHSH);
3685 GetExpandedInteger(
RHS, RHSL, RHSH);
3688 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3690 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3698 SDValue LHSL, LHSH, RHSL, RHSH;
3699 GetExpandedInteger(
LHS, LHSL, LHSH);
3700 GetExpandedInteger(
RHS, RHSL, RHSH);
3702 EVT CCT = getSetCCResultType(NVT);
3705 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3707 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3709 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3711 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3715 const APInt *RHSVal =
nullptr;
3717 RHSVal = &RHSConst->getAPIntValue();
3724 SDValue LHSL, LHSH, RHSL, RHSH;
3725 GetExpandedInteger(
LHS, LHSL, LHSH);
3726 GetExpandedInteger(
RHS, RHSL, RHSH);
3728 EVT CCT = getSetCCResultType(NVT);
3734 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3737 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3741 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3744 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3746 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3753 switch (
N->getOpcode()) {
3780 EVT VT =
N->getValueType(0);
3781 EVT CCT = getSetCCResultType(VT);
3784 SplitInteger(Result,
Lo,
Hi);
3788 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3789 SplitInteger(ExpandedCMP,
Lo,
Hi);
3792void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3796 SDValue LHSL, LHSH, RHSL, RHSH;
3797 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3798 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3801 SDValue LoOps[2] = { LHSL, RHSL };
3802 SDValue HiOps[3] = { LHSH, RHSH };
3804 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3806 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3808 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3812 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3818 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3831 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3833 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3836 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3850 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3852 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3856 EVT OvfVT = getSetCCResultType(NVT);
3857 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3872 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3875 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3879 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3891 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3895 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3898 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3901 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3906 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3908 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3909 DAG.getConstant(0, dl, NVT));
3912 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3921 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3926 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3928 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3929 DAG.getConstant(0, dl, NVT));
3935void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3938 SDValue LHSL, LHSH, RHSL, RHSH;
3940 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3941 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3942 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3943 SDValue LoOps[2] = { LHSL, RHSL };
3944 SDValue HiOps[3] = { LHSH, RHSH };
3958 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3961void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3964 SDValue LHSL, LHSH, RHSL, RHSH;
3966 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3967 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3968 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3970 SDValue HiOps[3] = { LHSH, RHSH };
3972 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3974 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3978 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3981void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3989 unsigned CarryOp, NoCarryOp;
3991 switch(
N->getOpcode()) {
4006 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4007 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4011 SDValue LHSL, LHSH, RHSL, RHSH;
4012 GetExpandedInteger(
LHS, LHSL, LHSH);
4013 GetExpandedInteger(
RHS, RHSL, RHSH);
4014 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4015 SDValue LoOps[2] = { LHSL, RHSL };
4016 SDValue HiOps[3] = { LHSH, RHSH };
4018 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4020 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4027 SplitInteger(Sum,
Lo,
Hi);
4033 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4034 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4038 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4043 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4049 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4055 SDValue LHSL, LHSH, RHSL, RHSH;
4057 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4058 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4059 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4063 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4065 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4069 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4072void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4075 SDValue LHSL, LHSH, RHSL, RHSH;
4077 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4078 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4079 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4084 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4085 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4089 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4092void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4094 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4097 if (
Op.getValueType().bitsLE(NVT)) {
4100 Hi = DAG.getUNDEF(NVT);
4104 assert(getTypeAction(
Op.getValueType()) ==
4106 "Only know how to promote this result!");
4109 "Operand over promoted?");
4111 SplitInteger(Res,
Lo,
Hi);
4115void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4118 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4119 EVT NVT =
Lo.getValueType();
4124 if (NVTBits < EVTBits) {
4127 EVTBits - NVTBits)));
4132 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4136void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4139 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4140 EVT NVT =
Lo.getValueType();
4145 if (NVTBits < EVTBits) {
4148 EVTBits - NVTBits)));
4152 Hi = DAG.getConstant(0, dl, NVT);
4156void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4159 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4164void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4167 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4176 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4177 EVT NVT =
Lo.getValueType();
4180 Hi = DAG.getConstant(0, dl, NVT);
4183void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4185 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4188 const APInt &Cst =
Constant->getAPIntValue();
4189 bool IsTarget =
Constant->isTargetOpcode();
4190 bool IsOpaque =
Constant->isOpaque();
4192 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4193 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4201 GetExpandedInteger(N0,
Lo,
Hi);
4202 EVT NVT =
Lo.getValueType();
4207 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4212 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4213 Hi = DAG.getConstant(0, dl, NVT);
4223 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4228 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4229 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4238 EVT VT =
N->getValueType(0);
4240 DAG.getConstant(0, dl, VT), N0);
4242 SplitInteger(Neg, NegLo, NegHi);
4244 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4246 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4247 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4250void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4254 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4255 EVT NVT =
Lo.getValueType();
4257 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4260 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4263 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4264 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4267 Hi = DAG.getConstant(0, dl, NVT);
4275 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4276 EVT NVT =
Lo.getValueType();
4279 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4280 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4283 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4286 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4288 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4290 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4291 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4293 Hi = DAG.getConstant(0, dl, NVT);
4298 SplitInteger(Result,
Lo,
Hi);
4303 EVT VT =
N->getValueType(0);
4308 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4309 "LibCall explicitly requested, but not available");
4311 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4312 TargetLowering::MakeLibCallOptions CallOptions;
4316 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4317 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4325 GetExpandedInteger(
Op,
Lo,
Hi);
4326 EVT NVT =
Lo.getValueType();
4329 Hi = DAG.getConstant(0,
DL, NVT);
4332void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4336 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4337 EVT NVT =
Lo.getValueType();
4339 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4345 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4346 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4349 Hi = DAG.getConstant(0, dl, NVT);
4355 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4362 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4366 ReplaceValueWith(
SDValue(
N, 1), Chain);
4374 Chain =
Op.getValue(1);
4383 EVT VT =
N->getValueType(0);
4387 bool IsStrict =
N->isStrictFPOpcode();
4389 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4393 Op.getValueType() == MVT::bf16) {
4399 EVT OpVT =
Op.getValueType();
4403 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4404 TargetLowering::MakeLibCallOptions CallOptions;
4409 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4410 CallOptions, dl, Chain);
4411 SplitInteger(Tmp.first,
Lo,
Hi);
4414 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4419 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4420 SplitInteger(Res,
Lo,
Hi);
4426 bool IsStrict =
N->isStrictFPOpcode();
4427 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4430 EVT VT =
Op.getValueType();
4432 if (VT == MVT::f16) {
4438 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4442 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4446 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4450 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4454 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4458 EVT RetVT =
N->getValueType(0);
4460 TargetLowering::MakeLibCallOptions CallOptions;
4462 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4463 Op, CallOptions, dl,
4465 SplitInteger(Tmp.first,
Lo,
Hi);
4467 if (
N->isStrictFPOpcode())
4468 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4471void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4473 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4476 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4482 EVT VT =
N->getValueType(0);
4483 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4488 AAMDNodes AAInfo =
N->getAAInfo();
4493 if (
N->getMemoryVT().bitsLE(NVT)) {
4494 EVT MemVT =
N->getMemoryVT();
4496 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4497 N->getBaseAlign(), MMOFlags, AAInfo);
4505 unsigned LoSize =
Lo.getValueSizeInBits();
4507 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4510 Hi = DAG.getConstant(0, dl, NVT);
4514 Hi = DAG.getUNDEF(NVT);
4516 }
else if (DAG.getDataLayout().isLittleEndian()) {
4518 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4521 unsigned ExcessBits =
4528 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4529 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4530 N->getBaseAlign(), MMOFlags, AAInfo);
4539 EVT MemVT =
N->getMemoryVT();
4542 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4545 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4548 N->getBaseAlign(), MMOFlags, AAInfo);
4554 N->getPointerInfo().getWithOffset(IncrementSize),
4556 N->getBaseAlign(), MMOFlags, AAInfo);
4568 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4572 DAG.getShiftAmountConstant(
4579 ReplaceValueWith(
SDValue(
N, 1), Ch);
4582void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4586 GetExpandedInteger(
N->getOperand(0), LL, LH);
4587 GetExpandedInteger(
N->getOperand(1), RL, RH);
4591 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4593 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4594 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4597void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4599 EVT VT =
N->getValueType(0);
4600 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4604 GetExpandedInteger(
N->getOperand(0), LL, LH);
4605 GetExpandedInteger(
N->getOperand(1), RL, RH);
4607 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4614 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4615 if (LCImpl == RTLIB::Unsupported) {
4618 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4624 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4625 TargetLowering::MakeLibCallOptions CallOptions;
4627 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4634 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4635 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4636 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4639 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4644 SplitInteger(Result,
Lo,
Hi);
4650 SplitInteger(Result,
Lo,
Hi);
4656 SplitInteger(Result,
Lo,
Hi);
4667 EVT VT =
N->getValueType(0);
4671 uint64_t Scale =
N->getConstantOperandVal(2);
4683 EVT BoolVT = getSetCCResultType(VT);
4685 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4691 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4692 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4698 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4699 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4704 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4705 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4708 SplitInteger(Result,
Lo,
Hi);
4714 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4716 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4718 GetExpandedInteger(
LHS, LL, LH);
4719 GetExpandedInteger(
RHS, RL, RH);
4723 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4730 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4731 SplitInteger(LoTmp, Result[0], Result[1]);
4732 SplitInteger(HiTmp, Result[2], Result[3]);
4734 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4737 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4738 "the size of the current value type");
4759 uint64_t Part0 = Scale / NVTSize;
4760 if (Scale % NVTSize) {
4761 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4764 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4776 if (Scale == VTSize)
4795 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4796 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4797 EVT BoolNVT = getSetCCResultType(NVT);
4800 if (Scale < NVTSize) {
4803 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4804 DAG.getShiftAmountConstant(Scale, NVT, dl));
4805 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4806 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4807 }
else if (Scale == NVTSize) {
4809 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4810 }
else if (Scale < VTSize) {
4814 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4815 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4818 "(and saturation can't happen with Scale==VTSize).");
4820 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4821 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4825 if (Scale < NVTSize) {
4830 unsigned OverflowBits = VTSize - Scale + 1;
4831 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4832 "Extent of overflow bits must start within HL");
4833 SDValue HLHiMask = DAG.getConstant(
4835 SDValue HLLoMask = DAG.getConstant(
4842 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4848 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4849 }
else if (Scale == NVTSize) {
4855 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4861 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4862 }
else if (Scale < VTSize) {
4865 unsigned OverflowBits = VTSize - Scale + 1;
4866 SDValue HHHiMask = DAG.getConstant(
4868 SDValue HHLoMask = DAG.getConstant(
4870 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4871 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4878 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4879 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4882 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4883 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4890 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4892 N->getConstantOperandVal(2), DAG);
4896 N->getConstantOperandVal(2), TLI, DAG);
4897 SplitInteger(Res,
Lo,
Hi);
4900void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4903 "Node has unexpected Opcode");
4913 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4914 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4918 SDValue LHSL, LHSH, RHSL, RHSH;
4919 GetExpandedInteger(
LHS, LHSL, LHSH);
4920 GetExpandedInteger(
RHS, RHSL, RHSH);
4921 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4924 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4933 SplitInteger(Sum,
Lo,
Hi);
4958 EVT VT =
LHS.getValueType();
4961 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4965 EVT OType =
Node->getValueType(1);
4966 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4970 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4973void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4975 EVT VT =
N->getValueType(0);
4977 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4986 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4988 TargetLowering::MakeLibCallOptions CallOptions;
4990 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4993void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4996 SDValue Shiftee =
N->getOperand(0);
5003 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5004 }
while (!TLI.isTypeLegal(LoadVT));
5009 "Shifting unit is not a a power of two!");
5011 const bool IsOneStepShift =
5012 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5017 if (!IsOneStepShift)
5018 ShAmt = DAG.getFreeze(ShAmt);
5021 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5022 unsigned VTByteWidth = VTBitWidth / 8;
5024 "Shiftee type size is not a power of two!");
5025 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5026 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5031 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5033 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5034 EVT PtrTy =
StackPtr.getValueType();
5035 SDValue Ch = DAG.getEntryNode();
5038 DAG.getMachineFunction(),
5044 unsigned WideningOpc =
5046 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5049 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5053 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5059 Flags.setExact(IsOneStepShift);
5062 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5064 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5065 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5068 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5073 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5080 if (DAG.getDataLayout().isBigEndian())
5081 WillIndexUpwards = !WillIndexUpwards;
5084 if (WillIndexUpwards) {
5087 AdjStackPtr = DAG.getMemBasePlusOffset(
5088 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5089 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5093 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5094 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5098 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5103 if (!IsOneStepShift) {
5105 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5106 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5107 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5111 SplitInteger(Res,
Lo,
Hi);
5114void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5116 EVT VT =
N->getValueType(0);
5117 unsigned Opc =
N->getOpcode();
5123 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5127 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5144 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5146 const bool LegalOrCustom =
5150 unsigned ExpansionFactor = 1;
5152 for (EVT TmpVT = NVT;;) {
5153 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5154 if (NewTMPVT == TmpVT)
5161 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5164 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5166 if (LegalOrCustom &&
5170 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5176 SDValue ShiftOp =
N->getOperand(1);
5177 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5179 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5182 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5183 Hi =
Lo.getValue(1);
5188 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5202 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5205 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5207 TargetLowering::MakeLibCallOptions CallOptions;
5210 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5215 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5219void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5221 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5224 if (
Op.getValueType().bitsLE(NVT)) {
5230 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5234 assert(getTypeAction(
Op.getValueType()) ==
5236 "Only know how to promote this result!");
5239 "Operand over promoted?");
5241 SplitInteger(Res,
Lo,
Hi);
5249void DAGTypeLegalizer::
5252 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5255 if (EVT.
bitsLE(
Lo.getValueType())) {
5263 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5264 Hi.getValueType(), dl));
5275void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5277 EVT VT =
N->getValueType(0);
5279 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5288 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5290 TargetLowering::MakeLibCallOptions CallOptions;
5292 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5295void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5297 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5307void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5309 EVT VT =
N->getValueType(0);
5328 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5329 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5330 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5332 EVT BitVT =
N->getValueType(1);
5333 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5335 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5337 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5338 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5357 SplitInteger(Three,
Lo,
Hi);
5361 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5366 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5371 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5375 if (LCImpl == RTLIB::Unsupported ||
5377 DAG.getMachineFunction().getName()) {
5380 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5381 N->getOperand(1), MulLo, MulHi);
5386 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5387 SplitInteger(MulLo,
Lo,
Hi);
5388 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5392 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5395 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5396 MachinePointerInfo());
5400 EVT ArgVT =
Op.getValueType();
5402 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5403 Entry.IsSExt =
true;
5404 Entry.IsZExt =
false;
5405 Args.push_back(Entry);
5409 TargetLowering::ArgListEntry
Entry(
5411 Entry.IsSExt =
true;
5412 Entry.IsZExt =
false;
5413 Args.push_back(Entry);
5415 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5417 TargetLowering::CallLoweringInfo CLI(DAG);
5420 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5421 Func, std::move(Args))
5424 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5426 SplitInteger(CallInfo.first,
Lo,
Hi);
5428 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5429 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5430 DAG.getConstant(0, dl, PtrVT),
5433 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5436void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5438 EVT VT =
N->getValueType(0);
5440 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5450 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5452 if (isTypeLegal(NVT)) {
5454 GetExpandedInteger(
N->getOperand(0), InL, InH);
5456 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5465 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5467 TargetLowering::MakeLibCallOptions CallOptions;
5468 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5471void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5473 EVT VT =
N->getValueType(0);
5475 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5485 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5487 if (isTypeLegal(NVT)) {
5489 GetExpandedInteger(
N->getOperand(0), InL, InH);
5491 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5500 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5502 TargetLowering::MakeLibCallOptions CallOptions;
5503 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5506void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5508 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5511 if (
Op.getValueType().bitsLE(NVT)) {
5514 Hi = DAG.getConstant(0, dl, NVT);
5518 assert(getTypeAction(
Op.getValueType()) ==
5520 "Only know how to promote this result!");
5523 "Operand over promoted?");
5525 SplitInteger(Res,
Lo,
Hi);
5527 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5533void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5537 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5539 SDValue Swap = DAG.getAtomicCmpSwap(
5548void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5552 SDValue Res = TLI.expandVecReduce(
N, DAG);
5553 SplitInteger(Res,
Lo,
Hi);
5556void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5562 N->getOperand(0),
N->getOperand(1));
5563 SplitInteger(Res,
Lo,
Hi);
5570 GetExpandedInteger(
N->getOperand(0), In3, In4);
5571 GetExpandedInteger(
N->getOperand(1), In1, In2);
5575 unsigned Opc =
N->getOpcode();
5578 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5583 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5585 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5589 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5590 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5595 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5596 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5601 SDValue Res = TLI.expandCLMUL(
N, DAG);
5602 return SplitInteger(Res,
Lo,
Hi);
5606 GetExpandedInteger(
N->getOperand(0), LL, LH);
5607 GetExpandedInteger(
N->getOperand(1), RL, RH);
5621 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5626 EVT VT =
N->getValueType(0);
5633 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5636 SplitInteger(Res,
Lo,
Hi);
5643 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5644 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5646 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5647 Lo = DAG.getPOISON(LoVT);
5648 Hi = DAG.getPOISON(HiVT);
5655 EVT VT =
N->getSimpleValueType(0);
5656 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5658 "VectorIdxTy should be smaller than type to be expanded?");
5662 SplitInteger(Res,
Lo,
Hi);
5673bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5677 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5680 switch (
N->getOpcode()) {
5683 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5684 N->dump(&DAG);
dbgs() <<
"\n";
5689 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5693 Res = ExpandOp_FAKE_USE(
N);
5697 Res = TLI.expandLoopDependenceMask(
N, DAG);
5703 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5716 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5721 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5725 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5728 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5730 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5731 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5732 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5735 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5740 if (!Res.
getNode())
return false;
5748 "Invalid operand expansion");
5750 ReplaceValueWith(
SDValue(
N, 0), Res);
5756void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5760 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5761 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5762 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5775 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5782 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5783 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5813 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5814 RHSLo, LowCC,
false, DagCombineInfo, dl);
5816 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5819 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5820 RHSHi, CCCode,
false, DagCombineInfo, dl);
5824 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5833 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5835 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5844 if (LHSHi == RHSHi) {
5853 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5854 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5857 if (HasSETCCCARRY) {
5860 bool FlipOperands =
false;
5877 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5881 DAG.getCondCode(CCCode));
5887 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5888 false, DagCombineInfo, dl);
5891 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5892 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5899 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5904 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5909 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5910 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5911 N->getOperand(4)), 0);
5917 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5922 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5927 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5928 N->getOperand(2),
N->getOperand(3),
5929 DAG.getCondCode(CCCode)), 0);
5935 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5940 "Unexpected setcc expansion!");
5946 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5954 SDLoc dl = SDLoc(
N);
5956 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5957 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5958 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5971 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5981 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5982 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5986 return TLI.expandCMP(
N, DAG);
5994 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5995 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5999 bool IsStrict =
N->isStrictFPOpcode();
6003 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6004 EVT DstVT =
N->getValueType(0);
6007 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6008 "Don't know how to expand this XINT_TO_FP!");
6009 TargetLowering::MakeLibCallOptions CallOptions;
6011 std::pair<SDValue, SDValue> Tmp =
6012 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6017 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6018 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6023 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6026 return ExpandOp_NormalStore(
N, OpNo);
6029 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6031 EVT VT =
N->getOperand(1).getValueType();
6032 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6036 AAMDNodes AAInfo =
N->getAAInfo();
6042 if (
N->getMemoryVT().bitsLE(NVT)) {
6043 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6044 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6045 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6049 if (DAG.getDataLayout().isLittleEndian()) {
6051 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6053 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6056 unsigned ExcessBits =
6063 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6064 N->getPointerInfo().getWithOffset(IncrementSize),
6065 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6071 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6073 EVT ExtVT =
N->getMemoryVT();
6076 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6084 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6088 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6092 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6093 N->getBaseAlign(), MMOFlags, AAInfo);
6098 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6099 N->getPointerInfo().getWithOffset(IncrementSize),
6101 N->getBaseAlign(), MMOFlags, AAInfo);
6107 GetExpandedInteger(
N->getOperand(0), InL, InH);
6116 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6121SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6122 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6123 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6127 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6129 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6132SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6135 "cannot use llvm.write_register with illegal type", Fn,
6138 return N->getOperand(0);
6141SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6144 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6145 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6148 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6151SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6153 unsigned Factor =
N->getNumOperands();
6156 for (
unsigned i = 0; i != Factor; i++)
6157 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6162 for (
unsigned i = 0; i != Factor; i++)
6168SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6170 EVT OutVT =
N->getValueType(0);
6171 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6172 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6176 SDValue BaseIdx =
N->getOperand(1);
6193 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6197 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6203 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6212 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6216 "Promoted operand has an element type greater than result");
6229 InOp0 = GetPromotedInteger(InOp0);
6236 Ops.reserve(OutNumElems);
6237 for (
unsigned i = 0; i != OutNumElems; ++i) {
6242 N->getOperand(0), Index);
6243 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6248 return DAG.getBuildVector(NOutVT, dl,
Ops);
6251SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6252 EVT OutVT =
N->getValueType(0);
6253 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6254 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6266 Vec = GetPromotedInteger(Vec);
6272SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6275 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6281SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6283 EVT VT =
N->getValueType(0);
6288 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6289 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6292 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6296 EVT OutVT =
N->getValueType(0);
6297 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6298 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6299 unsigned NumElems =
N->getNumOperands();
6306 Ops.reserve(NumElems);
6307 for (
unsigned i = 0; i != NumElems; ++i) {
6309 EVT OpVT =
Op.getValueType();
6314 if (OpVT.
bitsLT(NOutVTElem)) {
6320 ExtOpc = NOutExtOpc;
6321 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6326 return DAG.getBuildVector(NOutVT, dl,
Ops);
6333 assert(!
N->getOperand(0).getValueType().isVector() &&
6334 "Input must be a scalar");
6336 EVT OutVT =
N->getValueType(0);
6337 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6338 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6342 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6347 EVT OutVT =
N->getValueType(0);
6348 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6350 "Type must be promoted to a scalable vector type");
6351 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6352 return DAG.getStepVector(dl, NOutVT,
6356SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6359 EVT OutVT =
N->getValueType(0);
6360 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6361 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6363 unsigned NumOperands =
N->getNumOperands();
6368 SDUse *MaxSizedValue = std::max_element(
6370 EVT AVT = A.getValueType().getVectorElementType();
6371 EVT BVT = B.getValueType().getVectorElementType();
6372 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6378 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6380 EVT OpVT =
Op.getValueType();
6382 Op = GetPromotedInteger(
Op);
6385 "Unhandled legalization type");
6389 Op = DAG.getAnyExtOrTrunc(
6397 return DAG.getAnyExtOrTrunc(
6405 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6406 assert(NumElem * NumOperands == NumOutElem &&
6407 "Unexpected number of elements");
6411 for (
unsigned i = 0; i < NumOperands; ++i) {
6414 Op = GetPromotedInteger(
Op);
6415 EVT SclrTy =
Op.getValueType().getVectorElementType();
6416 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6417 "Unexpected number of elements");
6419 for (
unsigned j = 0;
j < NumElem; ++
j) {
6421 DAG.getVectorIdxConstant(j, dl));
6422 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6426 return DAG.getBuildVector(NOutVT, dl,
Ops);
6429SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6430 EVT VT =
N->getValueType(0);
6431 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6432 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6440 if (getTypeAction(
N->getOperand(0).getValueType())
6444 switch(
N->getOpcode()) {
6446 Promoted = SExtPromotedInteger(
N->getOperand(0));
6449 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6452 Promoted = GetPromotedInteger(
N->getOperand(0));
6464 DAG.getVectorIdxConstant(0, dl));
6466 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6470 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6473SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6474 EVT VT =
N->getValueType(0);
6475 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6479SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6480 EVT VT =
N->getValueType(0);
6481 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6485SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6487 EVT VT =
N->getValueType(0);
6488 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6489 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6490 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6494SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6495 EVT OutVT =
N->getValueType(0);
6496 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6497 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6502 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6505 NOutVTElem,
N->getOperand(1));
6507 V0, ConvElem,
N->getOperand(2));
6514 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6515 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6523 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6524 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6525 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6529 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6532 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6533 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6541 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6546SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6549 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6551 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6552 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6553 return DAG.getPOISON(NVT);
6556SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6558 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6559 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6560 TLI.getVectorIdxTy(DAG.getDataLayout()));
6567 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6570SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6575 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6580 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6582 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6594 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6595 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6598SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6600 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6608SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6611 EVT ResVT =
N->getValueType(0);
6612 unsigned NumElems =
N->getNumOperands();
6615 SDValue ResVec = DAG.getUNDEF(ResVT);
6619 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6621 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6633 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6634 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6638 for (
unsigned i=0; i<NumElem; ++i) {
6641 DAG.getVectorIdxConstant(i, dl));
6647 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6650SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6663 for (
unsigned I = 0;
I < OpNo;
I++)
6666 EVT Ty =
Op.getValueType();
6667 SDLoc
DL = SDLoc(
N);
6670 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6678 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6683 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6689SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6702 for (
unsigned I = 0;
I < OpNo;
I++)
6705 EVT Ty =
Op.getValueType();
6706 SDLoc
DL = SDLoc(
N);
6709 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6717 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6722 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)