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_UNDEF:
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_UNDEF:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
83 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
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);
292 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
325 Res = PromoteIntRes_VECREDUCE(
N);
328 case ISD::VP_REDUCE_ADD:
329 case ISD::VP_REDUCE_MUL:
330 case ISD::VP_REDUCE_AND:
331 case ISD::VP_REDUCE_OR:
332 case ISD::VP_REDUCE_XOR:
333 case ISD::VP_REDUCE_SMAX:
334 case ISD::VP_REDUCE_SMIN:
335 case ISD::VP_REDUCE_UMAX:
336 case ISD::VP_REDUCE_UMIN:
337 Res = PromoteIntRes_VP_REDUCE(
N);
342 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
346 Res = PromoteIntRes_FREEZE(
N);
351 Res = PromoteIntRes_Rotate(
N);
356 Res = PromoteIntRes_FunnelShift(
N);
361 Res = PromoteIntRes_VPFunnelShift(
N);
367 Res = PromoteIntRes_CLMUL(
N);
371 Res = PromoteIntRes_IS_FPCLASS(
N);
374 Res = PromoteIntRes_FFREXP(
N);
379 Res = PromoteIntRes_XRINT(
N);
383 Res = PromoteIntRes_PATCHPOINT(
N);
386 Res = PromoteIntRes_READ_REGISTER(
N);
392 SetPromotedInteger(
SDValue(
N, ResNo), Res);
397 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
398 return GetPromotedInteger(
Op);
401SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
403 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
404 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
409 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
411 Op.getValueType(),
Op,
N->getOperand(1));
416 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
418 Op.getValueType(),
Op,
N->getOperand(1));
422 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
425 switch (TLI.getExtendForAtomicOps()) {
441 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
442 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
452 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
454 Op2 = SExtPromotedInteger(Op2);
457 Op2 = ZExtPromotedInteger(Op2);
460 Op2 = GetPromotedInteger(Op2);
465 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
467 N->getChain(),
N->getBasePtr(),
468 Op2,
N->getMemOperand());
479 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
480 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
484 if (!TLI.isTypeLegal(SVT))
487 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
488 SDValue Res = DAG.getAtomicCmpSwap(
490 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
494 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
500 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
501 switch (TLI.getExtendForAtomicCmpSwapArg()) {
503 Op2 = SExtPromotedInteger(Op2);
506 Op2 = ZExtPromotedInteger(Op2);
509 Op2 = GetPromotedInteger(Op2);
516 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
517 SDValue Res = DAG.getAtomicCmpSwap(
518 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
519 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
521 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
529 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
530 EVT OutVT =
N->getValueType(0);
531 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
534 switch (getTypeAction(InVT)) {
540 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
544 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
547 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
555 BitConvertToInteger(GetScalarizedVector(InOp)));
564 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
565 Lo = BitConvertToInteger(
Lo);
566 Hi = BitConvertToInteger(
Hi);
568 if (DAG.getDataLayout().isBigEndian())
574 JoinIntegers(
Lo,
Hi));
589 if (DAG.getDataLayout().isBigEndian()) {
593 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
608 if (isTypeLegal(WideOutVT)) {
609 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
611 DAG.getVectorIdxConstant(0, dl));
620 DAG.getDataLayout().isLittleEndian()) {
631 if (isTypeLegal(WideVecVT)) {
633 DAG.getUNDEF(WideVecVT), InOp,
634 DAG.getVectorIdxConstant(0, dl));
642 CreateStackStoreLoad(InOp, OutVT));
646 SDValue V = GetPromotedInteger(
N->getOperand(0));
648 V.getValueType(), V);
652 SDValue Op = GetPromotedInteger(
N->getOperand(0));
653 EVT OVT =
N->getValueType(0);
654 EVT NVT =
Op.getValueType();
662 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
663 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
668 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
674 return DAG.getNode(ISD::VP_SRL, dl, NVT,
675 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
680 SDValue Op = GetPromotedInteger(
N->getOperand(0));
681 EVT OVT =
N->getValueType(0);
682 EVT NVT =
Op.getValueType();
691 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
696 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
702 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
703 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
711 TLI.getTypeToTransformTo(*DAG.getContext(),
712 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
717 EVT VT =
N->getValueType(0);
724 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
731 EVT OVT =
N->getValueType(0);
732 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
738 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
739 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
741 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
747 unsigned CtlzOpcode =
N->getOpcode();
748 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
750 SDValue ExtractLeadingBits = DAG.getConstant(
753 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
757 if (!
N->isVPOpcode())
758 return DAG.getNode(
ISD::SUB, dl, NVT,
759 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
763 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
764 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
765 ExtractLeadingBits, Mask, EVL,
769 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
771 SDValue Op = GetPromotedInteger(
N->getOperand(0));
775 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
776 if (!
N->isVPOpcode()) {
778 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
783 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
784 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
790 EVT OVT =
N->getValueType(0);
791 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
794 SDValue ExtractLeadingBits = DAG.getConstant(
797 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
803 EVT OVT =
N->getValueType(0);
804 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
812 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
813 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
820 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
821 if (!
N->isVPOpcode())
822 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
826 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
831 SDValue Op = GetPromotedInteger(
N->getOperand(0));
832 EVT OVT =
N->getValueType(0);
833 EVT NVT =
Op.getValueType();
840 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
841 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
845 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
851 unsigned NewOpc =
N->getOpcode();
852 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
859 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
863 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
864 N->getOperand(1),
N->getOperand(2));
865 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
868 if (!
N->isVPOpcode())
869 return DAG.getNode(NewOpc, dl, NVT,
Op);
870 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
873SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
875 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
876 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
879SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
881 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
888 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
894 EVT SVT =
In.getValueType().getScalarType();
897 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
905 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
907 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
911 if (
N->isStrictFPOpcode()) {
912 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
913 {
N->getOperand(0),
N->getOperand(1)});
917 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
918 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
921 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
933 N->getOpcode() == ISD::VP_FP_TO_UINT)
937 DAG.getValueType(
N->getValueType(0).getScalarType()));
940SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
942 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
944 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
948SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
949 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
952 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
955SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
956 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
959 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
960 N->getOperand(0),
N->getOperand(1));
966 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
968 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
972 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
976 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
985 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
988 if (getTypeAction(
N->getOperand(0).getValueType())
990 SDValue Res = GetPromotedInteger(
N->getOperand(0));
999 DAG.getValueType(
N->getOperand(0).getValueType()));
1001 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
1008 if (
N->getNumOperands() != 1) {
1009 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1010 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1011 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1012 N->getOperand(1),
N->getOperand(2));
1014 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1019 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1023 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1024 N->getMemoryVT(),
N->getMemOperand());
1033 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1034 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1037 :
N->getExtensionType();
1040 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1041 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1042 N->getMemOperand(),
N->isExpandingLoad());
1050 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1051 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1058 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1059 N->getOffset(),
N->getMask(), ExtPassThru,
1060 N->getMemoryVT(),
N->getMemOperand(),
1061 N->getAddressingMode(), ExtType,
1062 N->isExpandingLoad());
1070 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1071 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1073 "Gather result type and the passThru argument type should be the same");
1080 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1081 N->getIndex(),
N->getScale() };
1082 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1083 N->getMemoryVT(), dl,
Ops,
1084 N->getMemOperand(),
N->getIndexType(),
1092SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1093 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1094 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1096 N->getOperand(1), Passthru);
1103 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1104 EVT VT =
N->getValueType(0);
1105 EVT SVT = getSetCCResultType(VT);
1106 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1107 unsigned NumOps =
N->getNumOperands();
1110 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1118 ReplaceValueWith(
SDValue(
N, 0), Res);
1121 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1124template <
class MatchContextClass>
1136 MatchContextClass matcher(DAG, TLI,
N);
1138 unsigned Opcode = matcher.getRootBaseOpcode();
1144 SExtOrZExtPromotedOperands(Op1, Op2);
1150 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1152 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1153 Op1 = SExtPromotedInteger(Op1);
1154 Op2 = SExtPromotedInteger(Op2);
1155 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1158 Op1 = ZExtPromotedInteger(Op1);
1159 Op2 = ZExtPromotedInteger(Op2);
1162 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1164 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1171 Op1 = GetPromotedInteger(Op1);
1173 Op2 = ZExtPromotedInteger(Op2);
1175 Op1 = SExtPromotedInteger(Op1);
1176 Op2 = SExtPromotedInteger(Op2);
1183 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1196 "addition, subtraction or left shift");
1199 unsigned SHLAmount = NewBits - OldBits;
1201 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1206 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1207 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1213 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1214 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1215 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1216 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1217 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1224 SDValue Op1Promoted, Op2Promoted;
1230 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1231 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1233 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1234 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1236 EVT OldType =
N->getOperand(0).getValueType();
1248 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1249 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1250 Op2Promoted,
N->getOperand(2));
1252 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1253 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1255 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1260 unsigned SatW,
bool Signed,
1263 EVT VT = V.getValueType();
1290 EVT VT =
LHS.getValueType();
1306 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1312 "Tried to saturate to more than the original type?");
1321 SDValue Op1Promoted, Op2Promoted;
1327 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1328 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1330 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1331 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1334 unsigned Scale =
N->getConstantOperandVal(2);
1338 if (TLI.isTypeLegal(PromotedType)) {
1340 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1343 N->getValueType(0).getScalarSizeInBits();
1347 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1348 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1349 Op2Promoted,
N->getOperand(2));
1352 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1358 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1359 Op2Promoted, Scale, DAG)) {
1362 N->getValueType(0).getScalarSizeInBits(),
1370 N->getValueType(0).getScalarSizeInBits());
1373SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1375 return PromoteIntRes_Overflow(
N);
1379 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1380 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1381 EVT OVT =
N->getOperand(0).getValueType();
1382 EVT NVT =
LHS.getValueType();
1392 DAG.getValueType(OVT));
1394 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1397 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1403 EVT PromotedResultTy =
1404 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1405 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1406 N->getOperand(0),
N->getOperand(1));
1412 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1413 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1415 unsigned Opcode =
N->getOpcode();
1416 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1417 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1419 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1423 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1424 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1426 LHS.getValueType(),
N->getOperand(0),
1427 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1432 EVT InVT =
N->getOperand(OpNo).getValueType();
1433 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1435 EVT SVT = getSetCCResultType(InVT);
1442 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1443 SVT = getSetCCResultType(InVT);
1451 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1452 "Vector compare must return a vector result!");
1456 if (
N->isStrictFPOpcode()) {
1457 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1458 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1459 N->getOperand(2),
N->getOperand(3)};
1460 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1465 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1466 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1469 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1476 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1481 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1482 EVT VT =
N->getValueType(0);
1486 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1488 ReplaceValueWith(
SDValue(
N, 0), Res);
1493 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1496 RHS = ZExtPromotedInteger(
RHS);
1497 if (
N->getOpcode() != ISD::VP_SHL)
1498 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1506SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1507 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1509 Op.getValueType(),
Op,
N->getOperand(1));
1512SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1516 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1517 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1518 if (
N->getNumOperands() == 2)
1519 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1520 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1521 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1522 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1523 N->getOperand(2),
N->getOperand(3));
1528 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1529 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1530 if (
N->getNumOperands() == 2)
1531 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1532 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1533 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1542 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1543 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1544 if (
N->getNumOperands() == 2)
1545 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1546 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1547 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1555SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1556 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1557 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1559 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1563SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1564 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1565 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1567 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1577 SExtOrZExtPromotedOperands(
LHS,
RHS);
1579 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1585 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1588 RHS = ZExtPromotedInteger(
RHS);
1589 if (
N->getOpcode() != ISD::VP_SRA)
1590 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1601 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1603 RHS = ZExtPromotedInteger(
RHS);
1604 if (
N->getOpcode() != ISD::VP_SRL)
1605 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1615 SDValue Res = TLI.expandROT(
N,
true , DAG);
1616 ReplaceValueWith(
SDValue(
N, 0), Res);
1621 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1622 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1625 Amt = ZExtPromotedInteger(Amt);
1629 EVT OldVT =
N->getOperand(0).getValueType();
1630 EVT VT =
Lo.getValueType();
1631 unsigned Opcode =
N->getOpcode();
1638 DAG.getConstant(OldBits,
DL, AmtVT));
1646 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1647 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1649 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1659 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1665 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1667 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1671SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1672 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1673 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1678 Amt = ZExtPromotedInteger(Amt);
1682 EVT OldVT =
N->getOperand(0).getValueType();
1683 EVT VT =
Lo.getValueType();
1684 unsigned Opcode =
N->getOpcode();
1685 bool IsFSHR = Opcode == ISD::VP_FSHR;
1690 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1691 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1699 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1700 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1701 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1702 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1704 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1707 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1712 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1713 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1718 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1720 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1724 unsigned Opcode =
N->getOpcode();
1727 EVT OldVT =
N->getOperand(0).getValueType();
1728 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1731 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1732 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1735 SDValue X = GetPromotedInteger(
N->getOperand(0));
1736 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1740 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1741 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1745 if (NewBits < 2 * OldBits) {
1747 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1749 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1751 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1753 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1758 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1760 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1764 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1776 Res = GetPromotedInteger(InOp);
1783 "Dst and Src must have the same number of elements");
1785 "Promoted vector type must be a power of two");
1788 GetSplitVector(InOp, EOp1, EOp2);
1796 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1797 "Expected VP_TRUNCATE opcode");
1798 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1799 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1800 std::tie(EVLLo, EVLHi) =
1801 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1802 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1803 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1810 SDValue WideInOp = GetWidenedVector(InOp);
1815 N->getValueType(0).getScalarType(), NumElem);
1824 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1830 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1831 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1836SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1838 return PromoteIntRes_Overflow(
N);
1842 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1843 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1844 EVT OVT =
N->getOperand(0).getValueType();
1845 EVT NVT =
LHS.getValueType();
1854 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1856 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1859 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1870 return PromoteIntRes_Overflow(
N);
1882 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1883 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1885 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1888 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1899 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1900 return PromoteIntRes_Overflow(
N);
1904 EVT OVT =
N->getValueType(0);
1905 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1911 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1912 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1913 if (
SDValue Res = TLI.expandABS(
N, DAG))
1917 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1921SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1924 return PromoteIntRes_Overflow(
N);
1928 EVT SmallVT =
LHS.getValueType();
1935 LHS = SExtPromotedInteger(
LHS);
1936 RHS = SExtPromotedInteger(
RHS);
1938 LHS = ZExtPromotedInteger(
LHS);
1939 RHS = ZExtPromotedInteger(
RHS);
1941 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1953 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1954 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1955 DAG.getConstant(0,
DL,
Hi.getValueType()),
1960 Mul, DAG.getValueType(SmallVT));
1970 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1975 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1976 N->getValueType(0)));
1980 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1982 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1989 EVT VT =
N->getValueType(0);
1992 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1993 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1997 for (
unsigned i = 0; i < NumRegs; ++i) {
1998 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1999 N->getConstantOperandVal(3));
2004 if (DAG.getDataLayout().isBigEndian())
2005 std::reverse(Parts.begin(), Parts.end());
2008 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2010 for (
unsigned i = 1; i < NumRegs; ++i) {
2015 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2021 ReplaceValueWith(
SDValue(
N, 1), Chain);
2034bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2037 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2042 switch (
N->getOpcode()) {
2045 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2046 N->dump(&DAG);
dbgs() <<
"\n";
2052 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2058 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2059 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2064 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2068 Res = PromoteIntOp_FAKE_USE(
N);
2071 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2075 Res = PromoteIntOp_ScalarOp(
N);
2078 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2081 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2083 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2084 case ISD::VP_SINT_TO_FP:
2101 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2103 case ISD::VP_TRUNCATE:
2107 case ISD::VP_UINT_TO_FP:
2110 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2115 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2126 Res = PromoteIntOp_Shift(
N);
2130 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2133 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2159 case ISD::VP_REDUCE_ADD:
2160 case ISD::VP_REDUCE_MUL:
2161 case ISD::VP_REDUCE_AND:
2162 case ISD::VP_REDUCE_OR:
2163 case ISD::VP_REDUCE_XOR:
2164 case ISD::VP_REDUCE_SMAX:
2165 case ISD::VP_REDUCE_SMIN:
2166 case ISD::VP_REDUCE_UMAX:
2167 case ISD::VP_REDUCE_UMIN:
2168 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2173 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2176 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2179 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2181 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2182 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2183 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2185 case ISD::EXPERIMENTAL_VP_SPLICE:
2186 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2189 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2194 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2197 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2203 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2208 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2212 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2217 if (!Res.
getNode())
return false;
2224 const bool IsStrictFp =
N->isStrictFPOpcode();
2226 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2227 "Invalid operand expansion");
2231 ReplaceValueWith(
SDValue(
N, 0), Res);
2245 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2249 unsigned OpLEffectiveBits =
2250 DAG.computeKnownBits(OpL).countMaxActiveBits();
2251 unsigned OpREffectiveBits =
2252 DAG.computeKnownBits(OpR).countMaxActiveBits();
2253 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2254 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2261 LHS = SExtPromotedInteger(
LHS);
2262 RHS = SExtPromotedInteger(
RHS);
2271 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2272 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2273 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2274 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2281 LHS = ZExtPromotedInteger(
LHS);
2282 RHS = ZExtPromotedInteger(
RHS);
2296 LHS = SExtPromotedInteger(
LHS);
2297 RHS = SExtPromotedInteger(
RHS);
2302 "Unknown integer comparison!");
2304 SExtOrZExtPromotedOperands(
LHS,
RHS);
2308 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2312SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2313 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2314 EVT ResVT =
N->getValueType(0);
2315 EVT OpVT =
Op.getValueType();
2318 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2323 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2324 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2325 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2329 EVT OutVT =
N->getValueType(0);
2332 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2335 switch (getTypeAction(InVT)) {
2339 DAG.getDataLayout().isLittleEndian()) {
2349 if (isTypeLegal(WideVecVT)) {
2350 SDValue Promoted = GetPromotedInteger(InOp);
2353 DAG.getVectorIdxConstant(0, dl));
2366 return CreateStackStoreLoad(InOp, OutVT);
2369SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2370 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2378 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2379 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2383SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2384 assert(OpNo == 1 &&
"only know how to promote condition");
2387 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2390 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2391 N->getOperand(2)), 0);
2394SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2395 assert(OpNo == 1 &&
"only know how to promote condition");
2398 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2401 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2406 EVT OVT =
N->getOperand(0).getValueType();
2407 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2408 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2409 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2414 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2415 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2424 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2425 "Legal vector of one illegal element?");
2430 assert(
N->getOperand(0).getValueSizeInBits() >=
2431 N->getValueType(0).getScalarSizeInBits() &&
2432 "Type of inserted value narrower than vector element type!");
2435 for (
unsigned i = 0; i < NumElts; ++i)
2436 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2438 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2441SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2448 assert(
N->getOperand(1).getValueSizeInBits() >=
2449 N->getValueType(0).getScalarSizeInBits() &&
2450 "Type of inserted value narrower than vector element type!");
2451 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2452 GetPromotedInteger(
N->getOperand(1)),
2457 assert(OpNo == 2 &&
"Different operand and result vector types?");
2460 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2461 TLI.getVectorIdxTy(DAG.getDataLayout()));
2462 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2463 N->getOperand(1), Idx), 0);
2467 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2471 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2474SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2475 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2477 EVT OpTy =
N->getOperand(1).getValueType();
2480 if (
SDValue Res = WidenVSELECTMask(
N))
2481 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2482 Res,
N->getOperand(1),
N->getOperand(2));
2486 Cond = PromoteTargetBoolean(
Cond, OpVT);
2488 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2489 N->getOperand(2)), 0);
2492SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2493 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2501 N->getOperand(3),
N->getOperand(4)), 0);
2504SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2505 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2513 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2515 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2518 N->getOperand(3),
N->getOperand(4)),
2523 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2524 ZExtPromotedInteger(
N->getOperand(1))), 0);
2532 LHS = SExtPromotedInteger(
LHS);
2533 RHS = SExtPromotedInteger(
RHS);
2535 SExtOrZExtPromotedOperands(
LHS,
RHS);
2542 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2543 ZExtPromotedInteger(
N->getOperand(2))), 0);
2547 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2551 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2554SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2556 EVT VT =
N->getValueType(0);
2557 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2559 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2563 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2565 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2567 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2572 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2573 return SDValue(DAG.UpdateNodeOperands(
N,
2574 SExtPromotedInteger(
N->getOperand(0)),
2575 N->getOperand(1),
N->getOperand(2)),
2577 return SDValue(DAG.UpdateNodeOperands(
N,
2578 SExtPromotedInteger(
N->getOperand(0))), 0);
2581SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2582 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2583 SExtPromotedInteger(
N->getOperand(1))), 0);
2588 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2591 SDValue Val = GetPromotedInteger(
N->getValue());
2594 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2595 N->getMemoryVT(),
N->getMemOperand());
2601 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2602 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2604 SDValue DataOp = GetPromotedInteger(
N->getValue());
2605 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2606 N->getMask(),
N->getVectorLength(),
2607 N->getMemoryVT(),
N->getMemOperand(),
2608 N->isCompressingStore());
2619 Mask = PromoteTargetBoolean(Mask, DataVT);
2622 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2625 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2626 DataOp = GetPromotedInteger(DataOp);
2628 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2629 N->getOffset(), Mask,
N->getMemoryVT(),
2630 N->getMemOperand(),
N->getAddressingMode(),
2631 true,
N->isCompressingStore());
2636 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2637 EVT DataVT =
N->getValueType(0);
2638 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2640 NewOps[OpNo] =
Mask;
2641 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2657 EVT DataVT =
N->getValueType(0);
2658 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2659 }
else if (OpNo == 4) {
2661 if (
N->isIndexSigned())
2663 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2665 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2667 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2669 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2681 bool TruncateStore =
N->isTruncatingStore();
2686 EVT DataVT =
N->getValue().getValueType();
2687 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2688 }
else if (OpNo == 4) {
2690 if (
N->isIndexSigned())
2692 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2694 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2696 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2697 TruncateStore =
true;
2700 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2701 SDLoc(
N), NewOps,
N->getMemOperand(),
2702 N->getIndexType(), TruncateStore);
2707 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2711 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2716 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2717 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2718 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2719 N->getOperand(1),
N->getOperand(2));
2724 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2725 return SDValue(DAG.UpdateNodeOperands(
N,
2726 ZExtPromotedInteger(
N->getOperand(0)),
2727 N->getOperand(1),
N->getOperand(2)),
2729 return SDValue(DAG.UpdateNodeOperands(
N,
2730 ZExtPromotedInteger(
N->getOperand(0))), 0);
2733SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2734 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2739SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2740 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2741 ZExtPromotedInteger(
N->getOperand(1))), 0);
2748 EVT VT =
N->getValueType(0);
2753 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2754 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2755 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2756 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2761 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2764SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2766 EVT VT =
N->getValueType(0);
2767 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2769 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2771 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2772 N->getOperand(0).getValueType());
2776 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2778 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2781SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2783 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2784 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2793 unsigned OpOffset = IsStrict ? 1 : 0;
2800 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2801 if (LCImpl == RTLIB::Unsupported) {
2807 if (IsPowI &&
N->getValueType(0).isVector())
2808 return DAG.UnrollVectorOp(
N);
2810 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2811 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2821 assert(DAG.getLibInfo().getIntSize() ==
2822 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2823 "POWI exponent should match with sizeof(int) when doing the libcall.");
2824 TargetLowering::MakeLibCallOptions CallOptions;
2826 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2827 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2828 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2829 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2831 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2836 switch (
N->getOpcode()) {
2844 case ISD::VP_REDUCE_ADD:
2845 case ISD::VP_REDUCE_MUL:
2846 case ISD::VP_REDUCE_AND:
2847 case ISD::VP_REDUCE_OR:
2848 case ISD::VP_REDUCE_XOR:
2852 case ISD::VP_REDUCE_SMAX:
2853 case ISD::VP_REDUCE_SMIN:
2857 case ISD::VP_REDUCE_UMAX:
2858 case ISD::VP_REDUCE_UMIN:
2868 return GetPromotedInteger(V);
2870 return SExtPromotedInteger(V);
2872 return ZExtPromotedInteger(V);
2878 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2880 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2881 EVT InVT =
Op.getValueType();
2883 EVT ResVT =
N->getValueType(0);
2884 unsigned Opcode =
N->getOpcode();
2901 switch (TLI.getBooleanContents(InVT)) {
2904 Op = ZExtPromotedInteger(
N->getOperand(0));
2907 Op = SExtPromotedInteger(
N->getOperand(0));
2920 switch (TLI.getBooleanContents(InVT)) {
2923 Op = ZExtPromotedInteger(
N->getOperand(0));
2926 Op = SExtPromotedInteger(
N->getOperand(0));
2932 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2936 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2940SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2947 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2948 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2951 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2953 Op = PromoteIntOpVectorReduction(
N,
Op);
2957 EVT VT =
N->getValueType(0);
2958 EVT EltVT =
Op.getValueType().getScalarType();
2961 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2973 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2974 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2977SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2980 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2981 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2984SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2987 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2988 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2993 const Function &Fn = DAG.getMachineFunction().getFunction();
2995 "cannot use llvm.write_register with illegal type", Fn,
2997 return N->getOperand(0);
3000SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3001 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3002 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3005 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3007 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3010SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3014 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3015 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3018 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3020 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3021 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3024SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3026 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3028 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3029 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3032SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3034 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3038 if (TLI.getBooleanContents(
Op.getValueType()) ==
3040 NewOp = SExtPromotedInteger(
Op);
3042 NewOp = ZExtPromotedInteger(
Op);
3044 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3047SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3049 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3050 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3051 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3054SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3057 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3058 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3061SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3063 switch (
N->getOpcode()) {
3065 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3066 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3069 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3070 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3073 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3074 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3079 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3082SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3084 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3085 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3086 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3088 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3099void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3105 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3108 switch (
N->getOpcode()) {
3111 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3112 N->dump(&DAG);
dbgs() <<
"\n";
3190 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3191 SplitInteger(Tmp.first,
Lo,
Hi);
3192 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3197 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3198 SDValue Tmp = DAG.getAtomicCmpSwap(
3200 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3209 SplitInteger(Tmp,
Lo,
Hi);
3288 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3293 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3299 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3303 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3307 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3312 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3322std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3323 unsigned Opc =
Node->getOpcode();
3329 EVT RetVT =
Node->getValueType(0);
3330 TargetLowering::MakeLibCallOptions CallOptions;
3333 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3334 if (LCImpl != RTLIB::Unsupported) {
3336 Ops.push_back(
Node->getOperand(1));
3339 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3340 "Unexpected atomic op or value type!");
3342 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3344 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3345 Node->getOperand(0));
3350void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3355 GetExpandedInteger(
N->getOperand(0), InL, InH);
3370 if (Amt.
uge(VTBits)) {
3371 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3372 }
else if (Amt.
ugt(NVTBits)) {
3373 Lo = DAG.getConstant(0,
DL, NVT);
3375 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3376 }
else if (Amt == NVTBits) {
3377 Lo = DAG.getConstant(0,
DL, NVT);
3381 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3383 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3385 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3390 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3392 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3399 if (Amt.
uge(VTBits)) {
3400 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3401 }
else if (Amt.
ugt(NVTBits)) {
3403 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3404 Hi = DAG.getConstant(0,
DL, NVT);
3405 }
else if (Amt == NVTBits) {
3407 Hi = DAG.getConstant(0,
DL, NVT);
3410 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3412 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3417 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3419 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3422 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3428 if (Amt.
uge(VTBits)) {
3430 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3431 }
else if (Amt.
ugt(NVTBits)) {
3433 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3435 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3436 }
else if (Amt == NVTBits) {
3439 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3442 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3444 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3449 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3451 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3454 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3462bool DAGTypeLegalizer::
3464 unsigned Opc =
N->getOpcode();
3467 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3472 "Expanded integer type size not a power of two!");
3476 KnownBits Known = DAG.computeKnownBits(Amt);
3479 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3484 GetExpandedInteger(In, InL, InH);
3491 DAG.getConstant(~HighBitMask, dl, ShTy));
3496 Lo = DAG.getConstant(0, dl, NVT);
3497 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3500 Hi = DAG.getConstant(0, dl, NVT);
3501 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3505 DAG.getConstant(NVTBits - 1, dl, ShTy));
3506 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3518 DAG.getConstant(NVTBits - 1, dl, ShTy));
3534 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3536 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3538 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3539 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3551bool DAGTypeLegalizer::
3554 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3558 "Expanded integer type size not a power of two!");
3563 GetExpandedInteger(
N->getOperand(0), InL, InH);
3565 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3568 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3571 Amt, DAG.getConstant(0, dl, ShTy),
3575 switch (
N->getOpcode()) {
3581 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3582 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3585 LoL = DAG.getConstant(0, dl, NVT);
3588 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3589 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3590 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3596 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3599 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3602 HiL = DAG.getConstant(0, dl, NVT);
3605 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3606 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3607 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3613 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3614 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3618 DAG.getConstant(NVTBits - 1, dl, ShTy));
3621 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3622 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3623 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3648 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3653 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3654 SplitInteger(Res,
Lo,
Hi);
3657void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3666 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3667 unsigned NumHalfBits = NumBits / 2;
3668 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3669 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3670 SDValue LHSL, LHSH, RHSL, RHSH;
3671 GetExpandedInteger(
LHS, LHSL, LHSH);
3672 GetExpandedInteger(
RHS, RHSL, RHSH);
3675 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3677 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3685 SDValue LHSL, LHSH, RHSL, RHSH;
3686 GetExpandedInteger(
LHS, LHSL, LHSH);
3687 GetExpandedInteger(
RHS, RHSL, RHSH);
3689 EVT CCT = getSetCCResultType(NVT);
3692 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3694 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3696 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3698 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3702 const APInt *RHSVal =
nullptr;
3704 RHSVal = &RHSConst->getAPIntValue();
3711 SDValue LHSL, LHSH, RHSL, RHSH;
3712 GetExpandedInteger(
LHS, LHSL, LHSH);
3713 GetExpandedInteger(
RHS, RHSL, RHSH);
3715 EVT CCT = getSetCCResultType(NVT);
3721 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3724 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3728 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3731 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3733 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3740 switch (
N->getOpcode()) {
3767 EVT VT =
N->getValueType(0);
3768 EVT CCT = getSetCCResultType(VT);
3771 SplitInteger(Result,
Lo,
Hi);
3775 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3776 SplitInteger(ExpandedCMP,
Lo,
Hi);
3779void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3783 SDValue LHSL, LHSH, RHSL, RHSH;
3784 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3785 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3788 SDValue LoOps[2] = { LHSL, RHSL };
3789 SDValue HiOps[3] = { LHSH, RHSH };
3791 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3793 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3795 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3799 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3805 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3818 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3820 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3823 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3837 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3839 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3843 EVT OvfVT = getSetCCResultType(NVT);
3844 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3859 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3862 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3866 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3878 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3882 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3885 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3888 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3893 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3895 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3896 DAG.getConstant(0, dl, NVT));
3899 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3908 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3913 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3915 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3916 DAG.getConstant(0, dl, NVT));
3922void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3925 SDValue LHSL, LHSH, RHSL, RHSH;
3927 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3928 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3929 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3930 SDValue LoOps[2] = { LHSL, RHSL };
3931 SDValue HiOps[3] = { LHSH, RHSH };
3945 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3948void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3951 SDValue LHSL, LHSH, RHSL, RHSH;
3953 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3954 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3955 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3957 SDValue HiOps[3] = { LHSH, RHSH };
3959 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3961 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3965 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3968void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3976 unsigned CarryOp, NoCarryOp;
3978 switch(
N->getOpcode()) {
3993 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3994 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3998 SDValue LHSL, LHSH, RHSL, RHSH;
3999 GetExpandedInteger(
LHS, LHSL, LHSH);
4000 GetExpandedInteger(
RHS, RHSL, RHSH);
4001 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4002 SDValue LoOps[2] = { LHSL, RHSL };
4003 SDValue HiOps[3] = { LHSH, RHSH };
4005 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4007 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4014 SplitInteger(Sum,
Lo,
Hi);
4020 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4021 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4025 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4030 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4036 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4042 SDValue LHSL, LHSH, RHSL, RHSH;
4044 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4045 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4046 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4050 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4052 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4056 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4059void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4062 SDValue LHSL, LHSH, RHSL, RHSH;
4064 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4065 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4066 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4071 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4072 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4076 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4079void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4081 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4084 if (
Op.getValueType().bitsLE(NVT)) {
4087 Hi = DAG.getUNDEF(NVT);
4091 assert(getTypeAction(
Op.getValueType()) ==
4093 "Only know how to promote this result!");
4096 "Operand over promoted?");
4098 SplitInteger(Res,
Lo,
Hi);
4102void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4105 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4106 EVT NVT =
Lo.getValueType();
4111 if (NVTBits < EVTBits) {
4114 EVTBits - NVTBits)));
4119 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4123void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4126 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4127 EVT NVT =
Lo.getValueType();
4132 if (NVTBits < EVTBits) {
4135 EVTBits - NVTBits)));
4139 Hi = DAG.getConstant(0, dl, NVT);
4143void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4146 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4151void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4154 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4163 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4164 EVT NVT =
Lo.getValueType();
4167 Hi = DAG.getConstant(0, dl, NVT);
4170void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4172 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4175 const APInt &Cst =
Constant->getAPIntValue();
4176 bool IsTarget =
Constant->isTargetOpcode();
4177 bool IsOpaque =
Constant->isOpaque();
4179 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4180 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4188 GetExpandedInteger(N0,
Lo,
Hi);
4189 EVT NVT =
Lo.getValueType();
4195 Hi = DAG.getConstant(0, dl, NVT);
4205 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4210 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4211 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4220 EVT VT =
N->getValueType(0);
4222 DAG.getConstant(0, dl, VT), N0);
4224 SplitInteger(Neg, NegLo, NegHi);
4226 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4228 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4229 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4232void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4236 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4237 EVT NVT =
Lo.getValueType();
4239 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4242 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4245 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4246 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4249 Hi = DAG.getConstant(0, dl, NVT);
4257 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4258 EVT NVT =
Lo.getValueType();
4261 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4262 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4265 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4268 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4270 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4272 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4273 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4275 Hi = DAG.getConstant(0, dl, NVT);
4280 SplitInteger(Result,
Lo,
Hi);
4285 EVT VT =
N->getValueType(0);
4290 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4291 "LibCall explicitly requested, but not available");
4293 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4294 TargetLowering::MakeLibCallOptions CallOptions;
4298 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4299 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4307 GetExpandedInteger(
Op,
Lo,
Hi);
4308 EVT NVT =
Lo.getValueType();
4311 Hi = DAG.getConstant(0,
DL, NVT);
4314void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4318 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4319 EVT NVT =
Lo.getValueType();
4321 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4327 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4328 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4331 Hi = DAG.getConstant(0, dl, NVT);
4337 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4344 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4348 ReplaceValueWith(
SDValue(
N, 1), Chain);
4356 Chain =
Op.getValue(1);
4365 EVT VT =
N->getValueType(0);
4369 bool IsStrict =
N->isStrictFPOpcode();
4371 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4375 Op.getValueType() == MVT::bf16) {
4381 EVT OpVT =
Op.getValueType();
4385 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4386 TargetLowering::MakeLibCallOptions CallOptions;
4391 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4392 CallOptions, dl, Chain);
4393 SplitInteger(Tmp.first,
Lo,
Hi);
4396 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4401 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4402 SplitInteger(Res,
Lo,
Hi);
4408 bool IsStrict =
N->isStrictFPOpcode();
4409 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4412 EVT VT =
Op.getValueType();
4414 if (VT == MVT::f16) {
4420 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4424 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4428 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4432 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4436 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4440 EVT RetVT =
N->getValueType(0);
4442 TargetLowering::MakeLibCallOptions CallOptions;
4444 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4445 Op, CallOptions, dl,
4447 SplitInteger(Tmp.first,
Lo,
Hi);
4449 if (
N->isStrictFPOpcode())
4450 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4453void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4455 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4458 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4464 EVT VT =
N->getValueType(0);
4465 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4470 AAMDNodes AAInfo =
N->getAAInfo();
4475 if (
N->getMemoryVT().bitsLE(NVT)) {
4476 EVT MemVT =
N->getMemoryVT();
4478 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4479 N->getBaseAlign(), MMOFlags, AAInfo);
4487 unsigned LoSize =
Lo.getValueSizeInBits();
4489 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4492 Hi = DAG.getConstant(0, dl, NVT);
4496 Hi = DAG.getUNDEF(NVT);
4498 }
else if (DAG.getDataLayout().isLittleEndian()) {
4500 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4503 unsigned ExcessBits =
4510 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4511 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4512 N->getBaseAlign(), MMOFlags, AAInfo);
4521 EVT MemVT =
N->getMemoryVT();
4524 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4527 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4530 N->getBaseAlign(), MMOFlags, AAInfo);
4536 N->getPointerInfo().getWithOffset(IncrementSize),
4538 N->getBaseAlign(), MMOFlags, AAInfo);
4550 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4554 DAG.getShiftAmountConstant(
4561 ReplaceValueWith(
SDValue(
N, 1), Ch);
4564void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4568 GetExpandedInteger(
N->getOperand(0), LL, LH);
4569 GetExpandedInteger(
N->getOperand(1), RL, RH);
4573 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4575 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4576 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4579void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4581 EVT VT =
N->getValueType(0);
4582 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4586 GetExpandedInteger(
N->getOperand(0), LL, LH);
4587 GetExpandedInteger(
N->getOperand(1), RL, RH);
4589 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4596 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4597 if (LCImpl == RTLIB::Unsupported) {
4600 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4606 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4607 TargetLowering::MakeLibCallOptions CallOptions;
4609 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4616 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4617 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4618 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4621 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4626 SplitInteger(Result,
Lo,
Hi);
4632 SplitInteger(Result,
Lo,
Hi);
4638 SplitInteger(Result,
Lo,
Hi);
4649 EVT VT =
N->getValueType(0);
4653 uint64_t Scale =
N->getConstantOperandVal(2);
4665 EVT BoolVT = getSetCCResultType(VT);
4667 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4673 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4674 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4680 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4681 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4686 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4687 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4690 SplitInteger(Result,
Lo,
Hi);
4696 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4698 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4700 GetExpandedInteger(
LHS, LL, LH);
4701 GetExpandedInteger(
RHS, RL, RH);
4705 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4712 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4713 SplitInteger(LoTmp, Result[0], Result[1]);
4714 SplitInteger(HiTmp, Result[2], Result[3]);
4716 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4719 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4720 "the size of the current value type");
4741 uint64_t Part0 = Scale / NVTSize;
4742 if (Scale % NVTSize) {
4743 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4746 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4758 if (Scale == VTSize)
4777 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4778 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4779 EVT BoolNVT = getSetCCResultType(NVT);
4782 if (Scale < NVTSize) {
4785 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4786 DAG.getShiftAmountConstant(Scale, NVT, dl));
4787 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4788 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4789 }
else if (Scale == NVTSize) {
4791 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4792 }
else if (Scale < VTSize) {
4796 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4797 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4800 "(and saturation can't happen with Scale==VTSize).");
4802 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4803 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4807 if (Scale < NVTSize) {
4812 unsigned OverflowBits = VTSize - Scale + 1;
4813 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4814 "Extent of overflow bits must start within HL");
4815 SDValue HLHiMask = DAG.getConstant(
4817 SDValue HLLoMask = DAG.getConstant(
4824 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4830 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4831 }
else if (Scale == NVTSize) {
4837 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4843 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4844 }
else if (Scale < VTSize) {
4847 unsigned OverflowBits = VTSize - Scale + 1;
4848 SDValue HHHiMask = DAG.getConstant(
4850 SDValue HHLoMask = DAG.getConstant(
4852 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4853 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4860 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4861 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4864 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4865 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4872 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4874 N->getConstantOperandVal(2), DAG);
4878 N->getConstantOperandVal(2), TLI, DAG);
4879 SplitInteger(Res,
Lo,
Hi);
4882void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4885 "Node has unexpected Opcode");
4895 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4896 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4900 SDValue LHSL, LHSH, RHSL, RHSH;
4901 GetExpandedInteger(
LHS, LHSL, LHSH);
4902 GetExpandedInteger(
RHS, RHSL, RHSH);
4903 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4906 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4915 SplitInteger(Sum,
Lo,
Hi);
4940 EVT VT =
LHS.getValueType();
4943 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4947 EVT OType =
Node->getValueType(1);
4948 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4952 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4955void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4957 EVT VT =
N->getValueType(0);
4959 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4968 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4970 TargetLowering::MakeLibCallOptions CallOptions;
4972 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4975void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4978 SDValue Shiftee =
N->getOperand(0);
4985 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4986 }
while (!TLI.isTypeLegal(LoadVT));
4991 "Shifting unit is not a a power of two!");
4993 const bool IsOneStepShift =
4994 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4999 if (!IsOneStepShift)
5000 ShAmt = DAG.getFreeze(ShAmt);
5003 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5004 unsigned VTByteWidth = VTBitWidth / 8;
5006 "Shiftee type size is not a power of two!");
5007 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5008 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5013 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5015 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5016 EVT PtrTy =
StackPtr.getValueType();
5017 SDValue Ch = DAG.getEntryNode();
5020 DAG.getMachineFunction(),
5026 unsigned WideningOpc =
5028 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5031 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5035 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5041 Flags.setExact(IsOneStepShift);
5044 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5046 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5047 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5050 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5055 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5062 if (DAG.getDataLayout().isBigEndian())
5063 WillIndexUpwards = !WillIndexUpwards;
5066 if (WillIndexUpwards) {
5069 AdjStackPtr = DAG.getMemBasePlusOffset(
5070 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5071 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5075 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5076 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5080 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5085 if (!IsOneStepShift) {
5087 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5088 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5089 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5093 SplitInteger(Res,
Lo,
Hi);
5096void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5098 EVT VT =
N->getValueType(0);
5099 unsigned Opc =
N->getOpcode();
5105 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5109 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5126 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5128 const bool LegalOrCustom =
5132 unsigned ExpansionFactor = 1;
5134 for (EVT TmpVT = NVT;;) {
5135 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5136 if (NewTMPVT == TmpVT)
5143 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5146 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5148 if (LegalOrCustom &&
5152 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5158 SDValue ShiftOp =
N->getOperand(1);
5159 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5161 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5164 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5165 Hi =
Lo.getValue(1);
5170 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5184 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5187 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5189 TargetLowering::MakeLibCallOptions CallOptions;
5192 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5197 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5201void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5203 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5206 if (
Op.getValueType().bitsLE(NVT)) {
5212 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5216 assert(getTypeAction(
Op.getValueType()) ==
5218 "Only know how to promote this result!");
5221 "Operand over promoted?");
5223 SplitInteger(Res,
Lo,
Hi);
5231void DAGTypeLegalizer::
5234 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5237 if (EVT.
bitsLE(
Lo.getValueType())) {
5245 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5246 Hi.getValueType(), dl));
5257void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5259 EVT VT =
N->getValueType(0);
5261 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5270 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5272 TargetLowering::MakeLibCallOptions CallOptions;
5274 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5277void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5279 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5289void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5291 EVT VT =
N->getValueType(0);
5310 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5311 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5312 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5314 EVT BitVT =
N->getValueType(1);
5315 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5317 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5319 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5320 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5339 SplitInteger(Three,
Lo,
Hi);
5343 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5348 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5353 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5357 if (LCImpl == RTLIB::Unsupported ||
5359 DAG.getMachineFunction().getName()) {
5362 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5363 N->getOperand(1), MulLo, MulHi);
5368 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5369 SplitInteger(MulLo,
Lo,
Hi);
5370 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5374 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5377 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5378 MachinePointerInfo());
5382 EVT ArgVT =
Op.getValueType();
5384 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5385 Entry.IsSExt =
true;
5386 Entry.IsZExt =
false;
5387 Args.push_back(Entry);
5391 TargetLowering::ArgListEntry
Entry(
5393 Entry.IsSExt =
true;
5394 Entry.IsZExt =
false;
5395 Args.push_back(Entry);
5397 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5399 TargetLowering::CallLoweringInfo CLI(DAG);
5402 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5403 Func, std::move(Args))
5406 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5408 SplitInteger(CallInfo.first,
Lo,
Hi);
5410 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5411 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5412 DAG.getConstant(0, dl, PtrVT),
5415 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5418void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5420 EVT VT =
N->getValueType(0);
5422 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5432 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5434 if (isTypeLegal(NVT)) {
5436 GetExpandedInteger(
N->getOperand(0), InL, InH);
5438 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5447 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5449 TargetLowering::MakeLibCallOptions CallOptions;
5450 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5453void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5455 EVT VT =
N->getValueType(0);
5457 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5467 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5469 if (isTypeLegal(NVT)) {
5471 GetExpandedInteger(
N->getOperand(0), InL, InH);
5473 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5482 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5484 TargetLowering::MakeLibCallOptions CallOptions;
5485 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5488void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5490 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5493 if (
Op.getValueType().bitsLE(NVT)) {
5496 Hi = DAG.getConstant(0, dl, NVT);
5500 assert(getTypeAction(
Op.getValueType()) ==
5502 "Only know how to promote this result!");
5505 "Operand over promoted?");
5507 SplitInteger(Res,
Lo,
Hi);
5509 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5515void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5519 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5521 SDValue Swap = DAG.getAtomicCmpSwap(
5530void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5534 SDValue Res = TLI.expandVecReduce(
N, DAG);
5535 SplitInteger(Res,
Lo,
Hi);
5538void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5544 N->getOperand(0),
N->getOperand(1));
5545 SplitInteger(Res,
Lo,
Hi);
5552 GetExpandedInteger(
N->getOperand(0), In3, In4);
5553 GetExpandedInteger(
N->getOperand(1), In1, In2);
5557 unsigned Opc =
N->getOpcode();
5560 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5565 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5567 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5571 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5572 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5577 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5578 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5583 SDValue Res = TLI.expandCLMUL(
N, DAG);
5584 return SplitInteger(Res,
Lo,
Hi);
5588 GetExpandedInteger(
N->getOperand(0), LL, LH);
5589 GetExpandedInteger(
N->getOperand(1), RL, RH);
5603 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5608 EVT VT =
N->getValueType(0);
5615 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5618 SplitInteger(Res,
Lo,
Hi);
5625 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5626 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5628 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5629 Lo = DAG.getPOISON(LoVT);
5630 Hi = DAG.getPOISON(HiVT);
5637 EVT VT =
N->getSimpleValueType(0);
5638 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5640 "VectorIdxTy should be smaller than type to be expanded?");
5644 SplitInteger(Res,
Lo,
Hi);
5655bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5659 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5662 switch (
N->getOpcode()) {
5665 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5666 N->dump(&DAG);
dbgs() <<
"\n";
5671 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5675 Res = ExpandOp_FAKE_USE(
N);
5679 Res = TLI.expandLoopDependenceMask(
N, DAG);
5685 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5698 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5703 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5707 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5710 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5712 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5713 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5714 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5717 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5722 if (!Res.
getNode())
return false;
5730 "Invalid operand expansion");
5732 ReplaceValueWith(
SDValue(
N, 0), Res);
5738void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5742 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5743 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5744 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5757 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5764 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5765 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5795 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5796 RHSLo, LowCC,
false, DagCombineInfo, dl);
5798 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5801 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5802 RHSHi, CCCode,
false, DagCombineInfo, dl);
5806 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5815 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5817 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5826 if (LHSHi == RHSHi) {
5835 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5836 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5839 if (HasSETCCCARRY) {
5842 bool FlipOperands =
false;
5859 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5863 DAG.getCondCode(CCCode));
5869 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5870 false, DagCombineInfo, dl);
5873 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5874 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5881 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5886 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5891 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5892 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5893 N->getOperand(4)), 0);
5899 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5904 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5909 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5910 N->getOperand(2),
N->getOperand(3),
5911 DAG.getCondCode(CCCode)), 0);
5917 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5922 "Unexpected setcc expansion!");
5928 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5936 SDLoc dl = SDLoc(
N);
5938 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5939 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5940 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5953 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5963 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5964 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5968 return TLI.expandCMP(
N, DAG);
5976 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5977 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5981 bool IsStrict =
N->isStrictFPOpcode();
5985 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5986 EVT DstVT =
N->getValueType(0);
5989 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5990 "Don't know how to expand this XINT_TO_FP!");
5991 TargetLowering::MakeLibCallOptions CallOptions;
5993 std::pair<SDValue, SDValue> Tmp =
5994 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5999 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6000 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6005 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6008 return ExpandOp_NormalStore(
N, OpNo);
6011 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6013 EVT VT =
N->getOperand(1).getValueType();
6014 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6018 AAMDNodes AAInfo =
N->getAAInfo();
6024 if (
N->getMemoryVT().bitsLE(NVT)) {
6025 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6026 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6027 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6031 if (DAG.getDataLayout().isLittleEndian()) {
6033 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6035 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6038 unsigned ExcessBits =
6045 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6046 N->getPointerInfo().getWithOffset(IncrementSize),
6047 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6053 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6055 EVT ExtVT =
N->getMemoryVT();
6058 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6066 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6070 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6074 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6075 N->getBaseAlign(), MMOFlags, AAInfo);
6080 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6081 N->getPointerInfo().getWithOffset(IncrementSize),
6083 N->getBaseAlign(), MMOFlags, AAInfo);
6089 GetExpandedInteger(
N->getOperand(0), InL, InH);
6098 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6103SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6104 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6105 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6109 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6111 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6114SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6117 "cannot use llvm.write_register with illegal type", Fn,
6120 return N->getOperand(0);
6123SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6126 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6127 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6130 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6133SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6135 unsigned Factor =
N->getNumOperands();
6138 for (
unsigned i = 0; i != Factor; i++)
6139 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6144 for (
unsigned i = 0; i != Factor; i++)
6150SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6152 EVT OutVT =
N->getValueType(0);
6153 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6154 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6158 SDValue BaseIdx =
N->getOperand(1);
6175 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6179 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6185 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6194 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6198 "Promoted operand has an element type greater than result");
6211 InOp0 = GetPromotedInteger(InOp0);
6218 Ops.reserve(OutNumElems);
6219 for (
unsigned i = 0; i != OutNumElems; ++i) {
6224 N->getOperand(0), Index);
6225 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6230 return DAG.getBuildVector(NOutVT, dl,
Ops);
6233SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6234 EVT OutVT =
N->getValueType(0);
6235 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6236 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6248 Vec = GetPromotedInteger(Vec);
6254SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6257 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6263SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6265 EVT VT =
N->getValueType(0);
6270 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6271 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6274 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6278 EVT OutVT =
N->getValueType(0);
6279 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6280 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6281 unsigned NumElems =
N->getNumOperands();
6288 Ops.reserve(NumElems);
6289 for (
unsigned i = 0; i != NumElems; ++i) {
6291 EVT OpVT =
Op.getValueType();
6296 if (OpVT.
bitsLT(NOutVTElem)) {
6302 ExtOpc = NOutExtOpc;
6303 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6308 return DAG.getBuildVector(NOutVT, dl,
Ops);
6315 assert(!
N->getOperand(0).getValueType().isVector() &&
6316 "Input must be a scalar");
6318 EVT OutVT =
N->getValueType(0);
6319 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6320 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6324 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6329 EVT OutVT =
N->getValueType(0);
6330 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6332 "Type must be promoted to a scalable vector type");
6333 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6334 return DAG.getStepVector(dl, NOutVT,
6338SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6341 EVT OutVT =
N->getValueType(0);
6342 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6343 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6345 unsigned NumOperands =
N->getNumOperands();
6350 SDUse *MaxSizedValue = std::max_element(
6352 EVT AVT = A.getValueType().getVectorElementType();
6353 EVT BVT = B.getValueType().getVectorElementType();
6354 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6360 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6362 EVT OpVT =
Op.getValueType();
6364 Op = GetPromotedInteger(
Op);
6367 "Unhandled legalization type");
6371 Op = DAG.getAnyExtOrTrunc(
6379 return DAG.getAnyExtOrTrunc(
6387 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6388 assert(NumElem * NumOperands == NumOutElem &&
6389 "Unexpected number of elements");
6393 for (
unsigned i = 0; i < NumOperands; ++i) {
6396 Op = GetPromotedInteger(
Op);
6397 EVT SclrTy =
Op.getValueType().getVectorElementType();
6398 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6399 "Unexpected number of elements");
6401 for (
unsigned j = 0;
j < NumElem; ++
j) {
6403 DAG.getVectorIdxConstant(j, dl));
6404 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6408 return DAG.getBuildVector(NOutVT, dl,
Ops);
6411SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6412 EVT VT =
N->getValueType(0);
6413 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6414 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6422 if (getTypeAction(
N->getOperand(0).getValueType())
6426 switch(
N->getOpcode()) {
6428 Promoted = SExtPromotedInteger(
N->getOperand(0));
6431 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6434 Promoted = GetPromotedInteger(
N->getOperand(0));
6446 DAG.getVectorIdxConstant(0, dl));
6448 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6452 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6455SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6456 EVT VT =
N->getValueType(0);
6457 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6461SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6462 EVT VT =
N->getValueType(0);
6463 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6467SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6469 EVT VT =
N->getValueType(0);
6470 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6471 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6472 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6476SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6477 EVT OutVT =
N->getValueType(0);
6478 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6479 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6484 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6487 NOutVTElem,
N->getOperand(1));
6489 V0, ConvElem,
N->getOperand(2));
6496 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6497 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6505 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6506 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6507 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6511 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6514 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6515 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6523 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6528SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6531 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6533 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6534 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6535 return DAG.getPOISON(NVT);
6538SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6540 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6541 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6542 TLI.getVectorIdxTy(DAG.getDataLayout()));
6549 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6552SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6557 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6562 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6564 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6576 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6577 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6580SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6582 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6590SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6593 EVT ResVT =
N->getValueType(0);
6594 unsigned NumElems =
N->getNumOperands();
6597 SDValue ResVec = DAG.getUNDEF(ResVT);
6601 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6603 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6615 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6616 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6620 for (
unsigned i=0; i<NumElem; ++i) {
6623 DAG.getVectorIdxConstant(i, dl));
6629 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6632SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6645 for (
unsigned I = 0;
I < OpNo;
I++)
6648 EVT Ty =
Op.getValueType();
6649 SDLoc
DL = SDLoc(
N);
6652 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6660 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6665 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6671SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6684 for (
unsigned I = 0;
I < OpNo;
I++)
6687 EVT Ty =
Op.getValueType();
6688 SDLoc
DL = SDLoc(
N);
6691 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6699 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6704 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")
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.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ 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,...
@ 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.
@ 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)