32#define DEBUG_TYPE "legalize-types"
42void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
47 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
52 switch (
N->getOpcode()) {
55 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
56 N->dump(&DAG);
dbgs() <<
"\n";
64 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
68 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
69 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
71 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
73 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
76 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
77 case ISD::VP_CTTZ_ELTS:
78 Res = PromoteIntRes_VP_CttzElements(
N);
81 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
91 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
96 Res = PromoteIntRes_Select(
N);
101 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
103 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
105 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
107 case ISD::SHL: Res = PromoteIntRes_SHL(
N);
break;
109 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
110 case ISD::SRA: Res = PromoteIntRes_SRA(
N);
break;
111 case ISD::SRL: Res = PromoteIntRes_SRL(
N);
break;
114 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
115 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
119 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
121 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
123 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
125 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
128 Res = PromoteIntRes_VECTOR_SPLICE(
N);
131 Res = PromoteIntRes_VECTOR_REPEAT(
N);
135 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
138 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
140 Res = PromoteIntRes_BUILD_VECTOR(
N);
144 Res = PromoteIntRes_ScalarOp(
N);
148 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
153 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
156 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
160 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
163 Res = PromoteIntRes_VECTOR_MATCH(
N);
169 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
183 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
187 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
190 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
194 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
203 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
211 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
219 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
223 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
227 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
231 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
233 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
235 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
251 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
256 Res = PromoteIntRes_CMP(
N);
271 Res = PromoteIntRes_ABS(
N);
305 Res = PromoteIntRes_VECREDUCE(
N);
308 case ISD::VP_REDUCE_ADD:
309 case ISD::VP_REDUCE_MUL:
310 case ISD::VP_REDUCE_AND:
311 case ISD::VP_REDUCE_OR:
312 case ISD::VP_REDUCE_XOR:
313 case ISD::VP_REDUCE_SMAX:
314 case ISD::VP_REDUCE_SMIN:
315 case ISD::VP_REDUCE_UMAX:
316 case ISD::VP_REDUCE_UMIN:
317 Res = PromoteIntRes_VP_REDUCE(
N);
322 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
326 Res = PromoteIntRes_FREEZE(
N);
331 Res = PromoteIntRes_Rotate(
N);
336 Res = PromoteIntRes_FunnelShift(
N);
342 Res = PromoteIntRes_CLMUL(
N);
346 Res = PromoteIntRes_PEXT(
N);
350 Res = PromoteIntRes_PDEP(
N);
355 Res = PromoteIntRes_MULH(
N);
359 Res = PromoteIntRes_IS_FPCLASS(
N);
362 Res = PromoteIntRes_FFREXP(
N);
367 Res = PromoteIntRes_XRINT(
N);
371 Res = PromoteIntRes_PATCHPOINT(
N);
374 Res = PromoteIntRes_READ_REGISTER(
N);
380 SetPromotedInteger(
SDValue(
N, ResNo), Res);
385 SDValue
Op = DisintegrateMERGE_VALUES(
N, ResNo);
386 return GetPromotedInteger(
Op);
389SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
391 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
392 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
397 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
399 Op.getValueType(),
Op,
N->getOperand(1));
404 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
406 Op.getValueType(),
Op,
N->getOperand(1));
410 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
413 switch (TLI.getExtendForAtomicOps()) {
429 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
430 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
434 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
440 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
442 Op2 = SExtPromotedInteger(Op2);
445 Op2 = ZExtPromotedInteger(Op2);
448 Op2 = GetPromotedInteger(Op2);
453 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
455 N->getChain(),
N->getBasePtr(),
456 Op2,
N->getMemOperand());
459 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
467 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
468 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
472 if (!TLI.isTypeLegal(SVT))
475 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
476 SDValue Res = DAG.getAtomicCmpSwap(
478 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
480 ReplaceValueWith(SDValue(
N, 0), Res.
getValue(0));
481 ReplaceValueWith(SDValue(
N, 2), Res.
getValue(2));
482 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
488 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
489 switch (TLI.getExtendForAtomicCmpSwapArg()) {
491 Op2 = SExtPromotedInteger(Op2);
494 Op2 = ZExtPromotedInteger(Op2);
497 Op2 = GetPromotedInteger(Op2);
504 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
505 SDValue Res = DAG.getAtomicCmpSwap(
506 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
507 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
509 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
510 ReplaceValueWith(SDValue(
N, i), Res.
getValue(i));
517 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
518 EVT OutVT =
N->getValueType(0);
519 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
522 switch (getTypeAction(InVT)) {
528 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
532 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
535 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
543 BitConvertToInteger(GetScalarizedVector(InOp)));
552 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
553 Lo = BitConvertToInteger(
Lo);
554 Hi = BitConvertToInteger(
Hi);
556 if (DAG.getDataLayout().isBigEndian())
562 JoinIntegers(
Lo,
Hi));
577 if (DAG.getDataLayout().isBigEndian()) {
581 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
596 if (isTypeLegal(WideOutVT)) {
597 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
599 DAG.getVectorIdxConstant(0, dl));
608 DAG.getDataLayout().isLittleEndian()) {
619 if (isTypeLegal(WideVecVT)) {
621 DAG.getUNDEF(WideVecVT), InOp,
622 DAG.getVectorIdxConstant(0, dl));
630 CreateStackStoreLoad(InOp, OutVT));
634 SDValue
V = GetPromotedInteger(
N->getOperand(0));
636 V.getValueType(), V);
640 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
641 EVT OVT =
N->getValueType(0);
642 EVT NVT =
Op.getValueType();
650 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
651 if (SDValue Res = TLI.expandBSWAP(
N, DAG))
656 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
662 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
663 EVT OVT =
N->getValueType(0);
664 EVT NVT =
Op.getValueType();
673 if (SDValue Res = TLI.expandBITREVERSE(
N, DAG))
678 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
687 TLI.getTypeToTransformTo(*DAG.getContext(),
688 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
693 EVT VT =
N->getValueType(0);
700 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
707 EVT OVT =
N->getValueType(0);
708 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
714 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
715 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
717 if (SDValue Result = TLI.expandCTLZ(
N, DAG)) {
723 unsigned CtlzOpcode =
N->getOpcode();
726 SDValue ExtractLeadingBits = DAG.getConstant(
729 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
733 return DAG.getNode(
ISD::SUB, dl, NVT,
734 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
739 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
743 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
745 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
751 EVT OVT =
N->getValueType(0);
752 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
755 SDValue ExtractLeadingBits = DAG.getConstant(
758 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
764 EVT OVT =
N->getValueType(0);
765 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
773 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
774 if (SDValue Result = TLI.expandCTPOP(
N, DAG)) {
781 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
782 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
786 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
787 EVT OVT =
N->getValueType(0);
788 EVT NVT =
Op.getValueType();
795 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
796 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
800 if (SDValue Result = TLI.expandCTTZ(
N, DAG)) {
806 unsigned NewOpc =
N->getOpcode();
813 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
816 return DAG.getNode(NewOpc, dl, NVT,
Op);
819SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
821 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
822 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
825SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
827 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
829 SDValue Op0 =
N->getOperand(0);
830 SDValue Op1 =
N->getOperand(1);
834 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
836 SDValue
In = GetPromotedInteger(Op0);
840 EVT SVT =
In.getValueType().getScalarType();
843 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
851 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
853 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
857 if (
N->isStrictFPOpcode()) {
858 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
859 {
N->getOperand(0),
N->getOperand(1)});
862 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
864 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
879 DAG.getValueType(
N->getValueType(0).getScalarType()));
882SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
884 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
886 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
890SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
891 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
894 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
899SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
900 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
904 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
907SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
908 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
911 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
912 N->getOperand(0),
N->getOperand(1));
913 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
918 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
920 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
924 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
928 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
932 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
937 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
940 if (getTypeAction(
N->getOperand(0).getValueType())
942 SDValue Res = GetPromotedInteger(
N->getOperand(0));
951 DAG.getValueType(
N->getOperand(0).getValueType()));
953 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
960 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
965 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
969 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
970 N->getMemoryVT(),
N->getMemOperand());
974 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
979 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
980 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
983 :
N->getExtensionType();
986 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
987 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
988 N->getMemOperand(),
N->isExpandingLoad());
991 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
996 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
997 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1004 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1005 N->getOffset(),
N->getMask(), ExtPassThru,
1006 N->getMemoryVT(),
N->getMemOperand(),
1007 N->getAddressingMode(), ExtType,
1008 N->isExpandingLoad());
1011 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1016 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1017 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1019 "Gather result type and the passThru argument type should be the same");
1026 SDValue
Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1027 N->getIndex(),
N->getScale() };
1028 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1029 N->getMemoryVT(), dl,
Ops,
1030 N->getMemOperand(),
N->getIndexType(),
1034 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1038SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1039 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1040 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1042 N->getOperand(1), Passthru);
1049 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1050 EVT VT =
N->getValueType(0);
1051 EVT SVT = getSetCCResultType(VT);
1052 SDValue
Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1053 unsigned NumOps =
N->getNumOperands();
1056 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1059 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, SVT),
1064 ReplaceValueWith(SDValue(
N, 0), Res);
1067 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1082 unsigned Opcode =
N->getOpcode();
1088 SExtOrZExtPromotedOperands(Op1, Op2);
1094 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1096 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1097 Op1 = SExtPromotedInteger(Op1);
1098 Op2 = SExtPromotedInteger(Op2);
1102 Op1 = ZExtPromotedInteger(Op1);
1103 Op2 = ZExtPromotedInteger(Op2);
1106 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1107 SDValue
Add = DAG.getNode(
ISD::ADD, dl, NVT, Op1, Op2);
1115 Op1 = GetPromotedInteger(Op1);
1117 Op2 = ZExtPromotedInteger(Op2);
1119 Op1 = SExtPromotedInteger(Op1);
1120 Op2 = SExtPromotedInteger(Op2);
1127 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1140 "addition, subtraction or left shift");
1143 unsigned SHLAmount = NewBits - OldBits;
1144 SDValue ShiftAmount =
1145 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1150 SDValue
Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1151 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1157 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1158 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1159 SDValue
Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1168 SDValue Op1Promoted, Op2Promoted;
1174 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1175 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1177 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1178 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1180 EVT OldType =
N->getOperand(0).getValueType();
1192 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1193 SDValue
Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1194 Op2Promoted,
N->getOperand(2));
1196 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1197 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1199 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1204 unsigned SatW,
bool Signed,
1207 EVT VT = V.getValueType();
1234 EVT VT =
LHS.getValueType();
1250 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1256 "Tried to saturate to more than the original type?");
1265 SDValue Op1Promoted, Op2Promoted;
1271 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1272 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1274 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1275 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1278 unsigned Scale =
N->getConstantOperandVal(2);
1282 if (TLI.isTypeLegal(PromotedType)) {
1284 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1287 N->getValueType(0).getScalarSizeInBits();
1291 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1292 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1293 Op2Promoted,
N->getOperand(2));
1296 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1302 if (SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1303 Op2Promoted, Scale, DAG)) {
1306 N->getValueType(0).getScalarSizeInBits(),
1314 N->getValueType(0).getScalarSizeInBits());
1317SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1319 return PromoteIntRes_Overflow(
N);
1323 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1324 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1325 EVT OVT =
N->getOperand(0).getValueType();
1326 EVT NVT =
LHS.getValueType();
1336 DAG.getValueType(OVT));
1338 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1341 ReplaceValueWith(SDValue(
N, 1), Ofl);
1347 EVT PromotedResultTy =
1348 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1349 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1350 N->getOperand(0),
N->getOperand(1));
1354 SDValue
Mask =
N->getOperand(0);
1356 SDValue
LHS = GetPromotedInteger(
N->getOperand(1));
1357 SDValue
RHS = GetPromotedInteger(
N->getOperand(2));
1359 unsigned Opcode =
N->getOpcode();
1360 if (Opcode == ISD::VP_MERGE)
1361 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1363 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1367 SDValue
LHS = GetPromotedInteger(
N->getOperand(2));
1368 SDValue
RHS = GetPromotedInteger(
N->getOperand(3));
1370 LHS.getValueType(),
N->getOperand(0),
1371 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1376 EVT InVT =
N->getOperand(OpNo).getValueType();
1377 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1379 EVT SVT = getSetCCResultType(InVT);
1386 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1387 SVT = getSetCCResultType(InVT);
1395 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1396 "Vector compare must return a vector result!");
1400 if (
N->isStrictFPOpcode()) {
1401 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1402 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1403 N->getOperand(2),
N->getOperand(3)};
1404 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1407 ReplaceValueWith(SDValue(
N, 1), SetCC.
getValue(1));
1409 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1410 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1413 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1418 SDValue Arg =
N->getOperand(0);
1419 SDValue
Test =
N->getOperand(1);
1420 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1425 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1426 EVT VT =
N->getValueType(0);
1430 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1432 ReplaceValueWith(SDValue(
N, 0), Res);
1437 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1438 SDValue
RHS =
N->getOperand(1);
1440 RHS = ZExtPromotedInteger(
RHS);
1441 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1444SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1445 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
1447 Op.getValueType(),
Op,
N->getOperand(1));
1450SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1454 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1455 SDValue
RHS = GetPromotedInteger(
N->getOperand(1));
1456 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1461 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1462 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1463 if (
N->getNumOperands() == 2)
1464 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1465 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1466 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1467 "Expected VP opcode");
1468 SDValue
Mask =
N->getOperand(2);
1469 SDValue EVL =
N->getOperand(3);
1470 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1476 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1477 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1478 if (
N->getNumOperands() == 2)
1479 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1480 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1481 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1482 "Expected VP opcode");
1484 SDValue
Mask =
N->getOperand(2);
1490SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1491 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1492 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1493 SDValue
Mask =
N->getOperand(2);
1494 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1498SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1499 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1500 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1501 SDValue
Mask =
N->getOperand(2);
1502 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1507 SDValue
LHS =
N->getOperand(0);
1508 SDValue
RHS =
N->getOperand(1);
1512 SExtOrZExtPromotedOperands(
LHS,
RHS);
1514 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1520 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1521 SDValue
RHS =
N->getOperand(1);
1523 RHS = ZExtPromotedInteger(
RHS);
1524 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1528 SDValue
RHS =
N->getOperand(1);
1530 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1532 RHS = ZExtPromotedInteger(
RHS);
1533 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1538 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1539 SDValue Amt =
N->getOperand(1);
1540 unsigned Opcode =
N->getOpcode();
1551 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1554 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1556 Amt = ZExtPromotedInteger(Amt);
1562 DAG.getConstant(OldBits,
DL, AmtVT));
1563 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1564 SDValue
Hi = DAG.getNode(
ISD::SHL,
DL, VT, Op0, HiShift);
1565 SDValue
Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1577 SDValue Res = TLI.expandROT(
N,
true , DAG);
1578 ReplaceValueWith(SDValue(
N, 0), Res);
1583 SDValue
Hi = GetPromotedInteger(
N->getOperand(0));
1584 SDValue
Lo = GetPromotedInteger(
N->getOperand(1));
1587 Amt = ZExtPromotedInteger(Amt);
1591 EVT OldVT =
N->getOperand(0).getValueType();
1592 EVT VT =
Lo.getValueType();
1593 unsigned Opcode =
N->getOpcode();
1600 DAG.getConstant(OldBits,
DL, AmtVT));
1608 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1609 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1611 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1621 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1627 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1629 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1633 unsigned Opcode =
N->getOpcode();
1636 EVT OldVT =
N->getOperand(0).getValueType();
1637 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1642 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1644 TLI.isOperationLegalOrCustom(
1645 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1646 if (SDValue Res = TLI.expandCLMUL(
N, DAG))
1649 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1650 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1654 SDValue
X = ZExtPromotedInteger(
N->getOperand(0));
1655 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1659 if (NewBits < 2 * OldBits) {
1661 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1663 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1665 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1667 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1672 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1674 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1679 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1680 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1681 if (SDValue Res = TLI.expandPEXT(
N, DAG))
1686 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1687 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1693 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1694 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1695 if (SDValue Res = TLI.expandPDEP(
N, DAG))
1700 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1701 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1707 EVT VT =
N->getValueType(0);
1708 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1715 LHS = SExtPromotedInteger(
N->getOperand(0));
1716 RHS = SExtPromotedInteger(
N->getOperand(1));
1718 LHS = ZExtPromotedInteger(
N->getOperand(0));
1719 RHS = ZExtPromotedInteger(
N->getOperand(1));
1726 DAG.getShiftAmountConstant(BW, NVT, dl));
1730 DAG.getShiftAmountConstant(NBW - BW, NVT, dl));
1731 return DAG.getNode(
N->getOpcode(), dl, NVT,
LHS,
RHS);
1735 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1747 Res = GetPromotedInteger(InOp);
1754 "Dst and Src must have the same number of elements");
1756 "Promoted vector type must be a power of two");
1759 GetSplitVector(InOp, EOp1, EOp2);
1768 SDValue WideInOp = GetWidenedVector(InOp);
1773 N->getValueType(0).getScalarType(), NumElem);
1774 SDValue WideTrunc = DAG.getNode(
ISD::TRUNCATE, dl, TruncVT, WideInOp);
1782 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1791SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1793 return PromoteIntRes_Overflow(
N);
1797 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1798 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1799 EVT OVT =
N->getOperand(0).getValueType();
1800 EVT NVT =
LHS.getValueType();
1809 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1811 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1814 ReplaceValueWith(SDValue(
N, 1), Ofl);
1825 return PromoteIntRes_Overflow(
N);
1837 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1838 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1840 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1843 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1847 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1849 return SDValue(Res.
getNode(), 0);
1854 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1855 return PromoteIntRes_Overflow(
N);
1859 EVT OVT =
N->getValueType(0);
1860 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1866 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1868 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1869 if (SDValue Res = TLI.expandABS(
N, DAG))
1873 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1877SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1880 return PromoteIntRes_Overflow(
N);
1882 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
1884 EVT SmallVT =
LHS.getValueType();
1891 LHS = SExtPromotedInteger(
LHS);
1892 RHS = SExtPromotedInteger(
RHS);
1894 LHS = ZExtPromotedInteger(
LHS);
1895 RHS = ZExtPromotedInteger(
RHS);
1897 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1898 SDValue
Mul = DAG.getNode(
N->getOpcode(),
DL, VTs,
LHS,
RHS);
1909 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1910 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1911 DAG.getConstant(0,
DL,
Hi.getValueType()),
1916 Mul, DAG.getValueType(SmallVT));
1923 SDValue(
Mul.getNode(), 1));
1926 ReplaceValueWith(SDValue(
N, 1), Overflow);
1931 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1932 N->getValueType(0)));
1936 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1938 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1945 EVT VT =
N->getValueType(0);
1948 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1949 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1953 for (
unsigned i = 0; i < NumRegs; ++i) {
1954 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1955 N->getConstantOperandVal(3));
1960 if (DAG.getDataLayout().isBigEndian())
1961 std::reverse(Parts.begin(), Parts.end());
1964 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1966 for (
unsigned i = 1; i < NumRegs; ++i) {
1971 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1977 ReplaceValueWith(SDValue(
N, 1), Chain);
1990bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1992 SDValue Res = SDValue();
1993 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1998 switch (
N->getOpcode()) {
2001 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2002 N->dump(&DAG);
dbgs() <<
"\n";
2008 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2014 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2015 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2020 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2024 Res = PromoteIntOp_FAKE_USE(
N);
2027 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2031 Res = PromoteIntOp_ScalarOp(
N);
2034 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2036 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2054 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2061 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2076 Res = PromoteIntOp_Shift(
N);
2080 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2083 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2109 case ISD::VP_REDUCE_ADD:
2110 case ISD::VP_REDUCE_MUL:
2111 case ISD::VP_REDUCE_AND:
2112 case ISD::VP_REDUCE_OR:
2113 case ISD::VP_REDUCE_XOR:
2114 case ISD::VP_REDUCE_SMAX:
2115 case ISD::VP_REDUCE_SMIN:
2116 case ISD::VP_REDUCE_UMAX:
2117 case ISD::VP_REDUCE_UMIN:
2118 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2123 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2126 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2129 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2131 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2132 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2133 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2135 case ISD::EXPERIMENTAL_VP_SPLICE:
2136 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2139 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2144 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2147 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2150 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2156 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2161 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2164 Res = PromoteIntOp_VECTOR_REPEAT(
N);
2168 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2173 if (!Res.
getNode())
return false;
2180 const bool IsStrictFp =
N->isStrictFPOpcode();
2182 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2183 "Invalid operand expansion");
2187 ReplaceValueWith(SDValue(
N, 0), Res);
2189 ReplaceValueWith(SDValue(
N, 1), SDValue(Res.
getNode(), 1));
2198 SDValue OpL = GetPromotedInteger(
LHS);
2199 SDValue OpR = GetPromotedInteger(
RHS);
2201 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2205 unsigned OpLEffectiveBits =
2206 DAG.computeKnownBits(OpL).countMaxActiveBits();
2207 unsigned OpREffectiveBits =
2208 DAG.computeKnownBits(OpR).countMaxActiveBits();
2209 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2210 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2217 LHS = SExtPromotedInteger(
LHS);
2218 RHS = SExtPromotedInteger(
RHS);
2227 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2228 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2229 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2230 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2237 LHS = ZExtPromotedInteger(
LHS);
2238 RHS = ZExtPromotedInteger(
RHS);
2252 LHS = SExtPromotedInteger(
LHS);
2253 RHS = SExtPromotedInteger(
RHS);
2258 "Unknown integer comparison!");
2260 SExtOrZExtPromotedOperands(
LHS,
RHS);
2264 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2268SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2269 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2270 EVT ResVT =
N->getValueType(0);
2271 EVT OpVT =
Op.getValueType();
2274 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2279 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2280 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2281 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2285 EVT OutVT =
N->getValueType(0);
2288 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2291 switch (getTypeAction(InVT)) {
2295 DAG.getDataLayout().isLittleEndian()) {
2305 if (isTypeLegal(WideVecVT)) {
2306 SDValue Promoted = GetPromotedInteger(InOp);
2307 SDValue Cast = DAG.getNode(
ISD::BITCAST, dl, WideVecVT, Promoted);
2309 DAG.getVectorIdxConstant(0, dl));
2322 return CreateStackStoreLoad(InOp, OutVT);
2325SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2326 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2328 SDValue
LHS =
N->getOperand(2);
2329 SDValue
RHS =
N->getOperand(3);
2334 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2335 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2339SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2340 assert(OpNo == 1 &&
"only know how to promote condition");
2343 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2346 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2347 N->getOperand(2)), 0);
2350SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2351 assert(OpNo == 1 &&
"only know how to promote condition");
2354 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2357 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2362 EVT OVT =
N->getOperand(0).getValueType();
2363 SDValue
Lo = ZExtPromotedInteger(
N->getOperand(0));
2364 SDValue
Hi = GetPromotedInteger(
N->getOperand(1));
2365 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2370 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2371 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2380 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2381 "Legal vector of one illegal element?");
2386 assert(
N->getOperand(0).getValueSizeInBits() >=
2387 N->getValueType(0).getScalarSizeInBits() &&
2388 "Type of inserted value narrower than vector element type!");
2391 for (
unsigned i = 0; i < NumElts; ++i)
2392 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2394 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2397SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2404 assert(
N->getOperand(1).getValueSizeInBits() >=
2405 N->getValueType(0).getScalarSizeInBits() &&
2406 "Type of inserted value narrower than vector element type!");
2407 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2408 GetPromotedInteger(
N->getOperand(1)),
2413 assert(OpNo == 2 &&
"Different operand and result vector types?");
2416 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2417 TLI.getVectorIdxTy(DAG.getDataLayout()));
2418 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2419 N->getOperand(1), Idx), 0);
2423 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2427 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2430SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2431 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2432 SDValue
Cond =
N->getOperand(0);
2433 EVT OpTy =
N->getOperand(1).getValueType();
2436 if (SDValue Res = WidenVSELECTMask(
N))
2437 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2438 Res,
N->getOperand(1),
N->getOperand(2));
2442 Cond = PromoteTargetBoolean(
Cond, OpVT);
2444 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2445 N->getOperand(2)), 0);
2448SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2449 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2451 SDValue
LHS =
N->getOperand(0);
2452 SDValue
RHS =
N->getOperand(1);
2456 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2),
2457 N->getOperand(3),
N->getOperand(4)), 0);
2460SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2461 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2463 SDValue
LHS =
N->getOperand(0);
2464 SDValue
RHS =
N->getOperand(1);
2468 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2472 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2473 ZExtPromotedInteger(
N->getOperand(1))), 0);
2477 SDValue
LHS =
N->getOperand(0);
2478 SDValue
RHS =
N->getOperand(1);
2481 LHS = SExtPromotedInteger(
LHS);
2482 RHS = SExtPromotedInteger(
RHS);
2484 SExtOrZExtPromotedOperands(
LHS,
RHS);
2487 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS), 0);
2491 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2492 ZExtPromotedInteger(
N->getOperand(2))), 0);
2496 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2500 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2504 return SDValue(DAG.UpdateNodeOperands(
N,
2505 SExtPromotedInteger(
N->getOperand(0))), 0);
2508SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2509 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2510 SExtPromotedInteger(
N->getOperand(1))), 0);
2515 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2518 SDValue Val = GetPromotedInteger(
N->getValue());
2521 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2522 N->getMemoryVT(),
N->getMemOperand());
2528 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2529 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2531 SDValue DataOp = GetPromotedInteger(
N->getValue());
2532 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2533 N->getMask(),
N->getVectorLength(),
2534 N->getMemoryVT(),
N->getMemOperand(),
2535 N->isCompressingStore());
2540 SDValue DataOp =
N->getValue();
2541 SDValue
Mask =
N->getMask();
2546 Mask = PromoteTargetBoolean(Mask, DataVT);
2549 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2552 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2553 DataOp = GetPromotedInteger(DataOp);
2555 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2556 N->getOffset(), Mask,
N->getMemoryVT(),
2557 N->getMemOperand(),
N->getAddressingMode(),
2558 true,
N->isCompressingStore());
2563 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2564 EVT DataVT =
N->getValueType(0);
2565 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2567 NewOps[OpNo] =
Mask;
2568 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2570 return SDValue(Res, 0);
2573 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2574 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2584 EVT DataVT =
N->getValueType(0);
2585 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2586 }
else if (OpNo == 4) {
2588 if (
N->isIndexSigned())
2590 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2592 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2594 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2596 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2598 return SDValue(Res, 0);
2601 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2602 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2608 bool TruncateStore =
N->isTruncatingStore();
2613 EVT DataVT =
N->getValue().getValueType();
2614 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2615 }
else if (OpNo == 4) {
2617 if (
N->isIndexSigned())
2619 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2621 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2623 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2624 TruncateStore =
true;
2627 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2628 SDLoc(
N), NewOps,
N->getMemOperand(),
2629 N->getIndexType(), TruncateStore);
2634 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2638 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2643 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2648 return SDValue(DAG.UpdateNodeOperands(
N,
2649 ZExtPromotedInteger(
N->getOperand(0))), 0);
2652SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2653 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2658SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2659 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2660 ZExtPromotedInteger(
N->getOperand(1))), 0);
2665 SDValue Src =
N->getOperand(0);
2666 SDValue
Op = GetPromotedInteger(Src);
2667 EVT VT =
N->getValueType(0);
2672 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2673 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2674 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2675 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2680 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2684 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2686 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2689SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2691 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
2692 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2697 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
2701 unsigned OpOffset = IsStrict ? 1 : 0;
2705 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2708 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2709 if (LCImpl == RTLIB::Unsupported) {
2715 if (IsPowI &&
N->getValueType(0).isVector())
2716 return DAG.UnrollVectorOp(
N);
2718 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2719 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2731 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2732 DAG.getLibInfo().getIntSize()) {
2733 const Function &Fn = DAG.getMachineFunction().getFunction();
2734 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2735 Twine(IsPowI ?
"powi" :
"ldexp") +
2736 " exponent does not match sizeof(int)",
2737 Fn, N->getDebugLoc()));
2739 ReplaceValueWith(SDValue(N, 1), Chain);
2740 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2744 TargetLowering::MakeLibCallOptions CallOptions;
2745 CallOptions.setIsSigned(
true);
2746 SDValue
Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2747 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2748 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2749 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
2751 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
2756 switch (
N->getOpcode()) {
2764 case ISD::VP_REDUCE_ADD:
2765 case ISD::VP_REDUCE_MUL:
2766 case ISD::VP_REDUCE_AND:
2767 case ISD::VP_REDUCE_OR:
2768 case ISD::VP_REDUCE_XOR:
2772 case ISD::VP_REDUCE_SMAX:
2773 case ISD::VP_REDUCE_SMIN:
2777 case ISD::VP_REDUCE_UMAX:
2778 case ISD::VP_REDUCE_UMIN:
2788 return GetPromotedInteger(V);
2790 return SExtPromotedInteger(V);
2792 return ZExtPromotedInteger(V);
2798 SDValue
Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2800 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2801 EVT InVT =
Op.getValueType();
2803 EVT ResVT =
N->getValueType(0);
2804 unsigned Opcode =
N->getOpcode();
2821 switch (TLI.getBooleanContents(InVT)) {
2824 Op = ZExtPromotedInteger(
N->getOperand(0));
2827 Op = SExtPromotedInteger(
N->getOperand(0));
2840 switch (TLI.getBooleanContents(InVT)) {
2843 Op = ZExtPromotedInteger(
N->getOperand(0));
2846 Op = SExtPromotedInteger(
N->getOperand(0));
2852 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2856 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2860SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2862 SDValue
Op =
N->getOperand(OpNo);
2867 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2868 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2871 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2873 Op = PromoteIntOpVectorReduction(
N,
Op);
2877 EVT VT =
N->getValueType(0);
2878 EVT EltVT =
Op.getValueType().getScalarType();
2881 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2888 SDValue Reduce = DAG.
getNode(
N->getOpcode(),
DL, EltVT, NewOps);
2893 SDValue
Op = ZExtPromotedInteger(
N->getOperand(1));
2894 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2897SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2900 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2901 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2904SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2907 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2908 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2913 const Function &Fn = DAG.getMachineFunction().getFunction();
2915 "cannot use llvm.write_register with illegal type", Fn,
2917 return N->getOperand(0);
2920SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2921 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2922 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2925 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2926 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2928 return SDValue(Res, 0);
2931 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2932 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2936SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2940 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2941 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2944 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2946 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2947 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2950SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2952 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2954 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2955 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2958SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
2960 assert(OpNo == 0 &&
"Unexpected operand for promotion");
2961 SDValue
Op =
N->getOperand(0);
2964 if (TLI.getBooleanContents(
Op.getValueType()) ==
2966 NewOp = SExtPromotedInteger(
Op);
2968 NewOp = ZExtPromotedInteger(
Op);
2970 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
2973SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2975 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2976 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2977 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2980SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
2981 assert(OpNo < 3 &&
"Unexpected operand for promotion");
2983 return TLI.expandVectorMatch(
N, DAG);
2986 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
2987 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2990SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
2993 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
2994 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2997SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2999 switch (
N->getOpcode()) {
3001 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3002 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3005 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3006 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3009 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3010 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3015 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3018SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3020 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3021 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3022 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3024 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3029 SDValue Src = GetPromotedInteger(
N->getOperand(0));
3030 EVT SrcVT = Src.getValueType();
3031 EVT OrigVT =
N->getValueType(0);
3046void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3049 Lo =
Hi = SDValue();
3052 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3055 switch (
N->getOpcode()) {
3058 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3059 N->dump(&DAG);
dbgs() <<
"\n";
3088 ExpandIntRes_ABS(
N,
Lo,
Hi);
3140 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3141 SplitInteger(Tmp.first,
Lo,
Hi);
3142 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
3147 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3148 SDValue Tmp = DAG.getAtomicCmpSwap(
3150 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3156 SDValue
Success = DAG.getSetCC(SDLoc(
N),
N->getValueType(1), Tmp,
3159 SplitInteger(Tmp,
Lo,
Hi);
3160 ReplaceValueWith(SDValue(
N, 1),
Success);
3161 ReplaceValueWith(SDValue(
N, 2), Tmp.
getValue(1));
3238 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3243 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3249 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3253 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3257 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3262 ExpandIntRes_MULH(
N,
Lo,
Hi);
3266 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3270 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3275 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3281 SetExpandedInteger(SDValue(
N, ResNo),
Lo,
Hi);
3285std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3286 unsigned Opc =
Node->getOpcode();
3292 EVT RetVT =
Node->getValueType(0);
3293 TargetLowering::MakeLibCallOptions CallOptions;
3296 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3297 if (LCImpl != RTLIB::Unsupported) {
3299 Ops.push_back(
Node->getOperand(1));
3302 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3303 "Unexpected atomic op or value type!");
3305 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3307 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3308 Node->getOperand(0));
3313void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3318 GetExpandedInteger(
N->getOperand(0), InL, InH);
3333 if (Amt.
uge(VTBits)) {
3334 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3335 }
else if (Amt.
ugt(NVTBits)) {
3336 Lo = DAG.getConstant(0,
DL, NVT);
3338 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3339 }
else if (Amt == NVTBits) {
3340 Lo = DAG.getConstant(0,
DL, NVT);
3344 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3346 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3348 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3353 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3355 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3362 if (Amt.
uge(VTBits)) {
3363 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3364 }
else if (Amt.
ugt(NVTBits)) {
3366 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3367 Hi = DAG.getConstant(0,
DL, NVT);
3368 }
else if (Amt == NVTBits) {
3370 Hi = DAG.getConstant(0,
DL, NVT);
3373 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3375 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3380 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3382 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3385 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3391 if (Amt.
uge(VTBits)) {
3393 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3394 }
else if (Amt.
ugt(NVTBits)) {
3396 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3398 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3399 }
else if (Amt == NVTBits) {
3402 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3405 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3407 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3412 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3414 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3417 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3425bool DAGTypeLegalizer::
3427 unsigned Opc =
N->getOpcode();
3428 SDValue
In =
N->getOperand(0);
3429 SDValue Amt =
N->getOperand(1);
3430 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3435 "Expanded integer type size not a power of two!");
3439 KnownBits
Known = DAG.computeKnownBits(Amt);
3442 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3447 GetExpandedInteger(In, InL, InH);
3451 if (
Known.One.intersects(HighBitMask)) {
3454 DAG.getConstant(~HighBitMask, dl, ShTy));
3459 Lo = DAG.getConstant(0, dl, NVT);
3460 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3463 Hi = DAG.getConstant(0, dl, NVT);
3464 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3468 DAG.getConstant(NVTBits - 1, dl, ShTy));
3469 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3480 SDValue Amt2 = DAG.getNode(
ISD::XOR, dl, ShTy, Amt,
3481 DAG.getConstant(NVTBits - 1, dl, ShTy));
3497 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3499 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3501 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3502 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3514bool DAGTypeLegalizer::
3517 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3521 "Expanded integer type size not a power of two!");
3526 GetExpandedInteger(
N->getOperand(0), InL, InH);
3528 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3529 SDValue AmtExcess = DAG.getNode(
ISD::SUB, dl, ShTy, Amt, NVBitsNode);
3530 SDValue AmtLack = DAG.getNode(
ISD::SUB, dl, ShTy, NVBitsNode, Amt);
3531 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3533 SDValue
isZero = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3534 Amt, DAG.getConstant(0, dl, ShTy),
3537 SDValue LoS, HiS, LoL, HiL;
3538 switch (
N->getOpcode()) {
3544 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3545 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3548 LoL = DAG.getConstant(0, dl, NVT);
3551 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3552 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3553 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3559 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3562 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3565 HiL = DAG.getConstant(0, dl, NVT);
3568 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3569 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3570 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3576 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3577 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3581 DAG.getConstant(NVTBits - 1, dl, ShTy));
3584 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3585 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3586 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3609 SDValue
LHS =
N->getOperand(0);
3610 SDValue
RHS =
N->getOperand(1);
3611 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3616 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3617 SplitInteger(Res,
Lo,
Hi);
3620void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3624 SDValue
LHS =
N->getOperand(0);
3625 SDValue
RHS =
N->getOperand(1);
3629 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3630 unsigned NumHalfBits = NumBits / 2;
3631 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3632 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3633 SDValue LHSL, LHSH, RHSL, RHSH;
3634 GetExpandedInteger(
LHS, LHSL, LHSH);
3635 GetExpandedInteger(
RHS, RHSL, RHSH);
3638 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3640 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3648 SDValue LHSL, LHSH, RHSL, RHSH;
3649 GetExpandedInteger(
LHS, LHSL, LHSH);
3650 GetExpandedInteger(
RHS, RHSL, RHSH);
3652 EVT CCT = getSetCCResultType(NVT);
3655 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3657 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3659 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3661 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3665 const APInt *RHSVal =
nullptr;
3667 RHSVal = &RHSConst->getAPIntValue();
3674 SDValue LHSL, LHSH, RHSL, RHSH;
3675 GetExpandedInteger(
LHS, LHSL, LHSH);
3676 GetExpandedInteger(
RHS, RHSL, RHSH);
3678 EVT CCT = getSetCCResultType(NVT);
3684 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3687 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3688 SDValue IsHiEq = DAG.getSetCC(
DL, CCT, LHSH, RHSH,
ISD::SETEQ);
3691 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3694 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3696 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3703 switch (
N->getOpcode()) {
3730 EVT VT =
N->getValueType(0);
3731 EVT CCT = getSetCCResultType(VT);
3734 SplitInteger(Result,
Lo,
Hi);
3738 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3739 SplitInteger(ExpandedCMP,
Lo,
Hi);
3742void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3746 SDValue LHSL, LHSH, RHSL, RHSH;
3747 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3748 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3751 SDValue LoOps[2] = { LHSL, RHSL };
3752 SDValue HiOps[3] = { LHSH, RHSH };
3754 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3756 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3758 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3762 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3768 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3781 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3783 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3786 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3800 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3802 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3806 EVT OvfVT = getSetCCResultType(NVT);
3807 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3818 SDValue OVF =
Lo.getValue(1);
3822 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3825 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3829 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3841 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3845 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3848 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3851 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3856 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3858 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3859 DAG.getConstant(0, dl, NVT));
3862 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3871 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3876 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3878 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3879 DAG.getConstant(0, dl, NVT));
3885void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3888 SDValue LHSL, LHSH, RHSL, RHSH;
3890 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3891 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3892 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3893 SDValue LoOps[2] = { LHSL, RHSL };
3894 SDValue HiOps[3] = { LHSH, RHSH };
3908 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
3911void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3914 SDValue LHSL, LHSH, RHSL, RHSH;
3916 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3917 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3918 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3919 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
3920 SDValue HiOps[3] = { LHSH, RHSH };
3922 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3924 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3928 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
3931void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3933 SDValue
LHS =
N->getOperand(0);
3934 SDValue
RHS =
N->getOperand(1);
3939 unsigned CarryOp, NoCarryOp;
3941 switch(
N->getOpcode()) {
3956 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3957 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3961 SDValue LHSL, LHSH, RHSL, RHSH;
3962 GetExpandedInteger(
LHS, LHSL, LHSH);
3963 GetExpandedInteger(
RHS, RHSL, RHSH);
3964 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3965 SDValue LoOps[2] = { LHSL, RHSL };
3966 SDValue HiOps[3] = { LHSH, RHSH };
3968 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3970 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3976 SDValue Sum = DAG.getNode(NoCarryOp, dl,
LHS.getValueType(),
LHS,
RHS);
3977 SplitInteger(Sum,
Lo,
Hi);
3983 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3984 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3988 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3993 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3999 ReplaceValueWith(SDValue(
N, 1), Ovf);
4005 SDValue LHSL, LHSH, RHSL, RHSH;
4007 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4008 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4009 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4010 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
4011 SDValue HiOps[3] = { LHSH, RHSH, SDValue() };
4013 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4015 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4019 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4022void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4025 SDValue LHSL, LHSH, RHSL, RHSH;
4027 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4028 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4029 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4034 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4035 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4039 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4042void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4044 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4046 SDValue
Op =
N->getOperand(0);
4047 if (
Op.getValueType().bitsLE(NVT)) {
4050 Hi = DAG.getUNDEF(NVT);
4054 assert(getTypeAction(
Op.getValueType()) ==
4056 "Only know how to promote this result!");
4057 SDValue Res = GetPromotedInteger(
Op);
4059 "Operand over promoted?");
4061 SplitInteger(Res,
Lo,
Hi);
4065void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4068 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4069 EVT NVT =
Lo.getValueType();
4074 if (NVTBits < EVTBits) {
4077 EVTBits - NVTBits)));
4082 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4086void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4089 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4090 EVT NVT =
Lo.getValueType();
4095 if (NVTBits < EVTBits) {
4098 EVTBits - NVTBits)));
4102 Hi = DAG.getConstant(0, dl, NVT);
4106void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4109 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4114void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4117 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4126 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4127 EVT NVT =
Lo.getValueType();
4130 Hi = DAG.getConstant(0, dl, NVT);
4133void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4135 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4138 const APInt &Cst =
Constant->getAPIntValue();
4139 bool IsTarget =
Constant->isTargetOpcode();
4140 bool IsOpaque =
Constant->isOpaque();
4142 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4143 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4150 SDValue N0 =
N->getOperand(0);
4151 GetExpandedInteger(N0,
Lo,
Hi);
4152 EVT NVT =
Lo.getValueType();
4157 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4162 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4163 Hi = DAG.getConstant(0, dl, NVT);
4173 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4176 SDValue Sign = DAG.getNode(
4178 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4179 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4188 EVT VT =
N->getValueType(0);
4189 SDValue Neg = DAG.getNode(
ISD::SUB, dl, VT,
4190 DAG.getConstant(0, dl, VT), N0);
4191 SDValue NegLo, NegHi;
4192 SplitInteger(Neg, NegLo, NegHi);
4194 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4196 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4197 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4200void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4204 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4205 EVT NVT =
Lo.getValueType();
4207 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4210 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4213 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4214 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4217 Hi = DAG.getConstant(0, dl, NVT);
4225 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4226 EVT NVT =
Lo.getValueType();
4229 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4230 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4232 SDValue HiCTLS = DAG.getNode(
ISD::CTLS, dl, NVT,
Hi);
4233 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4235 SDValue IsNegative =
4236 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4237 SDValue AdjustedLo =
4238 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4239 SDValue LoCLZ = DAG.getNode(
ISD::CTLZ, dl, NVT, AdjustedLo);
4240 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4241 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4243 Hi = DAG.getConstant(0, dl, NVT);
4247 SDValue
Result = TLI.expandABD(
N, DAG);
4248 SplitInteger(Result,
Lo,
Hi);
4252 SDValue
Op =
N->getOperand(0);
4253 EVT VT =
N->getValueType(0);
4258 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4259 "LibCall explicitly requested, but not available");
4261 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4262 TargetLowering::MakeLibCallOptions CallOptions;
4266 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4267 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4275 GetExpandedInteger(
Op,
Lo,
Hi);
4276 EVT NVT =
Lo.getValueType();
4279 Hi = DAG.getConstant(0,
DL, NVT);
4282void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4286 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4287 EVT NVT =
Lo.getValueType();
4289 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4293 SDValue HiLZ = DAG.
getNode(
N->getOpcode(), dl, NVT,
Hi);
4295 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4296 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4299 Hi = DAG.getConstant(0, dl, NVT);
4305 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4312 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4316 ReplaceValueWith(SDValue(
N, 1), Chain);
4324 Chain =
Op.getValue(1);
4333 EVT VT =
N->getValueType(0);
4337 bool IsStrict =
N->isStrictFPOpcode();
4338 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4339 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4343 Op.getValueType() == MVT::bf16) {
4349 EVT OpVT =
Op.getValueType();
4353 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4354 TargetLowering::MakeLibCallOptions CallOptions;
4359 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4360 CallOptions, dl, Chain);
4361 SplitInteger(Tmp.first,
Lo,
Hi);
4364 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4369 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4370 SplitInteger(Res,
Lo,
Hi);
4376 bool IsStrict =
N->isStrictFPOpcode();
4377 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4378 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4380 EVT VT =
Op.getValueType();
4382 if (VT == MVT::f16) {
4388 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4391 LC = RTLIB::getLROUND(VT);
4392 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4395 LC = RTLIB::getLRINT(VT);
4396 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4399 LC = RTLIB::getLLROUND(VT);
4400 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4403 LC = RTLIB::getLLRINT(VT);
4404 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4408 EVT RetVT =
N->getValueType(0);
4410 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4411 if (LCImpl == RTLIB::Unsupported) {
4412 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4413 N->getOperationName(&DAG));
4414 SDValue
Poison = DAG.getPOISON(
N->getValueType(0));
4416 if (
N->isStrictFPOpcode())
4417 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
4421 TargetLowering::MakeLibCallOptions CallOptions;
4423 std::pair<SDValue, SDValue> Tmp =
4424 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4425 SplitInteger(Tmp.first,
Lo,
Hi);
4427 if (
N->isStrictFPOpcode())
4428 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4431void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4433 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4436 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4442 EVT VT =
N->getValueType(0);
4443 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4444 SDValue Ch =
N->getChain();
4445 SDValue Ptr =
N->getBasePtr();
4448 AAMDNodes AAInfo =
N->getAAInfo();
4453 if (
N->getMemoryVT().bitsLE(NVT)) {
4454 EVT MemVT =
N->getMemoryVT();
4456 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4457 N->getBaseAlign(), MMOFlags, AAInfo);
4465 unsigned LoSize =
Lo.getValueSizeInBits();
4467 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4470 Hi = DAG.getConstant(0, dl, NVT);
4474 Hi = DAG.getUNDEF(NVT);
4476 }
else if (DAG.getDataLayout().isLittleEndian()) {
4478 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4481 unsigned ExcessBits =
4488 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4489 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4490 N->getBaseAlign(), MMOFlags, AAInfo);
4499 EVT MemVT =
N->getMemoryVT();
4502 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4505 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4508 N->getBaseAlign(), MMOFlags, AAInfo);
4514 N->getPointerInfo().getWithOffset(IncrementSize),
4516 N->getBaseAlign(), MMOFlags, AAInfo);
4528 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4532 DAG.getShiftAmountConstant(
4539 ReplaceValueWith(SDValue(
N, 1), Ch);
4542void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4545 SDValue LL, LH, RL, RH;
4546 GetExpandedInteger(
N->getOperand(0), LL, LH);
4547 GetExpandedInteger(
N->getOperand(1), RL, RH);
4551 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4553 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4554 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4557void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4559 EVT VT =
N->getValueType(0);
4560 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4563 SDValue LL, LH, RL, RH;
4564 GetExpandedInteger(
N->getOperand(0), LL, LH);
4565 GetExpandedInteger(
N->getOperand(1), RL, RH);
4567 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4574 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4575 if (LCImpl == RTLIB::Unsupported) {
4578 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4584 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4585 TargetLowering::MakeLibCallOptions CallOptions;
4587 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4594 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4595 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4596 SDValue
R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4599 ReplaceValueWith(SDValue(
N, 1),
R.getValue(2));
4603 SDValue
Result = TLI.expandAVG(
N, DAG);
4604 SplitInteger(Result,
Lo,
Hi);
4609 SDValue
Result = TLI.expandAddSubSat(
N, DAG);
4610 SplitInteger(Result,
Lo,
Hi);
4615 SDValue
Result = TLI.expandShlSat(
N, DAG);
4616 SplitInteger(Result,
Lo,
Hi);
4627 EVT VT =
N->getValueType(0);
4629 SDValue
LHS =
N->getOperand(0);
4630 SDValue
RHS =
N->getOperand(1);
4631 uint64_t Scale =
N->getConstantOperandVal(2);
4643 EVT BoolVT = getSetCCResultType(VT);
4645 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4646 SDValue Product =
Result.getValue(0);
4647 SDValue Overflow =
Result.getValue(1);
4651 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4652 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4653 SDValue
Zero = DAG.getConstant(0, dl, VT);
4657 SDValue ProdNeg = DAG.getSetCC(dl, BoolVT,
Xor, Zero,
ISD::SETLT);
4658 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4659 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4664 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4665 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4668 SplitInteger(Result,
Lo,
Hi);
4674 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4676 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4677 SDValue LL, LH, RL, RH;
4678 GetExpandedInteger(
LHS, LL, LH);
4679 GetExpandedInteger(
RHS, RL, RH);
4683 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4689 SDValue LoTmp, HiTmp;
4690 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4691 SplitInteger(LoTmp, Result[0], Result[1]);
4692 SplitInteger(HiTmp, Result[2], Result[3]);
4694 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4697 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4698 "the size of the current value type");
4720 if (Scale % NVTSize) {
4721 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4724 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4736 if (Scale == VTSize)
4751 SDValue ResultHL =
Result[2];
4752 SDValue ResultHH =
Result[3];
4754 SDValue SatMax, SatMin;
4755 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4756 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4757 EVT BoolNVT = getSetCCResultType(NVT);
4760 if (Scale < NVTSize) {
4762 SDValue HLAdjusted =
4763 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4764 DAG.getShiftAmountConstant(Scale, NVT, dl));
4765 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4766 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4767 }
else if (Scale == NVTSize) {
4769 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4770 }
else if (Scale < VTSize) {
4772 SDValue HLAdjusted =
4774 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4775 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4778 "(and saturation can't happen with Scale==VTSize).");
4780 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4781 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4785 if (Scale < NVTSize) {
4790 unsigned OverflowBits = VTSize - Scale + 1;
4791 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4792 "Extent of overflow bits must start within HL");
4793 SDValue HLHiMask = DAG.getConstant(
4795 SDValue HLLoMask = DAG.getConstant(
4798 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4799 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4800 SDValue HLUGT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLLoMask,
ISD::SETUGT);
4802 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4804 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4805 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4806 SDValue HLULT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLHiMask,
ISD::SETULT);
4808 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4809 }
else if (Scale == NVTSize) {
4811 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4812 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4813 SDValue HLNeg = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETLT);
4815 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4817 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4818 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4819 SDValue HLPos = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETGE);
4821 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4822 }
else if (Scale < VTSize) {
4825 unsigned OverflowBits = VTSize - Scale + 1;
4826 SDValue HHHiMask = DAG.getConstant(
4828 SDValue HHLoMask = DAG.getConstant(
4830 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4831 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4838 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4839 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4842 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4843 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4850 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4852 N->getConstantOperandVal(2), DAG);
4856 N->getConstantOperandVal(2), TLI, DAG);
4857 SplitInteger(Res,
Lo,
Hi);
4860void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4863 "Node has unexpected Opcode");
4864 SDValue
LHS =
Node->getOperand(0);
4865 SDValue
RHS =
Node->getOperand(1);
4873 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4874 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4878 SDValue LHSL, LHSH, RHSL, RHSH;
4879 GetExpandedInteger(
LHS, LHSL, LHSH);
4880 GetExpandedInteger(
RHS, RHSL, RHSH);
4881 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4884 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4893 SplitInteger(Sum,
Lo,
Hi);
4918 EVT VT =
LHS.getValueType();
4921 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4925 EVT OType =
Node->getValueType(1);
4926 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4930 ReplaceValueWith(SDValue(Node, 1), Ovf);
4933void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4935 EVT VT =
N->getValueType(0);
4937 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4946 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4948 TargetLowering::MakeLibCallOptions CallOptions;
4950 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4953void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4956 SDValue Shiftee =
N->getOperand(0);
4958 SDValue ShAmt =
N->getOperand(1);
4963 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4964 }
while (!TLI.isTypeLegal(LoadVT));
4969 "Shifting unit is not a a power of two!");
4971 const bool IsOneStepShift =
4972 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4977 if (!IsOneStepShift)
4978 ShAmt = DAG.getFreeze(ShAmt);
4981 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4982 unsigned VTByteWidth = VTBitWidth / 8;
4984 "Shiftee type size is not a power of two!");
4985 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4986 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4991 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4993 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4994 EVT PtrTy =
StackPtr.getValueType();
4995 SDValue Ch = DAG.getEntryNode();
4998 DAG.getMachineFunction(),
5004 unsigned WideningOpc =
5006 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5009 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5013 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5019 Flags.setExact(IsOneStepShift);
5020 SDValue SrlTmp = DAG.getNode(
5022 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5024 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5025 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5027 SDValue ByteOffset =
5028 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5033 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5040 if (DAG.getDataLayout().isBigEndian())
5041 WillIndexUpwards = !WillIndexUpwards;
5043 SDValue AdjStackPtr;
5044 if (WillIndexUpwards) {
5047 AdjStackPtr = DAG.getMemBasePlusOffset(
5048 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5049 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5053 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5054 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5058 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5063 if (!IsOneStepShift) {
5065 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5066 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5067 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5071 SplitInteger(Res,
Lo,
Hi);
5074void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5076 EVT VT =
N->getValueType(0);
5077 unsigned Opc =
N->getOpcode();
5083 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5087 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5104 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5106 const bool LegalOrCustom =
5110 unsigned ExpansionFactor = 1;
5112 for (EVT TmpVT = NVT;;) {
5113 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5114 if (NewTMPVT == TmpVT)
5121 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5124 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5126 if (LegalOrCustom &&
5130 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5136 SDValue ShiftOp =
N->getOperand(1);
5137 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5139 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5141 SDValue
Ops[] = { LHSL, LHSH, ShiftOp };
5142 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5143 Hi =
Lo.getValue(1);
5148 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5162 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5165 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5166 SDValue
Ops[2] = {
N->getOperand(0), ShAmt};
5167 TargetLowering::MakeLibCallOptions CallOptions;
5170 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5175 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5179void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5181 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5183 SDValue
Op =
N->getOperand(0);
5184 if (
Op.getValueType().bitsLE(NVT)) {
5190 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5194 assert(getTypeAction(
Op.getValueType()) ==
5196 "Only know how to promote this result!");
5197 SDValue Res = GetPromotedInteger(
Op);
5199 "Operand over promoted?");
5201 SplitInteger(Res,
Lo,
Hi);
5209void DAGTypeLegalizer::
5212 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5215 if (EVT.
bitsLE(
Lo.getValueType())) {
5223 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5224 Hi.getValueType(), dl));
5235void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5237 EVT VT =
N->getValueType(0);
5239 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5248 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5250 TargetLowering::MakeLibCallOptions CallOptions;
5252 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5255void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5257 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5267void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5269 EVT VT =
N->getValueType(0);
5287 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
5288 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5289 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5290 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5292 EVT BitVT =
N->getValueType(1);
5293 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5295 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5297 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5298 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5300 SDValue One = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, LHSHigh, RHSLow);
5303 SDValue Two = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, RHSHigh, LHSLow);
5306 SDValue HighSum = DAG.getNode(
ISD::ADD, dl, HalfVT, One, Two);
5314 SDValue Three = DAG.getNode(
ISD::MUL, dl, VT,
5317 SplitInteger(Three,
Lo,
Hi);
5321 ReplaceValueWith(SDValue(
N, 1), Overflow);
5326 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5331 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5335 if (LCImpl == RTLIB::Unsupported ||
5337 DAG.getMachineFunction().getName()) {
5339 SDValue MulLo, MulHi;
5340 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5341 N->getOperand(1), MulLo, MulHi);
5342 SDValue
SRA = DAG.getNode(
5346 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5347 SplitInteger(MulLo,
Lo,
Hi);
5348 ReplaceValueWith(SDValue(
N, 1), Overflow);
5352 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5355 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5356 MachinePointerInfo());
5359 for (
const SDValue &
Op :
N->op_values()) {
5360 EVT ArgVT =
Op.getValueType();
5362 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5363 Entry.IsSExt =
true;
5364 Entry.IsZExt =
false;
5365 Args.push_back(Entry);
5369 TargetLowering::ArgListEntry
Entry(
5371 Entry.IsSExt =
true;
5372 Entry.IsZExt =
false;
5373 Args.push_back(Entry);
5375 SDValue
Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5377 TargetLowering::CallLoweringInfo CLI(DAG);
5380 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5381 Func, std::move(Args))
5384 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5386 SplitInteger(CallInfo.first,
Lo,
Hi);
5388 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5389 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5390 DAG.getConstant(0, dl, PtrVT),
5393 ReplaceValueWith(SDValue(
N, 1), Ofl);
5396void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5398 EVT VT =
N->getValueType(0);
5400 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5412 if (isTypeLegal(NVT)) {
5414 GetExpandedInteger(
N->getOperand(0), InL, InH);
5416 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5425 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5427 TargetLowering::MakeLibCallOptions CallOptions;
5428 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5431void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5433 EVT VT =
N->getValueType(0);
5435 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5445 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5447 if (isTypeLegal(NVT)) {
5449 GetExpandedInteger(
N->getOperand(0), InL, InH);
5451 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5460 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5462 TargetLowering::MakeLibCallOptions CallOptions;
5463 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5466void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5468 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5470 SDValue
Op =
N->getOperand(0);
5471 if (
Op.getValueType().bitsLE(NVT)) {
5474 Hi = DAG.getConstant(0, dl, NVT);
5478 assert(getTypeAction(
Op.getValueType()) ==
5480 "Only know how to promote this result!");
5481 SDValue Res = GetPromotedInteger(
Op);
5483 "Operand over promoted?");
5485 SplitInteger(Res,
Lo,
Hi);
5487 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5493void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5497 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5498 SDValue
Zero = DAG.getConstant(0, dl, VT);
5499 SDValue
Swap = DAG.getAtomicCmpSwap(
5504 ReplaceValueWith(SDValue(
N, 0),
Swap.getValue(0));
5505 ReplaceValueWith(SDValue(
N, 1),
Swap.getValue(2));
5508void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5512 SDValue Res = TLI.expandVecReduce(
N, DAG);
5513 SplitInteger(Res,
Lo,
Hi);
5516void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5521 SDValue Res = DAG.
getNode(Opcode,
DL,
N->getValueType(0),
N->getOperand(0),
5522 N->getOperand(0),
N->getOperand(1));
5523 SplitInteger(Res,
Lo,
Hi);
5529 SDValue In1, In2, In3, In4;
5530 GetExpandedInteger(
N->getOperand(0), In3, In4);
5531 GetExpandedInteger(
N->getOperand(1), In1, In2);
5535 unsigned Opc =
N->getOpcode();
5538 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5542 SDValue AndNode = DAG.getNode(
ISD::AND,
DL, ShAmtVT, ShAmt,
5543 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5545 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5549 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5550 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5555 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5556 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5561 SDValue Res = TLI.expandCLMUL(
N, DAG);
5562 return SplitInteger(Res,
Lo,
Hi);
5565 SDValue LL, LH, RL, RH;
5566 GetExpandedInteger(
N->getOperand(0), LL, LH);
5567 GetExpandedInteger(
N->getOperand(1), RL, RH);
5578 SDValue HiLoCross1 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LL, RH);
5579 SDValue HiLoCross2 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LH, RL);
5580 SDValue HiLoCross = DAG.getNode(
ISD::XOR,
DL, HalfVT, HiLoCross1, HiLoCross2);
5581 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5585 SDValue Res = TLI.expandPEXT(
N, DAG);
5586 SplitInteger(Res,
Lo,
Hi);
5590 SDValue Res = TLI.expandPDEP(
N, DAG);
5591 SplitInteger(Res,
Lo,
Hi);
5595 SDValue Res = TLI.expandMULH(
N, DAG);
5596 SplitInteger(Res,
Lo,
Hi);
5601 EVT VT =
N->getValueType(0);
5608 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5611 SplitInteger(Res,
Lo,
Hi);
5618 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5619 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
5621 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5622 Lo = DAG.getPOISON(LoVT);
5623 Hi = DAG.getPOISON(HiVT);
5630 EVT VT =
N->getSimpleValueType(0);
5631 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5633 "VectorIdxTy should be smaller than type to be expanded?");
5635 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), IdxVT,
N->getOperand(0));
5637 SplitInteger(Res,
Lo,
Hi);
5648bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5650 SDValue Res = SDValue();
5652 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5655 switch (
N->getOpcode()) {
5658 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5659 N->dump(&DAG);
dbgs() <<
"\n";
5664 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5668 Res = ExpandOp_FAKE_USE(
N);
5672 Res = TLI.expandLoopDependenceMask(
N, DAG);
5678 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5691 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5696 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5700 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5703 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5705 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5706 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5707 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5710 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5715 if (!Res.
getNode())
return false;
5723 "Invalid operand expansion");
5725 ReplaceValueWith(SDValue(
N, 0), Res);
5731void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5735 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5736 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5737 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5750 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5757 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5758 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5786 SDValue LoCmp, HiCmp;
5788 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5789 RHSLo, LowCC,
false, DagCombineInfo, dl);
5791 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5794 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5795 RHSHi, CCCode,
false, DagCombineInfo, dl);
5799 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5808 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5810 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5819 if (LHSHi == RHSHi) {
5828 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5829 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5832 if (HasSETCCCARRY) {
5835 bool FlipOperands =
false;
5852 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5853 SDValue LowCmp = DAG.getNode(
ISD::USUBO, dl, VTList, LHSLo, RHSLo);
5856 DAG.getCondCode(CCCode));
5862 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5863 false, DagCombineInfo, dl);
5866 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5867 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5874 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5879 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5884 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5885 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5886 N->getOperand(4)), 0);
5892 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5897 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5902 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5903 N->getOperand(2),
N->getOperand(3),
5904 DAG.getCondCode(CCCode)), 0);
5910 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5915 "Unexpected setcc expansion!");
5921 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5925 SDValue
LHS =
N->getOperand(0);
5926 SDValue
RHS =
N->getOperand(1);
5928 SDValue
Cond =
N->getOperand(3);
5929 SDLoc dl = SDLoc(
N);
5931 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5932 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5933 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5946 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5956 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5957 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5961 return TLI.expandCMP(
N, DAG);
5969 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5970 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5974 bool IsStrict =
N->isStrictFPOpcode();
5977 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
5978 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
5979 EVT DstVT =
N->getValueType(0);
5982 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5983 "Don't know how to expand this XINT_TO_FP!");
5984 TargetLowering::MakeLibCallOptions CallOptions;
5986 std::pair<SDValue, SDValue> Tmp =
5987 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5992 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
5993 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
5998 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6001 return ExpandOp_NormalStore(
N, OpNo);
6004 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6006 EVT VT =
N->getOperand(1).getValueType();
6007 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6008 SDValue Ch =
N->getChain();
6009 SDValue Ptr =
N->getBasePtr();
6011 AAMDNodes AAInfo =
N->getAAInfo();
6017 if (
N->getMemoryVT().bitsLE(NVT)) {
6018 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6019 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6020 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6024 if (DAG.getDataLayout().isLittleEndian()) {
6026 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6028 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6031 unsigned ExcessBits =
6038 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6039 N->getPointerInfo().getWithOffset(IncrementSize),
6040 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6046 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6048 EVT ExtVT =
N->getMemoryVT();
6051 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6059 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6063 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6067 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6068 N->getBaseAlign(), MMOFlags, AAInfo);
6073 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6074 N->getPointerInfo().getWithOffset(IncrementSize),
6076 N->getBaseAlign(), MMOFlags, AAInfo);
6082 GetExpandedInteger(
N->getOperand(0), InL, InH);
6091 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6093 return Swap.getValue(1);
6096SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6097 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6098 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6102 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6104 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6107SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6110 "cannot use llvm.write_register with illegal type", Fn,
6113 return N->getOperand(0);
6116SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6119 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6120 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6121 EVT OutVT =
V0.getValueType();
6123 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6126SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REPEAT(
SDNode *
N) {
6129 EVT OutVT =
N->getValueType(0);
6130 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6135 return DAG.getNode(
N->getOpcode(),
DL, NOutVT,
Op);
6138SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6140 unsigned Factor =
N->getNumOperands();
6143 for (
unsigned i = 0; i != Factor; i++)
6144 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6147 SDValue Res = DAG.
getNode(
N->getOpcode(),
DL, DAG.getVTList(ResVTs),
Ops);
6149 for (
unsigned i = 0; i != Factor; i++)
6150 SetPromotedInteger(SDValue(
N, i), Res.
getValue(i));
6155SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6157 EVT OutVT =
N->getValueType(0);
6158 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6159 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6163 SDValue BaseIdx =
N->getOperand(1);
6168 SDValue InOp0 =
N->getOperand(0);
6180 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6182 SDValue Step2 = DAG.getNode(
6184 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6190 SDValue
Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6199 SDValue
Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6203 "Promoted operand has an element type greater than result");
6216 InOp0 = GetPromotedInteger(InOp0);
6223 Ops.reserve(OutNumElems);
6224 for (
unsigned i = 0; i != OutNumElems; ++i) {
6229 N->getOperand(0), Index);
6230 SDValue
Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6235 return DAG.getBuildVector(NOutVT, dl,
Ops);
6238SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6239 EVT OutVT =
N->getValueType(0);
6240 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6241 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6253 Vec = GetPromotedInteger(Vec);
6259SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6262 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6263 EVT OutVT =
V0.getValueType();
6268SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6270 EVT VT =
N->getValueType(0);
6275 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6276 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6277 EVT OutVT =
V0.getValueType();
6279 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6283 EVT OutVT =
N->getValueType(0);
6284 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6285 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6286 unsigned NumElems =
N->getNumOperands();
6293 Ops.reserve(NumElems);
6294 for (
unsigned i = 0; i != NumElems; ++i) {
6295 SDValue
Op =
N->getOperand(i);
6296 EVT OpVT =
Op.getValueType();
6301 if (OpVT.
bitsLT(NOutVTElem)) {
6307 ExtOpc = NOutExtOpc;
6308 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6313 return DAG.getBuildVector(NOutVT, dl,
Ops);
6320 assert(!
N->getOperand(0).getValueType().isVector() &&
6321 "Input must be a scalar");
6323 EVT OutVT =
N->getValueType(0);
6324 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6325 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6329 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6334 EVT OutVT =
N->getValueType(0);
6335 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6337 "Type must be promoted to a scalable vector type");
6338 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6339 return DAG.getStepVector(dl, NOutVT,
6343SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6346 EVT OutVT =
N->getValueType(0);
6347 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6348 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6350 unsigned NumOperands =
N->getNumOperands();
6354 EVT OpVT =
N->getOperand(0).getValueType();
6359 "Unhandled legalization type");
6365 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6366 SDValue
Op =
N->getOperand(
I);
6368 Op = GetPromotedInteger(
Op);
6377 *DAG.getContext(),
Ops[0].getValueType().getVectorElementType());
6378 return DAG.getAnyExtOrTrunc(
6382 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6383 assert(NumElem * NumOperands == NumOutElem &&
6384 "Unexpected number of elements");
6388 for (
unsigned i = 0; i < NumOperands; ++i) {
6389 SDValue
Op =
N->getOperand(i);
6391 Op = GetPromotedInteger(
Op);
6392 EVT SclrTy =
Op.getValueType().getVectorElementType();
6393 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6394 "Unexpected number of elements");
6396 for (
unsigned j = 0;
j < NumElem; ++
j) {
6398 DAG.getVectorIdxConstant(j, dl));
6399 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6403 return DAG.getBuildVector(NOutVT, dl,
Ops);
6406SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6407 EVT VT =
N->getValueType(0);
6408 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6409 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6417 if (getTypeAction(
N->getOperand(0).getValueType())
6421 switch(
N->getOpcode()) {
6423 Promoted = SExtPromotedInteger(
N->getOperand(0));
6426 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6429 Promoted = GetPromotedInteger(
N->getOperand(0));
6441 DAG.getVectorIdxConstant(0, dl));
6443 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6447 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6450SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6451 EVT VT =
N->getValueType(0);
6452 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6456SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6457 EVT VT =
N->getValueType(0);
6458 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6463 EVT VT =
N->getValueType(0);
6464 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6466 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6470SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6472 EVT VT =
N->getValueType(0);
6473 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6474 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6475 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6479SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6480 EVT OutVT =
N->getValueType(0);
6481 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6482 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6487 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6490 NOutVTElem,
N->getOperand(1));
6492 V0, ConvElem,
N->getOperand(2));
6499 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6500 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6508 SDValue
Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6509 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6510 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6514 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6517 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6518 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6524 SDValue From[] = {SDValue(
N, 1), SDValue(
N, 2)};
6526 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6531SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6534 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6536 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6537 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
6538 return DAG.getPOISON(NVT);
6541SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6543 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6544 SDValue
V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6545 TLI.getVectorIdxTy(DAG.getDataLayout()));
6547 V0->getValueType(0).getScalarType(), V0,
V1);
6552 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6555SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6559 SDValue
V0 =
N->getOperand(0);
6560 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6563 V1.getValueType().getVectorElementType(),
6564 V0.getValueType().getVectorElementCount());
6565 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6567 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6574 SDValue
V0 =
N->getOperand(0);
6575 SDValue
V1 =
N->getOperand(1);
6576 EVT InVT1 =
V1.getValueType();
6579 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6580 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6583SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6585 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6586 MVT InVT =
V0.getValueType().getSimpleVT();
6593SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6596 EVT ResVT =
N->getValueType(0);
6597 unsigned NumElems =
N->getNumOperands();
6600 SDValue ResVec = DAG.getPOISON(ResVT);
6602 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6603 SDValue
Op =
N->getOperand(OpIdx);
6604 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6606 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6618 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6619 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6623 for (
unsigned i=0; i<NumElem; ++i) {
6626 DAG.getVectorIdxConstant(i, dl));
6632 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6635SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6637 SDValue
Op =
N->getOperand(OpNo);
6648 for (
unsigned I = 0;
I < OpNo;
I++)
6651 EVT Ty =
Op.getValueType();
6652 SDLoc
DL = SDLoc(
N);
6655 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6663 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6666 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6668 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6669 ReplaceValueWith(SDValue(
N, ResNum),
NewNode.getValue(ResNum));
6674SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6676 SDValue
Op =
N->getOperand(OpNo);
6687 for (
unsigned I = 0;
I < OpNo;
I++)
6690 EVT Ty =
Op.getValueType();
6691 SDLoc
DL = SDLoc(
N);
6694 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6702 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6705 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6707 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6708 ReplaceValueWith(SDValue(
N, ResNum),
NewNode.getValue(ResNum));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isSigned(unsigned Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
const SmallVectorImpl< MachineOperand > & Cond
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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*X will result in a value whose quantity matches our ...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS*X will result in a value whose quantity matches our own.
constexpr 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.
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ LOOP_DEPENDENCE_RAW_MASK
@ COND_LOOP
COND_LOOP is a conditional branch to self, used for implementing efficient conditional traps.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_MATCH
VECTOR_MATCH - this corresponds to the llvm.experimental.vector.match intrinsic.
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_REPEAT
VECTOR_REPEAT(FIXED_LENGTH_VECTOR) Repeatedly copies the elements of the source fixed-length vector t...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
The llvm.loop.dependence.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)