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);
2489 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
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 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2696 if (LCImpl == RTLIB::Unsupported) {
2702 if (IsPowI &&
N->getValueType(0).isVector())
2703 return DAG.UnrollVectorOp(
N);
2705 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2706 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2716 assert(DAG.getLibInfo().getIntSize() ==
2717 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2718 "POWI exponent should match with sizeof(int) when doing the libcall.");
2719 TargetLowering::MakeLibCallOptions CallOptions;
2721 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2722 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2723 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2724 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2726 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2731 switch (
N->getOpcode()) {
2734 case ISD::VECREDUCE_ADD:
2735 case ISD::VECREDUCE_MUL:
2736 case ISD::VECREDUCE_AND:
2737 case ISD::VECREDUCE_OR:
2738 case ISD::VECREDUCE_XOR:
2739 case ISD::VP_REDUCE_ADD:
2740 case ISD::VP_REDUCE_MUL:
2741 case ISD::VP_REDUCE_AND:
2742 case ISD::VP_REDUCE_OR:
2743 case ISD::VP_REDUCE_XOR:
2745 case ISD::VECREDUCE_SMAX:
2746 case ISD::VECREDUCE_SMIN:
2747 case ISD::VP_REDUCE_SMAX:
2748 case ISD::VP_REDUCE_SMIN:
2750 case ISD::VECREDUCE_UMAX:
2751 case ISD::VECREDUCE_UMIN:
2752 case ISD::VP_REDUCE_UMAX:
2753 case ISD::VP_REDUCE_UMIN:
2763 return GetPromotedInteger(V);
2765 return SExtPromotedInteger(V);
2767 return ZExtPromotedInteger(V);
2773 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2775 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2776 EVT InVT =
Op.getValueType();
2778 EVT ResVT =
N->getValueType(0);
2779 unsigned Opcode =
N->getOpcode();
2783 if (Opcode == ISD::VECREDUCE_XOR && OrigEltVT == MVT::i1 &&
2784 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_XOR, InVT) &&
2785 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_ADD, InVT))
2786 Opcode = ISD::VECREDUCE_ADD;
2790 else if (Opcode == ISD::VECREDUCE_OR && OrigEltVT == MVT::i1 &&
2791 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_OR, InVT) &&
2792 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMAX, InVT)) {
2793 Opcode = ISD::VECREDUCE_UMAX;
2796 switch (TLI.getBooleanContents(InVT)) {
2799 Op = ZExtPromotedInteger(
N->getOperand(0));
2802 Op = SExtPromotedInteger(
N->getOperand(0));
2809 else if (Opcode == ISD::VECREDUCE_AND && OrigEltVT == MVT::i1 &&
2810 !TLI.isOperationLegalOrCustom(ISD::VECREDUCE_AND, InVT) &&
2811 TLI.isOperationLegalOrCustom(ISD::VECREDUCE_UMIN, InVT)) {
2812 Opcode = ISD::VECREDUCE_UMIN;
2815 switch (TLI.getBooleanContents(InVT)) {
2818 Op = ZExtPromotedInteger(
N->getOperand(0));
2821 Op = SExtPromotedInteger(
N->getOperand(0));
2827 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2831 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2835SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2842 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2843 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2846 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2848 Op = PromoteIntOpVectorReduction(
N,
Op);
2852 EVT VT =
N->getValueType(0);
2853 EVT EltVT =
Op.getValueType().getScalarType();
2856 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2868 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2869 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2872SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2875 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2876 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2879SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2882 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2883 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2888 const Function &Fn = DAG.getMachineFunction().getFunction();
2890 "cannot use llvm.write_register with illegal type", Fn,
2892 return N->getOperand(0);
2895SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2896 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2897 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2900 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2902 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2905SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2909 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2910 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2913 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2915 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2916 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2919SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2921 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2923 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2924 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2927SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2930 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2931 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2934SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2936 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2937 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2938 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2941SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2943 switch (
N->getOpcode()) {
2944 case ISD::PARTIAL_REDUCE_SMLA:
2945 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2946 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2948 case ISD::PARTIAL_REDUCE_UMLA:
2949 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2950 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2952 case ISD::PARTIAL_REDUCE_SUMLA:
2953 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2954 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2959 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2970void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2976 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2979 switch (
N->getOpcode()) {
2982 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2983 N->dump(&DAG);
dbgs() <<
"\n";
2988 case ISD::ARITH_FENCE: SplitRes_ARITH_FENCE(
N,
Lo,
Hi);
break;
2997 case ISD::BITCAST: ExpandRes_BITCAST(
N,
Lo,
Hi);
break;
3001 case ISD::VAARG: ExpandRes_VAARG(
N,
Lo,
Hi);
break;
3032 case ISD::LLRINT: ExpandIntRes_XROUND_XRINT(
N,
Lo,
Hi);
break;
3035 case ISD::READCYCLECOUNTER:
3036 case ISD::READSTEADYCOUNTER: ExpandIntRes_READCOUNTER(
N,
Lo,
Hi);
break;
3045 case ISD::ATOMIC_LOAD: ExpandIntRes_ATOMIC_LOAD(
N,
Lo,
Hi);
break;
3047 case ISD::ATOMIC_LOAD_ADD:
3048 case ISD::ATOMIC_LOAD_SUB:
3049 case ISD::ATOMIC_LOAD_AND:
3050 case ISD::ATOMIC_LOAD_CLR:
3051 case ISD::ATOMIC_LOAD_OR:
3052 case ISD::ATOMIC_LOAD_XOR:
3053 case ISD::ATOMIC_LOAD_NAND:
3054 case ISD::ATOMIC_LOAD_MIN:
3055 case ISD::ATOMIC_LOAD_MAX:
3056 case ISD::ATOMIC_LOAD_UMIN:
3057 case ISD::ATOMIC_LOAD_UMAX:
3058 case ISD::ATOMIC_SWAP:
3059 case ISD::ATOMIC_CMP_SWAP: {
3060 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3061 SplitInteger(Tmp.first,
Lo,
Hi);
3062 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3065 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: {
3067 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3068 SDValue Tmp = DAG.getAtomicCmpSwap(
3069 ISD::ATOMIC_CMP_SWAP, SDLoc(
N), AN->
getMemoryVT(), VTs,
3070 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3079 SplitInteger(Tmp,
Lo,
Hi);
3146 case ISD::VECREDUCE_ADD:
3147 case ISD::VECREDUCE_MUL:
3148 case ISD::VECREDUCE_AND:
3149 case ISD::VECREDUCE_OR:
3150 case ISD::VECREDUCE_XOR:
3151 case ISD::VECREDUCE_SMAX:
3152 case ISD::VECREDUCE_SMIN:
3153 case ISD::VECREDUCE_UMAX:
3154 case ISD::VECREDUCE_UMIN: ExpandIntRes_VECREDUCE(
N,
Lo,
Hi);
break;
3158 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3163 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3167 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3171 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3181std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3182 unsigned Opc =
Node->getOpcode();
3188 EVT RetVT =
Node->getValueType(0);
3189 TargetLowering::MakeLibCallOptions CallOptions;
3192 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
3193 if (LCImpl != RTLIB::Unsupported) {
3195 Ops.push_back(
Node->getOperand(1));
3198 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3199 "Unexpected atomic op or value type!");
3201 LCImpl = TLI.getLibcallImpl(LC);
3203 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3204 Node->getOperand(0));
3209void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3214 GetExpandedInteger(
N->getOperand(0), InL, InH);
3229 if (Amt.
uge(VTBits)) {
3230 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3231 }
else if (Amt.
ugt(NVTBits)) {
3232 Lo = DAG.getConstant(0,
DL, NVT);
3234 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3235 }
else if (Amt == NVTBits) {
3236 Lo = DAG.getConstant(0,
DL, NVT);
3240 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3244 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3246 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3252 if (Amt.
uge(VTBits)) {
3253 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3254 }
else if (Amt.
ugt(NVTBits)) {
3256 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3257 Hi = DAG.getConstant(0,
DL, NVT);
3258 }
else if (Amt == NVTBits) {
3260 Hi = DAG.getConstant(0,
DL, NVT);
3265 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3267 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3269 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3275 if (Amt.
uge(VTBits)) {
3277 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3278 }
else if (Amt.
ugt(NVTBits)) {
3280 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3282 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3283 }
else if (Amt == NVTBits) {
3286 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3291 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3293 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3295 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3303bool DAGTypeLegalizer::
3305 unsigned Opc =
N->getOpcode();
3308 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3313 "Expanded integer type size not a power of two!");
3317 KnownBits Known = DAG.computeKnownBits(Amt);
3320 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3325 GetExpandedInteger(In, InL, InH);
3332 DAG.getConstant(~HighBitMask, dl, ShTy));
3337 Lo = DAG.getConstant(0, dl, NVT);
3338 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3341 Hi = DAG.getConstant(0, dl, NVT);
3342 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3346 DAG.getConstant(NVTBits - 1, dl, ShTy));
3347 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3359 DAG.getConstant(NVTBits - 1, dl, ShTy));
3375 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3377 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3379 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3380 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3392bool DAGTypeLegalizer::
3395 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3399 "Expanded integer type size not a power of two!");
3404 GetExpandedInteger(
N->getOperand(0), InL, InH);
3406 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3409 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3412 Amt, DAG.getConstant(0, dl, ShTy),
3416 switch (
N->getOpcode()) {
3422 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3423 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3426 LoL = DAG.getConstant(0, dl, NVT);
3429 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3430 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3431 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3437 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3440 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3443 HiL = DAG.getConstant(0, dl, NVT);
3446 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3447 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3448 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3454 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3455 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3459 DAG.getConstant(NVTBits - 1, dl, ShTy));
3462 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3463 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3464 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3489 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3494 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3495 SplitInteger(Res,
Lo,
Hi);
3498void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3507 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3508 unsigned NumHalfBits = NumBits / 2;
3509 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3510 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3511 SDValue LHSL, LHSH, RHSL, RHSH;
3512 GetExpandedInteger(
LHS, LHSL, LHSH);
3513 GetExpandedInteger(
RHS, RHSL, RHSH);
3516 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3518 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3526 SDValue LHSL, LHSH, RHSL, RHSH;
3527 GetExpandedInteger(
LHS, LHSL, LHSH);
3528 GetExpandedInteger(
RHS, RHSL, RHSH);
3530 EVT CCT = getSetCCResultType(NVT);
3533 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3535 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3537 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3539 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3543 const APInt *RHSVal =
nullptr;
3545 RHSVal = &RHSConst->getAPIntValue();
3552 SDValue LHSL, LHSH, RHSL, RHSH;
3553 GetExpandedInteger(
LHS, LHSL, LHSH);
3554 GetExpandedInteger(
RHS, RHSL, RHSH);
3556 EVT CCT = getSetCCResultType(NVT);
3562 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3565 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3569 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3572 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3574 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3581 switch (
N->getOpcode()) {
3608 EVT VT =
N->getValueType(0);
3609 EVT CCT = getSetCCResultType(VT);
3612 SplitInteger(Result,
Lo,
Hi);
3616 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3617 SplitInteger(ExpandedCMP,
Lo,
Hi);
3620void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3624 SDValue LHSL, LHSH, RHSL, RHSH;
3625 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3626 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3629 SDValue LoOps[2] = { LHSL, RHSL };
3630 SDValue HiOps[3] = { LHSH, RHSH };
3632 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3634 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3636 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3640 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3646 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3659 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3661 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3664 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3678 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3680 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3684 EVT OvfVT = getSetCCResultType(NVT);
3685 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3700 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3703 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3707 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3719 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3723 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3726 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3729 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3734 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3736 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3737 DAG.getConstant(0, dl, NVT));
3740 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3749 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3754 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3756 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3757 DAG.getConstant(0, dl, NVT));
3763void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3766 SDValue LHSL, LHSH, RHSL, RHSH;
3768 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3769 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3770 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3771 SDValue LoOps[2] = { LHSL, RHSL };
3772 SDValue HiOps[3] = { LHSH, RHSH };
3786 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3789void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3792 SDValue LHSL, LHSH, RHSL, RHSH;
3794 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3795 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3796 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3798 SDValue HiOps[3] = { LHSH, RHSH };
3800 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3802 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3806 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3809void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3817 unsigned CarryOp, NoCarryOp;
3819 switch(
N->getOpcode()) {
3834 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3835 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3839 SDValue LHSL, LHSH, RHSL, RHSH;
3840 GetExpandedInteger(
LHS, LHSL, LHSH);
3841 GetExpandedInteger(
RHS, RHSL, RHSH);
3842 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3843 SDValue LoOps[2] = { LHSL, RHSL };
3844 SDValue HiOps[3] = { LHSH, RHSH };
3846 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3848 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3855 SplitInteger(Sum,
Lo,
Hi);
3861 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3862 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3866 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3871 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3877 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3883 SDValue LHSL, LHSH, RHSL, RHSH;
3885 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3886 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3887 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3891 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3893 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3897 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3900void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3903 SDValue LHSL, LHSH, RHSL, RHSH;
3905 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3906 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3907 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3912 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3913 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3917 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3920void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3922 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3925 if (
Op.getValueType().bitsLE(NVT)) {
3928 Hi = DAG.getUNDEF(NVT);
3932 assert(getTypeAction(
Op.getValueType()) ==
3934 "Only know how to promote this result!");
3937 "Operand over promoted?");
3939 SplitInteger(Res,
Lo,
Hi);
3943void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3946 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3947 EVT NVT =
Lo.getValueType();
3952 if (NVTBits < EVTBits) {
3955 EVTBits - NVTBits)));
3960 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3964void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3967 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3968 EVT NVT =
Lo.getValueType();
3973 if (NVTBits < EVTBits) {
3976 EVTBits - NVTBits)));
3980 Hi = DAG.getConstant(0, dl, NVT);
3984void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3987 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3992void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3995 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4004 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4005 EVT NVT =
Lo.getValueType();
4008 Hi = DAG.getConstant(0, dl, NVT);
4011void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4013 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4016 const APInt &Cst =
Constant->getAPIntValue();
4017 bool IsTarget =
Constant->isTargetOpcode();
4018 bool IsOpaque =
Constant->isOpaque();
4020 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4021 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4029 GetExpandedInteger(N0,
Lo,
Hi);
4030 EVT NVT =
Lo.getValueType();
4036 Hi = DAG.getConstant(0, dl, NVT);
4046 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4051 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4052 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4061 EVT VT =
N->getValueType(0);
4063 DAG.getConstant(0, dl, VT), N0);
4065 SplitInteger(Neg, NegLo, NegHi);
4067 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4069 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4070 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4073void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4077 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4078 EVT NVT =
Lo.getValueType();
4080 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4083 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4086 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4087 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4090 Hi = DAG.getConstant(0, dl, NVT);
4095 SplitInteger(Result,
Lo,
Hi);
4100 EVT VT =
N->getValueType(0);
4105 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4106 "LibCall explicitly requested, but not available");
4108 if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) {
4109 TargetLowering::MakeLibCallOptions CallOptions;
4113 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4114 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4122 GetExpandedInteger(
Op,
Lo,
Hi);
4123 EVT NVT =
Lo.getValueType();
4126 Hi = DAG.getConstant(0,
DL, NVT);
4129void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4133 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4134 EVT NVT =
Lo.getValueType();
4136 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4142 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4143 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4146 Hi = DAG.getConstant(0, dl, NVT);
4152 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4159 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4163 ReplaceValueWith(
SDValue(
N, 1), Chain);
4171 Chain =
Op.getValue(1);
4180 EVT VT =
N->getValueType(0);
4184 bool IsStrict =
N->isStrictFPOpcode();
4186 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4188 Op = GetPromotedFloat(
Op);
4192 Op.getValueType() == MVT::bf16) {
4198 EVT OpVT =
Op.getValueType();
4202 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4203 TargetLowering::MakeLibCallOptions CallOptions;
4208 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4209 CallOptions, dl, Chain);
4210 SplitInteger(Tmp.first,
Lo,
Hi);
4213 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4218 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4219 SplitInteger(Res,
Lo,
Hi);
4225 bool IsStrict =
N->isStrictFPOpcode();
4226 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4230 "Input type needs to be promoted!");
4232 EVT VT =
Op.getValueType();
4234 if (VT == MVT::f16) {
4240 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4241 if (
N->getOpcode() == ISD::LROUND ||
4244 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4245 }
else if (
N->getOpcode() == ISD::LRINT ||
4248 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4249 }
else if (
N->getOpcode() == ISD::LLROUND ||
4252 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4253 }
else if (
N->getOpcode() == ISD::LLRINT ||
4256 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4260 EVT RetVT =
N->getValueType(0);
4262 TargetLowering::MakeLibCallOptions CallOptions;
4264 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4265 Op, CallOptions, dl,
4267 SplitInteger(Tmp.first,
Lo,
Hi);
4269 if (
N->isStrictFPOpcode())
4270 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4273void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4275 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4278 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4284 EVT VT =
N->getValueType(0);
4285 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4290 AAMDNodes AAInfo =
N->getAAInfo();
4295 if (
N->getMemoryVT().bitsLE(NVT)) {
4296 EVT MemVT =
N->getMemoryVT();
4298 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4299 N->getBaseAlign(), MMOFlags, AAInfo);
4307 unsigned LoSize =
Lo.getValueSizeInBits();
4309 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4312 Hi = DAG.getConstant(0, dl, NVT);
4316 Hi = DAG.getUNDEF(NVT);
4318 }
else if (DAG.getDataLayout().isLittleEndian()) {
4320 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4323 unsigned ExcessBits =
4330 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4331 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4332 N->getBaseAlign(), MMOFlags, AAInfo);
4341 EVT MemVT =
N->getMemoryVT();
4344 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4347 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4350 N->getBaseAlign(), MMOFlags, AAInfo);
4356 N->getPointerInfo().getWithOffset(IncrementSize),
4358 N->getBaseAlign(), MMOFlags, AAInfo);
4370 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4374 DAG.getShiftAmountConstant(
4381 ReplaceValueWith(
SDValue(
N, 1), Ch);
4384void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4388 GetExpandedInteger(
N->getOperand(0), LL, LH);
4389 GetExpandedInteger(
N->getOperand(1), RL, RH);
4393 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4395 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4396 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4399void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4401 EVT VT =
N->getValueType(0);
4402 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4406 GetExpandedInteger(
N->getOperand(0), LL, LH);
4407 GetExpandedInteger(
N->getOperand(1), RL, RH);
4409 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4416 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
4417 if (LCImpl == RTLIB::Unsupported) {
4420 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4426 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4427 TargetLowering::MakeLibCallOptions CallOptions;
4429 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4436 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4437 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4438 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4441 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4446 SplitInteger(Result,
Lo,
Hi);
4452 SplitInteger(Result,
Lo,
Hi);
4458 SplitInteger(Result,
Lo,
Hi);
4469 EVT VT =
N->getValueType(0);
4473 uint64_t Scale =
N->getConstantOperandVal(2);
4485 EVT BoolVT = getSetCCResultType(VT);
4487 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4493 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4494 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4500 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4501 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4506 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4507 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4510 SplitInteger(Result,
Lo,
Hi);
4516 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4518 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4520 GetExpandedInteger(
LHS, LL, LH);
4521 GetExpandedInteger(
RHS, RL, RH);
4525 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4532 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4533 SplitInteger(LoTmp, Result[0], Result[1]);
4534 SplitInteger(HiTmp, Result[2], Result[3]);
4536 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4539 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4540 "the size of the current value type");
4561 uint64_t Part0 = Scale / NVTSize;
4562 if (Scale % NVTSize) {
4563 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4566 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4578 if (Scale == VTSize)
4597 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4598 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4599 EVT BoolNVT = getSetCCResultType(NVT);
4602 if (Scale < NVTSize) {
4605 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4606 DAG.getShiftAmountConstant(Scale, NVT, dl));
4607 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4608 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4609 }
else if (Scale == NVTSize) {
4611 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4612 }
else if (Scale < VTSize) {
4616 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4617 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4620 "(and saturation can't happen with Scale==VTSize).");
4622 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4623 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4627 if (Scale < NVTSize) {
4632 unsigned OverflowBits = VTSize - Scale + 1;
4633 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4634 "Extent of overflow bits must start within HL");
4635 SDValue HLHiMask = DAG.getConstant(
4637 SDValue HLLoMask = DAG.getConstant(
4644 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4650 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4651 }
else if (Scale == NVTSize) {
4657 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4663 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4664 }
else if (Scale < VTSize) {
4667 unsigned OverflowBits = VTSize - Scale + 1;
4668 SDValue HHHiMask = DAG.getConstant(
4670 SDValue HHLoMask = DAG.getConstant(
4672 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4673 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4680 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4681 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4684 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4685 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4692 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4694 N->getConstantOperandVal(2), DAG);
4698 N->getConstantOperandVal(2), TLI, DAG);
4699 SplitInteger(Res,
Lo,
Hi);
4702void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4705 "Node has unexpected Opcode");
4715 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4716 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4720 SDValue LHSL, LHSH, RHSL, RHSH;
4721 GetExpandedInteger(
LHS, LHSL, LHSH);
4722 GetExpandedInteger(
RHS, RHSL, RHSH);
4723 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4726 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4735 SplitInteger(Sum,
Lo,
Hi);
4760 EVT VT =
LHS.getValueType();
4763 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4767 EVT OType =
Node->getValueType(1);
4768 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4772 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4775void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4777 EVT VT =
N->getValueType(0);
4779 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4788 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4790 TargetLowering::MakeLibCallOptions CallOptions;
4792 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4795void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4798 SDValue Shiftee =
N->getOperand(0);
4805 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4806 }
while (!TLI.isTypeLegal(LoadVT));
4811 "Shifting unit is not a a power of two!");
4813 const bool IsOneStepShift =
4814 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4819 if (!IsOneStepShift)
4820 ShAmt = DAG.getFreeze(ShAmt);
4823 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4824 unsigned VTByteWidth = VTBitWidth / 8;
4826 "Shiftee type size is not a power of two!");
4827 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4828 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4833 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4835 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4836 EVT PtrTy =
StackPtr.getValueType();
4837 SDValue Ch = DAG.getEntryNode();
4840 DAG.getMachineFunction(),
4846 unsigned WideningOpc =
4848 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4851 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4855 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4861 Flags.setExact(IsOneStepShift);
4864 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4866 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4867 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4870 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4875 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4882 if (DAG.getDataLayout().isBigEndian())
4883 WillIndexUpwards = !WillIndexUpwards;
4886 if (WillIndexUpwards) {
4889 AdjStackPtr = DAG.getMemBasePlusOffset(
4890 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4891 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4895 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4896 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4900 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4905 if (!IsOneStepShift) {
4907 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4908 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4909 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4913 SplitInteger(Res,
Lo,
Hi);
4916void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4918 EVT VT =
N->getValueType(0);
4919 unsigned Opc =
N->getOpcode();
4925 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4929 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4946 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4948 const bool LegalOrCustom =
4952 unsigned ExpansionFactor = 1;
4954 for (EVT TmpVT = NVT;;) {
4955 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
4956 if (NewTMPVT == TmpVT)
4963 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
4966 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
4968 if (LegalOrCustom &&
4972 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4978 SDValue ShiftOp =
N->getOperand(1);
4979 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
4981 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
4984 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
4985 Hi =
Lo.getValue(1);
4990 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5004 if (RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC)) {
5007 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5009 TargetLowering::MakeLibCallOptions CallOptions;
5012 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5017 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5021void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5023 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5026 if (
Op.getValueType().bitsLE(NVT)) {
5032 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5036 assert(getTypeAction(
Op.getValueType()) ==
5038 "Only know how to promote this result!");
5041 "Operand over promoted?");
5043 SplitInteger(Res,
Lo,
Hi);
5051void DAGTypeLegalizer::
5054 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5057 if (EVT.
bitsLE(
Lo.getValueType())) {
5065 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5066 Hi.getValueType(), dl));
5077void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5079 EVT VT =
N->getValueType(0);
5081 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5090 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5092 TargetLowering::MakeLibCallOptions CallOptions;
5094 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5097void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5099 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5109void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5111 EVT VT =
N->getValueType(0);
5130 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5131 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5132 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5134 EVT BitVT =
N->getValueType(1);
5135 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5137 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5139 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5140 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5159 SplitInteger(Three,
Lo,
Hi);
5163 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5168 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5173 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
5177 if (LCImpl == RTLIB::Unsupported ||
5178 TLI.getLibcallImplName(LCImpl) == DAG.getMachineFunction().getName()) {
5181 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5182 N->getOperand(1), MulLo, MulHi);
5187 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5188 SplitInteger(MulLo,
Lo,
Hi);
5189 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5193 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5196 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5197 MachinePointerInfo());
5201 EVT ArgVT =
Op.getValueType();
5203 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5204 Entry.IsSExt =
true;
5205 Entry.IsZExt =
false;
5206 Args.push_back(Entry);
5210 TargetLowering::ArgListEntry
Entry(
5212 Entry.IsSExt =
true;
5213 Entry.IsZExt =
false;
5214 Args.push_back(Entry);
5216 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5218 TargetLowering::CallLoweringInfo CLI(DAG);
5221 .setLibCallee(TLI.getLibcallImplCallingConv(LCImpl), RetTy, Func,
5225 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5227 SplitInteger(CallInfo.first,
Lo,
Hi);
5229 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5230 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5231 DAG.getConstant(0, dl, PtrVT),
5234 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5237void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5239 EVT VT =
N->getValueType(0);
5241 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5251 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5253 if (isTypeLegal(NVT)) {
5255 GetExpandedInteger(
N->getOperand(0), InL, InH);
5257 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5266 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5268 TargetLowering::MakeLibCallOptions CallOptions;
5269 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5272void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5274 EVT VT =
N->getValueType(0);
5276 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5286 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5288 if (isTypeLegal(NVT)) {
5290 GetExpandedInteger(
N->getOperand(0), InL, InH);
5292 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5301 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5303 TargetLowering::MakeLibCallOptions CallOptions;
5304 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5307void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5309 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5312 if (
Op.getValueType().bitsLE(NVT)) {
5315 Hi = DAG.getConstant(0, dl, NVT);
5319 assert(getTypeAction(
Op.getValueType()) ==
5321 "Only know how to promote this result!");
5324 "Operand over promoted?");
5326 SplitInteger(Res,
Lo,
Hi);
5328 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5334void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5338 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5340 SDValue Swap = DAG.getAtomicCmpSwap(
5341 ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS, dl,
5349void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5353 SDValue Res = TLI.expandVecReduce(
N, DAG);
5354 SplitInteger(Res,
Lo,
Hi);
5357void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5363 N->getOperand(0),
N->getOperand(1));
5364 SplitInteger(Res,
Lo,
Hi);
5371 GetExpandedInteger(
N->getOperand(0), In3, In4);
5372 GetExpandedInteger(
N->getOperand(1), In1, In2);
5376 unsigned Opc =
N->getOpcode();
5379 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5384 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5386 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5390 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5391 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5396 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5397 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5402 EVT VT =
N->getValueType(0);
5409 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5412 SplitInteger(Res,
Lo,
Hi);
5419 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5420 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5422 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5423 Lo = DAG.getPOISON(LoVT);
5424 Hi = DAG.getPOISON(HiVT);
5435bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5439 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5442 switch (
N->getOpcode()) {
5445 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5446 N->dump(&DAG);
dbgs() <<
"\n";
5450 case ISD::BITCAST: Res = ExpandOp_BITCAST(
N);
break;
5451 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5455 Res = ExpandOp_FAKE_USE(
N);
5459 case ISD::EXPERIMENTAL_VP_SPLAT:
5462 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5475 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5480 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5482 case ISD::ATOMIC_STORE: Res = ExpandIntOp_ATOMIC_STORE(
N);
break;
5484 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5486 case ISD::PATCHPOINT:
5487 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5489 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5490 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5491 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5494 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5499 if (!Res.
getNode())
return false;
5507 "Invalid operand expansion");
5509 ReplaceValueWith(
SDValue(
N, 0), Res);
5515void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5519 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5520 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5521 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5534 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5541 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5542 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5573 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5574 RHSLo, LowCC,
false, DagCombineInfo, dl);
5576 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5580 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5581 RHSHi, CCCode,
false, DagCombineInfo, dl);
5585 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5594 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5596 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5605 if (LHSHi == RHSHi) {
5614 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5615 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5618 if (HasSETCCCARRY) {
5621 bool FlipOperands =
false;
5638 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5642 DAG.getCondCode(CCCode));
5648 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5649 false, DagCombineInfo, dl);
5652 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5653 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5660 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5665 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5670 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5671 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5672 N->getOperand(4)), 0);
5678 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5683 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5688 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5689 N->getOperand(2),
N->getOperand(3),
5690 DAG.getCondCode(CCCode)), 0);
5696 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5701 "Unexpected setcc expansion!");
5707 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5715 SDLoc dl = SDLoc(
N);
5717 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5718 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5719 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5732 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5742 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5743 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5747 return TLI.expandCMP(
N, DAG);
5755 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5756 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5760 bool IsStrict =
N->isStrictFPOpcode();
5764 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5765 EVT DstVT =
N->getValueType(0);
5768 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5769 "Don't know how to expand this XINT_TO_FP!");
5770 TargetLowering::MakeLibCallOptions CallOptions;
5772 std::pair<SDValue, SDValue> Tmp =
5773 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5778 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5779 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5784 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5787 return ExpandOp_NormalStore(
N, OpNo);
5790 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5792 EVT VT =
N->getOperand(1).getValueType();
5793 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5797 AAMDNodes AAInfo =
N->getAAInfo();
5803 if (
N->getMemoryVT().bitsLE(NVT)) {
5804 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5805 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5806 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5810 if (DAG.getDataLayout().isLittleEndian()) {
5812 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5814 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5817 unsigned ExcessBits =
5824 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5825 N->getPointerInfo().getWithOffset(IncrementSize),
5826 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5832 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5834 EVT ExtVT =
N->getMemoryVT();
5837 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5845 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5849 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5853 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5854 N->getBaseAlign(), MMOFlags, AAInfo);
5859 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5860 N->getPointerInfo().getWithOffset(IncrementSize),
5862 N->getBaseAlign(), MMOFlags, AAInfo);
5868 GetExpandedInteger(
N->getOperand(0), InL, InH);
5877 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5882SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5883 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5884 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5888 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5890 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5893SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5896 "cannot use llvm.write_register with illegal type", Fn,
5899 return N->getOperand(0);
5902SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5905 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5906 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5912SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
5914 unsigned Factor =
N->getNumOperands();
5917 for (
unsigned i = 0; i != Factor; i++)
5918 Ops[i] = GetPromotedInteger(
N->getOperand(i));
5923 for (
unsigned i = 0; i != Factor; i++)
5929SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
5931 EVT OutVT =
N->getValueType(0);
5932 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
5933 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5937 SDValue BaseIdx =
N->getOperand(1);
5954 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
5958 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
5964 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
5973 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
5977 "Promoted operand has an element type greater than result");
5990 InOp0 = GetPromotedInteger(InOp0);
5997 Ops.reserve(OutNumElems);
5998 for (
unsigned i = 0; i != OutNumElems; ++i) {
6003 N->getOperand(0), Index);
6004 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6009 return DAG.getBuildVector(NOutVT, dl,
Ops);
6012SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6013 EVT OutVT =
N->getValueType(0);
6014 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6015 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6027 Vec = GetPromotedInteger(Vec);
6033SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6036 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6042SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6044 EVT VT =
N->getValueType(0);
6049 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6050 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6053 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6057 EVT OutVT =
N->getValueType(0);
6058 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6059 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6060 unsigned NumElems =
N->getNumOperands();
6067 Ops.reserve(NumElems);
6068 for (
unsigned i = 0; i != NumElems; ++i) {
6070 EVT OpVT =
Op.getValueType();
6075 if (OpVT.
bitsLT(NOutVTElem)) {
6081 ExtOpc = NOutExtOpc;
6082 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6087 return DAG.getBuildVector(NOutVT, dl,
Ops);
6094 assert(!
N->getOperand(0).getValueType().isVector() &&
6095 "Input must be a scalar");
6097 EVT OutVT =
N->getValueType(0);
6098 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6099 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6103 if (
N->isVPOpcode())
6104 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op,
N->getOperand(1),
6107 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6112 EVT OutVT =
N->getValueType(0);
6113 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6115 "Type must be promoted to a scalable vector type");
6116 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6117 return DAG.getStepVector(dl, NOutVT,
6121SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6124 EVT OutVT =
N->getValueType(0);
6125 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6126 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6128 unsigned NumOperands =
N->getNumOperands();
6133 SDUse *MaxSizedValue = std::max_element(
6135 EVT AVT = A.getValueType().getVectorElementType();
6136 EVT BVT = B.getValueType().getVectorElementType();
6137 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6143 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6145 EVT OpVT =
Op.getValueType();
6147 Op = GetPromotedInteger(
Op);
6150 "Unhandled legalization type");
6154 Op = DAG.getAnyExtOrTrunc(
Op, dl,
6161 return DAG.getAnyExtOrTrunc(
6167 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6168 assert(NumElem * NumOperands == NumOutElem &&
6169 "Unexpected number of elements");
6173 for (
unsigned i = 0; i < NumOperands; ++i) {
6176 Op = GetPromotedInteger(
Op);
6177 EVT SclrTy =
Op.getValueType().getVectorElementType();
6178 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6179 "Unexpected number of elements");
6181 for (
unsigned j = 0;
j < NumElem; ++
j) {
6183 DAG.getVectorIdxConstant(j, dl));
6184 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6188 return DAG.getBuildVector(NOutVT, dl,
Ops);
6191SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6192 EVT VT =
N->getValueType(0);
6193 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6194 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6202 if (getTypeAction(
N->getOperand(0).getValueType())
6206 switch(
N->getOpcode()) {
6208 Promoted = SExtPromotedInteger(
N->getOperand(0));
6211 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6214 Promoted = GetPromotedInteger(
N->getOperand(0));
6219 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6223 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6226SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6227 EVT VT =
N->getValueType(0);
6228 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6229 return DAG.getNode(ISD::VECTOR_FIND_LAST_ACTIVE, SDLoc(
N), NVT,
N->ops());
6232SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6233 EVT VT =
N->getValueType(0);
6234 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6235 return DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, SDLoc(
N), NVT,
N->ops());
6238SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6240 EVT VT =
N->getValueType(0);
6241 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6242 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6243 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6247SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6248 EVT OutVT =
N->getValueType(0);
6249 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6250 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6255 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6258 NOutVTElem,
N->getOperand(1));
6260 V0, ConvElem,
N->getOperand(2));
6267 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6268 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6276 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6277 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6278 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6282 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6285 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6286 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6294 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6299SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6302 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6304 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6305 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6306 return DAG.getPOISON(NVT);
6309SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6311 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6312 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6313 TLI.getVectorIdxTy(DAG.getDataLayout()));
6320 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6323SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6328 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6333 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6335 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6347 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6348 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6351SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6353 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6361SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6364 EVT ResVT =
N->getValueType(0);
6365 unsigned NumElems =
N->getNumOperands();
6368 SDValue ResVec = DAG.getUNDEF(ResVT);
6372 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6374 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6386 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6387 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6391 for (
unsigned i=0; i<NumElem; ++i) {
6394 DAG.getVectorIdxConstant(i, dl));
6400 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6403SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6416 for (
unsigned I = 0;
I < OpNo;
I++)
6419 EVT Ty =
Op.getValueType();
6420 SDLoc
DL = SDLoc(
N);
6423 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6431 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6436 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6442SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6455 for (
unsigned I = 0;
I < OpNo;
I++)
6458 EVT Ty =
Op.getValueType();
6459 SDLoc
DL = SDLoc(
N);
6462 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6470 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6475 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool isSigned(unsigned int Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getValueType() const
Convenience function for get().getValueType().
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
ArrayRef< int > getMask() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ LOOP_DEPENDENCE_RAW_MASK
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ SMULO
Same for multiplication.
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
Set rounding mode.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLRINT(EVT RetVT)
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getLLRINT(EVT RetVT)
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeVectorElementType(EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)