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";
64 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
68 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
69 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
71 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
73 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
76 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
77 case ISD::VP_CTTZ_ELTS:
78 Res = PromoteIntRes_VP_CttzElements(
N);
81 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
91 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
94 Res = PromoteIntRes_VECTOR_SHUFFLE_VAR(
N);
99 Res = PromoteIntRes_Select(
N);
104 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
106 case ISD::SHL: Res = PromoteIntRes_SHL(
N);
break;
108 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
109 case ISD::SRA: Res = PromoteIntRes_SRA(
N);
break;
110 case ISD::SRL: Res = PromoteIntRes_SRL(
N);
break;
113 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
114 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
118 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
120 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
122 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
124 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
127 Res = PromoteIntRes_VECTOR_SPLICE(
N);
130 Res = PromoteIntRes_VECTOR_REPEAT(
N);
134 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
137 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
139 Res = PromoteIntRes_BUILD_VECTOR(
N);
143 Res = PromoteIntRes_ScalarOp(
N);
147 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
152 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
155 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
159 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
162 Res = PromoteIntRes_MASK_BEFOREFIRST(
N);
165 Res = PromoteIntRes_VECTOR_MATCH(
N);
171 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
185 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
189 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
192 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
196 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
205 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
215 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
222 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
226 case ISD::ABDU: Res = PromoteIntRes_SExtOrZExtIntBinOp(
N);
break;
230 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
234 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
238 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
240 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
242 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
258 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
263 Res = PromoteIntRes_CMP(
N);
278 Res = PromoteIntRes_ABS(
N);
312 Res = PromoteIntRes_VECREDUCE(
N);
315 case ISD::VP_REDUCE_ADD:
316 case ISD::VP_REDUCE_MUL:
317 case ISD::VP_REDUCE_AND:
318 case ISD::VP_REDUCE_OR:
319 case ISD::VP_REDUCE_XOR:
320 case ISD::VP_REDUCE_SMAX:
321 case ISD::VP_REDUCE_SMIN:
322 case ISD::VP_REDUCE_UMAX:
323 case ISD::VP_REDUCE_UMIN:
324 Res = PromoteIntRes_VP_REDUCE(
N);
329 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
333 Res = PromoteIntRes_FREEZE(
N);
338 Res = PromoteIntRes_Rotate(
N);
343 Res = PromoteIntRes_FunnelShift(
N);
349 Res = PromoteIntRes_CLMUL(
N);
353 Res = PromoteIntRes_PEXT(
N);
357 Res = PromoteIntRes_PDEP(
N);
362 Res = PromoteIntRes_MULH(
N);
366 Res = PromoteIntRes_IS_FPCLASS(
N);
369 Res = PromoteIntRes_FFREXP(
N);
374 Res = PromoteIntRes_XRINT(
N);
378 Res = PromoteIntRes_PATCHPOINT(
N);
381 Res = PromoteIntRes_READ_REGISTER(
N);
387 SetPromotedInteger(
SDValue(
N, ResNo), Res);
392 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
393 return GetPromotedInteger(
Op);
396SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
398 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
399 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
404 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
406 Op.getValueType(),
Op,
N->getOperand(1));
411 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
413 Op.getValueType(),
Op,
N->getOperand(1));
417 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
420 switch (TLI.getExtendForAtomicOps()) {
436 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
437 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
447 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
449 Op2 = SExtPromotedInteger(Op2);
452 Op2 = ZExtPromotedInteger(Op2);
455 Op2 = GetPromotedInteger(Op2);
460 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
462 N->getChain(),
N->getBasePtr(),
463 Op2,
N->getMemOperand());
474 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
475 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
479 if (!TLI.isTypeLegal(SVT))
482 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
483 SDValue Res = DAG.getAtomicCmpSwap(
485 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
489 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
495 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
496 switch (TLI.getExtendForAtomicCmpSwapArg()) {
498 Op2 = SExtPromotedInteger(Op2);
501 Op2 = ZExtPromotedInteger(Op2);
504 Op2 = GetPromotedInteger(Op2);
511 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
512 SDValue Res = DAG.getAtomicCmpSwap(
513 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
514 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
516 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
524 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
525 EVT OutVT =
N->getValueType(0);
526 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
529 switch (getTypeAction(InVT)) {
535 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
539 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
542 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
550 BitConvertToInteger(GetScalarizedVector(InOp)));
559 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
560 Lo = BitConvertToInteger(
Lo);
561 Hi = BitConvertToInteger(
Hi);
563 if (DAG.getDataLayout().isBigEndian())
569 JoinIntegers(
Lo,
Hi));
584 if (DAG.getDataLayout().isBigEndian()) {
588 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
603 if (isTypeLegal(WideOutVT)) {
604 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
606 DAG.getVectorIdxConstant(0, dl));
615 DAG.getDataLayout().isLittleEndian()) {
626 if (isTypeLegal(WideVecVT)) {
628 DAG.getUNDEF(WideVecVT), InOp,
629 DAG.getVectorIdxConstant(0, dl));
637 CreateStackStoreLoad(InOp, OutVT));
641 SDValue V = GetPromotedInteger(
N->getOperand(0));
643 V.getValueType(),
V);
647 SDValue Op = GetPromotedInteger(
N->getOperand(0));
648 EVT OVT =
N->getValueType(0);
649 EVT NVT =
Op.getValueType();
657 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
658 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
663 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
669 SDValue Op = GetPromotedInteger(
N->getOperand(0));
670 EVT OVT =
N->getValueType(0);
671 EVT NVT =
Op.getValueType();
680 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
685 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
694 TLI.getTypeToTransformTo(*DAG.getContext(),
695 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
700 EVT VT =
N->getValueType(0);
707 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
714 EVT OVT =
N->getValueType(0);
715 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
721 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
722 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
724 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
730 unsigned CtlzOpcode =
N->getOpcode();
733 SDValue ExtractLeadingBits = DAG.getConstant(
736 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
740 return DAG.getNode(
ISD::SUB, dl, NVT,
741 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
746 SDValue Op = GetPromotedInteger(
N->getOperand(0));
750 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
752 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
758 EVT OVT =
N->getValueType(0);
759 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
762 SDValue ExtractLeadingBits = DAG.getConstant(
765 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
771 EVT OVT =
N->getValueType(0);
772 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
780 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
781 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
788 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
789 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
793 SDValue Op = GetPromotedInteger(
N->getOperand(0));
794 EVT OVT =
N->getValueType(0);
795 EVT NVT =
Op.getValueType();
802 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
803 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
807 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
813 unsigned NewOpc =
N->getOpcode();
820 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
823 return DAG.getNode(NewOpc, dl, NVT,
Op);
826SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
828 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
829 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
832SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
834 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
841 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
847 EVT SVT =
In.getValueType().getScalarType();
850 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
858 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
860 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
864 if (
N->isStrictFPOpcode()) {
865 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
866 {
N->getOperand(0),
N->getOperand(1)});
871 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
886 DAG.getValueType(
N->getValueType(0).getScalarType()));
889SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
891 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
893 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
897SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
898 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
901 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
906SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
907 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
911 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
914SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
915 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
918 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
919 N->getOperand(0),
N->getOperand(1));
925 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
927 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
931 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
935 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
944 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
947 if (getTypeAction(
N->getOperand(0).getValueType())
949 SDValue Res = GetPromotedInteger(
N->getOperand(0));
958 DAG.getValueType(
N->getOperand(0).getValueType()));
960 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
967 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
972 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
976 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
977 N->getMemoryVT(),
N->getMemOperand());
986 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
987 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
990 :
N->getExtensionType();
993 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
994 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
995 N->getMemOperand(),
N->isExpandingLoad());
1003 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1004 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1011 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1012 N->getOffset(),
N->getMask(), ExtPassThru,
1013 N->getMemoryVT(),
N->getMemOperand(),
1014 N->getAddressingMode(), ExtType,
1015 N->isExpandingLoad());
1023 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1024 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1026 "Gather result type and the passThru argument type should be the same");
1033 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1034 N->getIndex(),
N->getScale() };
1035 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1036 N->getMemoryVT(), dl,
Ops,
1037 N->getMemOperand(),
N->getIndexType(),
1045SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1046 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1047 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1049 N->getOperand(1), Passthru);
1052SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE_VAR(
SDNode *
N) {
1053 SDValue V = GetPromotedInteger(
N->getOperand(0));
1062 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1063 EVT VT =
N->getValueType(0);
1064 EVT SVT = getSetCCResultType(VT);
1065 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1066 unsigned NumOps =
N->getNumOperands();
1069 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1077 ReplaceValueWith(
SDValue(
N, 0), Res);
1080 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1095 unsigned Opcode =
N->getOpcode();
1101 SExtOrZExtPromotedOperands(Op1, Op2);
1107 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1109 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1110 Op1 = SExtPromotedInteger(Op1);
1111 Op2 = SExtPromotedInteger(Op2);
1115 Op1 = ZExtPromotedInteger(Op1);
1116 Op2 = ZExtPromotedInteger(Op2);
1119 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1128 Op1 = GetPromotedInteger(Op1);
1130 Op2 = ZExtPromotedInteger(Op2);
1132 Op1 = SExtPromotedInteger(Op1);
1133 Op2 = SExtPromotedInteger(Op2);
1140 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1153 "addition, subtraction or left shift");
1156 unsigned SHLAmount = NewBits - OldBits;
1158 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1163 SDValue Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1164 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1170 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1171 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1172 SDValue Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1181 SDValue Op1Promoted, Op2Promoted;
1187 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1188 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1190 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1191 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1193 EVT OldType =
N->getOperand(0).getValueType();
1205 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1206 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1207 Op2Promoted,
N->getOperand(2));
1209 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1210 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1212 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1217 unsigned SatW,
bool Signed,
1220 EVT VT =
V.getValueType();
1247 EVT VT =
LHS.getValueType();
1263 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1269 "Tried to saturate to more than the original type?");
1278 SDValue Op1Promoted, Op2Promoted;
1284 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1285 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1287 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1288 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1291 unsigned Scale =
N->getConstantOperandVal(2);
1295 if (TLI.isTypeLegal(PromotedType)) {
1297 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1300 N->getValueType(0).getScalarSizeInBits();
1304 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1305 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1306 Op2Promoted,
N->getOperand(2));
1309 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1315 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1316 Op2Promoted, Scale, DAG)) {
1319 N->getValueType(0).getScalarSizeInBits(),
1327 N->getValueType(0).getScalarSizeInBits());
1330SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1332 return PromoteIntRes_Overflow(
N);
1336 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1337 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1338 EVT OVT =
N->getOperand(0).getValueType();
1339 EVT NVT =
LHS.getValueType();
1349 DAG.getValueType(OVT));
1351 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1354 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1360 EVT PromotedResultTy =
1361 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1362 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1363 N->getOperand(0),
N->getOperand(1));
1369 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1370 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1372 unsigned Opcode =
N->getOpcode();
1373 if (Opcode == ISD::VP_MERGE)
1374 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1376 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1380 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1381 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1383 LHS.getValueType(),
N->getOperand(0),
1384 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1389 EVT InVT =
N->getOperand(OpNo).getValueType();
1390 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1392 EVT SVT = getSetCCResultType(InVT);
1399 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1400 SVT = getSetCCResultType(InVT);
1408 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1409 "Vector compare must return a vector result!");
1413 if (
N->isStrictFPOpcode()) {
1414 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1415 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1416 N->getOperand(2),
N->getOperand(3)};
1417 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1422 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1423 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1426 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1433 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1438 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1439 EVT VT =
N->getValueType(0);
1443 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1445 ReplaceValueWith(
SDValue(
N, 0), Res);
1450 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1453 RHS = ZExtPromotedInteger(
RHS);
1454 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1457SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1458 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1460 Op.getValueType(),
Op,
N->getOperand(1));
1463SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1467 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1468 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1469 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1474 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1475 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1476 if (
N->getNumOperands() == 2)
1477 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1478 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1479 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1480 "Expected VP opcode");
1483 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1489 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1490 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1491 if (
N->getNumOperands() == 2)
1492 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1493 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1494 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1495 "Expected VP opcode");
1503SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1504 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1505 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1507 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1511SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1512 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1513 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1515 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1519SDValue DAGTypeLegalizer::PromoteIntRes_SExtOrZExtIntBinOp(
SDNode *
N) {
1525 SExtOrZExtPromotedOperands(
LHS,
RHS);
1527 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1533 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1536 RHS = ZExtPromotedInteger(
RHS);
1537 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1543 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1545 RHS = ZExtPromotedInteger(
RHS);
1546 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1551 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1553 unsigned Opcode =
N->getOpcode();
1564 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1567 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1569 Amt = ZExtPromotedInteger(Amt);
1575 DAG.getConstant(OldBits,
DL, AmtVT));
1576 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1578 SDValue Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1590 SDValue Res = TLI.expandROT(
N,
true , DAG);
1591 ReplaceValueWith(
SDValue(
N, 0), Res);
1596 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1597 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1600 Amt = ZExtPromotedInteger(Amt);
1604 EVT OldVT =
N->getOperand(0).getValueType();
1605 EVT VT =
Lo.getValueType();
1606 unsigned Opcode =
N->getOpcode();
1613 DAG.getConstant(OldBits,
DL, AmtVT));
1621 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1622 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1624 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1634 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1640 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1642 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1646 unsigned Opcode =
N->getOpcode();
1649 EVT OldVT =
N->getOperand(0).getValueType();
1650 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1655 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1657 TLI.isOperationLegalOrCustom(
1658 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1659 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1662 SDValue X = GetPromotedInteger(
N->getOperand(0));
1663 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1667 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1668 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1672 if (NewBits < 2 * OldBits) {
1674 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1676 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1678 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1680 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1685 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1687 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1692 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1693 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1694 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1699 SDValue X = GetPromotedInteger(
N->getOperand(0));
1700 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1706 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1707 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1708 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1713 SDValue X = GetPromotedInteger(
N->getOperand(0));
1714 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1720 EVT VT =
N->getValueType(0);
1721 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1728 LHS = SExtPromotedInteger(
N->getOperand(0));
1729 RHS = SExtPromotedInteger(
N->getOperand(1));
1731 LHS = ZExtPromotedInteger(
N->getOperand(0));
1732 RHS = ZExtPromotedInteger(
N->getOperand(1));
1739 DAG.getShiftAmountConstant(BW, NVT, dl));
1743 DAG.getShiftAmountConstant(NBW - BW, NVT, dl));
1744 return DAG.getNode(
N->getOpcode(), dl, NVT,
LHS,
RHS);
1748 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1760 Res = GetPromotedInteger(InOp);
1767 "Dst and Src must have the same number of elements");
1769 "Promoted vector type must be a power of two");
1772 GetSplitVector(InOp, EOp1, EOp2);
1781 SDValue WideInOp = GetWidenedVector(InOp);
1786 N->getValueType(0).getScalarType(), NumElem);
1795 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1804SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1806 return PromoteIntRes_Overflow(
N);
1810 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1811 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1812 EVT OVT =
N->getOperand(0).getValueType();
1813 EVT NVT =
LHS.getValueType();
1822 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1824 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1827 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1838 return PromoteIntRes_Overflow(
N);
1850 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1851 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1853 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1856 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1867 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1868 return PromoteIntRes_Overflow(
N);
1872 EVT OVT =
N->getValueType(0);
1873 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1879 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1881 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1882 if (
SDValue Res = TLI.expandABS(
N, DAG))
1886 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1890SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1893 return PromoteIntRes_Overflow(
N);
1897 EVT SmallVT =
LHS.getValueType();
1904 LHS = SExtPromotedInteger(
LHS);
1905 RHS = SExtPromotedInteger(
RHS);
1907 LHS = ZExtPromotedInteger(
LHS);
1908 RHS = ZExtPromotedInteger(
RHS);
1910 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1922 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1923 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1924 DAG.getConstant(0,
DL,
Hi.getValueType()),
1929 Mul, DAG.getValueType(SmallVT));
1939 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1944 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1945 N->getValueType(0)));
1949 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1951 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1958 EVT VT =
N->getValueType(0);
1961 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1962 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1966 for (
unsigned i = 0; i < NumRegs; ++i) {
1967 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1968 N->getConstantOperandVal(3));
1973 if (DAG.getDataLayout().isBigEndian())
1974 std::reverse(Parts.begin(), Parts.end());
1977 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1979 for (
unsigned i = 1; i < NumRegs; ++i) {
1984 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1990 ReplaceValueWith(
SDValue(
N, 1), Chain);
2003bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2006 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2011 switch (
N->getOpcode()) {
2014 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2015 N->dump(&DAG);
dbgs() <<
"\n";
2021 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2027 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2028 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2033 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2037 Res = PromoteIntOp_FAKE_USE(
N);
2040 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2044 Res = PromoteIntOp_ScalarOp(
N);
2047 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2049 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2067 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2070 Res = PromoteIntOp_VECTOR_SHUFFLE_VAR(
N, OpNo);
2077 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2092 Res = PromoteIntOp_Shift(
N);
2096 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2099 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2125 case ISD::VP_REDUCE_ADD:
2126 case ISD::VP_REDUCE_MUL:
2127 case ISD::VP_REDUCE_AND:
2128 case ISD::VP_REDUCE_OR:
2129 case ISD::VP_REDUCE_XOR:
2130 case ISD::VP_REDUCE_SMAX:
2131 case ISD::VP_REDUCE_SMIN:
2132 case ISD::VP_REDUCE_UMAX:
2133 case ISD::VP_REDUCE_UMIN:
2134 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2139 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2142 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2145 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2147 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2148 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2149 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2151 case ISD::EXPERIMENTAL_VP_SPLICE:
2152 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2155 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2160 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2163 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2166 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2172 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2177 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2180 Res = PromoteIntOp_VECTOR_REPEAT(
N);
2184 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2189 if (!Res.
getNode())
return false;
2196 const bool IsStrictFp =
N->isStrictFPOpcode();
2198 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2199 "Invalid operand expansion");
2203 ReplaceValueWith(
SDValue(
N, 0), Res);
2217 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2221 unsigned OpLEffectiveBits =
2222 DAG.computeKnownBits(OpL).countMaxActiveBits();
2223 unsigned OpREffectiveBits =
2224 DAG.computeKnownBits(OpR).countMaxActiveBits();
2225 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2226 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2233 LHS = SExtPromotedInteger(
LHS);
2234 RHS = SExtPromotedInteger(
RHS);
2243 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2244 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2245 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2246 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2253 LHS = ZExtPromotedInteger(
LHS);
2254 RHS = ZExtPromotedInteger(
RHS);
2268 LHS = SExtPromotedInteger(
LHS);
2269 RHS = SExtPromotedInteger(
RHS);
2274 "Unknown integer comparison!");
2276 SExtOrZExtPromotedOperands(
LHS,
RHS);
2280 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2284SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2285 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2286 EVT ResVT =
N->getValueType(0);
2287 EVT OpVT =
Op.getValueType();
2290 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2295 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2296 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2297 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2301 EVT OutVT =
N->getValueType(0);
2304 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2307 switch (getTypeAction(InVT)) {
2313 if (OutEltBits % InEltBits == 0 && isTypeLegal(IntVT)) {
2316 SDValue Promoted = GetPromotedInteger(InOp);
2319 if (PromotedEltBits % InEltBits == 0) {
2320 unsigned Scale = PromotedEltBits / InEltBits;
2328 PromotedBits / OutEltBits);
2329 if (isTypeLegal(PackedVT) && isTypeLegal(CastVT) &&
2336 Mask[
I] =
I * Scale +
2337 (DAG.getDataLayout().isBigEndian() ? Scale - 1 : 0);
2338 if (TLI.isShuffleMaskLegal(Mask, PackedVT)) {
2341 Packed = DAG.getVectorShuffle(PackedVT, dl, Packed,
2342 DAG.getUNDEF(PackedVT), Mask);
2345 return DAG.getExtractSubvector(dl, OutVT, Packed, 0);
2346 return DAG.getExtractVectorElt(dl, OutVT, Packed, 0);
2351 unsigned PartsPerElt = OutEltBits / InEltBits;
2355 for (
unsigned I = 0;
I != NumElts; ++
I) {
2357 for (
unsigned J = 0; J != PartsPerElt; ++J) {
2358 SDValue Part = DAG.getExtractVectorElt(
2360 I * PartsPerElt + J);
2361 Part = DAG.getZeroExtendInReg(Part, dl, InVT.
getScalarType());
2362 Part = DAG.getZExtOrTrunc(Part, dl, IntVT);
2363 unsigned Shift = DAG.getDataLayout().isBigEndian()
2364 ? (PartsPerElt - 1 - J) * InEltBits
2367 DAG.getShiftAmountConstant(Shift, IntVT, dl));
2375 Packed = DAG.getBuildVector(VecVT, dl, Elts);
2382 DAG.getDataLayout().isLittleEndian()) {
2392 if (isTypeLegal(WideVecVT)) {
2393 SDValue Promoted = GetPromotedInteger(InOp);
2396 DAG.getVectorIdxConstant(0, dl));
2409 return CreateStackStoreLoad(InOp, OutVT);
2412SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2413 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2417 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(1));
2421 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2422 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2426SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2427 assert(OpNo == 1 &&
"only know how to promote condition");
2430 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2433 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2434 N->getOperand(2)), 0);
2437SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2438 assert(OpNo == 1 &&
"only know how to promote condition");
2441 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2444 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2449 EVT OVT =
N->getOperand(0).getValueType();
2450 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2451 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2452 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2457 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2458 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2467 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2468 "Legal vector of one illegal element?");
2473 assert(
N->getOperand(0).getValueSizeInBits() >=
2474 N->getValueType(0).getScalarSizeInBits() &&
2475 "Type of inserted value narrower than vector element type!");
2478 for (
unsigned i = 0; i < NumElts; ++i)
2479 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2481 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2484SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2491 assert(
N->getOperand(1).getValueSizeInBits() >=
2492 N->getValueType(0).getScalarSizeInBits() &&
2493 "Type of inserted value narrower than vector element type!");
2494 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2495 GetPromotedInteger(
N->getOperand(1)),
2500 assert(OpNo == 2 &&
"Different operand and result vector types?");
2503 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2504 TLI.getVectorIdxTy(DAG.getDataLayout()));
2505 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2506 N->getOperand(1), Idx), 0);
2510 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2514 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2517SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2518 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2520 EVT OpTy =
N->getOperand(1).getValueType();
2523 if (
SDValue Res = WidenVSELECTMask(
N))
2524 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2525 Res,
N->getOperand(1),
N->getOperand(2));
2529 Cond = PromoteTargetBoolean(
Cond, OpVT);
2531 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2532 N->getOperand(2)), 0);
2535SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2536 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2540 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(4));
2544 N->getOperand(3),
N->getOperand(4)), 0);
2547SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2548 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2552 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(2));
2555 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2559 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2560 ZExtPromotedInteger(
N->getOperand(1))), 0);
2568 LHS = SExtPromotedInteger(
LHS);
2569 RHS = SExtPromotedInteger(
RHS);
2571 SExtOrZExtPromotedOperands(
LHS,
RHS);
2578 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2579 ZExtPromotedInteger(
N->getOperand(2))), 0);
2583 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2587 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2591 return SDValue(DAG.UpdateNodeOperands(
N,
2592 SExtPromotedInteger(
N->getOperand(0))), 0);
2595SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2596 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2597 SExtPromotedInteger(
N->getOperand(1))), 0);
2602 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2605 SDValue Val = GetPromotedInteger(
N->getValue());
2608 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2609 N->getMemoryVT(),
N->getMemOperand());
2615 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2616 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2618 SDValue DataOp = GetPromotedInteger(
N->getValue());
2619 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2620 N->getMask(),
N->getVectorLength(),
2621 N->getMemoryVT(),
N->getMemOperand(),
2622 N->isCompressingStore());
2633 Mask = PromoteTargetBoolean(Mask, DataVT);
2636 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2639 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2640 DataOp = GetPromotedInteger(DataOp);
2642 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2643 N->getOffset(), Mask,
N->getMemoryVT(),
2644 N->getMemOperand(),
N->getAddressingMode(),
2645 true,
N->isCompressingStore());
2650 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2651 EVT DataVT =
N->getValueType(0);
2652 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2654 NewOps[OpNo] =
Mask;
2655 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2671 EVT DataVT =
N->getValueType(0);
2672 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2673 }
else if (OpNo == 4) {
2675 if (
N->isIndexSigned())
2677 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2679 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2681 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2683 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2695 bool TruncateStore =
N->isTruncatingStore();
2700 EVT DataVT =
N->getValue().getValueType();
2701 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2702 }
else if (OpNo == 4) {
2704 if (
N->isIndexSigned())
2706 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2708 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2710 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2711 TruncateStore =
true;
2714 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2715 SDLoc(
N), NewOps,
N->getMemOperand(),
2716 N->getIndexType(), TruncateStore);
2721 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2725 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2729SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_SHUFFLE_VAR(
SDNode *
N,
2731 assert(OpNo == 1 &&
"The source shares the result's type, so promoting it "
2732 "is a result promotion.");
2735 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0), Mask), 0);
2739 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2744 return SDValue(DAG.UpdateNodeOperands(
N,
2745 ZExtPromotedInteger(
N->getOperand(0))), 0);
2748SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2749 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2754SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2755 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2756 ZExtPromotedInteger(
N->getOperand(1))), 0);
2763 EVT VT =
N->getValueType(0);
2768 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2769 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2770 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2771 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2776 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2780 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2782 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2785SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2787 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2788 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2797 unsigned OpOffset = IsStrict ? 1 : 0;
2801 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2804 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2805 if (LCImpl == RTLIB::Unsupported) {
2811 if (IsPowI &&
N->getValueType(0).isVector())
2812 return DAG.UnrollVectorOp(
N);
2814 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2815 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2827 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2828 DAG.getLibInfo().getIntSize()) {
2829 const Function &Fn = DAG.getMachineFunction().getFunction();
2830 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2831 Twine(IsPowI ?
"powi" :
"ldexp") +
2832 " exponent does not match sizeof(int)",
2833 Fn, N->getDebugLoc()));
2835 ReplaceValueWith(SDValue(N, 1), Chain);
2836 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2840 TargetLowering::MakeLibCallOptions CallOptions;
2841 CallOptions.setIsSigned(
true);
2842 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2843 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2844 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2845 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2847 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2852 switch (
N->getOpcode()) {
2860 case ISD::VP_REDUCE_ADD:
2861 case ISD::VP_REDUCE_MUL:
2862 case ISD::VP_REDUCE_AND:
2863 case ISD::VP_REDUCE_OR:
2864 case ISD::VP_REDUCE_XOR:
2868 case ISD::VP_REDUCE_SMAX:
2869 case ISD::VP_REDUCE_SMIN:
2873 case ISD::VP_REDUCE_UMAX:
2874 case ISD::VP_REDUCE_UMIN:
2884 return GetPromotedInteger(
V);
2886 return SExtPromotedInteger(
V);
2888 return ZExtPromotedInteger(
V);
2894 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2896 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2897 EVT InVT =
Op.getValueType();
2899 EVT ResVT =
N->getValueType(0);
2900 unsigned Opcode =
N->getOpcode();
2917 switch (TLI.getBooleanContents(InVT)) {
2920 Op = ZExtPromotedInteger(
N->getOperand(0));
2923 Op = SExtPromotedInteger(
N->getOperand(0));
2936 switch (TLI.getBooleanContents(InVT)) {
2939 Op = ZExtPromotedInteger(
N->getOperand(0));
2942 Op = SExtPromotedInteger(
N->getOperand(0));
2948 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2952 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2956SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2963 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2964 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2967 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2969 Op = PromoteIntOpVectorReduction(
N,
Op);
2973 EVT VT =
N->getValueType(0);
2974 EVT EltVT =
Op.getValueType().getScalarType();
2977 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2989 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2990 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2993SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2996 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2997 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3000SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3003 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3004 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3009 const Function &Fn = DAG.getMachineFunction().getFunction();
3011 "cannot use llvm.write_register with illegal type", Fn,
3013 return N->getOperand(0);
3016SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3017 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3018 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3021 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3022 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3032SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3036 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3037 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3040 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3042 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3043 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3046SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3048 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3050 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3051 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3054SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3056 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3060 if (TLI.getBooleanContents(
Op.getValueType()) ==
3062 NewOp = SExtPromotedInteger(
Op);
3064 NewOp = ZExtPromotedInteger(
Op);
3066 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3069SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3071 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3072 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3073 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3076SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
3077 assert(OpNo < 3 &&
"Unexpected operand for promotion");
3079 return TLI.expandVectorMatch(
N, DAG);
3082 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
3083 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3086SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3089 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3090 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3093SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3095 switch (
N->getOpcode()) {
3097 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3098 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3101 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3102 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3105 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3106 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3111 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3114SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3116 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3117 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3118 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3120 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3125 SDValue Src = GetPromotedInteger(
N->getOperand(0));
3126 EVT SrcVT = Src.getValueType();
3127 EVT OrigVT =
N->getValueType(0);
3142void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3148 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3151 switch (
N->getOpcode()) {
3154 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3155 N->dump(&DAG);
dbgs() <<
"\n";
3184 ExpandIntRes_ABS(
N,
Lo,
Hi);
3236 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3237 SplitInteger(Tmp.first,
Lo,
Hi);
3238 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3243 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3244 SDValue Tmp = DAG.getAtomicCmpSwap(
3246 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3255 SplitInteger(Tmp,
Lo,
Hi);
3334 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3339 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3345 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3349 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3353 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3358 ExpandIntRes_MULH(
N,
Lo,
Hi);
3362 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3366 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3371 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3381std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3382 unsigned Opc =
Node->getOpcode();
3385 "expanded atomic requires a libcall action for the memory type");
3390 EVT RetVT =
Node->getValueType(0);
3391 TargetLowering::MakeLibCallOptions CallOptions;
3394 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3395 if (LCImpl != RTLIB::Unsupported) {
3397 Ops.push_back(
Node->getOperand(1));
3400 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3401 "Unexpected atomic op or value type!");
3403 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3405 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3406 Node->getOperand(0));
3411void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3416 GetExpandedInteger(
N->getOperand(0), InL, InH);
3431 if (Amt.
uge(VTBits)) {
3432 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3433 }
else if (Amt.
ugt(NVTBits)) {
3434 Lo = DAG.getConstant(0,
DL, NVT);
3436 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3437 }
else if (Amt == NVTBits) {
3438 Lo = DAG.getConstant(0,
DL, NVT);
3442 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3444 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3446 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3451 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3453 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3460 if (Amt.
uge(VTBits)) {
3461 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3462 }
else if (Amt.
ugt(NVTBits)) {
3464 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3465 Hi = DAG.getConstant(0,
DL, NVT);
3466 }
else if (Amt == NVTBits) {
3468 Hi = DAG.getConstant(0,
DL, NVT);
3471 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3473 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3478 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3480 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3483 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3489 if (Amt.
uge(VTBits)) {
3491 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3492 }
else if (Amt.
ugt(NVTBits)) {
3494 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3496 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3497 }
else if (Amt == NVTBits) {
3500 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3503 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3505 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3510 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3512 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3515 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3523bool DAGTypeLegalizer::
3525 unsigned Opc =
N->getOpcode();
3528 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3533 "Expanded integer type size not a power of two!");
3537 KnownBits
Known = DAG.computeKnownBits(Amt);
3540 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3545 GetExpandedInteger(In, InL, InH);
3549 if (
Known.One.intersects(HighBitMask)) {
3552 DAG.getConstant(~HighBitMask, dl, ShTy));
3557 Lo = DAG.getConstant(0, dl, NVT);
3558 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3561 Hi = DAG.getConstant(0, dl, NVT);
3562 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3566 DAG.getConstant(NVTBits - 1, dl, ShTy));
3567 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3579 DAG.getConstant(NVTBits - 1, dl, ShTy));
3595 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3597 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3599 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3600 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3612bool DAGTypeLegalizer::
3615 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3619 "Expanded integer type size not a power of two!");
3624 GetExpandedInteger(
N->getOperand(0), InL, InH);
3626 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3629 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3632 Amt, DAG.getConstant(0, dl, ShTy),
3636 switch (
N->getOpcode()) {
3642 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3643 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3646 LoL = DAG.getConstant(0, dl, NVT);
3649 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3650 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3651 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3657 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3660 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3663 HiL = DAG.getConstant(0, dl, NVT);
3666 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3667 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3668 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3674 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3675 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3679 DAG.getConstant(NVTBits - 1, dl, ShTy));
3682 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3683 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3684 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3709 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3714 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3715 SplitInteger(Res,
Lo,
Hi);
3718void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3727 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3728 unsigned NumHalfBits = NumBits / 2;
3729 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3730 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3731 SDValue LHSL, LHSH, RHSL, RHSH;
3732 GetExpandedInteger(
LHS, LHSL, LHSH);
3733 GetExpandedInteger(
RHS, RHSL, RHSH);
3736 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3738 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3746 SDValue LHSL, LHSH, RHSL, RHSH;
3747 GetExpandedInteger(
LHS, LHSL, LHSH);
3748 GetExpandedInteger(
RHS, RHSL, RHSH);
3750 EVT CCT = getSetCCResultType(NVT);
3753 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3755 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3757 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3759 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3763 const APInt *RHSVal =
nullptr;
3765 RHSVal = &RHSConst->getAPIntValue();
3772 SDValue LHSL, LHSH, RHSL, RHSH;
3773 GetExpandedInteger(
LHS, LHSL, LHSH);
3774 GetExpandedInteger(
RHS, RHSL, RHSH);
3776 EVT CCT = getSetCCResultType(NVT);
3782 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3785 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3789 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3792 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3794 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3801 switch (
N->getOpcode()) {
3828 EVT VT =
N->getValueType(0);
3829 EVT CCT = getSetCCResultType(VT);
3832 SplitInteger(Result,
Lo,
Hi);
3836 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3837 SplitInteger(ExpandedCMP,
Lo,
Hi);
3840void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3844 SDValue LHSL, LHSH, RHSL, RHSH;
3845 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3846 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3849 SDValue LoOps[2] = { LHSL, RHSL };
3850 SDValue HiOps[3] = { LHSH, RHSH };
3852 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3854 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3856 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3860 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3866 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3879 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3881 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3884 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3898 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3900 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3904 EVT OvfVT = getSetCCResultType(NVT);
3905 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3920 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3923 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3927 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3939 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3943 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3946 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3949 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3954 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3956 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3957 DAG.getConstant(0, dl, NVT));
3960 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3969 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3974 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3976 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3977 DAG.getConstant(0, dl, NVT));
3983void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3986 SDValue LHSL, LHSH, RHSL, RHSH;
3988 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3989 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3990 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3991 SDValue LoOps[2] = { LHSL, RHSL };
3992 SDValue HiOps[3] = { LHSH, RHSH };
4006 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4009void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4012 SDValue LHSL, LHSH, RHSL, RHSH;
4014 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4015 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4016 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4018 SDValue HiOps[3] = { LHSH, RHSH };
4020 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4022 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4026 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4029void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4037 unsigned CarryOp, NoCarryOp;
4039 switch(
N->getOpcode()) {
4054 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4055 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4059 SDValue LHSL, LHSH, RHSL, RHSH;
4060 GetExpandedInteger(
LHS, LHSL, LHSH);
4061 GetExpandedInteger(
RHS, RHSL, RHSH);
4062 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4063 SDValue LoOps[2] = { LHSL, RHSL };
4064 SDValue HiOps[3] = { LHSH, RHSH };
4066 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4068 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4075 SplitInteger(Sum,
Lo,
Hi);
4081 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4082 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4086 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4091 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4097 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4103 SDValue LHSL, LHSH, RHSL, RHSH;
4105 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4106 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4107 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4111 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4113 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4117 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4120void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4123 SDValue LHSL, LHSH, RHSL, RHSH;
4125 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4126 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4127 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4132 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4133 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4137 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4140void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4142 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4145 if (
Op.getValueType().bitsLE(NVT)) {
4148 Hi = DAG.getUNDEF(NVT);
4152 assert(getTypeAction(
Op.getValueType()) ==
4154 "Only know how to promote this result!");
4157 "Operand over promoted?");
4159 SplitInteger(Res,
Lo,
Hi);
4163void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4166 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4167 EVT NVT =
Lo.getValueType();
4172 if (NVTBits < EVTBits) {
4175 EVTBits - NVTBits)));
4180 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4184void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4187 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4188 EVT NVT =
Lo.getValueType();
4193 if (NVTBits < EVTBits) {
4196 EVTBits - NVTBits)));
4200 Hi = DAG.getConstant(0, dl, NVT);
4204void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4207 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4212void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4215 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4224 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4225 EVT NVT =
Lo.getValueType();
4228 Hi = DAG.getConstant(0, dl, NVT);
4231void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4233 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4236 const APInt &Cst =
Constant->getAPIntValue();
4237 bool IsTarget =
Constant->isTargetOpcode();
4238 bool IsOpaque =
Constant->isOpaque();
4240 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4241 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4249 GetExpandedInteger(N0,
Lo,
Hi);
4250 EVT NVT =
Lo.getValueType();
4255 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4260 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4261 Hi = DAG.getConstant(0, dl, NVT);
4271 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4276 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4277 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4286 EVT VT =
N->getValueType(0);
4288 DAG.getConstant(0, dl, VT), N0);
4290 SplitInteger(Neg, NegLo, NegHi);
4292 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4294 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4295 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4298void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4302 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4303 EVT NVT =
Lo.getValueType();
4305 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4308 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4311 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4312 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4315 Hi = DAG.getConstant(0, dl, NVT);
4323 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4324 EVT NVT =
Lo.getValueType();
4327 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4328 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4331 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4334 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4336 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4338 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4339 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4341 Hi = DAG.getConstant(0, dl, NVT);
4346 SplitInteger(Result,
Lo,
Hi);
4351 EVT VT =
N->getValueType(0);
4356 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4357 "LibCall explicitly requested, but not available");
4359 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4360 TargetLowering::MakeLibCallOptions CallOptions;
4364 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4365 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4373 GetExpandedInteger(
Op,
Lo,
Hi);
4374 EVT NVT =
Lo.getValueType();
4377 Hi = DAG.getConstant(0,
DL, NVT);
4380void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4384 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4385 EVT NVT =
Lo.getValueType();
4387 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4393 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4394 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4397 Hi = DAG.getConstant(0, dl, NVT);
4403 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4410 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4414 ReplaceValueWith(
SDValue(
N, 1), Chain);
4422 Chain =
Op.getValue(1);
4431 EVT VT =
N->getValueType(0);
4435 bool IsStrict =
N->isStrictFPOpcode();
4437 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4441 EVT SrcVT =
Op.getValueType();
4442 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4446 if (TLI.isTypeLegal(SrcVT) && MinIntBits <= NVT.
getSizeInBits()) {
4447 unsigned NewOpc = TLI.getPreferredFPToIntOpcode(
N->getOpcode(), SrcVT, NVT);
4449 Lo = DAG.getNode(NewOpc, dl, {NVT, MVT::Other}, {Chain,
Op});
4450 ReplaceValueWith(
SDValue(
N, 1),
Lo.getValue(1));
4452 Lo = DAG.getNode(NewOpc, dl, NVT,
Op);
4455 DAG.getShiftAmountConstant(
4457 : DAG.getConstant(0, dl, NVT);
4463 Op.getValueType() == MVT::bf16) {
4469 EVT OpVT =
Op.getValueType();
4473 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4474 TargetLowering::MakeLibCallOptions CallOptions;
4479 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4480 CallOptions, dl, Chain);
4481 SplitInteger(Tmp.first,
Lo,
Hi);
4484 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4489 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4490 SplitInteger(Res,
Lo,
Hi);
4496 bool IsStrict =
N->isStrictFPOpcode();
4497 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4500 EVT VT =
Op.getValueType();
4502 if (VT == MVT::f16) {
4508 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4511 LC = RTLIB::getLROUND(VT);
4512 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4515 LC = RTLIB::getLRINT(VT);
4516 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4519 LC = RTLIB::getLLROUND(VT);
4520 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4523 LC = RTLIB::getLLRINT(VT);
4524 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4528 EVT RetVT =
N->getValueType(0);
4530 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4531 if (LCImpl == RTLIB::Unsupported) {
4532 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4533 N->getOperationName(&DAG));
4535 SplitInteger(Poison,
Lo,
Hi);
4536 if (
N->isStrictFPOpcode())
4537 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
4541 TargetLowering::MakeLibCallOptions CallOptions;
4543 std::pair<SDValue, SDValue> Tmp =
4544 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4545 SplitInteger(Tmp.first,
Lo,
Hi);
4547 if (
N->isStrictFPOpcode())
4548 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4551void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4553 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4556 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4562 EVT VT =
N->getValueType(0);
4563 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4568 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
4573 if (
N->getMemoryVT().bitsLE(NVT)) {
4574 EVT MemVT =
N->getMemoryVT();
4576 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4585 unsigned LoSize =
Lo.getValueSizeInBits();
4587 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4590 Hi = DAG.getConstant(0, dl, NVT);
4594 Hi = DAG.getUNDEF(NVT);
4596 }
else if (DAG.getDataLayout().isLittleEndian()) {
4598 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4601 unsigned ExcessBits =
4608 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4609 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4619 EVT MemVT =
N->getMemoryVT();
4622 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4625 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4634 N->getPointerInfo().getWithOffset(IncrementSize),
4648 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4652 DAG.getShiftAmountConstant(
4659 ReplaceValueWith(
SDValue(
N, 1), Ch);
4662void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4666 GetExpandedInteger(
N->getOperand(0), LL, LH);
4667 GetExpandedInteger(
N->getOperand(1), RL, RH);
4671 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4673 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4674 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4677void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4679 EVT VT =
N->getValueType(0);
4680 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4684 GetExpandedInteger(
N->getOperand(0), LL, LH);
4685 GetExpandedInteger(
N->getOperand(1), RL, RH);
4687 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4694 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4695 if (LCImpl == RTLIB::Unsupported) {
4698 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4704 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4705 TargetLowering::MakeLibCallOptions CallOptions;
4707 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4714 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4715 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4716 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4719 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4724 SplitInteger(Result,
Lo,
Hi);
4730 SplitInteger(Result,
Lo,
Hi);
4736 SplitInteger(Result,
Lo,
Hi);
4747 EVT VT =
N->getValueType(0);
4751 uint64_t Scale =
N->getConstantOperandVal(2);
4763 EVT BoolVT = getSetCCResultType(VT);
4765 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4771 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4772 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4778 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4779 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4784 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4785 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4788 SplitInteger(Result,
Lo,
Hi);
4794 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4796 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4798 GetExpandedInteger(
LHS, LL, LH);
4799 GetExpandedInteger(
RHS, RL, RH);
4803 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4810 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4811 SplitInteger(LoTmp, Result[0], Result[1]);
4812 SplitInteger(HiTmp, Result[2], Result[3]);
4814 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4817 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4818 "the size of the current value type");
4840 if (Scale % NVTSize) {
4841 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4844 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4856 if (Scale == VTSize)
4875 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4876 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4877 EVT BoolNVT = getSetCCResultType(NVT);
4880 if (Scale < NVTSize) {
4883 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4884 DAG.getShiftAmountConstant(Scale, NVT, dl));
4885 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4886 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4887 }
else if (Scale == NVTSize) {
4889 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4890 }
else if (Scale < VTSize) {
4893 DAG.getNode(
ISD::SRL, dl, NVT, ResultHH,
4894 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4895 SatMax = DAG.getSetCC(dl, BoolNVT, HHAdjusted, NVTZero,
ISD::SETNE);
4898 "(and saturation can't happen with Scale==VTSize).");
4900 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4901 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4905 if (Scale < NVTSize) {
4910 unsigned OverflowBits = VTSize - Scale + 1;
4911 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4912 "Extent of overflow bits must start within HL");
4913 SDValue HLHiMask = DAG.getConstant(
4915 SDValue HLLoMask = DAG.getConstant(
4922 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4928 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4929 }
else if (Scale == NVTSize) {
4935 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4941 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4942 }
else if (Scale < VTSize) {
4945 unsigned OverflowBits = VTSize - Scale + 1;
4946 SDValue HHHiMask = DAG.getConstant(
4948 SDValue HHLoMask = DAG.getConstant(
4950 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4951 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4958 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4959 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4962 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4963 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4970 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4972 N->getConstantOperandVal(2), DAG);
4976 N->getConstantOperandVal(2), TLI, DAG);
4977 SplitInteger(Res,
Lo,
Hi);
4980void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4983 "Node has unexpected Opcode");
4993 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4994 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4998 SDValue LHSL, LHSH, RHSL, RHSH;
4999 GetExpandedInteger(
LHS, LHSL, LHSH);
5000 GetExpandedInteger(
RHS, RHSL, RHSH);
5001 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
5004 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5013 SplitInteger(Sum,
Lo,
Hi);
5038 EVT VT =
LHS.getValueType();
5041 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5045 EVT OType =
Node->getValueType(1);
5046 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5050 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5053void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5055 EVT VT =
N->getValueType(0);
5057 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5066 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5068 TargetLowering::MakeLibCallOptions CallOptions;
5070 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5073void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5076 SDValue Shiftee =
N->getOperand(0);
5083 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5084 }
while (!TLI.isTypeLegal(LoadVT));
5089 "Shifting unit is not a a power of two!");
5091 const bool IsOneStepShift =
5092 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5097 if (!IsOneStepShift)
5098 ShAmt = DAG.getFreeze(ShAmt);
5101 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5102 unsigned VTByteWidth = VTBitWidth / 8;
5104 "Shiftee type size is not a power of two!");
5105 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5106 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5111 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5113 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5114 EVT PtrTy =
StackPtr.getValueType();
5115 SDValue Ch = DAG.getEntryNode();
5118 DAG.getMachineFunction(),
5124 unsigned WideningOpc =
5126 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5129 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5133 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5139 Flags.setExact(IsOneStepShift);
5142 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5144 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5145 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5148 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5153 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5160 if (DAG.getDataLayout().isBigEndian())
5161 WillIndexUpwards = !WillIndexUpwards;
5164 if (WillIndexUpwards) {
5167 AdjStackPtr = DAG.getMemBasePlusOffset(
5168 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5169 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5173 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5174 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5178 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5183 if (!IsOneStepShift) {
5185 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5186 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5187 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5191 SplitInteger(Res,
Lo,
Hi);
5194void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5196 EVT VT =
N->getValueType(0);
5197 unsigned Opc =
N->getOpcode();
5203 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5207 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5224 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5226 const bool LegalOrCustom =
5230 unsigned ExpansionFactor = 1;
5232 for (EVT TmpVT = NVT;;) {
5233 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5234 if (NewTMPVT == TmpVT)
5241 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5244 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5246 if (LegalOrCustom &&
5250 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5256 SDValue ShiftOp =
N->getOperand(1);
5257 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5259 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5262 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5263 Hi =
Lo.getValue(1);
5268 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5282 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5285 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5287 TargetLowering::MakeLibCallOptions CallOptions;
5290 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5295 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5299void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5301 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5304 if (
Op.getValueType().bitsLE(NVT)) {
5310 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5314 assert(getTypeAction(
Op.getValueType()) ==
5316 "Only know how to promote this result!");
5319 "Operand over promoted?");
5321 SplitInteger(Res,
Lo,
Hi);
5329void DAGTypeLegalizer::
5332 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5335 if (EVT.
bitsLE(
Lo.getValueType())) {
5343 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5344 Hi.getValueType(), dl));
5355void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5357 EVT VT =
N->getValueType(0);
5359 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5368 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5370 TargetLowering::MakeLibCallOptions CallOptions;
5372 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5375void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5377 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5387void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5389 EVT VT =
N->getValueType(0);
5408 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5409 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5410 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5412 EVT BitVT =
N->getValueType(1);
5413 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5415 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5417 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5418 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5437 SplitInteger(Three,
Lo,
Hi);
5441 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5446 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5451 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5455 if (LCImpl == RTLIB::Unsupported ||
5457 DAG.getMachineFunction().getName()) {
5460 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5461 N->getOperand(1), MulLo, MulHi);
5466 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5467 SplitInteger(MulLo,
Lo,
Hi);
5468 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5472 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5475 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5476 MachinePointerInfo());
5480 EVT ArgVT =
Op.getValueType();
5482 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5483 Entry.IsSExt =
true;
5484 Entry.IsZExt =
false;
5485 Args.push_back(Entry);
5489 TargetLowering::ArgListEntry
Entry(
5491 Entry.IsSExt =
true;
5492 Entry.IsZExt =
false;
5493 Args.push_back(Entry);
5495 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5497 TargetLowering::CallLoweringInfo CLI(DAG);
5500 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5501 Func, std::move(Args))
5504 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5506 SplitInteger(CallInfo.first,
Lo,
Hi);
5508 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5509 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5510 DAG.getConstant(0, dl, PtrVT),
5513 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5516void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5518 EVT VT =
N->getValueType(0);
5520 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5530 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5532 if (isTypeLegal(NVT)) {
5534 GetExpandedInteger(
N->getOperand(0), InL, InH);
5536 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5545 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5547 TargetLowering::MakeLibCallOptions CallOptions;
5548 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5551void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5553 EVT VT =
N->getValueType(0);
5555 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5565 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5567 if (isTypeLegal(NVT)) {
5569 GetExpandedInteger(
N->getOperand(0), InL, InH);
5571 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5580 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5582 TargetLowering::MakeLibCallOptions CallOptions;
5583 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5586void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5588 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5591 if (
Op.getValueType().bitsLE(NVT)) {
5594 Hi = DAG.getConstant(0, dl, NVT);
5598 assert(getTypeAction(
Op.getValueType()) ==
5600 "Only know how to promote this result!");
5603 "Operand over promoted?");
5605 SplitInteger(Res,
Lo,
Hi);
5607 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5613void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5617 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5628void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5632 SDValue Res = TLI.expandVecReduce(
N, DAG);
5633 SplitInteger(Res,
Lo,
Hi);
5636void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5642 N->getOperand(0),
N->getOperand(1));
5643 SplitInteger(Res,
Lo,
Hi);
5650 GetExpandedInteger(
N->getOperand(0), In3, In4);
5651 GetExpandedInteger(
N->getOperand(1), In1, In2);
5655 unsigned Opc =
N->getOpcode();
5658 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5663 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5665 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5669 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5670 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5675 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5676 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5681 SDValue Res = TLI.expandCLMUL(
N, DAG);
5682 return SplitInteger(Res,
Lo,
Hi);
5686 GetExpandedInteger(
N->getOperand(0), LL, LH);
5687 GetExpandedInteger(
N->getOperand(1), RL, RH);
5701 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5705 SDValue Res = TLI.expandPEXT(
N, DAG);
5706 SplitInteger(Res,
Lo,
Hi);
5710 SDValue Res = TLI.expandPDEP(
N, DAG);
5711 SplitInteger(Res,
Lo,
Hi);
5715 SDValue Res = TLI.expandMULH(
N, DAG);
5716 SplitInteger(Res,
Lo,
Hi);
5721 EVT VT =
N->getValueType(0);
5728 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5731 SplitInteger(Res,
Lo,
Hi);
5738 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5739 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5741 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5742 Lo = DAG.getPOISON(LoVT);
5743 Hi = DAG.getPOISON(HiVT);
5750 EVT VT =
N->getSimpleValueType(0);
5751 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5753 "VectorIdxTy should be smaller than type to be expanded?");
5757 SplitInteger(Res,
Lo,
Hi);
5768bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5772 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5775 switch (
N->getOpcode()) {
5778 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5779 N->dump(&DAG);
dbgs() <<
"\n";
5784 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5788 Res = ExpandOp_FAKE_USE(
N);
5792 Res = TLI.expandLoopDependenceMask(
N, DAG);
5798 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5811 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5816 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5820 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5823 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5825 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5826 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5827 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5830 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5835 if (!Res.
getNode())
return false;
5843 "Invalid operand expansion");
5845 ReplaceValueWith(
SDValue(
N, 0), Res);
5851void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5855 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5856 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5857 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5870 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5877 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5878 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5908 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5909 RHSLo, LowCC,
false, DagCombineInfo, dl);
5911 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5914 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5915 RHSHi, CCCode,
false, DagCombineInfo, dl);
5919 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5928 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5930 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5939 if (LHSHi == RHSHi) {
5948 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5949 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5952 if (HasSETCCCARRY) {
5955 bool FlipOperands =
false;
5972 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5976 DAG.getCondCode(CCCode));
5982 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5983 false, DagCombineInfo, dl);
5986 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5987 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5994 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5999 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6004 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
6005 DAG.getCondCode(CCCode), NewLHS, NewRHS,
6006 N->getOperand(4)), 0);
6012 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6017 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6022 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6023 N->getOperand(2),
N->getOperand(3),
6024 DAG.getCondCode(CCCode)), 0);
6030 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6035 "Unexpected setcc expansion!");
6041 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6049 SDLoc dl = SDLoc(
N);
6051 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6052 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6053 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6066 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6076 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6077 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6081 return TLI.expandCMP(
N, DAG);
6089 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6090 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6094 bool IsStrict =
N->isStrictFPOpcode();
6098 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6099 EVT DstVT =
N->getValueType(0);
6102 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6103 "Don't know how to expand this XINT_TO_FP!");
6104 TargetLowering::MakeLibCallOptions CallOptions;
6106 std::pair<SDValue, SDValue> Tmp =
6107 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6112 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6113 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6118 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6121 return ExpandOp_NormalStore(
N, OpNo);
6124 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6126 EVT VT =
N->getOperand(1).getValueType();
6127 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6131 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
6137 if (
N->getMemoryVT().bitsLE(NVT)) {
6138 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6139 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6140 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6144 if (DAG.getDataLayout().isLittleEndian()) {
6146 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6148 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6151 unsigned ExcessBits =
6158 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6159 N->getPointerInfo().getWithOffset(IncrementSize),
6160 NEVT,
N->getBaseAlign(), MMOFlags,
Metadata);
6166 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6168 EVT ExtVT =
N->getMemoryVT();
6171 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6179 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6183 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6187 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6193 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6194 N->getPointerInfo().getWithOffset(IncrementSize),
6202 GetExpandedInteger(
N->getOperand(0), InL, InH);
6211 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6213 return Swap.getValue(1);
6216SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6217 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6218 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6222 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6224 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6227SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6230 "cannot use llvm.write_register with illegal type", Fn,
6233 return N->getOperand(0);
6236SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6239 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6240 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6241 EVT OutVT =
V0.getValueType();
6243 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6246SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REPEAT(
SDNode *
N) {
6249 EVT OutVT =
N->getValueType(0);
6250 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6255 return DAG.getNode(
N->getOpcode(),
DL, NOutVT,
Op);
6258SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6260 unsigned Factor =
N->getNumOperands();
6263 for (
unsigned i = 0; i != Factor; i++)
6264 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6269 for (
unsigned i = 0; i != Factor; i++)
6275SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6277 EVT OutVT =
N->getValueType(0);
6278 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6279 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6283 SDValue BaseIdx =
N->getOperand(1);
6300 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6304 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6310 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6319 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6323 "Promoted operand has an element type greater than result");
6336 InOp0 = GetPromotedInteger(InOp0);
6343 Ops.reserve(OutNumElems);
6344 for (
unsigned i = 0; i != OutNumElems; ++i) {
6349 N->getOperand(0), Index);
6350 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6355 return DAG.getBuildVector(NOutVT, dl,
Ops);
6358SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6359 EVT OutVT =
N->getValueType(0);
6360 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6361 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6373 Vec = GetPromotedInteger(Vec);
6379SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6382 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6383 EVT OutVT =
V0.getValueType();
6388SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6390 EVT VT =
N->getValueType(0);
6395 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6396 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6397 EVT OutVT =
V0.getValueType();
6399 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6403 EVT OutVT =
N->getValueType(0);
6404 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6405 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6406 unsigned NumElems =
N->getNumOperands();
6413 Ops.reserve(NumElems);
6414 for (
unsigned i = 0; i != NumElems; ++i) {
6416 EVT OpVT =
Op.getValueType();
6421 if (OpVT.
bitsLT(NOutVTElem)) {
6427 ExtOpc = NOutExtOpc;
6428 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6433 return DAG.getBuildVector(NOutVT, dl,
Ops);
6440 assert(!
N->getOperand(0).getValueType().isVector() &&
6441 "Input must be a scalar");
6443 EVT OutVT =
N->getValueType(0);
6444 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6445 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6449 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6454 EVT OutVT =
N->getValueType(0);
6455 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6457 "Type must be promoted to a scalable vector type");
6458 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6459 return DAG.getStepVector(dl, NOutVT,
6463SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6466 EVT OutVT =
N->getValueType(0);
6467 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6468 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6470 unsigned NumOperands =
N->getNumOperands();
6474 EVT OpVT =
N->getOperand(0).getValueType();
6479 "Unhandled legalization type");
6485 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6488 Op = GetPromotedInteger(
Op);
6497 *DAG.getContext(),
Ops[0].getValueType().getVectorElementType());
6498 return DAG.getAnyExtOrTrunc(
6502 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6503 assert(NumElem * NumOperands == NumOutElem &&
6504 "Unexpected number of elements");
6508 for (
unsigned i = 0; i < NumOperands; ++i) {
6511 Op = GetPromotedInteger(
Op);
6512 EVT SclrTy =
Op.getValueType().getVectorElementType();
6513 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6514 "Unexpected number of elements");
6516 for (
unsigned j = 0;
j < NumElem; ++
j) {
6518 DAG.getVectorIdxConstant(j, dl));
6519 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6523 return DAG.getBuildVector(NOutVT, dl,
Ops);
6526SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6527 EVT VT =
N->getValueType(0);
6528 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6529 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6537 if (getTypeAction(
N->getOperand(0).getValueType())
6541 switch(
N->getOpcode()) {
6543 Promoted = SExtPromotedInteger(
N->getOperand(0));
6546 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6549 Promoted = GetPromotedInteger(
N->getOperand(0));
6561 DAG.getVectorIdxConstant(0, dl));
6563 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6567 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6570SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6571 EVT VT =
N->getValueType(0);
6572 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6576SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6577 EVT VT =
N->getValueType(0);
6578 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6582SDValue DAGTypeLegalizer::PromoteIntRes_MASK_BEFOREFIRST(
SDNode *
N) {
6583 EVT VT =
N->getValueType(0);
6584 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6585 SDValue Op = PromoteTargetBoolean(
N->getOperand(0), NVT);
6590 EVT VT =
N->getValueType(0);
6591 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6593 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6597SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6599 EVT VT =
N->getValueType(0);
6600 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6601 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6602 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6606SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6607 EVT OutVT =
N->getValueType(0);
6608 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6609 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6614 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6617 NOutVTElem,
N->getOperand(1));
6619 V0, ConvElem,
N->getOperand(2));
6626 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6627 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6635 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6636 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6637 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6641 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6644 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6645 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6653 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6658SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6661 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6663 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6664 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6665 return DAG.getPOISON(NVT);
6668SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6670 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6671 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6672 TLI.getVectorIdxTy(DAG.getDataLayout()));
6674 V0->getValueType(0).getScalarType(), V0,
V1);
6679 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6682SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6687 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6690 V1.getValueType().getVectorElementType(),
6691 V0.getValueType().getVectorElementCount());
6692 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6694 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6703 EVT InVT1 =
V1.getValueType();
6706 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6707 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6710SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6712 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6713 MVT InVT =
V0.getValueType().getSimpleVT();
6720SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6723 EVT ResVT =
N->getValueType(0);
6724 unsigned NumElems =
N->getNumOperands();
6727 EVT PromotedOpTy = TLI.getTypeToTransformTo(*DAG.getContext(),
6728 N->getOperand(0).getValueType());
6731 if (isTypeLegal(WideVT)) {
6738 return DAG.getAnyExtOrTrunc(WideConcat, dl, ResVT);
6742 SDValue ResVec = DAG.getPOISON(ResVT);
6744 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6746 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6748 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6757 DAG.ExtractVectorElements(GetPromotedInteger(
Op), NewOps);
6758 return DAG.getBuildVector(ResVT, dl, NewOps);
6761SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6774 for (
unsigned I = 0;
I < OpNo;
I++)
6777 EVT Ty =
Op.getValueType();
6778 SDLoc
DL = SDLoc(
N);
6781 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6789 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6794 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6800SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6813 for (
unsigned I = 0;
I < OpNo;
I++)
6816 EVT Ty =
Op.getValueType();
6817 SDLoc
DL = SDLoc(
N);
6820 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6828 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6833 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isSigned(unsigned Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
SmallVector< MachineOperand, 4 > Cond
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static LLVM_ABI unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
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.
constexpr bool isPowerOf2() const
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
ISD::CondCode getOperandCondCode(unsigned Num) const
Helper method returns the CondCode of a CondCodeSDNode.
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.
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
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...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
@ 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...
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*X will result in a value whose quantity matches our ...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS*X will result in a value whose quantity matches our own.
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
@ MASK_BEFOREFIRST
Has one mask vector operand.
@ 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 ...
@ VECTOR_SHUFFLE_VAR
VECTOR_SHUFFLE_VAR(VEC, MASK) - Returns VEC permuted by MASK, an integer vector with the same number ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_MATCH
VECTOR_MATCH - this corresponds to the llvm.experimental.vector.match intrinsic.
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_REPEAT
VECTOR_REPEAT(FIXED_LENGTH_VECTOR) Repeatedly copies the elements of the source fixed-length vector t...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
The llvm.loop.dependence.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall 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 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 getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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 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
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
bool isFixedLengthVector() const
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...
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
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)