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());
433 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
435 Op2 = SExtPromotedInteger(Op2);
438 Op2 = ZExtPromotedInteger(Op2);
441 Op2 = GetPromotedInteger(Op2);
446 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
448 N->getChain(),
N->getBasePtr(),
449 Op2,
N->getMemOperand());
459 assert(
N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS);
460 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
461 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
465 if (!TLI.isTypeLegal(SVT))
468 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
469 SDValue Res = DAG.getAtomicCmpSwap(
470 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, SDLoc(
N),
N->getMemoryVT(), VTs,
471 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
475 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
481 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
482 switch (TLI.getExtendForAtomicCmpSwapArg()) {
484 Op2 = SExtPromotedInteger(Op2);
487 Op2 = ZExtPromotedInteger(Op2);
490 Op2 = GetPromotedInteger(Op2);
497 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
498 SDValue Res = DAG.getAtomicCmpSwap(
499 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
500 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
502 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
510 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
511 EVT OutVT =
N->getValueType(0);
512 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
515 switch (getTypeAction(InVT)) {
521 return DAG.getNode(ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
525 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
528 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
532 return DAG.getNode(ISD::FP_TO_FP16, dl, NOutVT, GetPromotedFloat(InOp));
542 BitConvertToInteger(GetScalarizedVector(InOp)));
551 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
552 Lo = BitConvertToInteger(
Lo);
553 Hi = BitConvertToInteger(
Hi);
555 if (DAG.getDataLayout().isBigEndian())
561 JoinIntegers(
Lo,
Hi));
562 return DAG.getNode(ISD::BITCAST, dl, NOutVT, InOp);
572 DAG.
getNode(ISD::BITCAST, dl, NOutVT, GetWidenedVector(InOp));
576 if (DAG.getDataLayout().isBigEndian()) {
580 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
595 if (isTypeLegal(WideOutVT)) {
596 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
598 DAG.getVectorIdxConstant(0, dl));
607 DAG.getDataLayout().isLittleEndian()) {
618 if (isTypeLegal(WideVecVT)) {
620 DAG.getUNDEF(WideVecVT), InOp,
621 DAG.getVectorIdxConstant(0, dl));
623 return DAG.getNode(ISD::BITCAST, dl, NOutVT, Inserted);
629 CreateStackStoreLoad(InOp, OutVT));
633 SDValue V = GetPromotedInteger(
N->getOperand(0));
635 V.getValueType(), V);
639 SDValue Op = GetPromotedInteger(
N->getOperand(0));
640 EVT OVT =
N->getValueType(0);
641 EVT NVT =
Op.getValueType();
649 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
650 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
655 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
661 return DAG.getNode(ISD::VP_SRL, dl, NVT,
662 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
667 SDValue Op = GetPromotedInteger(
N->getOperand(0));
668 EVT OVT =
N->getValueType(0);
669 EVT NVT =
Op.getValueType();
678 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
683 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
689 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
690 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
698 TLI.getTypeToTransformTo(*DAG.getContext(),
699 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
704 EVT VT =
N->getValueType(0);
711 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
718 EVT OVT =
N->getValueType(0);
719 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
725 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
726 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
728 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
734 unsigned CtlzOpcode =
N->getOpcode();
735 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
737 SDValue ExtractLeadingBits = DAG.getConstant(
740 if (!
N->isVPOpcode()) {
742 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
743 return DAG.getNode(
ISD::SUB, dl, NVT,
744 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
750 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
751 return DAG.getNode(ISD::VP_SUB, dl, NVT,
752 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
753 ExtractLeadingBits, Mask, EVL);
756 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
758 SDValue Op = GetPromotedInteger(
N->getOperand(0));
762 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
763 if (!
N->isVPOpcode()) {
765 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
770 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
771 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
777 EVT OVT =
N->getValueType(0);
778 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
786 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
787 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
794 if (!
N->isVPOpcode()) {
795 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
796 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
801 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
802 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
807 SDValue Op = GetPromotedInteger(
N->getOperand(0));
808 EVT OVT =
N->getValueType(0);
809 EVT NVT =
Op.getValueType();
816 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
817 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
821 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
827 unsigned NewOpc =
N->getOpcode();
828 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
835 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
839 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
840 N->getOperand(1),
N->getOperand(2));
841 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
844 if (!
N->isVPOpcode())
845 return DAG.getNode(NewOpc, dl, NVT,
Op);
846 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
849SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
851 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
852 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
855SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
857 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
864 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
870 EVT SVT =
In.getValueType().getScalarType();
873 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
881 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
883 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
887 if (
N->isStrictFPOpcode()) {
888 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
889 {
N->getOperand(0),
N->getOperand(1)});
893 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
894 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
897 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
909 N->getOpcode() == ISD::VP_FP_TO_UINT)
913 DAG.getValueType(
N->getValueType(0).getScalarType()));
916SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
918 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
920 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
924SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
925 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
928 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
931SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
932 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
935 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
936 N->getOperand(0),
N->getOperand(1));
942 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
944 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
948 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
952 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
961 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
964 if (getTypeAction(
N->getOperand(0).getValueType())
966 SDValue Res = GetPromotedInteger(
N->getOperand(0));
975 DAG.getValueType(
N->getOperand(0).getValueType()));
977 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
984 if (
N->getNumOperands() != 1) {
985 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
986 assert(
N->isVPOpcode() &&
"Expected VP opcode");
987 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
988 N->getOperand(1),
N->getOperand(2));
990 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
995 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
999 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1000 N->getMemoryVT(),
N->getMemOperand());
1009 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1010 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1013 :
N->getExtensionType();
1016 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1017 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1018 N->getMemOperand(),
N->isExpandingLoad());
1026 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1027 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1034 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1035 N->getOffset(),
N->getMask(), ExtPassThru,
1036 N->getMemoryVT(),
N->getMemOperand(),
1037 N->getAddressingMode(), ExtType,
1038 N->isExpandingLoad());
1046 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1047 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1049 "Gather result type and the passThru argument type should be the same");
1056 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1057 N->getIndex(),
N->getScale() };
1058 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1059 N->getMemoryVT(), dl,
Ops,
1060 N->getMemOperand(),
N->getIndexType(),
1068SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1069 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1070 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1072 N->getOperand(1), Passthru);
1079 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1080 EVT VT =
N->getValueType(0);
1081 EVT SVT = getSetCCResultType(VT);
1082 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1083 unsigned NumOps =
N->getNumOperands();
1086 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1094 ReplaceValueWith(
SDValue(
N, 0), Res);
1097 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1100template <
class MatchContextClass>
1112 MatchContextClass matcher(DAG, TLI,
N);
1114 unsigned Opcode = matcher.getRootBaseOpcode();
1120 SExtOrZExtPromotedOperands(Op1, Op2);
1126 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1128 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1129 Op1 = SExtPromotedInteger(Op1);
1130 Op2 = SExtPromotedInteger(Op2);
1131 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1134 Op1 = ZExtPromotedInteger(Op1);
1135 Op2 = ZExtPromotedInteger(Op2);
1138 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1140 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1147 Op1 = GetPromotedInteger(Op1);
1148 Op2 = ZExtPromotedInteger(Op2);
1150 Op1 = SExtPromotedInteger(Op1);
1151 Op2 = SExtPromotedInteger(Op2);
1158 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1171 "addition, subtraction or left shift");
1174 unsigned SHLAmount = NewBits - OldBits;
1176 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1181 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1182 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1188 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1189 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1190 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1191 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1192 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1199 SDValue Op1Promoted, Op2Promoted;
1205 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1206 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1208 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1209 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1211 EVT OldType =
N->getOperand(0).getValueType();
1223 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1224 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1225 Op2Promoted,
N->getOperand(2));
1227 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1228 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1230 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1235 unsigned SatW,
bool Signed,
1238 EVT VT = V.getValueType();
1265 EVT VT =
LHS.getValueType();
1283 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1289 "Tried to saturate to more than the original type?");
1298 SDValue Op1Promoted, Op2Promoted;
1304 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1305 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1307 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1308 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1311 unsigned Scale =
N->getConstantOperandVal(2);
1315 if (TLI.isTypeLegal(PromotedType)) {
1317 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1320 N->getValueType(0).getScalarSizeInBits();
1324 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1325 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1326 Op2Promoted,
N->getOperand(2));
1329 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1335 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1336 Op2Promoted, Scale, DAG)) {
1339 N->getValueType(0).getScalarSizeInBits(),
1347 N->getValueType(0).getScalarSizeInBits());
1350SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1352 return PromoteIntRes_Overflow(
N);
1356 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1357 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1358 EVT OVT =
N->getOperand(0).getValueType();
1359 EVT NVT =
LHS.getValueType();
1369 DAG.getValueType(OVT));
1371 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1374 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1380 EVT PromotedResultTy =
1381 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1382 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1383 N->getOperand(0),
N->getOperand(1));
1389 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1390 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1392 unsigned Opcode =
N->getOpcode();
1393 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1394 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1396 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1400 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1401 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1403 LHS.getValueType(),
N->getOperand(0),
1404 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1409 EVT InVT =
N->getOperand(OpNo).getValueType();
1410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1412 EVT SVT = getSetCCResultType(InVT);
1419 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1420 SVT = getSetCCResultType(InVT);
1428 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1429 "Vector compare must return a vector result!");
1433 if (
N->isStrictFPOpcode()) {
1434 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1435 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1436 N->getOperand(2),
N->getOperand(3)};
1437 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1442 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1443 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1446 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1453 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1458 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1459 EVT VT =
N->getValueType(0);
1463 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1465 ReplaceValueWith(
SDValue(
N, 0), Res);
1470 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1472 if (
N->getOpcode() != ISD::VP_SHL) {
1474 RHS = ZExtPromotedInteger(
RHS);
1476 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1482 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1483 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1487SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1488 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1490 Op.getValueType(),
Op,
N->getOperand(1));
1493SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1497 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1498 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1499 if (
N->getNumOperands() == 2)
1500 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");
1503 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1504 N->getOperand(2),
N->getOperand(3));
1508 if (
N->getNumOperands() == 2) {
1510 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1511 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1512 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1514 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1515 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1519 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1520 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1521 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1526 if (
N->getNumOperands() == 2) {
1528 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1529 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1530 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1532 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1533 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1537 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1538 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1539 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1549 SExtOrZExtPromotedOperands(
LHS,
RHS);
1551 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1557 if (
N->getOpcode() != ISD::VP_SRA) {
1559 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1561 RHS = ZExtPromotedInteger(
RHS);
1562 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1568 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1570 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1571 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1577 if (
N->getOpcode() != ISD::VP_SRL) {
1579 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1581 RHS = ZExtPromotedInteger(
RHS);
1582 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1588 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1590 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1591 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1597 SDValue Res = TLI.expandROT(
N,
true , DAG);
1598 ReplaceValueWith(
SDValue(
N, 0), Res);
1603 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1604 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1607 Amt = ZExtPromotedInteger(Amt);
1611 EVT OldVT =
N->getOperand(0).getValueType();
1612 EVT VT =
Lo.getValueType();
1613 unsigned Opcode =
N->getOpcode();
1620 DAG.getConstant(OldBits,
DL, AmtVT));
1628 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1629 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1631 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1641 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1647 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1649 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1653SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1654 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1655 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1660 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1664 EVT OldVT =
N->getOperand(0).getValueType();
1665 EVT VT =
Lo.getValueType();
1666 unsigned Opcode =
N->getOpcode();
1667 bool IsFSHR = Opcode == ISD::VP_FSHR;
1672 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1673 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1681 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1682 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1683 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1684 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1686 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1689 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1694 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1695 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1700 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1702 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1706 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1718 Res = GetPromotedInteger(InOp);
1725 "Dst and Src must have the same number of elements");
1727 "Promoted vector type must be a power of two");
1730 GetSplitVector(InOp, EOp1, EOp2);
1738 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1739 "Expected VP_TRUNCATE opcode");
1740 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1741 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1742 std::tie(EVLLo, EVLHi) =
1743 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1744 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1745 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1752 SDValue WideInOp = GetWidenedVector(InOp);
1757 N->getValueType(0).getScalarType(), NumElem);
1766 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1772 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1773 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1778SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1780 return PromoteIntRes_Overflow(
N);
1784 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1785 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1786 EVT OVT =
N->getOperand(0).getValueType();
1787 EVT NVT =
LHS.getValueType();
1796 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1798 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1801 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1812 return PromoteIntRes_Overflow(
N);
1824 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1825 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1827 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1830 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1841 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1842 return PromoteIntRes_Overflow(
N);
1846 EVT OVT =
N->getValueType(0);
1847 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1853 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1854 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1855 if (
SDValue Res = TLI.expandABS(
N, DAG))
1859 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1863SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1866 return PromoteIntRes_Overflow(
N);
1870 EVT SmallVT =
LHS.getValueType();
1877 LHS = SExtPromotedInteger(
LHS);
1878 RHS = SExtPromotedInteger(
RHS);
1880 LHS = ZExtPromotedInteger(
LHS);
1881 RHS = ZExtPromotedInteger(
RHS);
1883 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1895 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1896 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1897 DAG.getConstant(0,
DL,
Hi.getValueType()),
1902 Mul, DAG.getValueType(SmallVT));
1912 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1917 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1918 N->getValueType(0)));
1922 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1924 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1931 EVT VT =
N->getValueType(0);
1934 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1935 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1939 for (
unsigned i = 0; i < NumRegs; ++i) {
1940 Parts[i] = DAG.getVAArg(RegVT, dl, Chain,
Ptr,
N->getOperand(2),
1941 N->getConstantOperandVal(3));
1946 if (DAG.getDataLayout().isBigEndian())
1947 std::reverse(Parts.begin(), Parts.end());
1950 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1952 for (
unsigned i = 1; i < NumRegs; ++i) {
1957 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1963 ReplaceValueWith(
SDValue(
N, 1), Chain);
1976bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1979 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1984 switch (
N->getOpcode()) {
1987 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1988 N->dump(&DAG);
dbgs() <<
"\n";
1993 case ISD::ATOMIC_STORE:
1996 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(
N);
break;
1997 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1998 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2004 Res = PromoteIntOp_FAKE_USE(
N);
2007 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2011 case ISD::EXPERIMENTAL_VP_SPLAT:
2012 Res = PromoteIntOp_ScalarOp(
N);
2015 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2018 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2020 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2021 case ISD::VP_SINT_TO_FP:
2038 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2040 case ISD::VP_TRUNCATE:
2042 case ISD::BF16_TO_FP:
2043 case ISD::FP16_TO_FP:
2044 case ISD::VP_UINT_TO_FP:
2046 case ISD::STRICT_FP16_TO_FP:
2049 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2057 case ISD::ROTR: Res = PromoteIntOp_Shift(
N);
break;
2060 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2063 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2080 case ISD::VECREDUCE_ADD:
2081 case ISD::VECREDUCE_MUL:
2082 case ISD::VECREDUCE_AND:
2083 case ISD::VECREDUCE_OR:
2084 case ISD::VECREDUCE_XOR:
2085 case ISD::VECREDUCE_SMAX:
2086 case ISD::VECREDUCE_SMIN:
2087 case ISD::VECREDUCE_UMAX:
2088 case ISD::VECREDUCE_UMIN: Res = PromoteIntOp_VECREDUCE(
N);
break;
2089 case ISD::VP_REDUCE_ADD:
2090 case ISD::VP_REDUCE_MUL:
2091 case ISD::VP_REDUCE_AND:
2092 case ISD::VP_REDUCE_OR:
2093 case ISD::VP_REDUCE_XOR:
2094 case ISD::VP_REDUCE_SMAX:
2095 case ISD::VP_REDUCE_SMIN:
2096 case ISD::VP_REDUCE_UMAX:
2097 case ISD::VP_REDUCE_UMIN:
2098 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2101 case ISD::SET_ROUNDING: Res = PromoteIntOp_SET_ROUNDING(
N);
break;
2103 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2105 case ISD::PATCHPOINT:
2106 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2109 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2111 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2112 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2113 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2115 case ISD::EXPERIMENTAL_VP_SPLICE:
2116 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2118 case ISD::EXPERIMENTAL_VECTOR_HISTOGRAM:
2119 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2121 case ISD::VECTOR_FIND_LAST_ACTIVE:
2122 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2124 case ISD::GET_ACTIVE_LANE_MASK:
2125 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2127 case ISD::PARTIAL_REDUCE_UMLA:
2128 case ISD::PARTIAL_REDUCE_SMLA:
2129 case ISD::PARTIAL_REDUCE_SUMLA:
2130 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2135 if (!Res.
getNode())
return false;
2142 const bool IsStrictFp =
N->isStrictFPOpcode();
2144 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2145 "Invalid operand expansion");
2149 ReplaceValueWith(
SDValue(
N, 0), Res);
2163 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2167 unsigned OpLEffectiveBits =
2168 DAG.computeKnownBits(OpL).countMaxActiveBits();
2169 unsigned OpREffectiveBits =
2170 DAG.computeKnownBits(OpR).countMaxActiveBits();
2171 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2172 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2179 LHS = SExtPromotedInteger(
LHS);
2180 RHS = SExtPromotedInteger(
RHS);
2189 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2190 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2191 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2192 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2199 LHS = ZExtPromotedInteger(
LHS);
2200 RHS = ZExtPromotedInteger(
RHS);
2214 LHS = SExtPromotedInteger(
LHS);
2215 RHS = SExtPromotedInteger(
RHS);
2220 "Unknown integer comparison!");
2222 SExtOrZExtPromotedOperands(
LHS,
RHS);
2226 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2231 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2232 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2233 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2237 EVT OutVT =
N->getValueType(0);
2240 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2243 switch (getTypeAction(InVT)) {
2247 DAG.getDataLayout().isLittleEndian()) {
2257 if (isTypeLegal(WideVecVT)) {
2258 SDValue Promoted = GetPromotedInteger(InOp);
2259 SDValue Cast = DAG.getNode(ISD::BITCAST, dl, WideVecVT, Promoted);
2261 DAG.getVectorIdxConstant(0, dl));
2274 return CreateStackStoreLoad(InOp, OutVT);
2277SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2278 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2286 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2287 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2291SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2292 assert(OpNo == 1 &&
"only know how to promote condition");
2295 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2298 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2299 N->getOperand(2)), 0);
2304 EVT OVT =
N->getOperand(0).getValueType();
2305 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2306 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2307 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2312 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2313 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2322 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2323 "Legal vector of one illegal element?");
2328 assert(
N->getOperand(0).getValueSizeInBits() >=
2329 N->getValueType(0).getScalarSizeInBits() &&
2330 "Type of inserted value narrower than vector element type!");
2333 for (
unsigned i = 0; i < NumElts; ++i)
2334 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2336 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2339SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2346 assert(
N->getOperand(1).getValueSizeInBits() >=
2347 N->getValueType(0).getScalarSizeInBits() &&
2348 "Type of inserted value narrower than vector element type!");
2349 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2350 GetPromotedInteger(
N->getOperand(1)),
2355 assert(OpNo == 2 &&
"Different operand and result vector types?");
2358 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2359 TLI.getVectorIdxTy(DAG.getDataLayout()));
2360 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2361 N->getOperand(1), Idx), 0);
2365 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2366 if (
N->getOpcode() == ISD::EXPERIMENTAL_VP_SPLAT)
2368 DAG.UpdateNodeOperands(
N,
Op,
N->getOperand(1),
N->getOperand(2)), 0);
2372 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2375SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2376 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2378 EVT OpTy =
N->getOperand(1).getValueType();
2381 if (
SDValue Res = WidenVSELECTMask(
N))
2382 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2383 Res,
N->getOperand(1),
N->getOperand(2));
2387 Cond = PromoteTargetBoolean(
Cond, OpVT);
2389 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2390 N->getOperand(2)), 0);
2393SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2394 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2402 N->getOperand(3),
N->getOperand(4)), 0);
2405SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2406 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2414 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2416 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2419 N->getOperand(3),
N->getOperand(4)),
2424 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2425 ZExtPromotedInteger(
N->getOperand(1))), 0);
2433 LHS = SExtPromotedInteger(
LHS);
2434 RHS = SExtPromotedInteger(
RHS);
2436 SExtOrZExtPromotedOperands(
LHS,
RHS);
2443 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2444 ZExtPromotedInteger(
N->getOperand(2))), 0);
2448 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2452 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2455SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2457 EVT VT =
N->getValueType(0);
2458 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2460 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2464 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2468 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2473 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2474 return SDValue(DAG.UpdateNodeOperands(
N,
2475 SExtPromotedInteger(
N->getOperand(0)),
2476 N->getOperand(1),
N->getOperand(2)),
2478 return SDValue(DAG.UpdateNodeOperands(
N,
2479 SExtPromotedInteger(
N->getOperand(0))), 0);
2482SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2483 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2484 SExtPromotedInteger(
N->getOperand(1))), 0);
2492 SDValue Val = GetPromotedInteger(
N->getValue());
2495 return DAG.getTruncStore(Ch, dl, Val,
Ptr,
2496 N->getMemoryVT(),
N->getMemOperand());
2502 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2503 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2505 SDValue DataOp = GetPromotedInteger(
N->getValue());
2506 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2507 N->getMask(),
N->getVectorLength(),
2508 N->getMemoryVT(),
N->getMemOperand(),
2509 N->isCompressingStore());
2520 Mask = PromoteTargetBoolean(Mask, DataVT);
2523 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2526 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2527 DataOp = GetPromotedInteger(DataOp);
2529 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2530 N->getOffset(), Mask,
N->getMemoryVT(),
2531 N->getMemOperand(),
N->getAddressingMode(),
2532 true,
N->isCompressingStore());
2537 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2538 EVT DataVT =
N->getValueType(0);
2539 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2541 NewOps[OpNo] =
Mask;
2542 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2558 EVT DataVT =
N->getValueType(0);
2559 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2560 }
else if (OpNo == 4) {
2562 if (
N->isIndexSigned())
2564 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2566 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2568 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2570 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2582 bool TruncateStore =
N->isTruncatingStore();
2587 EVT DataVT =
N->getValue().getValueType();
2588 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2589 }
else if (OpNo == 4) {
2591 if (
N->isIndexSigned())
2593 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2595 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2597 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2598 TruncateStore =
true;
2601 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2602 SDLoc(
N), NewOps,
N->getMemOperand(),
2603 N->getIndexType(), TruncateStore);
2608 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2612 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2617 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2618 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2619 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2620 N->getOperand(1),
N->getOperand(2));
2625 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2626 return SDValue(DAG.UpdateNodeOperands(
N,
2627 ZExtPromotedInteger(
N->getOperand(0)),
2628 N->getOperand(1),
N->getOperand(2)),
2630 return SDValue(DAG.UpdateNodeOperands(
N,
2631 ZExtPromotedInteger(
N->getOperand(0))), 0);
2634SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2635 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2636 ZExtPromotedInteger(
N->getOperand(1))), 0);
2643 EVT VT =
N->getValueType(0);
2648 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2649 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2650 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2651 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2656 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2659SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2661 EVT VT =
N->getValueType(0);
2662 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2664 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2666 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2667 N->getOperand(0).getValueType());
2671 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2673 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2676SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2678 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2679 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2688 unsigned OpOffset = IsStrict ? 1 : 0;
2695 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
2701 if (IsPowI && N->getValueType(0).isVector())
2702 return DAG.UnrollVectorOp(N);
2703 SmallVector<SDValue, 3> NewOps(N->ops());
2704 NewOps[1 + OpOffset] = SExtPromotedInteger(N->getOperand(1 + OpOffset));
2705 return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
2715 assert(DAG.getLibInfo().getIntSize() ==
2716 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2717 "POWI exponent should match with sizeof(int) when doing the libcall.");
2718 TargetLowering::MakeLibCallOptions CallOptions;
2719 CallOptions.setIsSigned(
true);
2720 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2721 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2722 DAG, LC,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2723 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2725 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2730 switch (
N->getOpcode()) {
2733 case ISD::VECREDUCE_ADD:
2734 case ISD::VECREDUCE_MUL:
2735 case ISD::VECREDUCE_AND:
2736 case ISD::VECREDUCE_OR:
2737 case ISD::VECREDUCE_XOR:
2738 case ISD::VP_REDUCE_ADD:
2739 case ISD::VP_REDUCE_MUL:
2740 case ISD::VP_REDUCE_AND:
2741 case ISD::VP_REDUCE_OR:
2742 case ISD::VP_REDUCE_XOR:
2744 case ISD::VECREDUCE_SMAX:
2745 case ISD::VECREDUCE_SMIN:
2746 case ISD::VP_REDUCE_SMAX:
2747 case ISD::VP_REDUCE_SMIN:
2749 case ISD::VECREDUCE_UMAX:
2750 case ISD::VECREDUCE_UMIN:
2751 case ISD::VP_REDUCE_UMAX:
2752 case ISD::VP_REDUCE_UMIN:
2762 return GetPromotedInteger(V);
2764 return SExtPromotedInteger(V);
2766 return ZExtPromotedInteger(V);
2772 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2774 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2775 EVT InVT =
Op.getValueType();
2777 EVT ResVT =
N->getValueType(0);
2778 unsigned Opcode =
N->getOpcode();
2782 if (Opcode == ISD::VECREDUCE_XOR && OrigEltVT == MVT::i1 &&
2783 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_XOR, InVT) &&
2784 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_ADD, InVT))
2785 Opcode = ISD::VECREDUCE_ADD;
2789 else if (Opcode == ISD::VECREDUCE_OR && OrigEltVT == MVT::i1 &&
2790 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_OR, InVT) &&
2791 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMAX, InVT)) {
2792 Opcode = ISD::VECREDUCE_UMAX;
2795 switch (TLI.getBooleanContents(InVT)) {
2798 Op = ZExtPromotedInteger(
N->getOperand(0));
2801 Op = SExtPromotedInteger(
N->getOperand(0));
2808 else if (Opcode == ISD::VECREDUCE_AND && OrigEltVT == MVT::i1 &&
2809 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_AND, InVT) &&
2810 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMIN, InVT)) {
2811 Opcode = ISD::VECREDUCE_UMIN;
2814 switch (TLI.getBooleanContents(InVT)) {
2817 Op = ZExtPromotedInteger(
N->getOperand(0));
2820 Op = SExtPromotedInteger(
N->getOperand(0));
2826 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2830 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2834SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2841 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2842 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2845 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2847 Op = PromoteIntOpVectorReduction(
N,
Op);
2851 EVT VT =
N->getValueType(0);
2852 EVT EltVT =
Op.getValueType().getScalarType();
2855 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2867 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2868 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2871SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2874 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2875 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2878SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2881 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2882 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2887 const Function &Fn = DAG.getMachineFunction().getFunction();
2889 "cannot use llvm.write_register with illegal type", Fn,
2891 return N->getOperand(0);
2894SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2895 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2896 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2899 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2901 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2904SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2908 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2909 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2912 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2914 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2915 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2918SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2920 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2922 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2923 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2926SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2929 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2930 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2933SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2935 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2936 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2937 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2940SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2942 switch (
N->getOpcode()) {
2943 case ISD::PARTIAL_REDUCE_SMLA:
2944 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2945 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2947 case ISD::PARTIAL_REDUCE_UMLA:
2948 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2949 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2951 case ISD::PARTIAL_REDUCE_SUMLA:
2952 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2953 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2958 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2969void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2975 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2978 switch (
N->getOpcode()) {
2981 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2982 N->dump(&DAG);
dbgs() <<
"\n";
2987 case ISD::ARITH_FENCE: SplitRes_ARITH_FENCE(
N,
Lo,
Hi);
break;
2996 case ISD::BITCAST: ExpandRes_BITCAST(
N,
Lo,
Hi);
break;
3000 case ISD::VAARG: ExpandRes_VAARG(
N,
Lo,
Hi);
break;
3031 case ISD::LLRINT: ExpandIntRes_XROUND_XRINT(
N,
Lo,
Hi);
break;
3034 case ISD::READCYCLECOUNTER:
3035 case ISD::READSTEADYCOUNTER: ExpandIntRes_READCOUNTER(
N,
Lo,
Hi);
break;
3044 case ISD::ATOMIC_LOAD: ExpandIntRes_ATOMIC_LOAD(
N,
Lo,
Hi);
break;
3046 case ISD::ATOMIC_LOAD_ADD:
3047 case ISD::ATOMIC_LOAD_SUB:
3048 case ISD::ATOMIC_LOAD_AND:
3049 case ISD::ATOMIC_LOAD_CLR:
3050 case ISD::ATOMIC_LOAD_OR:
3051 case ISD::ATOMIC_LOAD_XOR:
3052 case ISD::ATOMIC_LOAD_NAND:
3053 case ISD::ATOMIC_LOAD_MIN:
3054 case ISD::ATOMIC_LOAD_MAX:
3055 case ISD::ATOMIC_LOAD_UMIN:
3056 case ISD::ATOMIC_LOAD_UMAX:
3057 case ISD::ATOMIC_SWAP:
3058 case ISD::ATOMIC_CMP_SWAP: {
3059 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3060 SplitInteger(Tmp.first,
Lo,
Hi);
3061 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3064 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: {
3066 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3067 SDValue Tmp = DAG.getAtomicCmpSwap(
3068 ISD::ATOMIC_CMP_SWAP, SDLoc(
N), AN->
getMemoryVT(), VTs,
3069 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3078 SplitInteger(Tmp,
Lo,
Hi);
3145 case ISD::VECREDUCE_ADD:
3146 case ISD::VECREDUCE_MUL:
3147 case ISD::VECREDUCE_AND:
3148 case ISD::VECREDUCE_OR:
3149 case ISD::VECREDUCE_XOR:
3150 case ISD::VECREDUCE_SMAX:
3151 case ISD::VECREDUCE_SMIN:
3152 case ISD::VECREDUCE_UMAX:
3153 case ISD::VECREDUCE_UMIN: ExpandIntRes_VECREDUCE(
N,
Lo,
Hi);
break;
3157 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3162 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3166 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3170 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3180std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3181 unsigned Opc =
Node->getOpcode();
3187 EVT RetVT =
Node->getValueType(0);
3188 TargetLowering::MakeLibCallOptions CallOptions;
3190 if (TLI.getLibcallName(LC)) {
3192 Ops.push_back(
Node->getOperand(1));
3195 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3196 "Unexpected atomic op or value type!");
3199 return TLI.makeLibCall(DAG, LC, RetVT,
Ops, CallOptions, SDLoc(Node),
3200 Node->getOperand(0));
3205void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3210 GetExpandedInteger(
N->getOperand(0), InL, InH);
3225 if (Amt.
uge(VTBits)) {
3226 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3227 }
else if (Amt.
ugt(NVTBits)) {
3228 Lo = DAG.getConstant(0,
DL, NVT);
3230 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3231 }
else if (Amt == NVTBits) {
3232 Lo = DAG.getConstant(0,
DL, NVT);
3236 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3240 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3242 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3248 if (Amt.
uge(VTBits)) {
3249 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3250 }
else if (Amt.
ugt(NVTBits)) {
3252 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3253 Hi = DAG.getConstant(0,
DL, NVT);
3254 }
else if (Amt == NVTBits) {
3256 Hi = DAG.getConstant(0,
DL, NVT);
3261 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3263 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3265 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3271 if (Amt.
uge(VTBits)) {
3273 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3274 }
else if (Amt.
ugt(NVTBits)) {
3276 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3278 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3279 }
else if (Amt == NVTBits) {
3282 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3287 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3289 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3291 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3299bool DAGTypeLegalizer::
3301 unsigned Opc =
N->getOpcode();
3304 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3309 "Expanded integer type size not a power of two!");
3313 KnownBits Known = DAG.computeKnownBits(Amt);
3316 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3321 GetExpandedInteger(In, InL, InH);
3328 DAG.getConstant(~HighBitMask, dl, ShTy));
3333 Lo = DAG.getConstant(0, dl, NVT);
3334 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3337 Hi = DAG.getConstant(0, dl, NVT);
3338 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3342 DAG.getConstant(NVTBits - 1, dl, ShTy));
3343 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3355 DAG.getConstant(NVTBits - 1, dl, ShTy));
3371 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3373 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3375 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3376 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3388bool DAGTypeLegalizer::
3391 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3395 "Expanded integer type size not a power of two!");
3400 GetExpandedInteger(
N->getOperand(0), InL, InH);
3402 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3405 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3408 Amt, DAG.getConstant(0, dl, ShTy),
3412 switch (
N->getOpcode()) {
3418 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3419 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3422 LoL = DAG.getConstant(0, dl, NVT);
3425 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3426 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3427 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3433 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3436 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3439 HiL = DAG.getConstant(0, dl, NVT);
3442 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3443 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3444 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3450 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3451 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3455 DAG.getConstant(NVTBits - 1, dl, ShTy));
3458 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3459 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3460 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3485 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3490 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3491 SplitInteger(Res,
Lo,
Hi);
3494void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3503 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3504 unsigned NumHalfBits = NumBits / 2;
3505 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3506 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3507 SDValue LHSL, LHSH, RHSL, RHSH;
3508 GetExpandedInteger(
LHS, LHSL, LHSH);
3509 GetExpandedInteger(
RHS, RHSL, RHSH);
3512 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3514 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3522 SDValue LHSL, LHSH, RHSL, RHSH;
3523 GetExpandedInteger(
LHS, LHSL, LHSH);
3524 GetExpandedInteger(
RHS, RHSL, RHSH);
3526 EVT CCT = getSetCCResultType(NVT);
3529 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3531 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3533 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3535 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3539 const APInt *RHSVal =
nullptr;
3541 RHSVal = &RHSConst->getAPIntValue();
3548 SDValue LHSL, LHSH, RHSL, RHSH;
3549 GetExpandedInteger(
LHS, LHSL, LHSH);
3550 GetExpandedInteger(
RHS, RHSL, RHSH);
3552 EVT CCT = getSetCCResultType(NVT);
3558 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3561 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3565 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3568 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3570 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3577 switch (
N->getOpcode()) {
3604 EVT VT =
N->getValueType(0);
3605 EVT CCT = getSetCCResultType(VT);
3608 SplitInteger(Result,
Lo,
Hi);
3612 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3613 SplitInteger(ExpandedCMP,
Lo,
Hi);
3616void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3620 SDValue LHSL, LHSH, RHSL, RHSH;
3621 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3622 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3625 SDValue LoOps[2] = { LHSL, RHSL };
3626 SDValue HiOps[3] = { LHSH, RHSH };
3628 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3630 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3632 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3636 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3642 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3655 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3657 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3660 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3674 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3676 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3680 EVT OvfVT = getSetCCResultType(NVT);
3681 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3696 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3699 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3703 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3715 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3719 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3722 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3725 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3730 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3732 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3733 DAG.getConstant(0, dl, NVT));
3736 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3745 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3750 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3752 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3753 DAG.getConstant(0, dl, NVT));
3759void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3762 SDValue LHSL, LHSH, RHSL, RHSH;
3764 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3765 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3766 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3767 SDValue LoOps[2] = { LHSL, RHSL };
3768 SDValue HiOps[3] = { LHSH, RHSH };
3782 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3785void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3788 SDValue LHSL, LHSH, RHSL, RHSH;
3790 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3791 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3792 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3794 SDValue HiOps[3] = { LHSH, RHSH };
3796 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3798 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3802 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3805void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3813 unsigned CarryOp, NoCarryOp;
3815 switch(
N->getOpcode()) {
3830 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3831 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3835 SDValue LHSL, LHSH, RHSL, RHSH;
3836 GetExpandedInteger(
LHS, LHSL, LHSH);
3837 GetExpandedInteger(
RHS, RHSL, RHSH);
3838 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3839 SDValue LoOps[2] = { LHSL, RHSL };
3840 SDValue HiOps[3] = { LHSH, RHSH };
3842 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3844 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3851 SplitInteger(Sum,
Lo,
Hi);
3857 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3858 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3862 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3867 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3873 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3879 SDValue LHSL, LHSH, RHSL, RHSH;
3881 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3882 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3883 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3887 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3889 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3893 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3896void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3899 SDValue LHSL, LHSH, RHSL, RHSH;
3901 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3902 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3903 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3908 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3909 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3913 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3916void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3918 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3921 if (
Op.getValueType().bitsLE(NVT)) {
3924 Hi = DAG.getUNDEF(NVT);
3928 assert(getTypeAction(
Op.getValueType()) ==
3930 "Only know how to promote this result!");
3933 "Operand over promoted?");
3935 SplitInteger(Res,
Lo,
Hi);
3939void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3942 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3943 EVT NVT =
Lo.getValueType();
3948 if (NVTBits < EVTBits) {
3951 EVTBits - NVTBits)));
3956 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3960void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3963 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3964 EVT NVT =
Lo.getValueType();
3969 if (NVTBits < EVTBits) {
3972 EVTBits - NVTBits)));
3976 Hi = DAG.getConstant(0, dl, NVT);
3980void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3983 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3988void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3991 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4000 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4001 EVT NVT =
Lo.getValueType();
4004 Hi = DAG.getConstant(0, dl, NVT);
4007void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4009 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4012 const APInt &Cst =
Constant->getAPIntValue();
4013 bool IsTarget =
Constant->isTargetOpcode();
4014 bool IsOpaque =
Constant->isOpaque();
4016 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4017 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4025 GetExpandedInteger(N0,
Lo,
Hi);
4026 EVT NVT =
Lo.getValueType();
4032 Hi = DAG.getConstant(0, dl, NVT);
4042 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4047 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4048 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4057 EVT VT =
N->getValueType(0);
4059 DAG.getConstant(0, dl, VT), N0);
4061 SplitInteger(Neg, NegLo, NegHi);
4063 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4065 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4066 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4069void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4073 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4074 EVT NVT =
Lo.getValueType();
4076 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4079 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4082 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4083 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4086 Hi = DAG.getConstant(0, dl, NVT);
4091 SplitInteger(Result,
Lo,
Hi);
4096 EVT VT =
N->getValueType(0);
4100 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4102 LC = RTLIB::CTPOP_I32;
4103 else if (VT == MVT::i64)
4104 LC = RTLIB::CTPOP_I64;
4105 else if (VT == MVT::i128)
4106 LC = RTLIB::CTPOP_I128;
4107 assert(LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC) &&
4108 "LibCall explicitly requested, but not available");
4109 TargetLowering::MakeLibCallOptions CallOptions;
4112 SDValue Res = TLI.makeLibCall(DAG, LC, IntVT,
Op, CallOptions,
DL).first;
4113 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4118 GetExpandedInteger(
Op,
Lo,
Hi);
4119 EVT NVT =
Lo.getValueType();
4122 Hi = DAG.getConstant(0,
DL, NVT);
4125void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4129 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4130 EVT NVT =
Lo.getValueType();
4132 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4138 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4139 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4142 Hi = DAG.getConstant(0, dl, NVT);
4148 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4155 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4159 ReplaceValueWith(
SDValue(
N, 1), Chain);
4167 Chain =
Op.getValue(1);
4176 EVT VT =
N->getValueType(0);
4180 bool IsStrict =
N->isStrictFPOpcode();
4182 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4184 Op = GetPromotedFloat(
Op);
4188 Op.getValueType() == MVT::bf16) {
4194 EVT OpVT =
Op.getValueType();
4198 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4199 TargetLowering::MakeLibCallOptions CallOptions;
4204 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4205 CallOptions, dl, Chain);
4206 SplitInteger(Tmp.first,
Lo,
Hi);
4209 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4214 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4215 SplitInteger(Res,
Lo,
Hi);
4221 bool IsStrict =
N->isStrictFPOpcode();
4222 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4226 "Input type needs to be promoted!");
4228 EVT VT =
Op.getValueType();
4230 if (VT == MVT::f16) {
4236 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4237 if (
N->getOpcode() == ISD::LROUND ||
4240 LC = RTLIB::LROUND_F32;
4241 else if (VT == MVT::f64)
4242 LC = RTLIB::LROUND_F64;
4243 else if (VT == MVT::f80)
4244 LC = RTLIB::LROUND_F80;
4245 else if (VT == MVT::f128)
4246 LC = RTLIB::LROUND_F128;
4247 else if (VT == MVT::ppcf128)
4248 LC = RTLIB::LROUND_PPCF128;
4249 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4250 }
else if (
N->getOpcode() == ISD::LRINT ||
4253 LC = RTLIB::LRINT_F32;
4254 else if (VT == MVT::f64)
4255 LC = RTLIB::LRINT_F64;
4256 else if (VT == MVT::f80)
4257 LC = RTLIB::LRINT_F80;
4258 else if (VT == MVT::f128)
4259 LC = RTLIB::LRINT_F128;
4260 else if (VT == MVT::ppcf128)
4261 LC = RTLIB::LRINT_PPCF128;
4262 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4263 }
else if (
N->getOpcode() == ISD::LLROUND ||
4266 LC = RTLIB::LLROUND_F32;
4267 else if (VT == MVT::f64)
4268 LC = RTLIB::LLROUND_F64;
4269 else if (VT == MVT::f80)
4270 LC = RTLIB::LLROUND_F80;
4271 else if (VT == MVT::f128)
4272 LC = RTLIB::LLROUND_F128;
4273 else if (VT == MVT::ppcf128)
4274 LC = RTLIB::LLROUND_PPCF128;
4275 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4276 }
else if (
N->getOpcode() == ISD::LLRINT ||
4279 LC = RTLIB::LLRINT_F32;
4280 else if (VT == MVT::f64)
4281 LC = RTLIB::LLRINT_F64;
4282 else if (VT == MVT::f80)
4283 LC = RTLIB::LLRINT_F80;
4284 else if (VT == MVT::f128)
4285 LC = RTLIB::LLRINT_F128;
4286 else if (VT == MVT::ppcf128)
4287 LC = RTLIB::LLRINT_PPCF128;
4288 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4292 EVT RetVT =
N->getValueType(0);
4294 TargetLowering::MakeLibCallOptions CallOptions;
4296 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4297 Op, CallOptions, dl,
4299 SplitInteger(Tmp.first,
Lo,
Hi);
4301 if (
N->isStrictFPOpcode())
4302 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4305void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4307 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4310 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4316 EVT VT =
N->getValueType(0);
4317 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4322 AAMDNodes AAInfo =
N->getAAInfo();
4327 if (
N->getMemoryVT().bitsLE(NVT)) {
4328 EVT MemVT =
N->getMemoryVT();
4330 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
N->getPointerInfo(), MemVT,
4331 N->getBaseAlign(), MMOFlags, AAInfo);
4339 unsigned LoSize =
Lo.getValueSizeInBits();
4341 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4344 Hi = DAG.getConstant(0, dl, NVT);
4348 Hi = DAG.getUNDEF(NVT);
4350 }
else if (DAG.getDataLayout().isLittleEndian()) {
4352 Lo = DAG.getLoad(NVT, dl, Ch,
Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4355 unsigned ExcessBits =
4362 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
4363 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4364 N->getBaseAlign(), MMOFlags, AAInfo);
4373 EVT MemVT =
N->getMemoryVT();
4376 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4379 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch,
Ptr,
N->getPointerInfo(),
4382 N->getBaseAlign(), MMOFlags, AAInfo);
4388 N->getPointerInfo().getWithOffset(IncrementSize),
4390 N->getBaseAlign(), MMOFlags, AAInfo);
4402 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4406 DAG.getShiftAmountConstant(
4413 ReplaceValueWith(
SDValue(
N, 1), Ch);
4416void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4420 GetExpandedInteger(
N->getOperand(0), LL, LH);
4421 GetExpandedInteger(
N->getOperand(1), RL, RH);
4425 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4427 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4428 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4431void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4433 EVT VT =
N->getValueType(0);
4434 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4438 GetExpandedInteger(
N->getOperand(0), LL, LH);
4439 GetExpandedInteger(
N->getOperand(1), RL, RH);
4441 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4447 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4449 LC = RTLIB::MUL_I16;
4450 else if (VT == MVT::i32)
4451 LC = RTLIB::MUL_I32;
4452 else if (VT == MVT::i64)
4453 LC = RTLIB::MUL_I64;
4454 else if (VT == MVT::i128)
4455 LC = RTLIB::MUL_I128;
4457 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) {
4460 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4466 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4467 TargetLowering::MakeLibCallOptions CallOptions;
4469 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
4476 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4477 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4478 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4481 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4486 SplitInteger(Result,
Lo,
Hi);
4492 SplitInteger(Result,
Lo,
Hi);
4498 SplitInteger(Result,
Lo,
Hi);
4509 EVT VT =
N->getValueType(0);
4513 uint64_t Scale =
N->getConstantOperandVal(2);
4525 EVT BoolVT = getSetCCResultType(VT);
4527 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4533 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4534 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4540 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4541 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4546 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4547 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4550 SplitInteger(Result,
Lo,
Hi);
4556 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4558 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4560 GetExpandedInteger(
LHS, LL, LH);
4561 GetExpandedInteger(
RHS, RL, RH);
4565 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4572 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4573 SplitInteger(LoTmp, Result[0], Result[1]);
4574 SplitInteger(HiTmp, Result[2], Result[3]);
4576 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4579 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4580 "the size of the current value type");
4601 uint64_t Part0 = Scale / NVTSize;
4602 if (Scale % NVTSize) {
4603 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4606 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4618 if (Scale == VTSize)
4637 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4638 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4639 EVT BoolNVT = getSetCCResultType(NVT);
4642 if (Scale < NVTSize) {
4645 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4646 DAG.getShiftAmountConstant(Scale, NVT, dl));
4647 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4648 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4649 }
else if (Scale == NVTSize) {
4651 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4652 }
else if (Scale < VTSize) {
4656 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4657 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4660 "(and saturation can't happen with Scale==VTSize).");
4662 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4663 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4667 if (Scale < NVTSize) {
4672 unsigned OverflowBits = VTSize - Scale + 1;
4673 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4674 "Extent of overflow bits must start within HL");
4675 SDValue HLHiMask = DAG.getConstant(
4677 SDValue HLLoMask = DAG.getConstant(
4684 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4690 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4691 }
else if (Scale == NVTSize) {
4697 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4703 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4704 }
else if (Scale < VTSize) {
4707 unsigned OverflowBits = VTSize - Scale + 1;
4708 SDValue HHHiMask = DAG.getConstant(
4710 SDValue HHLoMask = DAG.getConstant(
4712 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4713 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4720 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4721 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4724 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4725 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4732 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4734 N->getConstantOperandVal(2), DAG);
4738 N->getConstantOperandVal(2), TLI, DAG);
4739 SplitInteger(Res,
Lo,
Hi);
4742void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4745 "Node has unexpected Opcode");
4755 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4756 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4760 SDValue LHSL, LHSH, RHSL, RHSH;
4761 GetExpandedInteger(
LHS, LHSL, LHSH);
4762 GetExpandedInteger(
RHS, RHSL, RHSH);
4763 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4766 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4775 SplitInteger(Sum,
Lo,
Hi);
4800 EVT VT =
LHS.getValueType();
4803 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4807 EVT OType =
Node->getValueType(1);
4808 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4812 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4815void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4817 EVT VT =
N->getValueType(0);
4819 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4827 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4829 LC = RTLIB::SDIV_I16;
4830 else if (VT == MVT::i32)
4831 LC = RTLIB::SDIV_I32;
4832 else if (VT == MVT::i64)
4833 LC = RTLIB::SDIV_I64;
4834 else if (VT == MVT::i128)
4835 LC = RTLIB::SDIV_I128;
4836 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4838 TargetLowering::MakeLibCallOptions CallOptions;
4840 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4843void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4846 SDValue Shiftee =
N->getOperand(0);
4853 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4854 }
while (!TLI.isTypeLegal(LoadVT));
4859 "Shifting unit is not a a power of two!");
4861 const bool IsOneStepShift =
4862 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4867 if (!IsOneStepShift)
4868 ShAmt = DAG.getFreeze(ShAmt);
4871 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4872 unsigned VTByteWidth = VTBitWidth / 8;
4874 "Shiftee type size is not a power of two!");
4875 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4876 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4881 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4883 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4884 EVT PtrTy =
StackPtr.getValueType();
4885 SDValue Ch = DAG.getEntryNode();
4888 DAG.getMachineFunction(),
4894 unsigned WideningOpc =
4896 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4899 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4903 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4909 Flags.setExact(IsOneStepShift);
4912 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4914 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4915 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4918 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4923 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4930 if (DAG.getDataLayout().isBigEndian())
4931 WillIndexUpwards = !WillIndexUpwards;
4934 if (WillIndexUpwards) {
4937 AdjStackPtr = DAG.getMemBasePlusOffset(
4938 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4939 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4943 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4944 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4948 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4953 if (!IsOneStepShift) {
4955 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4956 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4957 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4961 SplitInteger(Res,
Lo,
Hi);
4964void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4966 EVT VT =
N->getValueType(0);
4967 unsigned Opc =
N->getOpcode();
4973 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4977 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4994 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4996 const bool LegalOrCustom =
5000 unsigned ExpansionFactor = 1;
5002 for (EVT TmpVT = NVT;;) {
5003 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5004 if (NewTMPVT == TmpVT)
5011 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5014 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5016 if (LegalOrCustom &&
5020 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5026 SDValue ShiftOp =
N->getOperand(1);
5027 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5029 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5032 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5033 Hi =
Lo.getValue(1);
5038 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5043 LC = RTLIB::SHL_I16;
5044 else if (VT == MVT::i32)
5045 LC = RTLIB::SHL_I32;
5046 else if (VT == MVT::i64)
5047 LC = RTLIB::SHL_I64;
5048 else if (VT == MVT::i128)
5049 LC = RTLIB::SHL_I128;
5053 LC = RTLIB::SRL_I16;
5054 else if (VT == MVT::i32)
5055 LC = RTLIB::SRL_I32;
5056 else if (VT == MVT::i64)
5057 LC = RTLIB::SRL_I64;
5058 else if (VT == MVT::i128)
5059 LC = RTLIB::SRL_I128;
5064 LC = RTLIB::SRA_I16;
5065 else if (VT == MVT::i32)
5066 LC = RTLIB::SRA_I32;
5067 else if (VT == MVT::i64)
5068 LC = RTLIB::SRA_I64;
5069 else if (VT == MVT::i128)
5070 LC = RTLIB::SRA_I128;
5073 if (LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC)) {
5076 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5078 TargetLowering::MakeLibCallOptions CallOptions;
5080 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5084 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5088void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5090 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5093 if (
Op.getValueType().bitsLE(NVT)) {
5099 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5103 assert(getTypeAction(
Op.getValueType()) ==
5105 "Only know how to promote this result!");
5108 "Operand over promoted?");
5110 SplitInteger(Res,
Lo,
Hi);
5118void DAGTypeLegalizer::
5121 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5124 if (EVT.
bitsLE(
Lo.getValueType())) {
5132 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5133 Hi.getValueType(), dl));
5144void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5146 EVT VT =
N->getValueType(0);
5148 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5156 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5158 LC = RTLIB::SREM_I16;
5159 else if (VT == MVT::i32)
5160 LC = RTLIB::SREM_I32;
5161 else if (VT == MVT::i64)
5162 LC = RTLIB::SREM_I64;
5163 else if (VT == MVT::i128)
5164 LC = RTLIB::SREM_I128;
5165 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5167 TargetLowering::MakeLibCallOptions CallOptions;
5169 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5172void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5174 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5184void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5186 EVT VT =
N->getValueType(0);
5205 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5206 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5207 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5209 EVT BitVT =
N->getValueType(1);
5210 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5212 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5214 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5215 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5234 SplitInteger(Three,
Lo,
Hi);
5238 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5243 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5247 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5249 LC = RTLIB::MULO_I32;
5250 else if (VT == MVT::i64)
5251 LC = RTLIB::MULO_I64;
5252 else if (VT == MVT::i128)
5253 LC = RTLIB::MULO_I128;
5257 if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC) ||
5258 TLI.getLibcallName(LC) == DAG.getMachineFunction().getName()) {
5261 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5262 N->getOperand(1), MulLo, MulHi);
5267 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5268 SplitInteger(MulLo,
Lo,
Hi);
5269 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5273 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5276 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5277 MachinePointerInfo());
5281 EVT ArgVT =
Op.getValueType();
5283 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5284 Entry.IsSExt =
true;
5285 Entry.IsZExt =
false;
5286 Args.push_back(Entry);
5290 TargetLowering::ArgListEntry
Entry(
5292 Entry.IsSExt =
true;
5293 Entry.IsZExt =
false;
5294 Args.push_back(Entry);
5296 SDValue Func = DAG.getExternalSymbol(TLI.getLibcallName(LC), PtrVT);
5298 TargetLowering::CallLoweringInfo CLI(DAG);
5301 .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Func, std::move(Args))
5304 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5306 SplitInteger(CallInfo.first,
Lo,
Hi);
5308 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5309 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5310 DAG.getConstant(0, dl, PtrVT),
5313 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5316void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5318 EVT VT =
N->getValueType(0);
5320 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5330 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5332 if (isTypeLegal(NVT)) {
5334 GetExpandedInteger(
N->getOperand(0), InL, InH);
5336 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5344 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5346 LC = RTLIB::UDIV_I16;
5347 else if (VT == MVT::i32)
5348 LC = RTLIB::UDIV_I32;
5349 else if (VT == MVT::i64)
5350 LC = RTLIB::UDIV_I64;
5351 else if (VT == MVT::i128)
5352 LC = RTLIB::UDIV_I128;
5353 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5355 TargetLowering::MakeLibCallOptions CallOptions;
5356 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5359void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5361 EVT VT =
N->getValueType(0);
5363 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5373 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5375 if (isTypeLegal(NVT)) {
5377 GetExpandedInteger(
N->getOperand(0), InL, InH);
5379 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5387 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5389 LC = RTLIB::UREM_I16;
5390 else if (VT == MVT::i32)
5391 LC = RTLIB::UREM_I32;
5392 else if (VT == MVT::i64)
5393 LC = RTLIB::UREM_I64;
5394 else if (VT == MVT::i128)
5395 LC = RTLIB::UREM_I128;
5396 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5398 TargetLowering::MakeLibCallOptions CallOptions;
5399 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5402void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5404 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5407 if (
Op.getValueType().bitsLE(NVT)) {
5410 Hi = DAG.getConstant(0, dl, NVT);
5414 assert(getTypeAction(
Op.getValueType()) ==
5416 "Only know how to promote this result!");
5419 "Operand over promoted?");
5421 SplitInteger(Res,
Lo,
Hi);
5423 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5429void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5433 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5435 SDValue Swap = DAG.getAtomicCmpSwap(
5436 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, dl,
5444void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5448 SDValue Res = TLI.expandVecReduce(
N, DAG);
5449 SplitInteger(Res,
Lo,
Hi);
5452void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5458 N->getOperand(0),
N->getOperand(1));
5459 SplitInteger(Res,
Lo,
Hi);
5466 GetExpandedInteger(
N->getOperand(0), In3, In4);
5467 GetExpandedInteger(
N->getOperand(1), In1, In2);
5471 unsigned Opc =
N->getOpcode();
5474 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5479 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5481 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5485 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5486 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5491 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5492 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5497 EVT VT =
N->getValueType(0);
5504 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5507 SplitInteger(Res,
Lo,
Hi);
5514 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5515 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5517 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5518 Lo = DAG.getPOISON(LoVT);
5519 Hi = DAG.getPOISON(HiVT);
5530bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5534 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5537 switch (
N->getOpcode()) {
5540 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5541 N->dump(&DAG);
dbgs() <<
"\n";
5545 case ISD::BITCAST: Res = ExpandOp_BITCAST(
N);
break;
5546 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5550 Res = ExpandOp_FAKE_USE(
N);
5554 case ISD::EXPERIMENTAL_VP_SPLAT:
5557 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5570 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5575 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5577 case ISD::ATOMIC_STORE: Res = ExpandIntOp_ATOMIC_STORE(
N);
break;
5579 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5581 case ISD::PATCHPOINT:
5582 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5584 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5585 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5586 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5589 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5594 if (!Res.
getNode())
return false;
5602 "Invalid operand expansion");
5604 ReplaceValueWith(
SDValue(
N, 0), Res);
5610void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5614 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5615 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5616 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5629 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5636 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5637 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5668 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5669 RHSLo, LowCC,
false, DagCombineInfo, dl);
5671 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5675 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5676 RHSHi, CCCode,
false, DagCombineInfo, dl);
5680 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5689 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5691 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5700 if (LHSHi == RHSHi) {
5709 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5710 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5713 if (HasSETCCCARRY) {
5716 bool FlipOperands =
false;
5733 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5737 DAG.getCondCode(CCCode));
5743 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5744 false, DagCombineInfo, dl);
5747 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5748 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5755 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5760 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5765 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5766 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5767 N->getOperand(4)), 0);
5773 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5778 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5783 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5784 N->getOperand(2),
N->getOperand(3),
5785 DAG.getCondCode(CCCode)), 0);
5791 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5796 "Unexpected setcc expansion!");
5802 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5810 SDLoc dl = SDLoc(
N);
5812 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5813 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5814 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5827 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5837 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5838 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5842 return TLI.expandCMP(
N, DAG);
5850 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5851 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5855 bool IsStrict =
N->isStrictFPOpcode();
5859 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5860 EVT DstVT =
N->getValueType(0);
5863 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5864 "Don't know how to expand this XINT_TO_FP!");
5865 TargetLowering::MakeLibCallOptions CallOptions;
5867 std::pair<SDValue, SDValue> Tmp =
5868 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5873 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5874 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5879 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5882 return ExpandOp_NormalStore(
N, OpNo);
5885 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5887 EVT VT =
N->getOperand(1).getValueType();
5888 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5892 AAMDNodes AAInfo =
N->getAAInfo();
5898 if (
N->getMemoryVT().bitsLE(NVT)) {
5899 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5900 return DAG.getTruncStore(Ch, dl,
Lo,
Ptr,
N->getPointerInfo(),
5901 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5905 if (DAG.getDataLayout().isLittleEndian()) {
5907 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5909 Lo = DAG.getStore(Ch, dl,
Lo,
Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5912 unsigned ExcessBits =
5919 Hi = DAG.getTruncStore(Ch, dl,
Hi,
Ptr,
5920 N->getPointerInfo().getWithOffset(IncrementSize),
5921 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5927 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5929 EVT ExtVT =
N->getMemoryVT();
5932 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5940 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5944 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5948 Hi = DAG.getTruncStore(Ch, dl,
Hi,
Ptr,
N->getPointerInfo(), HiVT,
5949 N->getBaseAlign(), MMOFlags, AAInfo);
5954 Lo = DAG.getTruncStore(Ch, dl,
Lo,
Ptr,
5955 N->getPointerInfo().getWithOffset(IncrementSize),
5957 N->getBaseAlign(), MMOFlags, AAInfo);
5963 GetExpandedInteger(
N->getOperand(0), InL, InH);
5972 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5977SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5978 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5979 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5983 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5985 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5988SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5991 "cannot use llvm.write_register with illegal type", Fn,
5994 return N->getOperand(0);
5997SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6000 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6001 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6007SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6009 unsigned Factor =
N->getNumOperands();
6012 for (
unsigned i = 0; i != Factor; i++)
6013 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6018 for (
unsigned i = 0; i != Factor; i++)
6024SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6026 EVT OutVT =
N->getValueType(0);
6027 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6028 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6032 SDValue BaseIdx =
N->getOperand(1);
6049 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6053 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6059 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6068 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6072 "Promoted operand has an element type greater than result");
6085 InOp0 = GetPromotedInteger(InOp0);
6092 Ops.reserve(OutNumElems);
6093 for (
unsigned i = 0; i != OutNumElems; ++i) {
6098 N->getOperand(0), Index);
6099 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6104 return DAG.getBuildVector(NOutVT, dl,
Ops);
6107SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6108 EVT OutVT =
N->getValueType(0);
6109 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6110 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6122 Vec = GetPromotedInteger(Vec);
6128SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6131 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6137SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6139 EVT VT =
N->getValueType(0);
6144 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6145 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6148 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6152 EVT OutVT =
N->getValueType(0);
6153 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6154 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6155 unsigned NumElems =
N->getNumOperands();
6162 Ops.reserve(NumElems);
6163 for (
unsigned i = 0; i != NumElems; ++i) {
6165 EVT OpVT =
Op.getValueType();
6170 if (OpVT.
bitsLT(NOutVTElem)) {
6176 ExtOpc = NOutExtOpc;
6177 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6182 return DAG.getBuildVector(NOutVT, dl,
Ops);
6189 assert(!
N->getOperand(0).getValueType().isVector() &&
6190 "Input must be a scalar");
6192 EVT OutVT =
N->getValueType(0);
6193 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6194 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6198 if (
N->isVPOpcode())
6199 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op,
N->getOperand(1),
6202 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6207 EVT OutVT =
N->getValueType(0);
6208 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6210 "Type must be promoted to a scalable vector type");
6211 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6212 return DAG.getStepVector(dl, NOutVT,
6216SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6219 EVT OutVT =
N->getValueType(0);
6220 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6221 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6223 unsigned NumOperands =
N->getNumOperands();
6228 SDUse *MaxSizedValue = std::max_element(
6230 EVT AVT = A.getValueType().getVectorElementType();
6231 EVT BVT = B.getValueType().getVectorElementType();
6232 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6238 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6240 EVT OpVT =
Op.getValueType();
6242 Op = GetPromotedInteger(
Op);
6245 "Unhandled legalization type");
6249 Op = DAG.getAnyExtOrTrunc(
Op, dl,
6256 return DAG.getAnyExtOrTrunc(
6262 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6263 assert(NumElem * NumOperands == NumOutElem &&
6264 "Unexpected number of elements");
6268 for (
unsigned i = 0; i < NumOperands; ++i) {
6271 Op = GetPromotedInteger(
Op);
6272 EVT SclrTy =
Op.getValueType().getVectorElementType();
6273 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6274 "Unexpected number of elements");
6276 for (
unsigned j = 0;
j < NumElem; ++
j) {
6278 DAG.getVectorIdxConstant(j, dl));
6279 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6283 return DAG.getBuildVector(NOutVT, dl,
Ops);
6286SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6287 EVT VT =
N->getValueType(0);
6288 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6289 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6297 if (getTypeAction(
N->getOperand(0).getValueType())
6301 switch(
N->getOpcode()) {
6303 Promoted = SExtPromotedInteger(
N->getOperand(0));
6306 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6309 Promoted = GetPromotedInteger(
N->getOperand(0));
6314 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6318 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6321SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6322 EVT VT =
N->getValueType(0);
6323 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6324 return DAG.getNode(ISD::VECTOR_FIND_LAST_ACTIVE, SDLoc(
N), NVT,
N->ops());
6327SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6328 EVT VT =
N->getValueType(0);
6329 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6330 return DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, SDLoc(
N), NVT,
N->ops());
6333SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6335 EVT VT =
N->getValueType(0);
6336 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6337 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6338 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6342SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6343 EVT OutVT =
N->getValueType(0);
6344 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6345 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6350 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6353 NOutVTElem,
N->getOperand(1));
6355 V0, ConvElem,
N->getOperand(2));
6362 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6363 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6371 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6372 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6373 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6377 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6380 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6381 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6389 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6394SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6397 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6399 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6400 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6401 return DAG.getPOISON(NVT);
6404SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6406 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6407 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6408 TLI.getVectorIdxTy(DAG.getDataLayout()));
6415 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6418SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6423 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6428 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6430 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6442 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6443 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6446SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6448 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6456SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6459 EVT ResVT =
N->getValueType(0);
6460 unsigned NumElems =
N->getNumOperands();
6463 SDValue ResVec = DAG.getUNDEF(ResVT);
6467 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6469 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6481 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6482 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6486 for (
unsigned i=0; i<NumElem; ++i) {
6489 DAG.getVectorIdxConstant(i, dl));
6495 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6498SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6511 for (
unsigned I = 0;
I < OpNo;
I++)
6514 EVT Ty =
Op.getValueType();
6515 SDLoc
DL = SDLoc(
N);
6518 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6526 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6531 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6537SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6550 for (
unsigned I = 0;
I < OpNo;
I++)
6553 EVT Ty =
Op.getValueType();
6554 SDLoc
DL = SDLoc(
N);
6557 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6565 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6570 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)