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 case ISD::EXPERIMENTAL_VP_SPLAT:
149 Res = PromoteIntRes_ScalarOp(
N);
153 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
158 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
160 case ISD::VECTOR_FIND_LAST_ACTIVE:
161 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
164 case ISD::GET_ACTIVE_LANE_MASK:
165 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
168 case ISD::PARTIAL_REDUCE_UMLA:
169 case ISD::PARTIAL_REDUCE_SMLA:
170 case ISD::PARTIAL_REDUCE_SUMLA:
171 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
175 case ISD::VP_SIGN_EXTEND:
177 case ISD::VP_ZERO_EXTEND:
180 case ISD::VP_FP_TO_SINT:
181 case ISD::VP_FP_TO_UINT:
189 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
191 case ISD::FP_TO_BF16:
192 case ISD::FP_TO_FP16:
193 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
195 case ISD::STRICT_FP_TO_BF16:
196 case ISD::STRICT_FP_TO_FP16:
197 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
212 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
222 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
232 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
235 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
237 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
239 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
255 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
257 case ISD::VP_SADDSAT:
258 case ISD::VP_UADDSAT:
259 case ISD::VP_SSUBSAT:
260 case ISD::VP_USUBSAT:
261 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
266 Res = PromoteIntRes_CMP(
N);
279 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
281 case ISD::ATOMIC_LOAD:
284 case ISD::ATOMIC_LOAD_ADD:
285 case ISD::ATOMIC_LOAD_SUB:
286 case ISD::ATOMIC_LOAD_AND:
287 case ISD::ATOMIC_LOAD_CLR:
288 case ISD::ATOMIC_LOAD_OR:
289 case ISD::ATOMIC_LOAD_XOR:
290 case ISD::ATOMIC_LOAD_NAND:
291 case ISD::ATOMIC_LOAD_MIN:
292 case ISD::ATOMIC_LOAD_MAX:
293 case ISD::ATOMIC_LOAD_UMIN:
294 case ISD::ATOMIC_LOAD_UMAX:
295 case ISD::ATOMIC_SWAP:
298 case ISD::ATOMIC_CMP_SWAP:
299 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS:
303 case ISD::VECREDUCE_ADD:
304 case ISD::VECREDUCE_MUL:
305 case ISD::VECREDUCE_AND:
306 case ISD::VECREDUCE_OR:
307 case ISD::VECREDUCE_XOR:
308 case ISD::VECREDUCE_SMAX:
309 case ISD::VECREDUCE_SMIN:
310 case ISD::VECREDUCE_UMAX:
311 case ISD::VECREDUCE_UMIN:
312 Res = PromoteIntRes_VECREDUCE(
N);
315 case ISD::VP_REDUCE_ADD:
316 case ISD::VP_REDUCE_MUL:
317 case ISD::VP_REDUCE_AND:
318 case ISD::VP_REDUCE_OR:
319 case ISD::VP_REDUCE_XOR:
320 case ISD::VP_REDUCE_SMAX:
321 case ISD::VP_REDUCE_SMIN:
322 case ISD::VP_REDUCE_UMAX:
323 case ISD::VP_REDUCE_UMIN:
324 Res = PromoteIntRes_VP_REDUCE(
N);
329 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
333 Res = PromoteIntRes_FREEZE(
N);
338 Res = PromoteIntRes_Rotate(
N);
343 Res = PromoteIntRes_FunnelShift(
N);
348 Res = PromoteIntRes_VPFunnelShift(
N);
352 Res = PromoteIntRes_IS_FPCLASS(
N);
355 Res = PromoteIntRes_FFREXP(
N);
360 Res = PromoteIntRes_XRINT(
N);
363 case ISD::PATCHPOINT:
364 Res = PromoteIntRes_PATCHPOINT(
N);
367 Res = PromoteIntRes_READ_REGISTER(
N);
373 SetPromotedInteger(
SDValue(
N, ResNo), Res);
378 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
379 return GetPromotedInteger(
Op);
382SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
384 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
385 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
390 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
392 Op.getValueType(),
Op,
N->getOperand(1));
397 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
399 Op.getValueType(),
Op,
N->getOperand(1));
403 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
406 switch (TLI.getExtendForAtomicOps()) {
422 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
423 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
432 SDValue Op2 = GetPromotedInteger(
N->getOperand(2));
433 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
435 N->getChain(),
N->getBasePtr(),
436 Op2,
N->getMemOperand());
446 assert(
N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS);
447 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
448 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
452 if (!TLI.isTypeLegal(SVT))
455 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
456 SDValue Res = DAG.getAtomicCmpSwap(
457 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, SDLoc(
N),
N->getMemoryVT(), VTs,
458 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
462 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
468 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
469 switch (TLI.getExtendForAtomicCmpSwapArg()) {
471 Op2 = SExtPromotedInteger(Op2);
474 Op2 = ZExtPromotedInteger(Op2);
477 Op2 = GetPromotedInteger(Op2);
484 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
485 SDValue Res = DAG.getAtomicCmpSwap(
486 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
487 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
489 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
497 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
498 EVT OutVT =
N->getValueType(0);
499 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
502 switch (getTypeAction(InVT)) {
508 return DAG.getNode(ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
512 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
515 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
519 return DAG.getNode(ISD::FP_TO_FP16, dl, NOutVT, GetPromotedFloat(InOp));
529 BitConvertToInteger(GetScalarizedVector(InOp)));
538 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
539 Lo = BitConvertToInteger(
Lo);
540 Hi = BitConvertToInteger(
Hi);
542 if (DAG.getDataLayout().isBigEndian())
548 JoinIntegers(
Lo,
Hi));
549 return DAG.getNode(ISD::BITCAST, dl, NOutVT, InOp);
559 DAG.
getNode(ISD::BITCAST, dl, NOutVT, GetWidenedVector(InOp));
563 if (DAG.getDataLayout().isBigEndian()) {
567 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
582 if (isTypeLegal(WideOutVT)) {
583 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
585 DAG.getVectorIdxConstant(0, dl));
594 DAG.getDataLayout().isLittleEndian()) {
605 if (isTypeLegal(WideVecVT)) {
607 DAG.getUNDEF(WideVecVT), InOp,
608 DAG.getVectorIdxConstant(0, dl));
610 return DAG.getNode(ISD::BITCAST, dl, NOutVT, Inserted);
616 CreateStackStoreLoad(InOp, OutVT));
620 SDValue V = GetPromotedInteger(
N->getOperand(0));
622 V.getValueType(), V);
626 SDValue Op = GetPromotedInteger(
N->getOperand(0));
627 EVT OVT =
N->getValueType(0);
628 EVT NVT =
Op.getValueType();
636 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
637 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
642 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
648 return DAG.getNode(ISD::VP_SRL, dl, NVT,
649 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
654 SDValue Op = GetPromotedInteger(
N->getOperand(0));
655 EVT OVT =
N->getValueType(0);
656 EVT NVT =
Op.getValueType();
665 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
670 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
676 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
677 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
685 TLI.getTypeToTransformTo(*DAG.getContext(),
686 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
691 EVT VT =
N->getValueType(0);
698 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
705 EVT OVT =
N->getValueType(0);
706 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
712 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
713 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
715 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
721 unsigned CtlzOpcode =
N->getOpcode();
722 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
724 SDValue ExtractLeadingBits = DAG.getConstant(
727 if (!
N->isVPOpcode()) {
729 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
730 return DAG.getNode(
ISD::SUB, dl, NVT,
731 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
737 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
738 return DAG.getNode(ISD::VP_SUB, dl, NVT,
739 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
740 ExtractLeadingBits, Mask, EVL);
743 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
745 SDValue Op = GetPromotedInteger(
N->getOperand(0));
749 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
750 if (!
N->isVPOpcode()) {
752 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
757 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
758 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
764 EVT OVT =
N->getValueType(0);
765 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
773 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
774 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
781 if (!
N->isVPOpcode()) {
782 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
783 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
788 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
789 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
794 SDValue Op = GetPromotedInteger(
N->getOperand(0));
795 EVT OVT =
N->getValueType(0);
796 EVT NVT =
Op.getValueType();
803 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
804 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
808 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
814 unsigned NewOpc =
N->getOpcode();
815 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
822 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
826 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
827 N->getOperand(1),
N->getOperand(2));
828 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
831 if (!
N->isVPOpcode())
832 return DAG.getNode(NewOpc, dl, NVT,
Op);
833 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
836SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
838 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
839 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
842SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
844 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
851 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
857 EVT SVT =
In.getValueType().getScalarType();
860 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
868 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
870 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
874 if (
N->isStrictFPOpcode()) {
875 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
876 {
N->getOperand(0),
N->getOperand(1)});
880 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
881 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
884 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
896 N->getOpcode() == ISD::VP_FP_TO_UINT)
900 DAG.getValueType(
N->getValueType(0).getScalarType()));
903SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
905 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
907 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
911SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
912 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
915 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
918SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
919 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
922 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
923 N->getOperand(0),
N->getOperand(1));
929 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
931 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
935 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
939 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
948 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
951 if (getTypeAction(
N->getOperand(0).getValueType())
953 SDValue Res = GetPromotedInteger(
N->getOperand(0));
962 DAG.getValueType(
N->getOperand(0).getValueType()));
964 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
971 if (
N->getNumOperands() != 1) {
972 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
973 assert(
N->isVPOpcode() &&
"Expected VP opcode");
974 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
975 N->getOperand(1),
N->getOperand(2));
977 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
982 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
986 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
987 N->getMemoryVT(),
N->getMemOperand());
996 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
997 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1000 :
N->getExtensionType();
1003 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1004 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1005 N->getMemOperand(),
N->isExpandingLoad());
1013 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1014 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1021 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1022 N->getOffset(),
N->getMask(), ExtPassThru,
1023 N->getMemoryVT(),
N->getMemOperand(),
1024 N->getAddressingMode(), ExtType,
1025 N->isExpandingLoad());
1033 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1034 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1036 "Gather result type and the passThru argument type should be the same");
1043 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1044 N->getIndex(),
N->getScale() };
1045 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1046 N->getMemoryVT(), dl,
Ops,
1047 N->getMemOperand(),
N->getIndexType(),
1055SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1056 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1057 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1059 N->getOperand(1), Passthru);
1066 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1067 EVT VT =
N->getValueType(0);
1068 EVT SVT = getSetCCResultType(VT);
1069 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1070 unsigned NumOps =
N->getNumOperands();
1073 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1081 ReplaceValueWith(
SDValue(
N, 0), Res);
1084 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1087template <
class MatchContextClass>
1099 MatchContextClass matcher(DAG, TLI,
N);
1101 unsigned Opcode = matcher.getRootBaseOpcode();
1107 SExtOrZExtPromotedOperands(Op1, Op2);
1113 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1115 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1116 Op1 = SExtPromotedInteger(Op1);
1117 Op2 = SExtPromotedInteger(Op2);
1118 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1121 Op1 = ZExtPromotedInteger(Op1);
1122 Op2 = ZExtPromotedInteger(Op2);
1125 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1127 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1134 Op1 = GetPromotedInteger(Op1);
1135 Op2 = ZExtPromotedInteger(Op2);
1137 Op1 = SExtPromotedInteger(Op1);
1138 Op2 = SExtPromotedInteger(Op2);
1145 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1158 "addition, subtraction or left shift");
1161 unsigned SHLAmount = NewBits - OldBits;
1163 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1168 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1169 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1175 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1176 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1177 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1178 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1179 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1186 SDValue Op1Promoted, Op2Promoted;
1192 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1193 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1195 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1196 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1198 EVT OldType =
N->getOperand(0).getValueType();
1210 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1211 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1212 Op2Promoted,
N->getOperand(2));
1214 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1215 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1217 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1222 unsigned SatW,
bool Signed,
1225 EVT VT = V.getValueType();
1252 EVT VT =
LHS.getValueType();
1270 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1276 "Tried to saturate to more than the original type?");
1285 SDValue Op1Promoted, Op2Promoted;
1291 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1292 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1294 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1295 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1298 unsigned Scale =
N->getConstantOperandVal(2);
1302 if (TLI.isTypeLegal(PromotedType)) {
1304 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1307 N->getValueType(0).getScalarSizeInBits();
1311 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1312 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1313 Op2Promoted,
N->getOperand(2));
1316 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1322 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1323 Op2Promoted, Scale, DAG)) {
1326 N->getValueType(0).getScalarSizeInBits(),
1334 N->getValueType(0).getScalarSizeInBits());
1337SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1339 return PromoteIntRes_Overflow(
N);
1343 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1344 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1345 EVT OVT =
N->getOperand(0).getValueType();
1346 EVT NVT =
LHS.getValueType();
1356 DAG.getValueType(OVT));
1358 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1361 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1367 EVT PromotedResultTy =
1368 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1369 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1370 N->getOperand(0),
N->getOperand(1));
1376 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1377 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1379 unsigned Opcode =
N->getOpcode();
1380 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1381 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1383 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1387 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1388 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1390 LHS.getValueType(),
N->getOperand(0),
1391 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1396 EVT InVT =
N->getOperand(OpNo).getValueType();
1397 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1399 EVT SVT = getSetCCResultType(InVT);
1406 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1407 SVT = getSetCCResultType(InVT);
1415 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1416 "Vector compare must return a vector result!");
1420 if (
N->isStrictFPOpcode()) {
1421 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1422 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1423 N->getOperand(2),
N->getOperand(3)};
1424 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1429 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1430 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1433 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1440 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1445 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1446 EVT VT =
N->getValueType(0);
1450 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1452 ReplaceValueWith(
SDValue(
N, 0), Res);
1457 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1459 if (
N->getOpcode() != ISD::VP_SHL) {
1461 RHS = ZExtPromotedInteger(
RHS);
1463 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1469 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1470 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1474SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1475 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1477 Op.getValueType(),
Op,
N->getOperand(1));
1480SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1484 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1485 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1486 if (
N->getNumOperands() == 2)
1487 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1488 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1489 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1490 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1491 N->getOperand(2),
N->getOperand(3));
1495 if (
N->getNumOperands() == 2) {
1497 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1498 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1499 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1501 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1502 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1506 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1507 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1508 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1513 if (
N->getNumOperands() == 2) {
1515 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1516 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1517 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1519 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1520 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1524 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1525 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1526 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1536 SExtOrZExtPromotedOperands(
LHS,
RHS);
1538 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1544 if (
N->getOpcode() != ISD::VP_SRA) {
1546 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1548 RHS = ZExtPromotedInteger(
RHS);
1549 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1555 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1557 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1558 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1564 if (
N->getOpcode() != ISD::VP_SRL) {
1566 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1568 RHS = ZExtPromotedInteger(
RHS);
1569 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1575 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1577 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1578 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1584 SDValue Res = TLI.expandROT(
N,
true , DAG);
1585 ReplaceValueWith(
SDValue(
N, 0), Res);
1590 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1591 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1594 Amt = ZExtPromotedInteger(Amt);
1598 EVT OldVT =
N->getOperand(0).getValueType();
1599 EVT VT =
Lo.getValueType();
1600 unsigned Opcode =
N->getOpcode();
1607 DAG.getConstant(OldBits,
DL, AmtVT));
1615 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1616 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1618 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1628 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1634 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1636 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1640SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1641 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1642 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1647 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1651 EVT OldVT =
N->getOperand(0).getValueType();
1652 EVT VT =
Lo.getValueType();
1653 unsigned Opcode =
N->getOpcode();
1654 bool IsFSHR = Opcode == ISD::VP_FSHR;
1659 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1660 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1668 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1669 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1670 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1671 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1673 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1676 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1681 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1682 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1687 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1689 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1693 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1705 Res = GetPromotedInteger(InOp);
1712 "Dst and Src must have the same number of elements");
1714 "Promoted vector type must be a power of two");
1717 GetSplitVector(InOp, EOp1, EOp2);
1725 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1726 "Expected VP_TRUNCATE opcode");
1727 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1728 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1729 std::tie(EVLLo, EVLHi) =
1730 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1731 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1732 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1739 SDValue WideInOp = GetWidenedVector(InOp);
1744 N->getValueType(0).getScalarType(), NumElem);
1753 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1759 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1760 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1765SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1767 return PromoteIntRes_Overflow(
N);
1771 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1772 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1773 EVT OVT =
N->getOperand(0).getValueType();
1774 EVT NVT =
LHS.getValueType();
1783 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1785 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1788 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1799 return PromoteIntRes_Overflow(
N);
1811 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1812 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1814 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1817 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1828 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1829 return PromoteIntRes_Overflow(
N);
1833 EVT OVT =
N->getValueType(0);
1834 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1840 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1841 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1842 if (
SDValue Res = TLI.expandABS(
N, DAG))
1846 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1850SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1853 return PromoteIntRes_Overflow(
N);
1857 EVT SmallVT =
LHS.getValueType();
1864 LHS = SExtPromotedInteger(
LHS);
1865 RHS = SExtPromotedInteger(
RHS);
1867 LHS = ZExtPromotedInteger(
LHS);
1868 RHS = ZExtPromotedInteger(
RHS);
1870 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1882 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1883 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1884 DAG.getConstant(0,
DL,
Hi.getValueType()),
1889 Mul, DAG.getValueType(SmallVT));
1899 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1904 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1905 N->getValueType(0)));
1909 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1911 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1918 EVT VT =
N->getValueType(0);
1921 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1922 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1926 for (
unsigned i = 0; i < NumRegs; ++i) {
1927 Parts[i] = DAG.getVAArg(RegVT, dl, Chain,
Ptr,
N->getOperand(2),
1928 N->getConstantOperandVal(3));
1933 if (DAG.getDataLayout().isBigEndian())
1934 std::reverse(Parts.begin(), Parts.end());
1937 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1939 for (
unsigned i = 1; i < NumRegs; ++i) {
1944 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1950 ReplaceValueWith(
SDValue(
N, 1), Chain);
1963bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1966 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1971 switch (
N->getOpcode()) {
1974 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1975 N->dump(&DAG);
dbgs() <<
"\n";
1980 case ISD::ATOMIC_STORE:
1983 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(
N);
break;
1984 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1985 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
1991 Res = PromoteIntOp_FAKE_USE(
N);
1994 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
1998 case ISD::EXPERIMENTAL_VP_SPLAT:
1999 Res = PromoteIntOp_ScalarOp(
N);
2002 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2005 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2007 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2008 case ISD::VP_SINT_TO_FP:
2025 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2027 case ISD::VP_TRUNCATE:
2029 case ISD::BF16_TO_FP:
2030 case ISD::FP16_TO_FP:
2031 case ISD::VP_UINT_TO_FP:
2033 case ISD::STRICT_FP16_TO_FP:
2036 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2044 case ISD::ROTR: Res = PromoteIntOp_Shift(
N);
break;
2047 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2050 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2067 case ISD::VECREDUCE_ADD:
2068 case ISD::VECREDUCE_MUL:
2069 case ISD::VECREDUCE_AND:
2070 case ISD::VECREDUCE_OR:
2071 case ISD::VECREDUCE_XOR:
2072 case ISD::VECREDUCE_SMAX:
2073 case ISD::VECREDUCE_SMIN:
2074 case ISD::VECREDUCE_UMAX:
2075 case ISD::VECREDUCE_UMIN: Res = PromoteIntOp_VECREDUCE(
N);
break;
2076 case ISD::VP_REDUCE_ADD:
2077 case ISD::VP_REDUCE_MUL:
2078 case ISD::VP_REDUCE_AND:
2079 case ISD::VP_REDUCE_OR:
2080 case ISD::VP_REDUCE_XOR:
2081 case ISD::VP_REDUCE_SMAX:
2082 case ISD::VP_REDUCE_SMIN:
2083 case ISD::VP_REDUCE_UMAX:
2084 case ISD::VP_REDUCE_UMIN:
2085 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2088 case ISD::SET_ROUNDING: Res = PromoteIntOp_SET_ROUNDING(
N);
break;
2090 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2092 case ISD::PATCHPOINT:
2093 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2096 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2098 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2099 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2100 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2102 case ISD::EXPERIMENTAL_VP_SPLICE:
2103 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2105 case ISD::EXPERIMENTAL_VECTOR_HISTOGRAM:
2106 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2108 case ISD::VECTOR_FIND_LAST_ACTIVE:
2109 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2111 case ISD::GET_ACTIVE_LANE_MASK:
2112 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2114 case ISD::PARTIAL_REDUCE_UMLA:
2115 case ISD::PARTIAL_REDUCE_SMLA:
2116 case ISD::PARTIAL_REDUCE_SUMLA:
2117 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2122 if (!Res.
getNode())
return false;
2129 const bool IsStrictFp =
N->isStrictFPOpcode();
2131 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2132 "Invalid operand expansion");
2136 ReplaceValueWith(
SDValue(
N, 0), Res);
2150 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2154 unsigned OpLEffectiveBits =
2155 DAG.computeKnownBits(OpL).countMaxActiveBits();
2156 unsigned OpREffectiveBits =
2157 DAG.computeKnownBits(OpR).countMaxActiveBits();
2158 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2159 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2166 LHS = SExtPromotedInteger(
LHS);
2167 RHS = SExtPromotedInteger(
RHS);
2176 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2177 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2178 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2179 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2186 LHS = ZExtPromotedInteger(
LHS);
2187 RHS = ZExtPromotedInteger(
RHS);
2201 LHS = SExtPromotedInteger(
LHS);
2202 RHS = SExtPromotedInteger(
RHS);
2207 "Unknown integer comparison!");
2209 SExtOrZExtPromotedOperands(
LHS,
RHS);
2213 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2218 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2219 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2220 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2224 EVT OutVT =
N->getValueType(0);
2227 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2230 switch (getTypeAction(InVT)) {
2234 DAG.getDataLayout().isLittleEndian()) {
2244 if (isTypeLegal(WideVecVT)) {
2245 SDValue Promoted = GetPromotedInteger(InOp);
2246 SDValue Cast = DAG.getNode(ISD::BITCAST, dl, WideVecVT, Promoted);
2248 DAG.getVectorIdxConstant(0, dl));
2261 return CreateStackStoreLoad(InOp, OutVT);
2264SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2265 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2273 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2274 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2278SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2279 assert(OpNo == 1 &&
"only know how to promote condition");
2282 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2285 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2286 N->getOperand(2)), 0);
2291 EVT OVT =
N->getOperand(0).getValueType();
2292 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2293 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2294 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2299 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2300 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2309 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2310 "Legal vector of one illegal element?");
2315 assert(
N->getOperand(0).getValueSizeInBits() >=
2316 N->getValueType(0).getScalarSizeInBits() &&
2317 "Type of inserted value narrower than vector element type!");
2320 for (
unsigned i = 0; i < NumElts; ++i)
2321 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2323 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2326SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2333 assert(
N->getOperand(1).getValueSizeInBits() >=
2334 N->getValueType(0).getScalarSizeInBits() &&
2335 "Type of inserted value narrower than vector element type!");
2336 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2337 GetPromotedInteger(
N->getOperand(1)),
2342 assert(OpNo == 2 &&
"Different operand and result vector types?");
2345 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2346 TLI.getVectorIdxTy(DAG.getDataLayout()));
2347 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2348 N->getOperand(1), Idx), 0);
2352 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2353 if (
N->getOpcode() == ISD::EXPERIMENTAL_VP_SPLAT)
2355 DAG.UpdateNodeOperands(
N,
Op,
N->getOperand(1),
N->getOperand(2)), 0);
2359 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2362SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2363 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2365 EVT OpTy =
N->getOperand(1).getValueType();
2368 if (
SDValue Res = WidenVSELECTMask(
N))
2369 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2370 Res,
N->getOperand(1),
N->getOperand(2));
2374 Cond = PromoteTargetBoolean(
Cond, OpVT);
2376 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2377 N->getOperand(2)), 0);
2380SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2381 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2389 N->getOperand(3),
N->getOperand(4)), 0);
2392SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2393 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2401 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2403 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2406 N->getOperand(3),
N->getOperand(4)),
2411 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2412 ZExtPromotedInteger(
N->getOperand(1))), 0);
2420 LHS = SExtPromotedInteger(
LHS);
2421 RHS = SExtPromotedInteger(
RHS);
2423 SExtOrZExtPromotedOperands(
LHS,
RHS);
2430 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2431 ZExtPromotedInteger(
N->getOperand(2))), 0);
2435 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2439 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2442SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2444 EVT VT =
N->getValueType(0);
2445 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2447 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2451 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2455 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2460 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2461 return SDValue(DAG.UpdateNodeOperands(
N,
2462 SExtPromotedInteger(
N->getOperand(0)),
2463 N->getOperand(1),
N->getOperand(2)),
2465 return SDValue(DAG.UpdateNodeOperands(
N,
2466 SExtPromotedInteger(
N->getOperand(0))), 0);
2469SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2470 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2471 SExtPromotedInteger(
N->getOperand(1))), 0);
2479 SDValue Val = GetPromotedInteger(
N->getValue());
2482 return DAG.getTruncStore(Ch, dl, Val,
Ptr,
2483 N->getMemoryVT(),
N->getMemOperand());
2489 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2490 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2492 SDValue DataOp = GetPromotedInteger(
N->getValue());
2493 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2494 N->getMask(),
N->getVectorLength(),
2495 N->getMemoryVT(),
N->getMemOperand(),
2496 N->isCompressingStore());
2507 Mask = PromoteTargetBoolean(Mask, DataVT);
2510 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2513 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2514 DataOp = GetPromotedInteger(DataOp);
2516 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2517 N->getOffset(), Mask,
N->getMemoryVT(),
2518 N->getMemOperand(),
N->getAddressingMode(),
2519 true,
N->isCompressingStore());
2524 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2525 EVT DataVT =
N->getValueType(0);
2526 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2528 NewOps[OpNo] =
Mask;
2529 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2545 EVT DataVT =
N->getValueType(0);
2546 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2547 }
else if (OpNo == 4) {
2549 if (
N->isIndexSigned())
2551 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2553 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2555 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2557 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2569 bool TruncateStore =
N->isTruncatingStore();
2574 EVT DataVT =
N->getValue().getValueType();
2575 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2576 }
else if (OpNo == 4) {
2578 if (
N->isIndexSigned())
2580 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2582 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2584 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2585 TruncateStore =
true;
2588 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2589 SDLoc(
N), NewOps,
N->getMemOperand(),
2590 N->getIndexType(), TruncateStore);
2595 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2599 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2604 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2605 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2606 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2607 N->getOperand(1),
N->getOperand(2));
2612 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2613 return SDValue(DAG.UpdateNodeOperands(
N,
2614 ZExtPromotedInteger(
N->getOperand(0)),
2615 N->getOperand(1),
N->getOperand(2)),
2617 return SDValue(DAG.UpdateNodeOperands(
N,
2618 ZExtPromotedInteger(
N->getOperand(0))), 0);
2621SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2622 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2623 ZExtPromotedInteger(
N->getOperand(1))), 0);
2630 EVT VT =
N->getValueType(0);
2635 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2636 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2637 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2638 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2643 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2646SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2648 EVT VT =
N->getValueType(0);
2649 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2651 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2653 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2654 N->getOperand(0).getValueType());
2658 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2660 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2663SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2665 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2666 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2675 unsigned OpOffset = IsStrict ? 1 : 0;
2682 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
2688 if (IsPowI && N->getValueType(0).isVector())
2689 return DAG.UnrollVectorOp(N);
2690 SmallVector<SDValue, 3> NewOps(N->ops());
2691 NewOps[1 + OpOffset] = SExtPromotedInteger(N->getOperand(1 + OpOffset));
2692 return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
2702 assert(DAG.getLibInfo().getIntSize() ==
2703 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2704 "POWI exponent should match with sizeof(int) when doing the libcall.");
2705 TargetLowering::MakeLibCallOptions CallOptions;
2706 CallOptions.setIsSigned(
true);
2707 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2708 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2709 DAG, LC,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2710 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2712 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2717 switch (
N->getOpcode()) {
2720 case ISD::VECREDUCE_ADD:
2721 case ISD::VECREDUCE_MUL:
2722 case ISD::VECREDUCE_AND:
2723 case ISD::VECREDUCE_OR:
2724 case ISD::VECREDUCE_XOR:
2725 case ISD::VP_REDUCE_ADD:
2726 case ISD::VP_REDUCE_MUL:
2727 case ISD::VP_REDUCE_AND:
2728 case ISD::VP_REDUCE_OR:
2729 case ISD::VP_REDUCE_XOR:
2731 case ISD::VECREDUCE_SMAX:
2732 case ISD::VECREDUCE_SMIN:
2733 case ISD::VP_REDUCE_SMAX:
2734 case ISD::VP_REDUCE_SMIN:
2736 case ISD::VECREDUCE_UMAX:
2737 case ISD::VECREDUCE_UMIN:
2738 case ISD::VP_REDUCE_UMAX:
2739 case ISD::VP_REDUCE_UMIN:
2749 return GetPromotedInteger(V);
2751 return SExtPromotedInteger(V);
2753 return ZExtPromotedInteger(V);
2759 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2761 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2762 EVT InVT =
Op.getValueType();
2764 EVT ResVT =
N->getValueType(0);
2765 unsigned Opcode =
N->getOpcode();
2769 if (Opcode == ISD::VECREDUCE_XOR && OrigEltVT == MVT::i1 &&
2770 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_XOR, InVT) &&
2771 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_ADD, InVT))
2772 Opcode = ISD::VECREDUCE_ADD;
2776 else if (Opcode == ISD::VECREDUCE_OR && OrigEltVT == MVT::i1 &&
2777 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_OR, InVT) &&
2778 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMAX, InVT)) {
2779 Opcode = ISD::VECREDUCE_UMAX;
2782 switch (TLI.getBooleanContents(InVT)) {
2785 Op = ZExtPromotedInteger(
N->getOperand(0));
2788 Op = SExtPromotedInteger(
N->getOperand(0));
2795 else if (Opcode == ISD::VECREDUCE_AND && OrigEltVT == MVT::i1 &&
2796 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_AND, InVT) &&
2797 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMIN, InVT)) {
2798 Opcode = ISD::VECREDUCE_UMIN;
2801 switch (TLI.getBooleanContents(InVT)) {
2804 Op = ZExtPromotedInteger(
N->getOperand(0));
2807 Op = SExtPromotedInteger(
N->getOperand(0));
2813 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2817 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2821SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2828 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2829 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2832 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2834 Op = PromoteIntOpVectorReduction(
N,
Op);
2838 EVT VT =
N->getValueType(0);
2839 EVT EltVT =
Op.getValueType().getScalarType();
2842 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2854 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2855 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2858SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2861 SDValue Operand =
N->getOperand(OpNo);
2862 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Operand.
getValueType());
2864 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2867SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2871 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Operand.
getValueType());
2873 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2878 const Function &Fn = DAG.getMachineFunction().getFunction();
2880 "cannot use llvm.write_register with illegal type", Fn,
2882 return N->getOperand(0);
2885SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2886 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2887 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2890 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2892 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2895SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2899 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2900 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2903 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2905 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2906 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2909SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2911 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2913 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2914 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2917SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2920 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2921 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2924SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2926 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2927 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2928 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2931SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2933 switch (
N->getOpcode()) {
2934 case ISD::PARTIAL_REDUCE_SMLA:
2935 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2936 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2938 case ISD::PARTIAL_REDUCE_UMLA:
2939 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2940 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2942 case ISD::PARTIAL_REDUCE_SUMLA:
2943 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2944 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2949 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2960void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2966 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2969 switch (
N->getOpcode()) {
2972 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2973 N->dump(&DAG);
dbgs() <<
"\n";
2978 case ISD::ARITH_FENCE: SplitRes_ARITH_FENCE(
N,
Lo,
Hi);
break;
2987 case ISD::BITCAST: ExpandRes_BITCAST(
N,
Lo,
Hi);
break;
2991 case ISD::VAARG: ExpandRes_VAARG(
N,
Lo,
Hi);
break;
3022 case ISD::LLRINT: ExpandIntRes_XROUND_XRINT(
N,
Lo,
Hi);
break;
3025 case ISD::READCYCLECOUNTER:
3026 case ISD::READSTEADYCOUNTER: ExpandIntRes_READCOUNTER(
N,
Lo,
Hi);
break;
3035 case ISD::ATOMIC_LOAD: ExpandIntRes_ATOMIC_LOAD(
N,
Lo,
Hi);
break;
3037 case ISD::ATOMIC_LOAD_ADD:
3038 case ISD::ATOMIC_LOAD_SUB:
3039 case ISD::ATOMIC_LOAD_AND:
3040 case ISD::ATOMIC_LOAD_CLR:
3041 case ISD::ATOMIC_LOAD_OR:
3042 case ISD::ATOMIC_LOAD_XOR:
3043 case ISD::ATOMIC_LOAD_NAND:
3044 case ISD::ATOMIC_LOAD_MIN:
3045 case ISD::ATOMIC_LOAD_MAX:
3046 case ISD::ATOMIC_LOAD_UMIN:
3047 case ISD::ATOMIC_LOAD_UMAX:
3048 case ISD::ATOMIC_SWAP:
3049 case ISD::ATOMIC_CMP_SWAP: {
3050 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3051 SplitInteger(Tmp.first,
Lo,
Hi);
3052 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3055 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: {
3057 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3058 SDValue Tmp = DAG.getAtomicCmpSwap(
3059 ISD::ATOMIC_CMP_SWAP, SDLoc(
N), AN->
getMemoryVT(), VTs,
3060 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3069 SplitInteger(Tmp,
Lo,
Hi);
3136 case ISD::VECREDUCE_ADD:
3137 case ISD::VECREDUCE_MUL:
3138 case ISD::VECREDUCE_AND:
3139 case ISD::VECREDUCE_OR:
3140 case ISD::VECREDUCE_XOR:
3141 case ISD::VECREDUCE_SMAX:
3142 case ISD::VECREDUCE_SMIN:
3143 case ISD::VECREDUCE_UMAX:
3144 case ISD::VECREDUCE_UMIN: ExpandIntRes_VECREDUCE(
N,
Lo,
Hi);
break;
3148 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3153 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3157 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3161 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3171std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3172 unsigned Opc =
Node->getOpcode();
3178 EVT RetVT =
Node->getValueType(0);
3179 TargetLowering::MakeLibCallOptions CallOptions;
3181 if (TLI.getLibcallName(LC)) {
3183 Ops.push_back(
Node->getOperand(1));
3186 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3187 "Unexpected atomic op or value type!");
3190 return TLI.makeLibCall(DAG, LC, RetVT,
Ops, CallOptions, SDLoc(Node),
3191 Node->getOperand(0));
3196void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3201 GetExpandedInteger(
N->getOperand(0), InL, InH);
3216 if (Amt.
uge(VTBits)) {
3217 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3218 }
else if (Amt.
ugt(NVTBits)) {
3219 Lo = DAG.getConstant(0,
DL, NVT);
3221 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3222 }
else if (Amt == NVTBits) {
3223 Lo = DAG.getConstant(0,
DL, NVT);
3227 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3231 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3233 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3239 if (Amt.
uge(VTBits)) {
3240 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3241 }
else if (Amt.
ugt(NVTBits)) {
3243 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3244 Hi = DAG.getConstant(0,
DL, NVT);
3245 }
else if (Amt == NVTBits) {
3247 Hi = DAG.getConstant(0,
DL, NVT);
3252 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3254 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3256 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3262 if (Amt.
uge(VTBits)) {
3264 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3265 }
else if (Amt.
ugt(NVTBits)) {
3267 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3269 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3270 }
else if (Amt == NVTBits) {
3273 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3278 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3280 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3282 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3290bool DAGTypeLegalizer::
3292 unsigned Opc =
N->getOpcode();
3295 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3300 "Expanded integer type size not a power of two!");
3304 KnownBits Known = DAG.computeKnownBits(Amt);
3307 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3312 GetExpandedInteger(In, InL, InH);
3319 DAG.getConstant(~HighBitMask, dl, ShTy));
3324 Lo = DAG.getConstant(0, dl, NVT);
3325 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3328 Hi = DAG.getConstant(0, dl, NVT);
3329 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3333 DAG.getConstant(NVTBits - 1, dl, ShTy));
3334 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3346 DAG.getConstant(NVTBits - 1, dl, ShTy));
3362 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3364 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3366 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3367 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3379bool DAGTypeLegalizer::
3382 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3386 "Expanded integer type size not a power of two!");
3391 GetExpandedInteger(
N->getOperand(0), InL, InH);
3393 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3396 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3399 Amt, DAG.getConstant(0, dl, ShTy),
3403 switch (
N->getOpcode()) {
3409 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3410 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3413 LoL = DAG.getConstant(0, dl, NVT);
3416 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3417 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3418 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3424 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3427 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3430 HiL = DAG.getConstant(0, dl, NVT);
3433 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3434 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3435 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3441 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3442 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3446 DAG.getConstant(NVTBits - 1, dl, ShTy));
3449 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3450 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3451 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3476 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3481 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3482 SplitInteger(Res,
Lo,
Hi);
3485void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3494 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3495 unsigned NumHalfBits = NumBits / 2;
3496 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3497 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3498 SDValue LHSL, LHSH, RHSL, RHSH;
3499 GetExpandedInteger(
LHS, LHSL, LHSH);
3500 GetExpandedInteger(
RHS, RHSL, RHSH);
3503 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3505 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3513 SDValue LHSL, LHSH, RHSL, RHSH;
3514 GetExpandedInteger(
LHS, LHSL, LHSH);
3515 GetExpandedInteger(
RHS, RHSL, RHSH);
3517 EVT CCT = getSetCCResultType(NVT);
3520 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3522 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3524 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3526 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3530 const APInt *RHSVal =
nullptr;
3532 RHSVal = &RHSConst->getAPIntValue();
3539 SDValue LHSL, LHSH, RHSL, RHSH;
3540 GetExpandedInteger(
LHS, LHSL, LHSH);
3541 GetExpandedInteger(
RHS, RHSL, RHSH);
3543 EVT CCT = getSetCCResultType(NVT);
3549 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3552 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3556 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3559 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3561 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3568 switch (
N->getOpcode()) {
3595 EVT VT =
N->getValueType(0);
3596 EVT CCT = getSetCCResultType(VT);
3599 SplitInteger(Result,
Lo,
Hi);
3603 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3604 SplitInteger(ExpandedCMP,
Lo,
Hi);
3607void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3611 SDValue LHSL, LHSH, RHSL, RHSH;
3612 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3613 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3616 SDValue LoOps[2] = { LHSL, RHSL };
3617 SDValue HiOps[3] = { LHSH, RHSH };
3619 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3621 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3623 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3627 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3633 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3646 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3648 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3651 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3665 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3667 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3671 EVT OvfVT = getSetCCResultType(NVT);
3672 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3687 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3690 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3694 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3706 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3710 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3713 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3716 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3721 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3723 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3724 DAG.getConstant(0, dl, NVT));
3727 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3736 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3741 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3743 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3744 DAG.getConstant(0, dl, NVT));
3750void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3753 SDValue LHSL, LHSH, RHSL, RHSH;
3755 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3756 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3757 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3758 SDValue LoOps[2] = { LHSL, RHSL };
3759 SDValue HiOps[3] = { LHSH, RHSH };
3773 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3776void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3779 SDValue LHSL, LHSH, RHSL, RHSH;
3781 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3782 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3783 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3785 SDValue HiOps[3] = { LHSH, RHSH };
3787 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3789 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3793 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3796void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3804 unsigned CarryOp, NoCarryOp;
3806 switch(
N->getOpcode()) {
3821 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3822 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3826 SDValue LHSL, LHSH, RHSL, RHSH;
3827 GetExpandedInteger(
LHS, LHSL, LHSH);
3828 GetExpandedInteger(
RHS, RHSL, RHSH);
3829 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3830 SDValue LoOps[2] = { LHSL, RHSL };
3831 SDValue HiOps[3] = { LHSH, RHSH };
3833 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3835 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3842 SplitInteger(Sum,
Lo,
Hi);
3848 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3849 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3853 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3858 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3864 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3870 SDValue LHSL, LHSH, RHSL, RHSH;
3872 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3873 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3874 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3878 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3880 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3884 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3887void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3890 SDValue LHSL, LHSH, RHSL, RHSH;
3892 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3893 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3894 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3899 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3900 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3904 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3907void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3909 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3912 if (
Op.getValueType().bitsLE(NVT)) {
3915 Hi = DAG.getUNDEF(NVT);
3919 assert(getTypeAction(
Op.getValueType()) ==
3921 "Only know how to promote this result!");
3924 "Operand over promoted?");
3926 SplitInteger(Res,
Lo,
Hi);
3930void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3933 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3934 EVT NVT =
Lo.getValueType();
3939 if (NVTBits < EVTBits) {
3942 EVTBits - NVTBits)));
3947 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3951void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3954 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3955 EVT NVT =
Lo.getValueType();
3960 if (NVTBits < EVTBits) {
3963 EVTBits - NVTBits)));
3967 Hi = DAG.getConstant(0, dl, NVT);
3971void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3974 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3979void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3982 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3991 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3992 EVT NVT =
Lo.getValueType();
3995 Hi = DAG.getConstant(0, dl, NVT);
3998void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4000 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4003 const APInt &Cst =
Constant->getAPIntValue();
4004 bool IsTarget =
Constant->isTargetOpcode();
4005 bool IsOpaque =
Constant->isOpaque();
4007 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4008 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4016 GetExpandedInteger(N0,
Lo,
Hi);
4017 EVT NVT =
Lo.getValueType();
4023 Hi = DAG.getConstant(0, dl, NVT);
4033 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4038 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4039 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4048 EVT VT =
N->getValueType(0);
4050 DAG.getConstant(0, dl, VT), N0);
4052 SplitInteger(Neg, NegLo, NegHi);
4054 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4056 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4057 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4060void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4064 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4065 EVT NVT =
Lo.getValueType();
4067 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4070 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4073 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4074 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4077 Hi = DAG.getConstant(0, dl, NVT);
4082 SplitInteger(Result,
Lo,
Hi);
4087 EVT VT =
N->getValueType(0);
4091 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4093 LC = RTLIB::CTPOP_I32;
4094 else if (VT == MVT::i64)
4095 LC = RTLIB::CTPOP_I64;
4096 else if (VT == MVT::i128)
4097 LC = RTLIB::CTPOP_I128;
4098 assert(LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC) &&
4099 "LibCall explicitly requested, but not available");
4100 TargetLowering::MakeLibCallOptions CallOptions;
4103 SDValue Res = TLI.makeLibCall(DAG, LC, IntVT,
Op, CallOptions,
DL).first;
4104 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4109 GetExpandedInteger(
Op,
Lo,
Hi);
4110 EVT NVT =
Lo.getValueType();
4113 Hi = DAG.getConstant(0,
DL, NVT);
4116void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4120 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4121 EVT NVT =
Lo.getValueType();
4123 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4129 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4130 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4133 Hi = DAG.getConstant(0, dl, NVT);
4139 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4146 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4150 ReplaceValueWith(
SDValue(
N, 1), Chain);
4158 Chain =
Op.getValue(1);
4167 EVT VT =
N->getValueType(0);
4171 bool IsStrict =
N->isStrictFPOpcode();
4173 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4175 Op = GetPromotedFloat(
Op);
4179 Op.getValueType() == MVT::bf16) {
4185 EVT OpVT =
Op.getValueType();
4189 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4190 TargetLowering::MakeLibCallOptions CallOptions;
4195 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4196 CallOptions, dl, Chain);
4197 SplitInteger(Tmp.first,
Lo,
Hi);
4200 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4205 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4206 SplitInteger(Res,
Lo,
Hi);
4212 bool IsStrict =
N->isStrictFPOpcode();
4213 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4217 "Input type needs to be promoted!");
4219 EVT VT =
Op.getValueType();
4221 if (VT == MVT::f16) {
4227 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4228 if (
N->getOpcode() == ISD::LROUND ||
4231 LC = RTLIB::LROUND_F32;
4232 else if (VT == MVT::f64)
4233 LC = RTLIB::LROUND_F64;
4234 else if (VT == MVT::f80)
4235 LC = RTLIB::LROUND_F80;
4236 else if (VT == MVT::f128)
4237 LC = RTLIB::LROUND_F128;
4238 else if (VT == MVT::ppcf128)
4239 LC = RTLIB::LROUND_PPCF128;
4240 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4241 }
else if (
N->getOpcode() == ISD::LRINT ||
4244 LC = RTLIB::LRINT_F32;
4245 else if (VT == MVT::f64)
4246 LC = RTLIB::LRINT_F64;
4247 else if (VT == MVT::f80)
4248 LC = RTLIB::LRINT_F80;
4249 else if (VT == MVT::f128)
4250 LC = RTLIB::LRINT_F128;
4251 else if (VT == MVT::ppcf128)
4252 LC = RTLIB::LRINT_PPCF128;
4253 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4254 }
else if (
N->getOpcode() == ISD::LLROUND ||
4257 LC = RTLIB::LLROUND_F32;
4258 else if (VT == MVT::f64)
4259 LC = RTLIB::LLROUND_F64;
4260 else if (VT == MVT::f80)
4261 LC = RTLIB::LLROUND_F80;
4262 else if (VT == MVT::f128)
4263 LC = RTLIB::LLROUND_F128;
4264 else if (VT == MVT::ppcf128)
4265 LC = RTLIB::LLROUND_PPCF128;
4266 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4267 }
else if (
N->getOpcode() == ISD::LLRINT ||
4270 LC = RTLIB::LLRINT_F32;
4271 else if (VT == MVT::f64)
4272 LC = RTLIB::LLRINT_F64;
4273 else if (VT == MVT::f80)
4274 LC = RTLIB::LLRINT_F80;
4275 else if (VT == MVT::f128)
4276 LC = RTLIB::LLRINT_F128;
4277 else if (VT == MVT::ppcf128)
4278 LC = RTLIB::LLRINT_PPCF128;
4279 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4283 EVT RetVT =
N->getValueType(0);
4285 TargetLowering::MakeLibCallOptions CallOptions;
4287 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4288 Op, CallOptions, dl,
4290 SplitInteger(Tmp.first,
Lo,
Hi);
4292 if (
N->isStrictFPOpcode())
4293 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4296void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4298 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4301 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4307 EVT VT =
N->getValueType(0);
4308 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4313 AAMDNodes AAInfo =
N->getAAInfo();
4318 if (
N->getMemoryVT().bitsLE(NVT)) {
4319 EVT MemVT =
N->getMemoryVT();
4321 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
N->getPointerInfo(), MemVT,
4322 N->getBaseAlign(), MMOFlags, AAInfo);
4330 unsigned LoSize =
Lo.getValueSizeInBits();
4332 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4335 Hi = DAG.getConstant(0, dl, NVT);
4339 Hi = DAG.getUNDEF(NVT);
4341 }
else if (DAG.getDataLayout().isLittleEndian()) {
4343 Lo = DAG.getLoad(NVT, dl, Ch,
Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4346 unsigned ExcessBits =
4353 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
4354 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4355 N->getBaseAlign(), MMOFlags, AAInfo);
4364 EVT MemVT =
N->getMemoryVT();
4367 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4370 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
N->getPointerInfo(),
4373 N->getBaseAlign(), MMOFlags, AAInfo);
4379 N->getPointerInfo().getWithOffset(IncrementSize),
4381 N->getBaseAlign(), MMOFlags, AAInfo);
4393 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4397 DAG.getShiftAmountConstant(
4404 ReplaceValueWith(
SDValue(
N, 1), Ch);
4407void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4411 GetExpandedInteger(
N->getOperand(0), LL, LH);
4412 GetExpandedInteger(
N->getOperand(1), RL, RH);
4416 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4418 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4419 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4422void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4424 EVT VT =
N->getValueType(0);
4425 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4429 GetExpandedInteger(
N->getOperand(0), LL, LH);
4430 GetExpandedInteger(
N->getOperand(1), RL, RH);
4432 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4438 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4440 LC = RTLIB::MUL_I16;
4441 else if (VT == MVT::i32)
4442 LC = RTLIB::MUL_I32;
4443 else if (VT == MVT::i64)
4444 LC = RTLIB::MUL_I64;
4445 else if (VT == MVT::i128)
4446 LC = RTLIB::MUL_I128;
4448 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
4451 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4457 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4458 TargetLowering::MakeLibCallOptions CallOptions;
4460 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
4467 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4468 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4469 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4472 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4477 SplitInteger(Result,
Lo,
Hi);
4483 SplitInteger(Result,
Lo,
Hi);
4489 SplitInteger(Result,
Lo,
Hi);
4500 EVT VT =
N->getValueType(0);
4504 uint64_t Scale =
N->getConstantOperandVal(2);
4516 EVT BoolVT = getSetCCResultType(VT);
4518 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4524 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4525 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4531 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4532 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4537 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4538 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4541 SplitInteger(Result,
Lo,
Hi);
4547 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4549 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4551 GetExpandedInteger(
LHS, LL, LH);
4552 GetExpandedInteger(
RHS, RL, RH);
4556 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4563 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4564 SplitInteger(LoTmp, Result[0], Result[1]);
4565 SplitInteger(HiTmp, Result[2], Result[3]);
4567 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4570 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4571 "the size of the current value type");
4592 uint64_t Part0 = Scale / NVTSize;
4593 if (Scale % NVTSize) {
4594 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4597 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4609 if (Scale == VTSize)
4628 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4629 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4630 EVT BoolNVT = getSetCCResultType(NVT);
4633 if (Scale < NVTSize) {
4636 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4637 DAG.getShiftAmountConstant(Scale, NVT, dl));
4638 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4639 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4640 }
else if (Scale == NVTSize) {
4642 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4643 }
else if (Scale < VTSize) {
4647 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4648 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4651 "(and saturation can't happen with Scale==VTSize).");
4653 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4654 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4658 if (Scale < NVTSize) {
4663 unsigned OverflowBits = VTSize - Scale + 1;
4664 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4665 "Extent of overflow bits must start within HL");
4666 SDValue HLHiMask = DAG.getConstant(
4668 SDValue HLLoMask = DAG.getConstant(
4675 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4681 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4682 }
else if (Scale == NVTSize) {
4688 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4694 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4695 }
else if (Scale < VTSize) {
4698 unsigned OverflowBits = VTSize - Scale + 1;
4699 SDValue HHHiMask = DAG.getConstant(
4701 SDValue HHLoMask = DAG.getConstant(
4703 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4704 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4711 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4712 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4715 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4716 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4723 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4725 N->getConstantOperandVal(2), DAG);
4729 N->getConstantOperandVal(2), TLI, DAG);
4730 SplitInteger(Res,
Lo,
Hi);
4733void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4736 "Node has unexpected Opcode");
4746 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4747 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4751 SDValue LHSL, LHSH, RHSL, RHSH;
4752 GetExpandedInteger(
LHS, LHSL, LHSH);
4753 GetExpandedInteger(
RHS, RHSL, RHSH);
4754 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4757 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4766 SplitInteger(Sum,
Lo,
Hi);
4791 EVT VT =
LHS.getValueType();
4794 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4798 EVT OType =
Node->getValueType(1);
4799 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4803 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4806void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4808 EVT VT =
N->getValueType(0);
4810 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4818 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4820 LC = RTLIB::SDIV_I16;
4821 else if (VT == MVT::i32)
4822 LC = RTLIB::SDIV_I32;
4823 else if (VT == MVT::i64)
4824 LC = RTLIB::SDIV_I64;
4825 else if (VT == MVT::i128)
4826 LC = RTLIB::SDIV_I128;
4827 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4829 TargetLowering::MakeLibCallOptions CallOptions;
4831 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4834void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4837 SDValue Shiftee =
N->getOperand(0);
4844 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4845 }
while (!TLI.isTypeLegal(LoadVT));
4850 "Shifting unit is not a a power of two!");
4852 const bool IsOneStepShift =
4853 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4858 if (!IsOneStepShift)
4859 ShAmt = DAG.getFreeze(ShAmt);
4862 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4863 unsigned VTByteWidth = VTBitWidth / 8;
4865 "Shiftee type size is not a power of two!");
4866 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4867 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4872 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4874 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4875 EVT PtrTy =
StackPtr.getValueType();
4876 SDValue Ch = DAG.getEntryNode();
4879 DAG.getMachineFunction(),
4885 unsigned WideningOpc =
4887 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4890 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4894 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4900 Flags.setExact(IsOneStepShift);
4903 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4905 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4906 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4909 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4914 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4921 if (DAG.getDataLayout().isBigEndian())
4922 WillIndexUpwards = !WillIndexUpwards;
4925 if (WillIndexUpwards) {
4928 AdjStackPtr = DAG.getMemBasePlusOffset(
4929 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4930 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4934 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4935 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4939 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4944 if (!IsOneStepShift) {
4946 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4947 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4948 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4952 SplitInteger(Res,
Lo,
Hi);
4955void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4957 EVT VT =
N->getValueType(0);
4958 unsigned Opc =
N->getOpcode();
4964 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4968 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4985 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4987 const bool LegalOrCustom =
4991 unsigned ExpansionFactor = 1;
4993 for (EVT TmpVT = NVT;;) {
4994 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
4995 if (NewTMPVT == TmpVT)
5002 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5005 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5007 if (LegalOrCustom &&
5011 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5017 SDValue ShiftOp =
N->getOperand(1);
5018 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5020 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5023 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5024 Hi =
Lo.getValue(1);
5029 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5034 LC = RTLIB::SHL_I16;
5035 else if (VT == MVT::i32)
5036 LC = RTLIB::SHL_I32;
5037 else if (VT == MVT::i64)
5038 LC = RTLIB::SHL_I64;
5039 else if (VT == MVT::i128)
5040 LC = RTLIB::SHL_I128;
5044 LC = RTLIB::SRL_I16;
5045 else if (VT == MVT::i32)
5046 LC = RTLIB::SRL_I32;
5047 else if (VT == MVT::i64)
5048 LC = RTLIB::SRL_I64;
5049 else if (VT == MVT::i128)
5050 LC = RTLIB::SRL_I128;
5055 LC = RTLIB::SRA_I16;
5056 else if (VT == MVT::i32)
5057 LC = RTLIB::SRA_I32;
5058 else if (VT == MVT::i64)
5059 LC = RTLIB::SRA_I64;
5060 else if (VT == MVT::i128)
5061 LC = RTLIB::SRA_I128;
5064 if (LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC)) {
5067 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5069 TargetLowering::MakeLibCallOptions CallOptions;
5071 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5075 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5079void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5081 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5084 if (
Op.getValueType().bitsLE(NVT)) {
5090 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5094 assert(getTypeAction(
Op.getValueType()) ==
5096 "Only know how to promote this result!");
5099 "Operand over promoted?");
5101 SplitInteger(Res,
Lo,
Hi);
5109void DAGTypeLegalizer::
5112 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5115 if (EVT.
bitsLE(
Lo.getValueType())) {
5123 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5124 Hi.getValueType(), dl));
5135void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5137 EVT VT =
N->getValueType(0);
5139 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5147 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5149 LC = RTLIB::SREM_I16;
5150 else if (VT == MVT::i32)
5151 LC = RTLIB::SREM_I32;
5152 else if (VT == MVT::i64)
5153 LC = RTLIB::SREM_I64;
5154 else if (VT == MVT::i128)
5155 LC = RTLIB::SREM_I128;
5156 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5158 TargetLowering::MakeLibCallOptions CallOptions;
5160 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5163void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5165 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5175void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5177 EVT VT =
N->getValueType(0);
5196 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5197 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5198 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5200 EVT BitVT =
N->getValueType(1);
5201 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5203 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5205 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5206 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5225 SplitInteger(Three,
Lo,
Hi);
5229 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5234 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5238 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5240 LC = RTLIB::MULO_I32;
5241 else if (VT == MVT::i64)
5242 LC = RTLIB::MULO_I64;
5243 else if (VT == MVT::i128)
5244 LC = RTLIB::MULO_I128;
5248 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC) ||
5249 TLI.getLibcallName(LC) == DAG.getMachineFunction().getName()) {
5252 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5253 N->getOperand(1), MulLo, MulHi);
5258 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5259 SplitInteger(MulLo,
Lo,
Hi);
5260 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5264 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5267 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5268 MachinePointerInfo());
5272 EVT ArgVT =
Op.getValueType();
5274 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5275 Entry.IsSExt =
true;
5276 Entry.IsZExt =
false;
5277 Args.push_back(Entry);
5281 TargetLowering::ArgListEntry
Entry(
5283 Entry.IsSExt =
true;
5284 Entry.IsZExt =
false;
5285 Args.push_back(Entry);
5287 SDValue Func = DAG.getExternalSymbol(TLI.getLibcallName(LC), PtrVT);
5289 TargetLowering::CallLoweringInfo CLI(DAG);
5292 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Func, std::move(Args))
5295 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5297 SplitInteger(CallInfo.first,
Lo,
Hi);
5299 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5300 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5301 DAG.getConstant(0, dl, PtrVT),
5304 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5307void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5309 EVT VT =
N->getValueType(0);
5311 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5321 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5323 if (isTypeLegal(NVT)) {
5325 GetExpandedInteger(
N->getOperand(0), InL, InH);
5327 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5335 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5337 LC = RTLIB::UDIV_I16;
5338 else if (VT == MVT::i32)
5339 LC = RTLIB::UDIV_I32;
5340 else if (VT == MVT::i64)
5341 LC = RTLIB::UDIV_I64;
5342 else if (VT == MVT::i128)
5343 LC = RTLIB::UDIV_I128;
5344 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5346 TargetLowering::MakeLibCallOptions CallOptions;
5347 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5350void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5352 EVT VT =
N->getValueType(0);
5354 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5364 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5366 if (isTypeLegal(NVT)) {
5368 GetExpandedInteger(
N->getOperand(0), InL, InH);
5370 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5378 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5380 LC = RTLIB::UREM_I16;
5381 else if (VT == MVT::i32)
5382 LC = RTLIB::UREM_I32;
5383 else if (VT == MVT::i64)
5384 LC = RTLIB::UREM_I64;
5385 else if (VT == MVT::i128)
5386 LC = RTLIB::UREM_I128;
5387 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5389 TargetLowering::MakeLibCallOptions CallOptions;
5390 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5393void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5395 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5398 if (
Op.getValueType().bitsLE(NVT)) {
5401 Hi = DAG.getConstant(0, dl, NVT);
5405 assert(getTypeAction(
Op.getValueType()) ==
5407 "Only know how to promote this result!");
5410 "Operand over promoted?");
5412 SplitInteger(Res,
Lo,
Hi);
5414 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5420void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5424 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5426 SDValue Swap = DAG.getAtomicCmpSwap(
5427 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, dl,
5435void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5439 SDValue Res = TLI.expandVecReduce(
N, DAG);
5440 SplitInteger(Res,
Lo,
Hi);
5443void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5449 N->getOperand(0),
N->getOperand(1));
5450 SplitInteger(Res,
Lo,
Hi);
5457 GetExpandedInteger(
N->getOperand(0), In3, In4);
5458 GetExpandedInteger(
N->getOperand(1), In1, In2);
5462 unsigned Opc =
N->getOpcode();
5465 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5470 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5472 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5476 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5477 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5482 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5483 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5488 EVT VT =
N->getValueType(0);
5495 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5498 SplitInteger(Res,
Lo,
Hi);
5505 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5506 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5508 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5509 Lo = DAG.getPOISON(LoVT);
5510 Hi = DAG.getPOISON(HiVT);
5521bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5525 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5528 switch (
N->getOpcode()) {
5531 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5532 N->dump(&DAG);
dbgs() <<
"\n";
5536 case ISD::BITCAST: Res = ExpandOp_BITCAST(
N);
break;
5537 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5541 Res = ExpandOp_FAKE_USE(
N);
5545 case ISD::EXPERIMENTAL_VP_SPLAT:
5548 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5561 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5566 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5568 case ISD::ATOMIC_STORE: Res = ExpandIntOp_ATOMIC_STORE(
N);
break;
5570 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5572 case ISD::PATCHPOINT:
5573 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5575 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5576 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5577 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5580 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5585 if (!Res.
getNode())
return false;
5593 "Invalid operand expansion");
5595 ReplaceValueWith(
SDValue(
N, 0), Res);
5601void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5605 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5606 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5607 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5620 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5627 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5628 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5659 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5660 RHSLo, LowCC,
false, DagCombineInfo, dl);
5662 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5666 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5667 RHSHi, CCCode,
false, DagCombineInfo, dl);
5671 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5680 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5682 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5691 if (LHSHi == RHSHi) {
5700 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5701 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5704 if (HasSETCCCARRY) {
5707 bool FlipOperands =
false;
5724 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5728 DAG.getCondCode(CCCode));
5734 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5735 false, DagCombineInfo, dl);
5738 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5739 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5746 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5751 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5756 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5757 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5758 N->getOperand(4)), 0);
5764 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5769 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5774 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5775 N->getOperand(2),
N->getOperand(3),
5776 DAG.getCondCode(CCCode)), 0);
5782 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5787 "Unexpected setcc expansion!");
5793 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5801 SDLoc dl = SDLoc(
N);
5803 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5804 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5805 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5818 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5828 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5829 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5833 return TLI.expandCMP(
N, DAG);
5841 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5842 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5846 bool IsStrict =
N->isStrictFPOpcode();
5850 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5851 EVT DstVT =
N->getValueType(0);
5854 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5855 "Don't know how to expand this XINT_TO_FP!");
5856 TargetLowering::MakeLibCallOptions CallOptions;
5858 std::pair<SDValue, SDValue> Tmp =
5859 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5864 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5865 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5870 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5873 return ExpandOp_NormalStore(
N, OpNo);
5876 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5878 EVT VT =
N->getOperand(1).getValueType();
5879 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5883 AAMDNodes AAInfo =
N->getAAInfo();
5889 if (
N->getMemoryVT().bitsLE(NVT)) {
5890 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5891 return DAG.getTruncStore(Ch, dl,
Lo,
Ptr,
N->getPointerInfo(),
5892 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5896 if (DAG.getDataLayout().isLittleEndian()) {
5898 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5900 Lo = DAG.getStore(Ch, dl,
Lo,
Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5903 unsigned ExcessBits =
5910 Hi = DAG.getTruncStore(Ch, dl,
Hi,
Ptr,
5911 N->getPointerInfo().getWithOffset(IncrementSize),
5912 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5918 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5920 EVT ExtVT =
N->getMemoryVT();
5923 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5931 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5935 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5939 Hi = DAG.getTruncStore(Ch, dl,
Hi,
Ptr,
N->getPointerInfo(), HiVT,
5940 N->getBaseAlign(), MMOFlags, AAInfo);
5945 Lo = DAG.getTruncStore(Ch, dl,
Lo,
Ptr,
5946 N->getPointerInfo().getWithOffset(IncrementSize),
5948 N->getBaseAlign(), MMOFlags, AAInfo);
5954 GetExpandedInteger(
N->getOperand(0), InL, InH);
5963 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5968SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5969 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5970 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5974 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5976 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5979SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5982 "cannot use llvm.write_register with illegal type", Fn,
5985 return N->getOperand(0);
5988SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5991 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5992 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5998SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6000 unsigned Factor =
N->getNumOperands();
6003 for (
unsigned i = 0; i != Factor; i++)
6004 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6009 for (
unsigned i = 0; i != Factor; i++)
6015SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6017 EVT OutVT =
N->getValueType(0);
6018 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6019 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6023 SDValue BaseIdx =
N->getOperand(1);
6040 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6044 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6050 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6059 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6063 "Promoted operand has an element type greater than result");
6076 InOp0 = GetPromotedInteger(InOp0);
6083 Ops.reserve(OutNumElems);
6084 for (
unsigned i = 0; i != OutNumElems; ++i) {
6089 N->getOperand(0), Index);
6090 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6095 return DAG.getBuildVector(NOutVT, dl,
Ops);
6098SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6099 EVT OutVT =
N->getValueType(0);
6100 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6101 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6113 Vec = GetPromotedInteger(Vec);
6119SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6122 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6128SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6130 EVT VT =
N->getValueType(0);
6135 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6136 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6139 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6143 EVT OutVT =
N->getValueType(0);
6144 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6145 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6146 unsigned NumElems =
N->getNumOperands();
6153 Ops.reserve(NumElems);
6154 for (
unsigned i = 0; i != NumElems; ++i) {
6156 EVT OpVT =
Op.getValueType();
6161 if (OpVT.
bitsLT(NOutVTElem)) {
6167 ExtOpc = NOutExtOpc;
6168 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6173 return DAG.getBuildVector(NOutVT, dl,
Ops);
6180 assert(!
N->getOperand(0).getValueType().isVector() &&
6181 "Input must be a scalar");
6183 EVT OutVT =
N->getValueType(0);
6184 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6185 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6189 if (
N->isVPOpcode())
6190 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op,
N->getOperand(1),
6193 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6198 EVT OutVT =
N->getValueType(0);
6199 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6201 "Type must be promoted to a scalable vector type");
6202 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6203 return DAG.getStepVector(dl, NOutVT,
6207SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6210 EVT OutVT =
N->getValueType(0);
6211 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6212 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6214 unsigned NumOperands =
N->getNumOperands();
6219 SDUse *MaxSizedValue = std::max_element(
6221 EVT AVT = A.getValueType().getVectorElementType();
6222 EVT BVT = B.getValueType().getVectorElementType();
6223 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6229 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6231 EVT OpVT =
Op.getValueType();
6233 Op = GetPromotedInteger(
Op);
6236 "Unhandled legalization type");
6240 Op = DAG.getAnyExtOrTrunc(
Op, dl,
6247 return DAG.getAnyExtOrTrunc(
6253 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6254 assert(NumElem * NumOperands == NumOutElem &&
6255 "Unexpected number of elements");
6259 for (
unsigned i = 0; i < NumOperands; ++i) {
6262 Op = GetPromotedInteger(
Op);
6263 EVT SclrTy =
Op.getValueType().getVectorElementType();
6264 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6265 "Unexpected number of elements");
6267 for (
unsigned j = 0;
j < NumElem; ++
j) {
6269 DAG.getVectorIdxConstant(j, dl));
6270 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6274 return DAG.getBuildVector(NOutVT, dl,
Ops);
6277SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6278 EVT VT =
N->getValueType(0);
6279 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6280 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6288 if (getTypeAction(
N->getOperand(0).getValueType())
6292 switch(
N->getOpcode()) {
6294 Promoted = SExtPromotedInteger(
N->getOperand(0));
6297 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6300 Promoted = GetPromotedInteger(
N->getOperand(0));
6305 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6309 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6312SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6313 EVT VT =
N->getValueType(0);
6314 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6315 return DAG.getNode(ISD::VECTOR_FIND_LAST_ACTIVE, SDLoc(
N), NVT,
N->ops());
6318SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6319 EVT VT =
N->getValueType(0);
6320 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6321 return DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, SDLoc(
N), NVT,
N->ops());
6324SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6326 EVT VT =
N->getValueType(0);
6327 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6328 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6329 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6333SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6334 EVT OutVT =
N->getValueType(0);
6335 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6336 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6341 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6344 NOutVTElem,
N->getOperand(1));
6346 V0, ConvElem,
N->getOperand(2));
6353 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6354 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6362 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6363 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6364 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6368 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6371 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6372 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6380 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6385SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6388 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6390 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6391 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6392 return DAG.getPOISON(NVT);
6395SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6397 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6398 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6399 TLI.getVectorIdxTy(DAG.getDataLayout()));
6406 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6409SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6414 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6419 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6421 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6433 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6434 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6437SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6439 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6447SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6450 EVT ResVT =
N->getValueType(0);
6451 unsigned NumElems =
N->getNumOperands();
6454 SDValue ResVec = DAG.getUNDEF(ResVT);
6458 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6460 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6472 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6473 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6477 for (
unsigned i=0; i<NumElem; ++i) {
6480 DAG.getVectorIdxConstant(i, dl));
6486 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6489SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6502 for (
unsigned I = 0;
I < OpNo;
I++)
6505 EVT Ty =
Op.getValueType();
6506 SDLoc
DL = SDLoc(
N);
6509 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6517 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6522 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6528SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6541 for (
unsigned I = 0;
I < OpNo;
I++)
6544 EVT Ty =
Op.getValueType();
6545 SDLoc
DL = SDLoc(
N);
6548 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6556 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6561 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 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 getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
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)