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";
62 case ISD::BITCAST: Res = PromoteIntRes_BITCAST(
N);
break;
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_UNDEF:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
75 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
76 case ISD::VP_CTTZ_ZERO_UNDEF:
79 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
80 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
81 case ISD::VP_CTTZ_ELTS:
82 Res = PromoteIntRes_VP_CttzElements(
N);
85 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
95 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
101 Res = PromoteIntRes_Select(
N);
106 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
108 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
110 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
113 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
115 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
117 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
119 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
120 case ISD::VP_TRUNCATE:
123 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
124 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
125 case ISD::VSCALE: Res = PromoteIntRes_VSCALE(
N);
break;
128 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
130 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
132 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
134 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
136 Res = PromoteIntRes_VECTOR_SPLICE(
N);
break;
139 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
142 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
144 Res = PromoteIntRes_BUILD_VECTOR(
N);
148 Res = PromoteIntRes_ScalarOp(
N);
152 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
157 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
159 case ISD::VECTOR_FIND_LAST_ACTIVE:
160 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
163 case ISD::GET_ACTIVE_LANE_MASK:
164 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
167 case ISD::PARTIAL_REDUCE_UMLA:
168 case ISD::PARTIAL_REDUCE_SMLA:
169 case ISD::PARTIAL_REDUCE_SUMLA:
170 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
174 case ISD::VP_SIGN_EXTEND:
176 case ISD::VP_ZERO_EXTEND:
179 case ISD::VP_FP_TO_SINT:
180 case ISD::VP_FP_TO_UINT:
188 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
190 case ISD::FP_TO_BF16:
191 case ISD::FP_TO_FP16:
192 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
194 case ISD::STRICT_FP_TO_BF16:
195 case ISD::STRICT_FP_TO_FP16:
196 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
211 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
221 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
231 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
234 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
236 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
238 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
254 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
256 case ISD::VP_SADDSAT:
257 case ISD::VP_UADDSAT:
258 case ISD::VP_SSUBSAT:
259 case ISD::VP_USUBSAT:
260 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
265 Res = PromoteIntRes_CMP(
N);
278 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
280 case ISD::ATOMIC_LOAD:
283 case ISD::ATOMIC_LOAD_ADD:
284 case ISD::ATOMIC_LOAD_SUB:
285 case ISD::ATOMIC_LOAD_AND:
286 case ISD::ATOMIC_LOAD_CLR:
287 case ISD::ATOMIC_LOAD_OR:
288 case ISD::ATOMIC_LOAD_XOR:
289 case ISD::ATOMIC_LOAD_NAND:
290 case ISD::ATOMIC_LOAD_MIN:
291 case ISD::ATOMIC_LOAD_MAX:
292 case ISD::ATOMIC_LOAD_UMIN:
293 case ISD::ATOMIC_LOAD_UMAX:
294 case ISD::ATOMIC_SWAP:
297 case ISD::ATOMIC_CMP_SWAP:
298 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
302 case ISD::VECREDUCE_ADD:
303 case ISD::VECREDUCE_MUL:
304 case ISD::VECREDUCE_AND:
305 case ISD::VECREDUCE_OR:
306 case ISD::VECREDUCE_XOR:
307 case ISD::VECREDUCE_SMAX:
308 case ISD::VECREDUCE_SMIN:
309 case ISD::VECREDUCE_UMAX:
310 case ISD::VECREDUCE_UMIN:
311 Res = PromoteIntRes_VECREDUCE(
N);
314 case ISD::VP_REDUCE_ADD:
315 case ISD::VP_REDUCE_MUL:
316 case ISD::VP_REDUCE_AND:
317 case ISD::VP_REDUCE_OR:
318 case ISD::VP_REDUCE_XOR:
319 case ISD::VP_REDUCE_SMAX:
320 case ISD::VP_REDUCE_SMIN:
321 case ISD::VP_REDUCE_UMAX:
322 case ISD::VP_REDUCE_UMIN:
323 Res = PromoteIntRes_VP_REDUCE(
N);
328 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
332 Res = PromoteIntRes_FREEZE(
N);
337 Res = PromoteIntRes_Rotate(
N);
342 Res = PromoteIntRes_FunnelShift(
N);
347 Res = PromoteIntRes_VPFunnelShift(
N);
351 Res = PromoteIntRes_IS_FPCLASS(
N);
354 Res = PromoteIntRes_FFREXP(
N);
359 Res = PromoteIntRes_XRINT(
N);
362 case ISD::PATCHPOINT:
363 Res = PromoteIntRes_PATCHPOINT(
N);
366 Res = PromoteIntRes_READ_REGISTER(
N);
372 SetPromotedInteger(
SDValue(
N, ResNo), Res);
377 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
378 return GetPromotedInteger(
Op);
381SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
383 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
384 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
389 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
391 Op.getValueType(),
Op,
N->getOperand(1));
396 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
398 Op.getValueType(),
Op,
N->getOperand(1));
402 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
405 switch (TLI.getExtendForAtomicOps()) {
421 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
422 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
432 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
434 Op2 = SExtPromotedInteger(Op2);
437 Op2 = ZExtPromotedInteger(Op2);
440 Op2 = GetPromotedInteger(Op2);
445 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
447 N->getChain(),
N->getBasePtr(),
448 Op2,
N->getMemOperand());
458 assert(
N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS);
459 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
460 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
464 if (!TLI.isTypeLegal(SVT))
467 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
468 SDValue Res = DAG.getAtomicCmpSwap(
469 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, SDLoc(
N),
N->getMemoryVT(), VTs,
470 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
474 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
480 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
481 switch (TLI.getExtendForAtomicCmpSwapArg()) {
483 Op2 = SExtPromotedInteger(Op2);
486 Op2 = ZExtPromotedInteger(Op2);
489 Op2 = GetPromotedInteger(Op2);
496 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
497 SDValue Res = DAG.getAtomicCmpSwap(
498 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
499 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
501 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
509 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
510 EVT OutVT =
N->getValueType(0);
511 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
514 switch (getTypeAction(InVT)) {
520 return DAG.getNode(ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
524 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
527 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
531 return DAG.getNode(ISD::FP_TO_FP16, dl, NOutVT, GetPromotedFloat(InOp));
541 BitConvertToInteger(GetScalarizedVector(InOp)));
550 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
551 Lo = BitConvertToInteger(
Lo);
552 Hi = BitConvertToInteger(
Hi);
554 if (DAG.getDataLayout().isBigEndian())
560 JoinIntegers(
Lo,
Hi));
561 return DAG.getNode(ISD::BITCAST, dl, NOutVT, InOp);
571 DAG.
getNode(ISD::BITCAST, dl, NOutVT, GetWidenedVector(InOp));
575 if (DAG.getDataLayout().isBigEndian()) {
579 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
594 if (isTypeLegal(WideOutVT)) {
595 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
597 DAG.getVectorIdxConstant(0, dl));
606 DAG.getDataLayout().isLittleEndian()) {
617 if (isTypeLegal(WideVecVT)) {
619 DAG.getUNDEF(WideVecVT), InOp,
620 DAG.getVectorIdxConstant(0, dl));
622 return DAG.getNode(ISD::BITCAST, dl, NOutVT, Inserted);
628 CreateStackStoreLoad(InOp, OutVT));
632 SDValue V = GetPromotedInteger(
N->getOperand(0));
634 V.getValueType(), V);
638 SDValue Op = GetPromotedInteger(
N->getOperand(0));
639 EVT OVT =
N->getValueType(0);
640 EVT NVT =
Op.getValueType();
648 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
649 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
654 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
660 return DAG.getNode(ISD::VP_SRL, dl, NVT,
661 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
666 SDValue Op = GetPromotedInteger(
N->getOperand(0));
667 EVT OVT =
N->getValueType(0);
668 EVT NVT =
Op.getValueType();
677 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
682 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
688 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
689 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
697 TLI.getTypeToTransformTo(*DAG.getContext(),
698 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
703 EVT VT =
N->getValueType(0);
710 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
717 EVT OVT =
N->getValueType(0);
718 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
724 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
725 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
727 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
733 unsigned CtlzOpcode =
N->getOpcode();
734 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
736 SDValue ExtractLeadingBits = DAG.getConstant(
739 if (!
N->isVPOpcode()) {
741 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
742 return DAG.getNode(
ISD::SUB, dl, NVT,
743 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
749 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
750 return DAG.getNode(ISD::VP_SUB, dl, NVT,
751 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
752 ExtractLeadingBits, Mask, EVL);
755 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
757 SDValue Op = GetPromotedInteger(
N->getOperand(0));
761 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
762 if (!
N->isVPOpcode()) {
764 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
769 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
770 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
776 EVT OVT =
N->getValueType(0);
777 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
785 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
786 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
793 if (!
N->isVPOpcode()) {
794 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
795 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
800 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
801 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
806 SDValue Op = GetPromotedInteger(
N->getOperand(0));
807 EVT OVT =
N->getValueType(0);
808 EVT NVT =
Op.getValueType();
815 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
816 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
820 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
826 unsigned NewOpc =
N->getOpcode();
827 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
834 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
838 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
839 N->getOperand(1),
N->getOperand(2));
840 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
843 if (!
N->isVPOpcode())
844 return DAG.getNode(NewOpc, dl, NVT,
Op);
845 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
848SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
850 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
851 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
854SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
856 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
863 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
869 EVT SVT =
In.getValueType().getScalarType();
872 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
880 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
882 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
886 if (
N->isStrictFPOpcode()) {
887 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
888 {
N->getOperand(0),
N->getOperand(1)});
892 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
893 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
896 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
908 N->getOpcode() == ISD::VP_FP_TO_UINT)
912 DAG.getValueType(
N->getValueType(0).getScalarType()));
915SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
917 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
919 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
923SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
924 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
927 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
930SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
931 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
934 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
935 N->getOperand(0),
N->getOperand(1));
941 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
943 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
947 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
951 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
960 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
963 if (getTypeAction(
N->getOperand(0).getValueType())
965 SDValue Res = GetPromotedInteger(
N->getOperand(0));
974 DAG.getValueType(
N->getOperand(0).getValueType()));
976 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
983 if (
N->getNumOperands() != 1) {
984 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
985 assert(
N->isVPOpcode() &&
"Expected VP opcode");
986 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
987 N->getOperand(1),
N->getOperand(2));
989 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
994 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
998 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
999 N->getMemoryVT(),
N->getMemOperand());
1008 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1009 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1012 :
N->getExtensionType();
1015 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1016 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1017 N->getMemOperand(),
N->isExpandingLoad());
1025 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1026 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1033 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1034 N->getOffset(),
N->getMask(), ExtPassThru,
1035 N->getMemoryVT(),
N->getMemOperand(),
1036 N->getAddressingMode(), ExtType,
1037 N->isExpandingLoad());
1045 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1046 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1048 "Gather result type and the passThru argument type should be the same");
1055 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1056 N->getIndex(),
N->getScale() };
1057 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1058 N->getMemoryVT(), dl,
Ops,
1059 N->getMemOperand(),
N->getIndexType(),
1067SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1068 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1069 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1071 N->getOperand(1), Passthru);
1078 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1079 EVT VT =
N->getValueType(0);
1080 EVT SVT = getSetCCResultType(VT);
1081 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1082 unsigned NumOps =
N->getNumOperands();
1085 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1093 ReplaceValueWith(
SDValue(
N, 0), Res);
1096 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1099template <
class MatchContextClass>
1111 MatchContextClass matcher(DAG, TLI,
N);
1113 unsigned Opcode = matcher.getRootBaseOpcode();
1119 SExtOrZExtPromotedOperands(Op1, Op2);
1125 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1127 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1128 Op1 = SExtPromotedInteger(Op1);
1129 Op2 = SExtPromotedInteger(Op2);
1130 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1133 Op1 = ZExtPromotedInteger(Op1);
1134 Op2 = ZExtPromotedInteger(Op2);
1137 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1139 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1146 Op1 = GetPromotedInteger(Op1);
1147 Op2 = ZExtPromotedInteger(Op2);
1149 Op1 = SExtPromotedInteger(Op1);
1150 Op2 = SExtPromotedInteger(Op2);
1157 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1170 "addition, subtraction or left shift");
1173 unsigned SHLAmount = NewBits - OldBits;
1175 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1180 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1181 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1187 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1188 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1189 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1190 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1191 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1198 SDValue Op1Promoted, Op2Promoted;
1204 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1205 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1207 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1208 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1210 EVT OldType =
N->getOperand(0).getValueType();
1222 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1223 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1224 Op2Promoted,
N->getOperand(2));
1226 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1227 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1229 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1234 unsigned SatW,
bool Signed,
1237 EVT VT = V.getValueType();
1264 EVT VT =
LHS.getValueType();
1282 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1288 "Tried to saturate to more than the original type?");
1297 SDValue Op1Promoted, Op2Promoted;
1303 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1304 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1306 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1307 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1310 unsigned Scale =
N->getConstantOperandVal(2);
1314 if (TLI.isTypeLegal(PromotedType)) {
1316 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1319 N->getValueType(0).getScalarSizeInBits();
1323 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1324 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1325 Op2Promoted,
N->getOperand(2));
1328 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1334 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1335 Op2Promoted, Scale, DAG)) {
1338 N->getValueType(0).getScalarSizeInBits(),
1346 N->getValueType(0).getScalarSizeInBits());
1349SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1351 return PromoteIntRes_Overflow(
N);
1355 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1356 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1357 EVT OVT =
N->getOperand(0).getValueType();
1358 EVT NVT =
LHS.getValueType();
1368 DAG.getValueType(OVT));
1370 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1373 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1379 EVT PromotedResultTy =
1380 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1381 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1382 N->getOperand(0),
N->getOperand(1));
1388 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1389 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1391 unsigned Opcode =
N->getOpcode();
1392 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1393 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1395 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1399 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1400 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1402 LHS.getValueType(),
N->getOperand(0),
1403 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1408 EVT InVT =
N->getOperand(OpNo).getValueType();
1409 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1411 EVT SVT = getSetCCResultType(InVT);
1418 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1419 SVT = getSetCCResultType(InVT);
1427 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1428 "Vector compare must return a vector result!");
1432 if (
N->isStrictFPOpcode()) {
1433 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1434 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1435 N->getOperand(2),
N->getOperand(3)};
1436 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1441 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1442 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1445 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1452 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1457 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1458 EVT VT =
N->getValueType(0);
1462 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1464 ReplaceValueWith(
SDValue(
N, 0), Res);
1469 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1471 if (
N->getOpcode() != ISD::VP_SHL) {
1473 RHS = ZExtPromotedInteger(
RHS);
1475 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1481 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1482 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1486SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1487 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1489 Op.getValueType(),
Op,
N->getOperand(1));
1492SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1496 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1497 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1498 if (
N->getNumOperands() == 2)
1499 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1500 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1501 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1502 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1503 N->getOperand(2),
N->getOperand(3));
1507 if (
N->getNumOperands() == 2) {
1509 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1510 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1511 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1513 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1514 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1518 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1519 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1520 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1525 if (
N->getNumOperands() == 2) {
1527 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1528 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1529 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1531 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1532 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1536 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1537 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1538 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1548 SExtOrZExtPromotedOperands(
LHS,
RHS);
1550 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1556 if (
N->getOpcode() != ISD::VP_SRA) {
1558 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1560 RHS = ZExtPromotedInteger(
RHS);
1561 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1567 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1569 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1570 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1576 if (
N->getOpcode() != ISD::VP_SRL) {
1578 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1580 RHS = ZExtPromotedInteger(
RHS);
1581 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1587 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1589 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1590 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1596 SDValue Res = TLI.expandROT(
N,
true , DAG);
1597 ReplaceValueWith(
SDValue(
N, 0), Res);
1602 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1603 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1606 Amt = ZExtPromotedInteger(Amt);
1610 EVT OldVT =
N->getOperand(0).getValueType();
1611 EVT VT =
Lo.getValueType();
1612 unsigned Opcode =
N->getOpcode();
1619 DAG.getConstant(OldBits,
DL, AmtVT));
1627 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1628 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1630 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1640 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1646 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1648 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1652SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1653 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1654 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1659 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1663 EVT OldVT =
N->getOperand(0).getValueType();
1664 EVT VT =
Lo.getValueType();
1665 unsigned Opcode =
N->getOpcode();
1666 bool IsFSHR = Opcode == ISD::VP_FSHR;
1671 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1672 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1680 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1681 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1682 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1683 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1685 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1688 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1693 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1694 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1699 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1701 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1705 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1717 Res = GetPromotedInteger(InOp);
1724 "Dst and Src must have the same number of elements");
1726 "Promoted vector type must be a power of two");
1729 GetSplitVector(InOp, EOp1, EOp2);
1737 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1738 "Expected VP_TRUNCATE opcode");
1739 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1740 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1741 std::tie(EVLLo, EVLHi) =
1742 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1743 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1744 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1751 SDValue WideInOp = GetWidenedVector(InOp);
1756 N->getValueType(0).getScalarType(), NumElem);
1765 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1771 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1772 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1777SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1779 return PromoteIntRes_Overflow(
N);
1783 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1784 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1785 EVT OVT =
N->getOperand(0).getValueType();
1786 EVT NVT =
LHS.getValueType();
1795 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1797 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1800 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1811 return PromoteIntRes_Overflow(
N);
1823 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1824 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1826 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1829 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1840 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1841 return PromoteIntRes_Overflow(
N);
1845 EVT OVT =
N->getValueType(0);
1846 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1852 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1853 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1854 if (
SDValue Res = TLI.expandABS(
N, DAG))
1858 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1862SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1865 return PromoteIntRes_Overflow(
N);
1869 EVT SmallVT =
LHS.getValueType();
1876 LHS = SExtPromotedInteger(
LHS);
1877 RHS = SExtPromotedInteger(
RHS);
1879 LHS = ZExtPromotedInteger(
LHS);
1880 RHS = ZExtPromotedInteger(
RHS);
1882 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1894 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1895 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1896 DAG.getConstant(0,
DL,
Hi.getValueType()),
1901 Mul, DAG.getValueType(SmallVT));
1911 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1916 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1917 N->getValueType(0)));
1921 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1923 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1930 EVT VT =
N->getValueType(0);
1933 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1934 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1938 for (
unsigned i = 0; i < NumRegs; ++i) {
1939 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1940 N->getConstantOperandVal(3));
1945 if (DAG.getDataLayout().isBigEndian())
1946 std::reverse(Parts.begin(), Parts.end());
1949 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1951 for (
unsigned i = 1; i < NumRegs; ++i) {
1956 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1962 ReplaceValueWith(
SDValue(
N, 1), Chain);
1975bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1978 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1983 switch (
N->getOpcode()) {
1986 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1987 N->dump(&DAG);
dbgs() <<
"\n";
1992 case ISD::ATOMIC_STORE:
1995 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(
N);
break;
1996 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1997 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2003 Res = PromoteIntOp_FAKE_USE(
N);
2006 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2010 Res = PromoteIntOp_ScalarOp(
N);
2013 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2016 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2018 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2019 case ISD::VP_SINT_TO_FP:
2036 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2038 case ISD::VP_TRUNCATE:
2040 case ISD::BF16_TO_FP:
2041 case ISD::FP16_TO_FP:
2042 case ISD::VP_UINT_TO_FP:
2044 case ISD::STRICT_FP16_TO_FP:
2047 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2055 case ISD::ROTR: Res = PromoteIntOp_Shift(
N);
break;
2058 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2061 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2078 case ISD::VECREDUCE_ADD:
2079 case ISD::VECREDUCE_MUL:
2080 case ISD::VECREDUCE_AND:
2081 case ISD::VECREDUCE_OR:
2082 case ISD::VECREDUCE_XOR:
2083 case ISD::VECREDUCE_SMAX:
2084 case ISD::VECREDUCE_SMIN:
2085 case ISD::VECREDUCE_UMAX:
2086 case ISD::VECREDUCE_UMIN: Res = PromoteIntOp_VECREDUCE(
N);
break;
2087 case ISD::VP_REDUCE_ADD:
2088 case ISD::VP_REDUCE_MUL:
2089 case ISD::VP_REDUCE_AND:
2090 case ISD::VP_REDUCE_OR:
2091 case ISD::VP_REDUCE_XOR:
2092 case ISD::VP_REDUCE_SMAX:
2093 case ISD::VP_REDUCE_SMIN:
2094 case ISD::VP_REDUCE_UMAX:
2095 case ISD::VP_REDUCE_UMIN:
2096 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2099 case ISD::SET_ROUNDING: Res = PromoteIntOp_SET_ROUNDING(
N);
break;
2101 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2103 case ISD::PATCHPOINT:
2104 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2107 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2109 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2110 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2111 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2113 case ISD::EXPERIMENTAL_VP_SPLICE:
2114 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2116 case ISD::EXPERIMENTAL_VECTOR_HISTOGRAM:
2117 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2119 case ISD::VECTOR_FIND_LAST_ACTIVE:
2120 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2122 case ISD::GET_ACTIVE_LANE_MASK:
2123 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2125 case ISD::PARTIAL_REDUCE_UMLA:
2126 case ISD::PARTIAL_REDUCE_SMLA:
2127 case ISD::PARTIAL_REDUCE_SUMLA:
2128 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2133 if (!Res.
getNode())
return false;
2140 const bool IsStrictFp =
N->isStrictFPOpcode();
2142 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2143 "Invalid operand expansion");
2147 ReplaceValueWith(
SDValue(
N, 0), Res);
2161 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2165 unsigned OpLEffectiveBits =
2166 DAG.computeKnownBits(OpL).countMaxActiveBits();
2167 unsigned OpREffectiveBits =
2168 DAG.computeKnownBits(OpR).countMaxActiveBits();
2169 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2170 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2177 LHS = SExtPromotedInteger(
LHS);
2178 RHS = SExtPromotedInteger(
RHS);
2187 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2188 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2189 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2190 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2197 LHS = ZExtPromotedInteger(
LHS);
2198 RHS = ZExtPromotedInteger(
RHS);
2212 LHS = SExtPromotedInteger(
LHS);
2213 RHS = SExtPromotedInteger(
RHS);
2218 "Unknown integer comparison!");
2220 SExtOrZExtPromotedOperands(
LHS,
RHS);
2224 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2229 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2230 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2231 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2235 EVT OutVT =
N->getValueType(0);
2238 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2241 switch (getTypeAction(InVT)) {
2245 DAG.getDataLayout().isLittleEndian()) {
2255 if (isTypeLegal(WideVecVT)) {
2256 SDValue Promoted = GetPromotedInteger(InOp);
2257 SDValue Cast = DAG.getNode(ISD::BITCAST, dl, WideVecVT, Promoted);
2259 DAG.getVectorIdxConstant(0, dl));
2272 return CreateStackStoreLoad(InOp, OutVT);
2275SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2276 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2284 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2285 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2289SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2290 assert(OpNo == 1 &&
"only know how to promote condition");
2293 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2296 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2297 N->getOperand(2)), 0);
2302 EVT OVT =
N->getOperand(0).getValueType();
2303 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2304 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2305 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2310 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2311 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2320 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2321 "Legal vector of one illegal element?");
2326 assert(
N->getOperand(0).getValueSizeInBits() >=
2327 N->getValueType(0).getScalarSizeInBits() &&
2328 "Type of inserted value narrower than vector element type!");
2331 for (
unsigned i = 0; i < NumElts; ++i)
2332 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2334 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2337SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2344 assert(
N->getOperand(1).getValueSizeInBits() >=
2345 N->getValueType(0).getScalarSizeInBits() &&
2346 "Type of inserted value narrower than vector element type!");
2347 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2348 GetPromotedInteger(
N->getOperand(1)),
2353 assert(OpNo == 2 &&
"Different operand and result vector types?");
2356 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2357 TLI.getVectorIdxTy(DAG.getDataLayout()));
2358 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2359 N->getOperand(1), Idx), 0);
2363 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2367 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2370SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2371 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2373 EVT OpTy =
N->getOperand(1).getValueType();
2376 if (
SDValue Res = WidenVSELECTMask(
N))
2377 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2378 Res,
N->getOperand(1),
N->getOperand(2));
2382 Cond = PromoteTargetBoolean(
Cond, OpVT);
2384 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2385 N->getOperand(2)), 0);
2388SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2389 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2397 N->getOperand(3),
N->getOperand(4)), 0);
2400SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2401 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2409 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2411 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2414 N->getOperand(3),
N->getOperand(4)),
2419 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2420 ZExtPromotedInteger(
N->getOperand(1))), 0);
2428 LHS = SExtPromotedInteger(
LHS);
2429 RHS = SExtPromotedInteger(
RHS);
2431 SExtOrZExtPromotedOperands(
LHS,
RHS);
2438 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2439 ZExtPromotedInteger(
N->getOperand(2))), 0);
2443 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2447 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2450SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2452 EVT VT =
N->getValueType(0);
2453 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2455 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2459 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2463 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2468 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2469 return SDValue(DAG.UpdateNodeOperands(
N,
2470 SExtPromotedInteger(
N->getOperand(0)),
2471 N->getOperand(1),
N->getOperand(2)),
2473 return SDValue(DAG.UpdateNodeOperands(
N,
2474 SExtPromotedInteger(
N->getOperand(0))), 0);
2477SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2478 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2479 SExtPromotedInteger(
N->getOperand(1))), 0);
2484 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2487 SDValue Val = GetPromotedInteger(
N->getValue());
2490 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2491 N->getMemoryVT(),
N->getMemOperand());
2497 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2498 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2500 SDValue DataOp = GetPromotedInteger(
N->getValue());
2501 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2502 N->getMask(),
N->getVectorLength(),
2503 N->getMemoryVT(),
N->getMemOperand(),
2504 N->isCompressingStore());
2515 Mask = PromoteTargetBoolean(Mask, DataVT);
2518 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2521 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2522 DataOp = GetPromotedInteger(DataOp);
2524 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2525 N->getOffset(), Mask,
N->getMemoryVT(),
2526 N->getMemOperand(),
N->getAddressingMode(),
2527 true,
N->isCompressingStore());
2532 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2533 EVT DataVT =
N->getValueType(0);
2534 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2536 NewOps[OpNo] =
Mask;
2537 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2553 EVT DataVT =
N->getValueType(0);
2554 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2555 }
else if (OpNo == 4) {
2557 if (
N->isIndexSigned())
2559 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2561 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2563 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2565 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2577 bool TruncateStore =
N->isTruncatingStore();
2582 EVT DataVT =
N->getValue().getValueType();
2583 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2584 }
else if (OpNo == 4) {
2586 if (
N->isIndexSigned())
2588 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2590 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2592 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2593 TruncateStore =
true;
2596 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2597 SDLoc(
N), NewOps,
N->getMemOperand(),
2598 N->getIndexType(), TruncateStore);
2603 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2607 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2612 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2613 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2614 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2615 N->getOperand(1),
N->getOperand(2));
2620 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2621 return SDValue(DAG.UpdateNodeOperands(
N,
2622 ZExtPromotedInteger(
N->getOperand(0)),
2623 N->getOperand(1),
N->getOperand(2)),
2625 return SDValue(DAG.UpdateNodeOperands(
N,
2626 ZExtPromotedInteger(
N->getOperand(0))), 0);
2629SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2630 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2631 ZExtPromotedInteger(
N->getOperand(1))), 0);
2638 EVT VT =
N->getValueType(0);
2643 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2644 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2645 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2646 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2651 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2654SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2656 EVT VT =
N->getValueType(0);
2657 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2659 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2661 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2662 N->getOperand(0).getValueType());
2666 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2668 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2671SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2673 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2674 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2683 unsigned OpOffset = IsStrict ? 1 : 0;
2690 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2691 if (LCImpl == RTLIB::Unsupported) {
2697 if (IsPowI &&
N->getValueType(0).isVector())
2698 return DAG.UnrollVectorOp(
N);
2700 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2701 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2711 assert(DAG.getLibInfo().getIntSize() ==
2712 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2713 "POWI exponent should match with sizeof(int) when doing the libcall.");
2714 TargetLowering::MakeLibCallOptions CallOptions;
2716 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2717 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2718 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2719 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2721 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2726 switch (
N->getOpcode()) {
2729 case ISD::VECREDUCE_ADD:
2730 case ISD::VECREDUCE_MUL:
2731 case ISD::VECREDUCE_AND:
2732 case ISD::VECREDUCE_OR:
2733 case ISD::VECREDUCE_XOR:
2734 case ISD::VP_REDUCE_ADD:
2735 case ISD::VP_REDUCE_MUL:
2736 case ISD::VP_REDUCE_AND:
2737 case ISD::VP_REDUCE_OR:
2738 case ISD::VP_REDUCE_XOR:
2740 case ISD::VECREDUCE_SMAX:
2741 case ISD::VECREDUCE_SMIN:
2742 case ISD::VP_REDUCE_SMAX:
2743 case ISD::VP_REDUCE_SMIN:
2745 case ISD::VECREDUCE_UMAX:
2746 case ISD::VECREDUCE_UMIN:
2747 case ISD::VP_REDUCE_UMAX:
2748 case ISD::VP_REDUCE_UMIN:
2758 return GetPromotedInteger(V);
2760 return SExtPromotedInteger(V);
2762 return ZExtPromotedInteger(V);
2768 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2770 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2771 EVT InVT =
Op.getValueType();
2773 EVT ResVT =
N->getValueType(0);
2774 unsigned Opcode =
N->getOpcode();
2778 if (Opcode == ISD::VECREDUCE_XOR && OrigEltVT == MVT::i1 &&
2779 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_XOR, InVT) &&
2780 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_ADD, InVT))
2781 Opcode = ISD::VECREDUCE_ADD;
2785 else if (Opcode == ISD::VECREDUCE_OR && OrigEltVT == MVT::i1 &&
2786 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_OR, InVT) &&
2787 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMAX, InVT)) {
2788 Opcode = ISD::VECREDUCE_UMAX;
2791 switch (TLI.getBooleanContents(InVT)) {
2794 Op = ZExtPromotedInteger(
N->getOperand(0));
2797 Op = SExtPromotedInteger(
N->getOperand(0));
2804 else if (Opcode == ISD::VECREDUCE_AND && OrigEltVT == MVT::i1 &&
2805 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_AND, InVT) &&
2806 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMIN, InVT)) {
2807 Opcode = ISD::VECREDUCE_UMIN;
2810 switch (TLI.getBooleanContents(InVT)) {
2813 Op = ZExtPromotedInteger(
N->getOperand(0));
2816 Op = SExtPromotedInteger(
N->getOperand(0));
2822 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2826 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2830SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2837 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2838 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2841 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2843 Op = PromoteIntOpVectorReduction(
N,
Op);
2847 EVT VT =
N->getValueType(0);
2848 EVT EltVT =
Op.getValueType().getScalarType();
2851 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2863 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2864 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2867SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2870 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2871 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2874SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2877 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2878 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2883 const Function &Fn = DAG.getMachineFunction().getFunction();
2885 "cannot use llvm.write_register with illegal type", Fn,
2887 return N->getOperand(0);
2890SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2891 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2892 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2895 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2897 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2900SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2904 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2905 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2908 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2910 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2911 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2914SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2916 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2918 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2919 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2922SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2925 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2926 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2929SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2931 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2932 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2933 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2936SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2938 switch (
N->getOpcode()) {
2939 case ISD::PARTIAL_REDUCE_SMLA:
2940 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2941 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2943 case ISD::PARTIAL_REDUCE_UMLA:
2944 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2945 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2947 case ISD::PARTIAL_REDUCE_SUMLA:
2948 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2949 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2954 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2965void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2971 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2974 switch (
N->getOpcode()) {
2977 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2978 N->dump(&DAG);
dbgs() <<
"\n";
2983 case ISD::ARITH_FENCE: SplitRes_ARITH_FENCE(
N,
Lo,
Hi);
break;
2992 case ISD::BITCAST: ExpandRes_BITCAST(
N,
Lo,
Hi);
break;
2996 case ISD::VAARG: ExpandRes_VAARG(
N,
Lo,
Hi);
break;
3027 case ISD::LLRINT: ExpandIntRes_XROUND_XRINT(
N,
Lo,
Hi);
break;
3030 case ISD::READCYCLECOUNTER:
3031 case ISD::READSTEADYCOUNTER: ExpandIntRes_READCOUNTER(
N,
Lo,
Hi);
break;
3040 case ISD::ATOMIC_LOAD: ExpandIntRes_ATOMIC_LOAD(
N,
Lo,
Hi);
break;
3042 case ISD::ATOMIC_LOAD_ADD:
3043 case ISD::ATOMIC_LOAD_SUB:
3044 case ISD::ATOMIC_LOAD_AND:
3045 case ISD::ATOMIC_LOAD_CLR:
3046 case ISD::ATOMIC_LOAD_OR:
3047 case ISD::ATOMIC_LOAD_XOR:
3048 case ISD::ATOMIC_LOAD_NAND:
3049 case ISD::ATOMIC_LOAD_MIN:
3050 case ISD::ATOMIC_LOAD_MAX:
3051 case ISD::ATOMIC_LOAD_UMIN:
3052 case ISD::ATOMIC_LOAD_UMAX:
3053 case ISD::ATOMIC_SWAP:
3054 case ISD::ATOMIC_CMP_SWAP: {
3055 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3056 SplitInteger(Tmp.first,
Lo,
Hi);
3057 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3060 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: {
3062 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3063 SDValue Tmp = DAG.getAtomicCmpSwap(
3064 ISD::ATOMIC_CMP_SWAP, SDLoc(
N), AN->
getMemoryVT(), VTs,
3065 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3074 SplitInteger(Tmp,
Lo,
Hi);
3141 case ISD::VECREDUCE_ADD:
3142 case ISD::VECREDUCE_MUL:
3143 case ISD::VECREDUCE_AND:
3144 case ISD::VECREDUCE_OR:
3145 case ISD::VECREDUCE_XOR:
3146 case ISD::VECREDUCE_SMAX:
3147 case ISD::VECREDUCE_SMIN:
3148 case ISD::VECREDUCE_UMAX:
3149 case ISD::VECREDUCE_UMIN: ExpandIntRes_VECREDUCE(
N,
Lo,
Hi);
break;
3153 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3158 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3162 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3166 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3176std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3177 unsigned Opc =
Node->getOpcode();
3183 EVT RetVT =
Node->getValueType(0);
3184 TargetLowering::MakeLibCallOptions CallOptions;
3187 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
3188 if (LCImpl != RTLIB::Unsupported) {
3190 Ops.push_back(
Node->getOperand(1));
3193 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3194 "Unexpected atomic op or value type!");
3196 LCImpl = TLI.getLibcallImpl(LC);
3198 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3199 Node->getOperand(0));
3204void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3209 GetExpandedInteger(
N->getOperand(0), InL, InH);
3224 if (Amt.
uge(VTBits)) {
3225 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3226 }
else if (Amt.
ugt(NVTBits)) {
3227 Lo = DAG.getConstant(0,
DL, NVT);
3229 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3230 }
else if (Amt == NVTBits) {
3231 Lo = DAG.getConstant(0,
DL, NVT);
3235 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3239 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3241 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3247 if (Amt.
uge(VTBits)) {
3248 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3249 }
else if (Amt.
ugt(NVTBits)) {
3251 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3252 Hi = DAG.getConstant(0,
DL, NVT);
3253 }
else if (Amt == NVTBits) {
3255 Hi = DAG.getConstant(0,
DL, NVT);
3260 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3262 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3264 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3270 if (Amt.
uge(VTBits)) {
3272 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3273 }
else if (Amt.
ugt(NVTBits)) {
3275 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3277 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3278 }
else if (Amt == NVTBits) {
3281 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3286 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3288 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3290 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3298bool DAGTypeLegalizer::
3300 unsigned Opc =
N->getOpcode();
3303 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3308 "Expanded integer type size not a power of two!");
3312 KnownBits Known = DAG.computeKnownBits(Amt);
3315 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3320 GetExpandedInteger(In, InL, InH);
3327 DAG.getConstant(~HighBitMask, dl, ShTy));
3332 Lo = DAG.getConstant(0, dl, NVT);
3333 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3336 Hi = DAG.getConstant(0, dl, NVT);
3337 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3341 DAG.getConstant(NVTBits - 1, dl, ShTy));
3342 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3354 DAG.getConstant(NVTBits - 1, dl, ShTy));
3370 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3372 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3374 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3375 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3387bool DAGTypeLegalizer::
3390 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3394 "Expanded integer type size not a power of two!");
3399 GetExpandedInteger(
N->getOperand(0), InL, InH);
3401 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3404 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3407 Amt, DAG.getConstant(0, dl, ShTy),
3411 switch (
N->getOpcode()) {
3417 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3418 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3421 LoL = DAG.getConstant(0, dl, NVT);
3424 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3425 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3426 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3432 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3435 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3438 HiL = DAG.getConstant(0, dl, NVT);
3441 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3442 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3443 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3449 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3450 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3454 DAG.getConstant(NVTBits - 1, dl, ShTy));
3457 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3458 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3459 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3484 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3489 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3490 SplitInteger(Res,
Lo,
Hi);
3493void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3502 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3503 unsigned NumHalfBits = NumBits / 2;
3504 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3505 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3506 SDValue LHSL, LHSH, RHSL, RHSH;
3507 GetExpandedInteger(
LHS, LHSL, LHSH);
3508 GetExpandedInteger(
RHS, RHSL, RHSH);
3511 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3513 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3521 SDValue LHSL, LHSH, RHSL, RHSH;
3522 GetExpandedInteger(
LHS, LHSL, LHSH);
3523 GetExpandedInteger(
RHS, RHSL, RHSH);
3525 EVT CCT = getSetCCResultType(NVT);
3528 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3530 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3532 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3534 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3538 const APInt *RHSVal =
nullptr;
3540 RHSVal = &RHSConst->getAPIntValue();
3547 SDValue LHSL, LHSH, RHSL, RHSH;
3548 GetExpandedInteger(
LHS, LHSL, LHSH);
3549 GetExpandedInteger(
RHS, RHSL, RHSH);
3551 EVT CCT = getSetCCResultType(NVT);
3557 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3560 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3564 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3567 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3569 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3576 switch (
N->getOpcode()) {
3603 EVT VT =
N->getValueType(0);
3604 EVT CCT = getSetCCResultType(VT);
3607 SplitInteger(Result,
Lo,
Hi);
3611 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3612 SplitInteger(ExpandedCMP,
Lo,
Hi);
3615void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3619 SDValue LHSL, LHSH, RHSL, RHSH;
3620 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3621 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3624 SDValue LoOps[2] = { LHSL, RHSL };
3625 SDValue HiOps[3] = { LHSH, RHSH };
3627 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3629 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3631 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3635 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3641 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3654 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3656 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3659 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3673 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3675 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3679 EVT OvfVT = getSetCCResultType(NVT);
3680 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3695 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3698 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3702 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3714 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3718 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3721 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3724 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3729 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3731 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3732 DAG.getConstant(0, dl, NVT));
3735 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3744 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3749 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3751 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3752 DAG.getConstant(0, dl, NVT));
3758void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3761 SDValue LHSL, LHSH, RHSL, RHSH;
3763 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3764 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3765 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3766 SDValue LoOps[2] = { LHSL, RHSL };
3767 SDValue HiOps[3] = { LHSH, RHSH };
3781 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3784void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3787 SDValue LHSL, LHSH, RHSL, RHSH;
3789 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3790 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3791 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3793 SDValue HiOps[3] = { LHSH, RHSH };
3795 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3797 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3801 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3804void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3812 unsigned CarryOp, NoCarryOp;
3814 switch(
N->getOpcode()) {
3829 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3830 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3834 SDValue LHSL, LHSH, RHSL, RHSH;
3835 GetExpandedInteger(
LHS, LHSL, LHSH);
3836 GetExpandedInteger(
RHS, RHSL, RHSH);
3837 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3838 SDValue LoOps[2] = { LHSL, RHSL };
3839 SDValue HiOps[3] = { LHSH, RHSH };
3841 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3843 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3850 SplitInteger(Sum,
Lo,
Hi);
3856 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3857 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3861 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3866 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3872 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3878 SDValue LHSL, LHSH, RHSL, RHSH;
3880 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3881 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3882 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3886 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3888 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3892 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3895void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3898 SDValue LHSL, LHSH, RHSL, RHSH;
3900 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3901 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3902 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3907 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3908 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3912 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3915void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3917 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3920 if (
Op.getValueType().bitsLE(NVT)) {
3923 Hi = DAG.getUNDEF(NVT);
3927 assert(getTypeAction(
Op.getValueType()) ==
3929 "Only know how to promote this result!");
3932 "Operand over promoted?");
3934 SplitInteger(Res,
Lo,
Hi);
3938void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3941 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3942 EVT NVT =
Lo.getValueType();
3947 if (NVTBits < EVTBits) {
3950 EVTBits - NVTBits)));
3955 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3959void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3962 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3963 EVT NVT =
Lo.getValueType();
3968 if (NVTBits < EVTBits) {
3971 EVTBits - NVTBits)));
3975 Hi = DAG.getConstant(0, dl, NVT);
3979void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3982 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3987void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3990 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3999 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4000 EVT NVT =
Lo.getValueType();
4003 Hi = DAG.getConstant(0, dl, NVT);
4006void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4008 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4011 const APInt &Cst =
Constant->getAPIntValue();
4012 bool IsTarget =
Constant->isTargetOpcode();
4013 bool IsOpaque =
Constant->isOpaque();
4015 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4016 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4024 GetExpandedInteger(N0,
Lo,
Hi);
4025 EVT NVT =
Lo.getValueType();
4031 Hi = DAG.getConstant(0, dl, NVT);
4041 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4046 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4047 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4056 EVT VT =
N->getValueType(0);
4058 DAG.getConstant(0, dl, VT), N0);
4060 SplitInteger(Neg, NegLo, NegHi);
4062 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4064 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4065 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4068void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4072 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4073 EVT NVT =
Lo.getValueType();
4075 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4078 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4081 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4082 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4085 Hi = DAG.getConstant(0, dl, NVT);
4090 SplitInteger(Result,
Lo,
Hi);
4095 EVT VT =
N->getValueType(0);
4100 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4101 "LibCall explicitly requested, but not available");
4103 if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) {
4104 TargetLowering::MakeLibCallOptions CallOptions;
4108 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4109 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4117 GetExpandedInteger(
Op,
Lo,
Hi);
4118 EVT NVT =
Lo.getValueType();
4121 Hi = DAG.getConstant(0,
DL, NVT);
4124void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4128 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4129 EVT NVT =
Lo.getValueType();
4131 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4137 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4138 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4141 Hi = DAG.getConstant(0, dl, NVT);
4147 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4154 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4158 ReplaceValueWith(
SDValue(
N, 1), Chain);
4166 Chain =
Op.getValue(1);
4175 EVT VT =
N->getValueType(0);
4179 bool IsStrict =
N->isStrictFPOpcode();
4181 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4183 Op = GetPromotedFloat(
Op);
4187 Op.getValueType() == MVT::bf16) {
4193 EVT OpVT =
Op.getValueType();
4197 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4198 TargetLowering::MakeLibCallOptions CallOptions;
4203 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4204 CallOptions, dl, Chain);
4205 SplitInteger(Tmp.first,
Lo,
Hi);
4208 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4213 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4214 SplitInteger(Res,
Lo,
Hi);
4220 bool IsStrict =
N->isStrictFPOpcode();
4221 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4225 "Input type needs to be promoted!");
4227 EVT VT =
Op.getValueType();
4229 if (VT == MVT::f16) {
4235 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4236 if (
N->getOpcode() == ISD::LROUND ||
4239 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4240 }
else if (
N->getOpcode() == ISD::LRINT ||
4243 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4244 }
else if (
N->getOpcode() == ISD::LLROUND ||
4247 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4248 }
else if (
N->getOpcode() == ISD::LLRINT ||
4251 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4255 EVT RetVT =
N->getValueType(0);
4257 TargetLowering::MakeLibCallOptions CallOptions;
4259 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4260 Op, CallOptions, dl,
4262 SplitInteger(Tmp.first,
Lo,
Hi);
4264 if (
N->isStrictFPOpcode())
4265 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4268void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4270 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4273 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4279 EVT VT =
N->getValueType(0);
4280 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4285 AAMDNodes AAInfo =
N->getAAInfo();
4290 if (
N->getMemoryVT().bitsLE(NVT)) {
4291 EVT MemVT =
N->getMemoryVT();
4293 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4294 N->getBaseAlign(), MMOFlags, AAInfo);
4302 unsigned LoSize =
Lo.getValueSizeInBits();
4304 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4307 Hi = DAG.getConstant(0, dl, NVT);
4311 Hi = DAG.getUNDEF(NVT);
4313 }
else if (DAG.getDataLayout().isLittleEndian()) {
4315 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4318 unsigned ExcessBits =
4325 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4326 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4327 N->getBaseAlign(), MMOFlags, AAInfo);
4336 EVT MemVT =
N->getMemoryVT();
4339 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4342 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4345 N->getBaseAlign(), MMOFlags, AAInfo);
4351 N->getPointerInfo().getWithOffset(IncrementSize),
4353 N->getBaseAlign(), MMOFlags, AAInfo);
4365 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4369 DAG.getShiftAmountConstant(
4376 ReplaceValueWith(
SDValue(
N, 1), Ch);
4379void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4383 GetExpandedInteger(
N->getOperand(0), LL, LH);
4384 GetExpandedInteger(
N->getOperand(1), RL, RH);
4388 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4390 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4391 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4394void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4396 EVT VT =
N->getValueType(0);
4397 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4401 GetExpandedInteger(
N->getOperand(0), LL, LH);
4402 GetExpandedInteger(
N->getOperand(1), RL, RH);
4404 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4411 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
4412 if (LCImpl == RTLIB::Unsupported) {
4415 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4421 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4422 TargetLowering::MakeLibCallOptions CallOptions;
4424 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4431 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4432 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4433 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4436 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4441 SplitInteger(Result,
Lo,
Hi);
4447 SplitInteger(Result,
Lo,
Hi);
4453 SplitInteger(Result,
Lo,
Hi);
4464 EVT VT =
N->getValueType(0);
4468 uint64_t Scale =
N->getConstantOperandVal(2);
4480 EVT BoolVT = getSetCCResultType(VT);
4482 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4488 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4489 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4495 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4496 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4501 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4502 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4505 SplitInteger(Result,
Lo,
Hi);
4511 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4513 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4515 GetExpandedInteger(
LHS, LL, LH);
4516 GetExpandedInteger(
RHS, RL, RH);
4520 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4527 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4528 SplitInteger(LoTmp, Result[0], Result[1]);
4529 SplitInteger(HiTmp, Result[2], Result[3]);
4531 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4534 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4535 "the size of the current value type");
4556 uint64_t Part0 = Scale / NVTSize;
4557 if (Scale % NVTSize) {
4558 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4561 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4573 if (Scale == VTSize)
4592 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4593 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4594 EVT BoolNVT = getSetCCResultType(NVT);
4597 if (Scale < NVTSize) {
4600 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4601 DAG.getShiftAmountConstant(Scale, NVT, dl));
4602 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4603 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4604 }
else if (Scale == NVTSize) {
4606 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4607 }
else if (Scale < VTSize) {
4611 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4612 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4615 "(and saturation can't happen with Scale==VTSize).");
4617 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4618 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4622 if (Scale < NVTSize) {
4627 unsigned OverflowBits = VTSize - Scale + 1;
4628 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4629 "Extent of overflow bits must start within HL");
4630 SDValue HLHiMask = DAG.getConstant(
4632 SDValue HLLoMask = DAG.getConstant(
4639 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4645 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4646 }
else if (Scale == NVTSize) {
4652 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4658 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4659 }
else if (Scale < VTSize) {
4662 unsigned OverflowBits = VTSize - Scale + 1;
4663 SDValue HHHiMask = DAG.getConstant(
4665 SDValue HHLoMask = DAG.getConstant(
4667 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4668 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4675 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4676 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4679 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4680 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4687 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4689 N->getConstantOperandVal(2), DAG);
4693 N->getConstantOperandVal(2), TLI, DAG);
4694 SplitInteger(Res,
Lo,
Hi);
4697void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4700 "Node has unexpected Opcode");
4710 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4711 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4715 SDValue LHSL, LHSH, RHSL, RHSH;
4716 GetExpandedInteger(
LHS, LHSL, LHSH);
4717 GetExpandedInteger(
RHS, RHSL, RHSH);
4718 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4721 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4730 SplitInteger(Sum,
Lo,
Hi);
4755 EVT VT =
LHS.getValueType();
4758 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4762 EVT OType =
Node->getValueType(1);
4763 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4767 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4770void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4772 EVT VT =
N->getValueType(0);
4774 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4783 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4785 TargetLowering::MakeLibCallOptions CallOptions;
4787 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4790void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4793 SDValue Shiftee =
N->getOperand(0);
4800 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4801 }
while (!TLI.isTypeLegal(LoadVT));
4806 "Shifting unit is not a a power of two!");
4808 const bool IsOneStepShift =
4809 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4814 if (!IsOneStepShift)
4815 ShAmt = DAG.getFreeze(ShAmt);
4818 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4819 unsigned VTByteWidth = VTBitWidth / 8;
4821 "Shiftee type size is not a power of two!");
4822 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4823 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4828 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4830 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4831 EVT PtrTy =
StackPtr.getValueType();
4832 SDValue Ch = DAG.getEntryNode();
4835 DAG.getMachineFunction(),
4841 unsigned WideningOpc =
4843 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4846 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4850 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4856 Flags.setExact(IsOneStepShift);
4859 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4861 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4862 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4865 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4870 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4877 if (DAG.getDataLayout().isBigEndian())
4878 WillIndexUpwards = !WillIndexUpwards;
4881 if (WillIndexUpwards) {
4884 AdjStackPtr = DAG.getMemBasePlusOffset(
4885 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4886 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4890 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4891 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4895 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4900 if (!IsOneStepShift) {
4902 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4903 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4904 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4908 SplitInteger(Res,
Lo,
Hi);
4911void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4913 EVT VT =
N->getValueType(0);
4914 unsigned Opc =
N->getOpcode();
4920 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4924 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4941 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4943 const bool LegalOrCustom =
4947 unsigned ExpansionFactor = 1;
4949 for (EVT TmpVT = NVT;;) {
4950 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
4951 if (NewTMPVT == TmpVT)
4958 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
4961 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
4963 if (LegalOrCustom &&
4967 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4973 SDValue ShiftOp =
N->getOperand(1);
4974 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
4976 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
4979 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
4980 Hi =
Lo.getValue(1);
4985 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4999 if (RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC)) {
5002 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5004 TargetLowering::MakeLibCallOptions CallOptions;
5007 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5012 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5016void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5018 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5021 if (
Op.getValueType().bitsLE(NVT)) {
5027 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5031 assert(getTypeAction(
Op.getValueType()) ==
5033 "Only know how to promote this result!");
5036 "Operand over promoted?");
5038 SplitInteger(Res,
Lo,
Hi);
5046void DAGTypeLegalizer::
5049 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5052 if (EVT.
bitsLE(
Lo.getValueType())) {
5060 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5061 Hi.getValueType(), dl));
5072void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5074 EVT VT =
N->getValueType(0);
5076 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5085 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5087 TargetLowering::MakeLibCallOptions CallOptions;
5089 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5092void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5094 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5104void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5106 EVT VT =
N->getValueType(0);
5125 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5126 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5127 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5129 EVT BitVT =
N->getValueType(1);
5130 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5132 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5134 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5135 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5154 SplitInteger(Three,
Lo,
Hi);
5158 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5163 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5168 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
5172 if (LCImpl == RTLIB::Unsupported ||
5173 TLI.getLibcallImplName(LCImpl) == DAG.getMachineFunction().getName()) {
5176 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5177 N->getOperand(1), MulLo, MulHi);
5182 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5183 SplitInteger(MulLo,
Lo,
Hi);
5184 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5188 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5191 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5192 MachinePointerInfo());
5196 EVT ArgVT =
Op.getValueType();
5198 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5199 Entry.IsSExt =
true;
5200 Entry.IsZExt =
false;
5201 Args.push_back(Entry);
5205 TargetLowering::ArgListEntry
Entry(
5207 Entry.IsSExt =
true;
5208 Entry.IsZExt =
false;
5209 Args.push_back(Entry);
5211 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5213 TargetLowering::CallLoweringInfo CLI(DAG);
5216 .setLibCallee(TLI.getLibcallImplCallingConv(LCImpl), RetTy, Func,
5220 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5222 SplitInteger(CallInfo.first,
Lo,
Hi);
5224 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5225 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5226 DAG.getConstant(0, dl, PtrVT),
5229 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5232void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5234 EVT VT =
N->getValueType(0);
5236 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5246 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5248 if (isTypeLegal(NVT)) {
5250 GetExpandedInteger(
N->getOperand(0), InL, InH);
5252 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5261 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5263 TargetLowering::MakeLibCallOptions CallOptions;
5264 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5267void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5269 EVT VT =
N->getValueType(0);
5271 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5281 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5283 if (isTypeLegal(NVT)) {
5285 GetExpandedInteger(
N->getOperand(0), InL, InH);
5287 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5296 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5298 TargetLowering::MakeLibCallOptions CallOptions;
5299 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5302void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5304 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5307 if (
Op.getValueType().bitsLE(NVT)) {
5310 Hi = DAG.getConstant(0, dl, NVT);
5314 assert(getTypeAction(
Op.getValueType()) ==
5316 "Only know how to promote this result!");
5319 "Operand over promoted?");
5321 SplitInteger(Res,
Lo,
Hi);
5323 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5329void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5333 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5335 SDValue Swap = DAG.getAtomicCmpSwap(
5336 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, dl,
5344void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5348 SDValue Res = TLI.expandVecReduce(
N, DAG);
5349 SplitInteger(Res,
Lo,
Hi);
5352void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5358 N->getOperand(0),
N->getOperand(1));
5359 SplitInteger(Res,
Lo,
Hi);
5366 GetExpandedInteger(
N->getOperand(0), In3, In4);
5367 GetExpandedInteger(
N->getOperand(1), In1, In2);
5371 unsigned Opc =
N->getOpcode();
5374 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5379 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5381 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5385 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5386 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5391 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5392 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5397 EVT VT =
N->getValueType(0);
5404 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5407 SplitInteger(Res,
Lo,
Hi);
5414 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5415 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5417 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5418 Lo = DAG.getPOISON(LoVT);
5419 Hi = DAG.getPOISON(HiVT);
5430bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5434 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5437 switch (
N->getOpcode()) {
5440 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5441 N->dump(&DAG);
dbgs() <<
"\n";
5445 case ISD::BITCAST: Res = ExpandOp_BITCAST(
N);
break;
5446 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5450 Res = ExpandOp_FAKE_USE(
N);
5456 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5469 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5474 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5476 case ISD::ATOMIC_STORE: Res = ExpandIntOp_ATOMIC_STORE(
N);
break;
5478 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5480 case ISD::PATCHPOINT:
5481 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5483 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5484 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5485 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5488 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5493 if (!Res.
getNode())
return false;
5501 "Invalid operand expansion");
5503 ReplaceValueWith(
SDValue(
N, 0), Res);
5509void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5513 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5514 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5515 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5528 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5535 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5536 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5567 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5568 RHSLo, LowCC,
false, DagCombineInfo, dl);
5570 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5574 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5575 RHSHi, CCCode,
false, DagCombineInfo, dl);
5579 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5588 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5590 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5599 if (LHSHi == RHSHi) {
5608 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5609 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5612 if (HasSETCCCARRY) {
5615 bool FlipOperands =
false;
5632 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5636 DAG.getCondCode(CCCode));
5642 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5643 false, DagCombineInfo, dl);
5646 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5647 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5654 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5659 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5664 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5665 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5666 N->getOperand(4)), 0);
5672 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5677 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5682 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5683 N->getOperand(2),
N->getOperand(3),
5684 DAG.getCondCode(CCCode)), 0);
5690 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5695 "Unexpected setcc expansion!");
5701 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5709 SDLoc dl = SDLoc(
N);
5711 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5712 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5713 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5726 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5736 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5737 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5741 return TLI.expandCMP(
N, DAG);
5749 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5750 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5754 bool IsStrict =
N->isStrictFPOpcode();
5758 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5759 EVT DstVT =
N->getValueType(0);
5762 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5763 "Don't know how to expand this XINT_TO_FP!");
5764 TargetLowering::MakeLibCallOptions CallOptions;
5766 std::pair<SDValue, SDValue> Tmp =
5767 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5772 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5773 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5778 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5781 return ExpandOp_NormalStore(
N, OpNo);
5784 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5786 EVT VT =
N->getOperand(1).getValueType();
5787 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5791 AAMDNodes AAInfo =
N->getAAInfo();
5797 if (
N->getMemoryVT().bitsLE(NVT)) {
5798 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5799 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5800 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5804 if (DAG.getDataLayout().isLittleEndian()) {
5806 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5808 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5811 unsigned ExcessBits =
5818 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5819 N->getPointerInfo().getWithOffset(IncrementSize),
5820 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5826 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5828 EVT ExtVT =
N->getMemoryVT();
5831 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5839 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5843 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5847 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5848 N->getBaseAlign(), MMOFlags, AAInfo);
5853 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5854 N->getPointerInfo().getWithOffset(IncrementSize),
5856 N->getBaseAlign(), MMOFlags, AAInfo);
5862 GetExpandedInteger(
N->getOperand(0), InL, InH);
5871 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5876SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5877 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5878 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5882 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5884 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5887SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5890 "cannot use llvm.write_register with illegal type", Fn,
5893 return N->getOperand(0);
5896SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5899 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5900 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5906SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
5908 unsigned Factor =
N->getNumOperands();
5911 for (
unsigned i = 0; i != Factor; i++)
5912 Ops[i] = GetPromotedInteger(
N->getOperand(i));
5917 for (
unsigned i = 0; i != Factor; i++)
5923SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
5925 EVT OutVT =
N->getValueType(0);
5926 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
5927 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5931 SDValue BaseIdx =
N->getOperand(1);
5948 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
5952 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
5958 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
5967 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
5971 "Promoted operand has an element type greater than result");
5984 InOp0 = GetPromotedInteger(InOp0);
5991 Ops.reserve(OutNumElems);
5992 for (
unsigned i = 0; i != OutNumElems; ++i) {
5997 N->getOperand(0), Index);
5998 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6003 return DAG.getBuildVector(NOutVT, dl,
Ops);
6006SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6007 EVT OutVT =
N->getValueType(0);
6008 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6009 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6021 Vec = GetPromotedInteger(Vec);
6027SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6030 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6036SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6038 EVT VT =
N->getValueType(0);
6043 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6044 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6047 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6051 EVT OutVT =
N->getValueType(0);
6052 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6053 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6054 unsigned NumElems =
N->getNumOperands();
6061 Ops.reserve(NumElems);
6062 for (
unsigned i = 0; i != NumElems; ++i) {
6064 EVT OpVT =
Op.getValueType();
6069 if (OpVT.
bitsLT(NOutVTElem)) {
6075 ExtOpc = NOutExtOpc;
6076 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6081 return DAG.getBuildVector(NOutVT, dl,
Ops);
6088 assert(!
N->getOperand(0).getValueType().isVector() &&
6089 "Input must be a scalar");
6091 EVT OutVT =
N->getValueType(0);
6092 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6093 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6097 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6102 EVT OutVT =
N->getValueType(0);
6103 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6105 "Type must be promoted to a scalable vector type");
6106 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6107 return DAG.getStepVector(dl, NOutVT,
6111SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6114 EVT OutVT =
N->getValueType(0);
6115 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6116 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6118 unsigned NumOperands =
N->getNumOperands();
6123 SDUse *MaxSizedValue = std::max_element(
6125 EVT AVT = A.getValueType().getVectorElementType();
6126 EVT BVT = B.getValueType().getVectorElementType();
6127 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6133 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6135 EVT OpVT =
Op.getValueType();
6137 Op = GetPromotedInteger(
Op);
6140 "Unhandled legalization type");
6144 Op = DAG.getAnyExtOrTrunc(
Op, dl,
6151 return DAG.getAnyExtOrTrunc(
6157 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6158 assert(NumElem * NumOperands == NumOutElem &&
6159 "Unexpected number of elements");
6163 for (
unsigned i = 0; i < NumOperands; ++i) {
6166 Op = GetPromotedInteger(
Op);
6167 EVT SclrTy =
Op.getValueType().getVectorElementType();
6168 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6169 "Unexpected number of elements");
6171 for (
unsigned j = 0;
j < NumElem; ++
j) {
6173 DAG.getVectorIdxConstant(j, dl));
6174 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6178 return DAG.getBuildVector(NOutVT, dl,
Ops);
6181SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6182 EVT VT =
N->getValueType(0);
6183 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6184 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6192 if (getTypeAction(
N->getOperand(0).getValueType())
6196 switch(
N->getOpcode()) {
6198 Promoted = SExtPromotedInteger(
N->getOperand(0));
6201 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6204 Promoted = GetPromotedInteger(
N->getOperand(0));
6209 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6213 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6216SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6217 EVT VT =
N->getValueType(0);
6218 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6219 return DAG.getNode(ISD::VECTOR_FIND_LAST_ACTIVE, SDLoc(
N), NVT,
N->ops());
6222SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6223 EVT VT =
N->getValueType(0);
6224 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6225 return DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, SDLoc(
N), NVT,
N->ops());
6228SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6230 EVT VT =
N->getValueType(0);
6231 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6232 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6233 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6237SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6238 EVT OutVT =
N->getValueType(0);
6239 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6240 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6245 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6248 NOutVTElem,
N->getOperand(1));
6250 V0, ConvElem,
N->getOperand(2));
6257 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6258 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6266 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6267 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6268 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6272 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6275 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6276 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6284 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6289SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6292 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6294 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6295 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6296 return DAG.getPOISON(NVT);
6299SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6301 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6302 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6303 TLI.getVectorIdxTy(DAG.getDataLayout()));
6310 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6313SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6318 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6323 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6325 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6337 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6338 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6341SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6343 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6351SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6354 EVT ResVT =
N->getValueType(0);
6355 unsigned NumElems =
N->getNumOperands();
6358 SDValue ResVec = DAG.getUNDEF(ResVT);
6362 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6364 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6376 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6377 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6381 for (
unsigned i=0; i<NumElem; ++i) {
6384 DAG.getVectorIdxConstant(i, dl));
6390 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6393SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6406 for (
unsigned I = 0;
I < OpNo;
I++)
6409 EVT Ty =
Op.getValueType();
6410 SDLoc
DL = SDLoc(
N);
6413 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6421 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6426 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6432SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6445 for (
unsigned I = 0;
I < OpNo;
I++)
6448 EVT Ty =
Op.getValueType();
6449 SDLoc
DL = SDLoc(
N);
6452 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6460 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6465 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool isSigned(unsigned int Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getValueType() const
Convenience function for get().getValueType().
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
ArrayRef< int > getMask() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ LOOP_DEPENDENCE_RAW_MASK
@ 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...
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ 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.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ 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...
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ 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).
@ 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.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ 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.
@ 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...
@ 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.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ 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],...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ 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.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ 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 ...
@ 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.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
Set rounding mode.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLRINT(EVT RetVT)
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getLLRINT(EVT RetVT)
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeVectorElementType(EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element 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.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)