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);
132 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
135 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
137 Res = PromoteIntRes_BUILD_VECTOR(
N);
141 Res = PromoteIntRes_ScalarOp(
N);
145 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
150 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
153 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
157 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
160 Res = PromoteIntRes_VECTOR_MATCH(
N);
166 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
180 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
184 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
187 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
191 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
200 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
208 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
216 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
220 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
224 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
228 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
230 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
232 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
248 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
253 Res = PromoteIntRes_CMP(
N);
268 Res = PromoteIntRes_ABS(
N);
302 Res = PromoteIntRes_VECREDUCE(
N);
305 case ISD::VP_REDUCE_ADD:
306 case ISD::VP_REDUCE_MUL:
307 case ISD::VP_REDUCE_AND:
308 case ISD::VP_REDUCE_OR:
309 case ISD::VP_REDUCE_XOR:
310 case ISD::VP_REDUCE_SMAX:
311 case ISD::VP_REDUCE_SMIN:
312 case ISD::VP_REDUCE_UMAX:
313 case ISD::VP_REDUCE_UMIN:
314 Res = PromoteIntRes_VP_REDUCE(
N);
319 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
323 Res = PromoteIntRes_FREEZE(
N);
328 Res = PromoteIntRes_Rotate(
N);
333 Res = PromoteIntRes_FunnelShift(
N);
339 Res = PromoteIntRes_CLMUL(
N);
343 Res = PromoteIntRes_PEXT(
N);
347 Res = PromoteIntRes_PDEP(
N);
352 Res = PromoteIntRes_MULH(
N);
356 Res = PromoteIntRes_IS_FPCLASS(
N);
359 Res = PromoteIntRes_FFREXP(
N);
364 Res = PromoteIntRes_XRINT(
N);
368 Res = PromoteIntRes_PATCHPOINT(
N);
371 Res = PromoteIntRes_READ_REGISTER(
N);
377 SetPromotedInteger(
SDValue(
N, ResNo), Res);
382 SDValue
Op = DisintegrateMERGE_VALUES(
N, ResNo);
383 return GetPromotedInteger(
Op);
386SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
388 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
389 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
394 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
396 Op.getValueType(),
Op,
N->getOperand(1));
401 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
403 Op.getValueType(),
Op,
N->getOperand(1));
407 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
410 switch (TLI.getExtendForAtomicOps()) {
426 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
427 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
431 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
437 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
439 Op2 = SExtPromotedInteger(Op2);
442 Op2 = ZExtPromotedInteger(Op2);
445 Op2 = GetPromotedInteger(Op2);
450 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
452 N->getChain(),
N->getBasePtr(),
453 Op2,
N->getMemOperand());
456 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
464 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
465 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
469 if (!TLI.isTypeLegal(SVT))
472 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
473 SDValue Res = DAG.getAtomicCmpSwap(
475 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
477 ReplaceValueWith(SDValue(
N, 0), Res.
getValue(0));
478 ReplaceValueWith(SDValue(
N, 2), Res.
getValue(2));
479 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
485 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
486 switch (TLI.getExtendForAtomicCmpSwapArg()) {
488 Op2 = SExtPromotedInteger(Op2);
491 Op2 = ZExtPromotedInteger(Op2);
494 Op2 = GetPromotedInteger(Op2);
501 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
502 SDValue Res = DAG.getAtomicCmpSwap(
503 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
504 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
506 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
507 ReplaceValueWith(SDValue(
N, i), Res.
getValue(i));
514 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
515 EVT OutVT =
N->getValueType(0);
516 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
519 switch (getTypeAction(InVT)) {
525 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
529 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
532 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
540 BitConvertToInteger(GetScalarizedVector(InOp)));
549 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
550 Lo = BitConvertToInteger(
Lo);
551 Hi = BitConvertToInteger(
Hi);
553 if (DAG.getDataLayout().isBigEndian())
559 JoinIntegers(
Lo,
Hi));
574 if (DAG.getDataLayout().isBigEndian()) {
578 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
593 if (isTypeLegal(WideOutVT)) {
594 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
596 DAG.getVectorIdxConstant(0, dl));
605 DAG.getDataLayout().isLittleEndian()) {
616 if (isTypeLegal(WideVecVT)) {
618 DAG.getUNDEF(WideVecVT), InOp,
619 DAG.getVectorIdxConstant(0, dl));
627 CreateStackStoreLoad(InOp, OutVT));
631 SDValue
V = GetPromotedInteger(
N->getOperand(0));
633 V.getValueType(), V);
637 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
638 EVT OVT =
N->getValueType(0);
639 EVT NVT =
Op.getValueType();
647 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
648 if (SDValue Res = TLI.expandBSWAP(
N, DAG))
653 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
659 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
660 EVT OVT =
N->getValueType(0);
661 EVT NVT =
Op.getValueType();
670 if (SDValue Res = TLI.expandBITREVERSE(
N, DAG))
675 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
684 TLI.getTypeToTransformTo(*DAG.getContext(),
685 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
690 EVT VT =
N->getValueType(0);
697 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
704 EVT OVT =
N->getValueType(0);
705 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
711 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
712 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
714 if (SDValue Result = TLI.expandCTLZ(
N, DAG)) {
720 unsigned CtlzOpcode =
N->getOpcode();
723 SDValue ExtractLeadingBits = DAG.getConstant(
726 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
730 return DAG.getNode(
ISD::SUB, dl, NVT,
731 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
736 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
740 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
742 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
748 EVT OVT =
N->getValueType(0);
749 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
752 SDValue ExtractLeadingBits = DAG.getConstant(
755 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
761 EVT OVT =
N->getValueType(0);
762 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
770 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
771 if (SDValue Result = TLI.expandCTPOP(
N, DAG)) {
778 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
779 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
783 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
784 EVT OVT =
N->getValueType(0);
785 EVT NVT =
Op.getValueType();
792 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
793 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
797 if (SDValue Result = TLI.expandCTTZ(
N, DAG)) {
803 unsigned NewOpc =
N->getOpcode();
810 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
813 return DAG.getNode(NewOpc, dl, NVT,
Op);
816SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
818 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
819 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
822SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
824 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
826 SDValue Op0 =
N->getOperand(0);
827 SDValue Op1 =
N->getOperand(1);
831 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
833 SDValue
In = GetPromotedInteger(Op0);
837 EVT SVT =
In.getValueType().getScalarType();
840 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
848 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
850 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
854 if (
N->isStrictFPOpcode()) {
855 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
856 {
N->getOperand(0),
N->getOperand(1)});
859 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
861 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
876 DAG.getValueType(
N->getValueType(0).getScalarType()));
879SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
881 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
883 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
887SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
888 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
891 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
896SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
897 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
901 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
904SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
905 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
908 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
909 N->getOperand(0),
N->getOperand(1));
910 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
915 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
917 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
921 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
925 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
929 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
934 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
937 if (getTypeAction(
N->getOperand(0).getValueType())
939 SDValue Res = GetPromotedInteger(
N->getOperand(0));
948 DAG.getValueType(
N->getOperand(0).getValueType()));
950 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
957 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
962 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
966 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
967 N->getMemoryVT(),
N->getMemOperand());
971 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
976 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
977 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
980 :
N->getExtensionType();
983 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
984 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
985 N->getMemOperand(),
N->isExpandingLoad());
988 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
993 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
994 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1001 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1002 N->getOffset(),
N->getMask(), ExtPassThru,
1003 N->getMemoryVT(),
N->getMemOperand(),
1004 N->getAddressingMode(), ExtType,
1005 N->isExpandingLoad());
1008 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1013 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1014 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1016 "Gather result type and the passThru argument type should be the same");
1023 SDValue
Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1024 N->getIndex(),
N->getScale() };
1025 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1026 N->getMemoryVT(), dl,
Ops,
1027 N->getMemOperand(),
N->getIndexType(),
1031 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1035SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1036 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1037 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1039 N->getOperand(1), Passthru);
1046 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1047 EVT VT =
N->getValueType(0);
1048 EVT SVT = getSetCCResultType(VT);
1049 SDValue
Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1050 unsigned NumOps =
N->getNumOperands();
1053 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1056 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, SVT),
1061 ReplaceValueWith(SDValue(
N, 0), Res);
1064 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1085 SExtOrZExtPromotedOperands(Op1, Op2);
1091 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1093 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1094 Op1 = SExtPromotedInteger(Op1);
1095 Op2 = SExtPromotedInteger(Op2);
1099 Op1 = ZExtPromotedInteger(Op1);
1100 Op2 = ZExtPromotedInteger(Op2);
1103 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1104 SDValue
Add = DAG.getNode(
ISD::ADD, dl, NVT, Op1, Op2);
1112 Op1 = GetPromotedInteger(Op1);
1114 Op2 = ZExtPromotedInteger(Op2);
1116 Op1 = SExtPromotedInteger(Op1);
1117 Op2 = SExtPromotedInteger(Op2);
1124 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1137 "addition, subtraction or left shift");
1140 unsigned SHLAmount = NewBits - OldBits;
1141 SDValue ShiftAmount =
1142 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1147 SDValue
Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1148 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1154 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1155 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1156 SDValue
Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1165 SDValue Op1Promoted, Op2Promoted;
1171 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1172 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1174 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1175 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1177 EVT OldType =
N->getOperand(0).getValueType();
1189 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1190 SDValue
Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1191 Op2Promoted,
N->getOperand(2));
1193 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1194 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1196 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1201 unsigned SatW,
bool Signed,
1204 EVT VT = V.getValueType();
1231 EVT VT =
LHS.getValueType();
1247 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1253 "Tried to saturate to more than the original type?");
1262 SDValue Op1Promoted, Op2Promoted;
1268 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1269 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1271 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1272 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1275 unsigned Scale =
N->getConstantOperandVal(2);
1279 if (TLI.isTypeLegal(PromotedType)) {
1281 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1284 N->getValueType(0).getScalarSizeInBits();
1288 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1289 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1290 Op2Promoted,
N->getOperand(2));
1293 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1299 if (SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1300 Op2Promoted, Scale, DAG)) {
1303 N->getValueType(0).getScalarSizeInBits(),
1311 N->getValueType(0).getScalarSizeInBits());
1314SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1316 return PromoteIntRes_Overflow(
N);
1320 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1321 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1322 EVT OVT =
N->getOperand(0).getValueType();
1323 EVT NVT =
LHS.getValueType();
1333 DAG.getValueType(OVT));
1335 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1338 ReplaceValueWith(SDValue(
N, 1), Ofl);
1344 EVT PromotedResultTy =
1345 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1346 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1347 N->getOperand(0),
N->getOperand(1));
1351 SDValue
Mask =
N->getOperand(0);
1353 SDValue
LHS = GetPromotedInteger(
N->getOperand(1));
1354 SDValue
RHS = GetPromotedInteger(
N->getOperand(2));
1356 unsigned Opcode =
N->getOpcode();
1357 if (Opcode == ISD::VP_MERGE)
1358 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1360 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1364 SDValue
LHS = GetPromotedInteger(
N->getOperand(2));
1365 SDValue
RHS = GetPromotedInteger(
N->getOperand(3));
1367 LHS.getValueType(),
N->getOperand(0),
1368 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1373 EVT InVT =
N->getOperand(OpNo).getValueType();
1374 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1376 EVT SVT = getSetCCResultType(InVT);
1383 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1384 SVT = getSetCCResultType(InVT);
1392 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1393 "Vector compare must return a vector result!");
1397 if (
N->isStrictFPOpcode()) {
1398 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1399 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1400 N->getOperand(2),
N->getOperand(3)};
1401 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1404 ReplaceValueWith(SDValue(
N, 1), SetCC.
getValue(1));
1406 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1407 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1410 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1415 SDValue Arg =
N->getOperand(0);
1416 SDValue
Test =
N->getOperand(1);
1417 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1422 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1423 EVT VT =
N->getValueType(0);
1427 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1429 ReplaceValueWith(SDValue(
N, 0), Res);
1434 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1435 SDValue
RHS =
N->getOperand(1);
1437 RHS = ZExtPromotedInteger(
RHS);
1438 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1441SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1442 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
1444 Op.getValueType(),
Op,
N->getOperand(1));
1447SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1451 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1452 SDValue
RHS = GetPromotedInteger(
N->getOperand(1));
1453 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1458 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1459 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1460 if (
N->getNumOperands() == 2)
1461 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1462 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1463 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1464 "Expected VP opcode");
1465 SDValue
Mask =
N->getOperand(2);
1466 SDValue EVL =
N->getOperand(3);
1467 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1473 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1474 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1475 if (
N->getNumOperands() == 2)
1476 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1477 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1478 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1479 "Expected VP opcode");
1481 SDValue
Mask =
N->getOperand(2);
1487SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1488 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1489 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1490 SDValue
Mask =
N->getOperand(2);
1491 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1495SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1496 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1497 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1498 SDValue
Mask =
N->getOperand(2);
1499 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1504 SDValue
LHS =
N->getOperand(0);
1505 SDValue
RHS =
N->getOperand(1);
1509 SExtOrZExtPromotedOperands(
LHS,
RHS);
1511 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1517 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1518 SDValue
RHS =
N->getOperand(1);
1520 RHS = ZExtPromotedInteger(
RHS);
1521 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1525 SDValue
RHS =
N->getOperand(1);
1527 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1529 RHS = ZExtPromotedInteger(
RHS);
1530 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1535 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1536 SDValue Amt =
N->getOperand(1);
1537 unsigned Opcode =
N->getOpcode();
1548 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1551 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1553 Amt = ZExtPromotedInteger(Amt);
1559 DAG.getConstant(OldBits,
DL, AmtVT));
1560 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1561 SDValue
Hi = DAG.getNode(
ISD::SHL,
DL, VT, Op0, HiShift);
1562 SDValue
Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1574 SDValue Res = TLI.expandROT(
N,
true , DAG);
1575 ReplaceValueWith(SDValue(
N, 0), Res);
1580 SDValue
Hi = GetPromotedInteger(
N->getOperand(0));
1581 SDValue
Lo = GetPromotedInteger(
N->getOperand(1));
1584 Amt = ZExtPromotedInteger(Amt);
1588 EVT OldVT =
N->getOperand(0).getValueType();
1589 EVT VT =
Lo.getValueType();
1590 unsigned Opcode =
N->getOpcode();
1597 DAG.getConstant(OldBits,
DL, AmtVT));
1605 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1606 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1608 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1618 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1624 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1626 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1630 unsigned Opcode =
N->getOpcode();
1633 EVT OldVT =
N->getOperand(0).getValueType();
1634 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1639 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1641 TLI.isOperationLegalOrCustom(
1642 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1643 if (SDValue Res = TLI.expandCLMUL(
N, DAG))
1646 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1647 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1651 SDValue
X = ZExtPromotedInteger(
N->getOperand(0));
1652 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1656 if (NewBits < 2 * OldBits) {
1658 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1660 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1662 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1664 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1669 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1671 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1676 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1677 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1678 if (SDValue Res = TLI.expandPEXT(
N, DAG))
1683 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1684 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1690 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1691 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1692 if (SDValue Res = TLI.expandPDEP(
N, DAG))
1697 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1698 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1704 EVT VT =
N->getValueType(0);
1705 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1712 LHS = SExtPromotedInteger(
N->getOperand(0));
1713 RHS = SExtPromotedInteger(
N->getOperand(1));
1715 LHS = ZExtPromotedInteger(
N->getOperand(0));
1716 RHS = ZExtPromotedInteger(
N->getOperand(1));
1723 DAG.getShiftAmountConstant(BW, NVT, dl));
1727 DAG.getShiftAmountConstant(NBW - BW, NVT, dl));
1728 return DAG.getNode(
N->getOpcode(), dl, NVT,
LHS,
RHS);
1732 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1744 Res = GetPromotedInteger(InOp);
1751 "Dst and Src must have the same number of elements");
1753 "Promoted vector type must be a power of two");
1756 GetSplitVector(InOp, EOp1, EOp2);
1765 SDValue WideInOp = GetWidenedVector(InOp);
1770 N->getValueType(0).getScalarType(), NumElem);
1771 SDValue WideTrunc = DAG.getNode(
ISD::TRUNCATE, dl, TruncVT, WideInOp);
1779 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1788SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1790 return PromoteIntRes_Overflow(
N);
1794 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1795 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1796 EVT OVT =
N->getOperand(0).getValueType();
1797 EVT NVT =
LHS.getValueType();
1806 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1808 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1811 ReplaceValueWith(SDValue(
N, 1), Ofl);
1822 return PromoteIntRes_Overflow(
N);
1834 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1835 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1837 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1840 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1844 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1846 return SDValue(Res.
getNode(), 0);
1851 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1852 return PromoteIntRes_Overflow(
N);
1856 EVT OVT =
N->getValueType(0);
1857 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1863 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1865 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1866 if (SDValue Res = TLI.expandABS(
N, DAG))
1870 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1874SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1877 return PromoteIntRes_Overflow(
N);
1879 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
1881 EVT SmallVT =
LHS.getValueType();
1888 LHS = SExtPromotedInteger(
LHS);
1889 RHS = SExtPromotedInteger(
RHS);
1891 LHS = ZExtPromotedInteger(
LHS);
1892 RHS = ZExtPromotedInteger(
RHS);
1894 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1895 SDValue
Mul = DAG.getNode(
N->getOpcode(),
DL, VTs,
LHS,
RHS);
1906 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1907 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1908 DAG.getConstant(0,
DL,
Hi.getValueType()),
1913 Mul, DAG.getValueType(SmallVT));
1920 SDValue(
Mul.getNode(), 1));
1923 ReplaceValueWith(SDValue(
N, 1), Overflow);
1928 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1929 N->getValueType(0)));
1933 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1935 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1942 EVT VT =
N->getValueType(0);
1945 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1946 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1950 for (
unsigned i = 0; i < NumRegs; ++i) {
1951 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1952 N->getConstantOperandVal(3));
1957 if (DAG.getDataLayout().isBigEndian())
1958 std::reverse(Parts.begin(), Parts.end());
1961 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1963 for (
unsigned i = 1; i < NumRegs; ++i) {
1968 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1974 ReplaceValueWith(SDValue(
N, 1), Chain);
1987bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1989 SDValue Res = SDValue();
1990 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1995 switch (
N->getOpcode()) {
1998 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1999 N->dump(&DAG);
dbgs() <<
"\n";
2005 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2011 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2012 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2017 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2021 Res = PromoteIntOp_FAKE_USE(
N);
2024 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2028 Res = PromoteIntOp_ScalarOp(
N);
2031 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2033 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2051 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2058 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2073 Res = PromoteIntOp_Shift(
N);
2077 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2080 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2106 case ISD::VP_REDUCE_ADD:
2107 case ISD::VP_REDUCE_MUL:
2108 case ISD::VP_REDUCE_AND:
2109 case ISD::VP_REDUCE_OR:
2110 case ISD::VP_REDUCE_XOR:
2111 case ISD::VP_REDUCE_SMAX:
2112 case ISD::VP_REDUCE_SMIN:
2113 case ISD::VP_REDUCE_UMAX:
2114 case ISD::VP_REDUCE_UMIN:
2115 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2120 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2123 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2126 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2128 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2129 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2130 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2132 case ISD::EXPERIMENTAL_VP_SPLICE:
2133 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2136 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2141 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2144 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2147 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2153 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2158 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2162 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2167 if (!Res.
getNode())
return false;
2174 const bool IsStrictFp =
N->isStrictFPOpcode();
2176 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2177 "Invalid operand expansion");
2181 ReplaceValueWith(SDValue(
N, 0), Res);
2183 ReplaceValueWith(SDValue(
N, 1), SDValue(Res.
getNode(), 1));
2192 SDValue OpL = GetPromotedInteger(
LHS);
2193 SDValue OpR = GetPromotedInteger(
RHS);
2195 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2199 unsigned OpLEffectiveBits =
2200 DAG.computeKnownBits(OpL).countMaxActiveBits();
2201 unsigned OpREffectiveBits =
2202 DAG.computeKnownBits(OpR).countMaxActiveBits();
2203 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2204 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2211 LHS = SExtPromotedInteger(
LHS);
2212 RHS = SExtPromotedInteger(
RHS);
2221 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2222 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2223 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2224 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2231 LHS = ZExtPromotedInteger(
LHS);
2232 RHS = ZExtPromotedInteger(
RHS);
2246 LHS = SExtPromotedInteger(
LHS);
2247 RHS = SExtPromotedInteger(
RHS);
2252 "Unknown integer comparison!");
2254 SExtOrZExtPromotedOperands(
LHS,
RHS);
2258 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2262SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2263 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2264 EVT ResVT =
N->getValueType(0);
2265 EVT OpVT =
Op.getValueType();
2268 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2273 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2274 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2275 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2279 EVT OutVT =
N->getValueType(0);
2282 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2285 switch (getTypeAction(InVT)) {
2289 DAG.getDataLayout().isLittleEndian()) {
2299 if (isTypeLegal(WideVecVT)) {
2300 SDValue Promoted = GetPromotedInteger(InOp);
2301 SDValue Cast = DAG.getNode(
ISD::BITCAST, dl, WideVecVT, Promoted);
2303 DAG.getVectorIdxConstant(0, dl));
2316 return CreateStackStoreLoad(InOp, OutVT);
2319SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2320 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2322 SDValue
LHS =
N->getOperand(2);
2323 SDValue
RHS =
N->getOperand(3);
2328 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2329 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2333SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2334 assert(OpNo == 1 &&
"only know how to promote condition");
2337 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2340 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2341 N->getOperand(2)), 0);
2344SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2345 assert(OpNo == 1 &&
"only know how to promote condition");
2348 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2351 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2356 EVT OVT =
N->getOperand(0).getValueType();
2357 SDValue
Lo = ZExtPromotedInteger(
N->getOperand(0));
2358 SDValue
Hi = GetPromotedInteger(
N->getOperand(1));
2359 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2364 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2365 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2374 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2375 "Legal vector of one illegal element?");
2380 assert(
N->getOperand(0).getValueSizeInBits() >=
2381 N->getValueType(0).getScalarSizeInBits() &&
2382 "Type of inserted value narrower than vector element type!");
2385 for (
unsigned i = 0; i < NumElts; ++i)
2386 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2388 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2391SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2398 assert(
N->getOperand(1).getValueSizeInBits() >=
2399 N->getValueType(0).getScalarSizeInBits() &&
2400 "Type of inserted value narrower than vector element type!");
2401 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2402 GetPromotedInteger(
N->getOperand(1)),
2407 assert(OpNo == 2 &&
"Different operand and result vector types?");
2410 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2411 TLI.getVectorIdxTy(DAG.getDataLayout()));
2412 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2413 N->getOperand(1), Idx), 0);
2417 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2421 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2424SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2425 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2426 SDValue
Cond =
N->getOperand(0);
2427 EVT OpTy =
N->getOperand(1).getValueType();
2430 if (SDValue Res = WidenVSELECTMask(
N))
2431 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2432 Res,
N->getOperand(1),
N->getOperand(2));
2436 Cond = PromoteTargetBoolean(
Cond, OpVT);
2438 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2439 N->getOperand(2)), 0);
2442SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2443 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2445 SDValue
LHS =
N->getOperand(0);
2446 SDValue
RHS =
N->getOperand(1);
2450 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2),
2451 N->getOperand(3),
N->getOperand(4)), 0);
2454SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2455 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2457 SDValue
LHS =
N->getOperand(0);
2458 SDValue
RHS =
N->getOperand(1);
2462 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2466 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2467 ZExtPromotedInteger(
N->getOperand(1))), 0);
2471 SDValue
LHS =
N->getOperand(0);
2472 SDValue
RHS =
N->getOperand(1);
2475 LHS = SExtPromotedInteger(
LHS);
2476 RHS = SExtPromotedInteger(
RHS);
2478 SExtOrZExtPromotedOperands(
LHS,
RHS);
2481 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS), 0);
2485 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2486 ZExtPromotedInteger(
N->getOperand(2))), 0);
2490 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2494 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2498 return SDValue(DAG.UpdateNodeOperands(
N,
2499 SExtPromotedInteger(
N->getOperand(0))), 0);
2502SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2503 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2504 SExtPromotedInteger(
N->getOperand(1))), 0);
2509 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2512 SDValue Val = GetPromotedInteger(
N->getValue());
2515 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2516 N->getMemoryVT(),
N->getMemOperand());
2522 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2523 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2525 SDValue DataOp = GetPromotedInteger(
N->getValue());
2526 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2527 N->getMask(),
N->getVectorLength(),
2528 N->getMemoryVT(),
N->getMemOperand(),
2529 N->isCompressingStore());
2534 SDValue DataOp =
N->getValue();
2535 SDValue
Mask =
N->getMask();
2540 Mask = PromoteTargetBoolean(Mask, DataVT);
2543 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2546 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2547 DataOp = GetPromotedInteger(DataOp);
2549 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2550 N->getOffset(), Mask,
N->getMemoryVT(),
2551 N->getMemOperand(),
N->getAddressingMode(),
2552 true,
N->isCompressingStore());
2557 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2558 EVT DataVT =
N->getValueType(0);
2559 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2561 NewOps[OpNo] =
Mask;
2562 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2564 return SDValue(Res, 0);
2567 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2568 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2578 EVT DataVT =
N->getValueType(0);
2579 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2580 }
else if (OpNo == 4) {
2582 if (
N->isIndexSigned())
2584 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2586 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2588 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2590 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2592 return SDValue(Res, 0);
2595 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2596 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2602 bool TruncateStore =
N->isTruncatingStore();
2607 EVT DataVT =
N->getValue().getValueType();
2608 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2609 }
else if (OpNo == 4) {
2611 if (
N->isIndexSigned())
2613 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2615 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2617 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2618 TruncateStore =
true;
2621 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2622 SDLoc(
N), NewOps,
N->getMemOperand(),
2623 N->getIndexType(), TruncateStore);
2628 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2632 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2637 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2642 return SDValue(DAG.UpdateNodeOperands(
N,
2643 ZExtPromotedInteger(
N->getOperand(0))), 0);
2646SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2647 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2652SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2653 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2654 ZExtPromotedInteger(
N->getOperand(1))), 0);
2659 SDValue Src =
N->getOperand(0);
2660 SDValue
Op = GetPromotedInteger(Src);
2661 EVT VT =
N->getValueType(0);
2666 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2667 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2668 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2669 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2674 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2678 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2680 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2683SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2685 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
2686 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2691 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
2695 unsigned OpOffset = IsStrict ? 1 : 0;
2699 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2702 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2703 if (LCImpl == RTLIB::Unsupported) {
2709 if (IsPowI &&
N->getValueType(0).isVector())
2710 return DAG.UnrollVectorOp(
N);
2712 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2713 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2725 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2726 DAG.getLibInfo().getIntSize()) {
2727 const Function &Fn = DAG.getMachineFunction().getFunction();
2728 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2729 Twine(IsPowI ?
"powi" :
"ldexp") +
2730 " exponent does not match sizeof(int)",
2731 Fn, N->getDebugLoc()));
2733 ReplaceValueWith(SDValue(N, 1), Chain);
2734 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2738 TargetLowering::MakeLibCallOptions CallOptions;
2739 CallOptions.setIsSigned(
true);
2740 SDValue
Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2741 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2742 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2743 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
2745 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
2750 switch (
N->getOpcode()) {
2758 case ISD::VP_REDUCE_ADD:
2759 case ISD::VP_REDUCE_MUL:
2760 case ISD::VP_REDUCE_AND:
2761 case ISD::VP_REDUCE_OR:
2762 case ISD::VP_REDUCE_XOR:
2766 case ISD::VP_REDUCE_SMAX:
2767 case ISD::VP_REDUCE_SMIN:
2771 case ISD::VP_REDUCE_UMAX:
2772 case ISD::VP_REDUCE_UMIN:
2782 return GetPromotedInteger(V);
2784 return SExtPromotedInteger(V);
2786 return ZExtPromotedInteger(V);
2792 SDValue
Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2794 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2795 EVT InVT =
Op.getValueType();
2797 EVT ResVT =
N->getValueType(0);
2798 unsigned Opcode =
N->getOpcode();
2815 switch (TLI.getBooleanContents(InVT)) {
2818 Op = ZExtPromotedInteger(
N->getOperand(0));
2821 Op = SExtPromotedInteger(
N->getOperand(0));
2834 switch (TLI.getBooleanContents(InVT)) {
2837 Op = ZExtPromotedInteger(
N->getOperand(0));
2840 Op = SExtPromotedInteger(
N->getOperand(0));
2846 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2850 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2854SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2856 SDValue
Op =
N->getOperand(OpNo);
2861 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2862 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2865 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2867 Op = PromoteIntOpVectorReduction(
N,
Op);
2871 EVT VT =
N->getValueType(0);
2872 EVT EltVT =
Op.getValueType().getScalarType();
2875 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2882 SDValue Reduce = DAG.
getNode(
N->getOpcode(),
DL, EltVT, NewOps);
2887 SDValue
Op = ZExtPromotedInteger(
N->getOperand(1));
2888 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2891SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2894 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2895 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2898SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2901 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2902 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2907 const Function &Fn = DAG.getMachineFunction().getFunction();
2909 "cannot use llvm.write_register with illegal type", Fn,
2911 return N->getOperand(0);
2914SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2915 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2916 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2919 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2920 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2922 return SDValue(Res, 0);
2925 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2926 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2930SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2934 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2935 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2938 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2940 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2941 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2944SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2946 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2948 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2949 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2952SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
2954 assert(OpNo == 0 &&
"Unexpected operand for promotion");
2955 SDValue
Op =
N->getOperand(0);
2958 if (TLI.getBooleanContents(
Op.getValueType()) ==
2960 NewOp = SExtPromotedInteger(
Op);
2962 NewOp = ZExtPromotedInteger(
Op);
2964 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
2967SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2969 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2970 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2971 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2974SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
2975 assert(OpNo < 3 &&
"Unexpected operand for promotion");
2977 return TLI.expandVectorMatch(
N, DAG);
2980 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
2981 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2984SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
2987 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
2988 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2991SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2993 switch (
N->getOpcode()) {
2995 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2996 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2999 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3000 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3003 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3004 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3009 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3012SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3014 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3015 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3016 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3018 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3029void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3032 Lo =
Hi = SDValue();
3035 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3038 switch (
N->getOpcode()) {
3041 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3042 N->dump(&DAG);
dbgs() <<
"\n";
3071 ExpandIntRes_ABS(
N,
Lo,
Hi);
3123 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3124 SplitInteger(Tmp.first,
Lo,
Hi);
3125 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
3130 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3131 SDValue Tmp = DAG.getAtomicCmpSwap(
3133 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3139 SDValue
Success = DAG.getSetCC(SDLoc(
N),
N->getValueType(1), Tmp,
3142 SplitInteger(Tmp,
Lo,
Hi);
3143 ReplaceValueWith(SDValue(
N, 1),
Success);
3144 ReplaceValueWith(SDValue(
N, 2), Tmp.
getValue(1));
3221 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3226 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3232 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3236 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3240 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3245 ExpandIntRes_MULH(
N,
Lo,
Hi);
3249 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3253 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3258 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3264 SetExpandedInteger(SDValue(
N, ResNo),
Lo,
Hi);
3268std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3269 unsigned Opc =
Node->getOpcode();
3275 EVT RetVT =
Node->getValueType(0);
3276 TargetLowering::MakeLibCallOptions CallOptions;
3279 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3280 if (LCImpl != RTLIB::Unsupported) {
3282 Ops.push_back(
Node->getOperand(1));
3285 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3286 "Unexpected atomic op or value type!");
3288 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3290 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3291 Node->getOperand(0));
3296void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3301 GetExpandedInteger(
N->getOperand(0), InL, InH);
3316 if (Amt.
uge(VTBits)) {
3317 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3318 }
else if (Amt.
ugt(NVTBits)) {
3319 Lo = DAG.getConstant(0,
DL, NVT);
3321 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3322 }
else if (Amt == NVTBits) {
3323 Lo = DAG.getConstant(0,
DL, NVT);
3327 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3329 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3331 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3336 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3338 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3345 if (Amt.
uge(VTBits)) {
3346 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3347 }
else if (Amt.
ugt(NVTBits)) {
3349 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3350 Hi = DAG.getConstant(0,
DL, NVT);
3351 }
else if (Amt == NVTBits) {
3353 Hi = DAG.getConstant(0,
DL, NVT);
3356 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3358 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3363 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3365 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3368 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3374 if (Amt.
uge(VTBits)) {
3376 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3377 }
else if (Amt.
ugt(NVTBits)) {
3379 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3381 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3382 }
else if (Amt == NVTBits) {
3385 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3388 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3390 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3395 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3397 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3400 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3408bool DAGTypeLegalizer::
3410 unsigned Opc =
N->getOpcode();
3411 SDValue
In =
N->getOperand(0);
3412 SDValue Amt =
N->getOperand(1);
3413 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3418 "Expanded integer type size not a power of two!");
3422 KnownBits
Known = DAG.computeKnownBits(Amt);
3425 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3430 GetExpandedInteger(In, InL, InH);
3434 if (
Known.One.intersects(HighBitMask)) {
3437 DAG.getConstant(~HighBitMask, dl, ShTy));
3442 Lo = DAG.getConstant(0, dl, NVT);
3443 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3446 Hi = DAG.getConstant(0, dl, NVT);
3447 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3451 DAG.getConstant(NVTBits - 1, dl, ShTy));
3452 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3463 SDValue Amt2 = DAG.getNode(
ISD::XOR, dl, ShTy, Amt,
3464 DAG.getConstant(NVTBits - 1, dl, ShTy));
3480 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3482 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3484 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3485 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3497bool DAGTypeLegalizer::
3500 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3504 "Expanded integer type size not a power of two!");
3509 GetExpandedInteger(
N->getOperand(0), InL, InH);
3511 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3512 SDValue AmtExcess = DAG.getNode(
ISD::SUB, dl, ShTy, Amt, NVBitsNode);
3513 SDValue AmtLack = DAG.getNode(
ISD::SUB, dl, ShTy, NVBitsNode, Amt);
3514 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3516 SDValue
isZero = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3517 Amt, DAG.getConstant(0, dl, ShTy),
3520 SDValue LoS, HiS, LoL, HiL;
3521 switch (
N->getOpcode()) {
3527 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3528 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3531 LoL = DAG.getConstant(0, dl, NVT);
3534 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3535 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3536 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3542 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3545 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3548 HiL = DAG.getConstant(0, dl, NVT);
3551 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3552 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3553 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3559 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3560 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3564 DAG.getConstant(NVTBits - 1, dl, ShTy));
3567 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3568 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3569 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3592 SDValue
LHS =
N->getOperand(0);
3593 SDValue
RHS =
N->getOperand(1);
3594 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3599 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3600 SplitInteger(Res,
Lo,
Hi);
3603void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3607 SDValue
LHS =
N->getOperand(0);
3608 SDValue
RHS =
N->getOperand(1);
3612 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3613 unsigned NumHalfBits = NumBits / 2;
3614 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3615 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3616 SDValue LHSL, LHSH, RHSL, RHSH;
3617 GetExpandedInteger(
LHS, LHSL, LHSH);
3618 GetExpandedInteger(
RHS, RHSL, RHSH);
3621 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3623 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3631 SDValue LHSL, LHSH, RHSL, RHSH;
3632 GetExpandedInteger(
LHS, LHSL, LHSH);
3633 GetExpandedInteger(
RHS, RHSL, RHSH);
3635 EVT CCT = getSetCCResultType(NVT);
3638 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3640 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3642 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3644 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3648 const APInt *RHSVal =
nullptr;
3650 RHSVal = &RHSConst->getAPIntValue();
3657 SDValue LHSL, LHSH, RHSL, RHSH;
3658 GetExpandedInteger(
LHS, LHSL, LHSH);
3659 GetExpandedInteger(
RHS, RHSL, RHSH);
3661 EVT CCT = getSetCCResultType(NVT);
3667 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3670 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3671 SDValue IsHiEq = DAG.getSetCC(
DL, CCT, LHSH, RHSH,
ISD::SETEQ);
3674 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3677 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3679 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3686 switch (
N->getOpcode()) {
3713 EVT VT =
N->getValueType(0);
3714 EVT CCT = getSetCCResultType(VT);
3717 SplitInteger(Result,
Lo,
Hi);
3721 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3722 SplitInteger(ExpandedCMP,
Lo,
Hi);
3725void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3729 SDValue LHSL, LHSH, RHSL, RHSH;
3730 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3731 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3734 SDValue LoOps[2] = { LHSL, RHSL };
3735 SDValue HiOps[3] = { LHSH, RHSH };
3737 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3739 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3741 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3745 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3751 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3764 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3766 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3769 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3783 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3785 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3789 EVT OvfVT = getSetCCResultType(NVT);
3790 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3801 SDValue OVF =
Lo.getValue(1);
3805 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3808 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3812 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3824 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3828 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3831 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3834 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3839 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3841 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3842 DAG.getConstant(0, dl, NVT));
3845 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3854 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3859 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3861 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3862 DAG.getConstant(0, dl, NVT));
3868void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3871 SDValue LHSL, LHSH, RHSL, RHSH;
3873 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3874 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3875 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3876 SDValue LoOps[2] = { LHSL, RHSL };
3877 SDValue HiOps[3] = { LHSH, RHSH };
3891 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
3894void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3897 SDValue LHSL, LHSH, RHSL, RHSH;
3899 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3900 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3901 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3902 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
3903 SDValue HiOps[3] = { LHSH, RHSH };
3905 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3907 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3911 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
3914void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3916 SDValue
LHS =
N->getOperand(0);
3917 SDValue
RHS =
N->getOperand(1);
3922 unsigned CarryOp, NoCarryOp;
3924 switch(
N->getOpcode()) {
3939 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3940 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3944 SDValue LHSL, LHSH, RHSL, RHSH;
3945 GetExpandedInteger(
LHS, LHSL, LHSH);
3946 GetExpandedInteger(
RHS, RHSL, RHSH);
3947 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3948 SDValue LoOps[2] = { LHSL, RHSL };
3949 SDValue HiOps[3] = { LHSH, RHSH };
3951 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3953 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3959 SDValue Sum = DAG.getNode(NoCarryOp, dl,
LHS.getValueType(),
LHS,
RHS);
3960 SplitInteger(Sum,
Lo,
Hi);
3966 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3967 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3971 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3976 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3982 ReplaceValueWith(SDValue(
N, 1), Ovf);
3988 SDValue LHSL, LHSH, RHSL, RHSH;
3990 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3991 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3992 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3993 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
3994 SDValue HiOps[3] = { LHSH, RHSH, SDValue() };
3996 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3998 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4002 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4005void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4008 SDValue LHSL, LHSH, RHSL, RHSH;
4010 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4011 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4012 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4017 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4018 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4022 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4025void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4027 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4029 SDValue
Op =
N->getOperand(0);
4030 if (
Op.getValueType().bitsLE(NVT)) {
4033 Hi = DAG.getUNDEF(NVT);
4037 assert(getTypeAction(
Op.getValueType()) ==
4039 "Only know how to promote this result!");
4040 SDValue Res = GetPromotedInteger(
Op);
4042 "Operand over promoted?");
4044 SplitInteger(Res,
Lo,
Hi);
4048void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4051 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4052 EVT NVT =
Lo.getValueType();
4057 if (NVTBits < EVTBits) {
4060 EVTBits - NVTBits)));
4065 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4069void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4072 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4073 EVT NVT =
Lo.getValueType();
4078 if (NVTBits < EVTBits) {
4081 EVTBits - NVTBits)));
4085 Hi = DAG.getConstant(0, dl, NVT);
4089void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4092 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4097void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4100 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4109 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4110 EVT NVT =
Lo.getValueType();
4113 Hi = DAG.getConstant(0, dl, NVT);
4116void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4118 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4121 const APInt &Cst =
Constant->getAPIntValue();
4122 bool IsTarget =
Constant->isTargetOpcode();
4123 bool IsOpaque =
Constant->isOpaque();
4125 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4126 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4133 SDValue N0 =
N->getOperand(0);
4134 GetExpandedInteger(N0,
Lo,
Hi);
4135 EVT NVT =
Lo.getValueType();
4140 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4145 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4146 Hi = DAG.getConstant(0, dl, NVT);
4156 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4159 SDValue Sign = DAG.getNode(
4161 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4162 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4171 EVT VT =
N->getValueType(0);
4172 SDValue Neg = DAG.getNode(
ISD::SUB, dl, VT,
4173 DAG.getConstant(0, dl, VT), N0);
4174 SDValue NegLo, NegHi;
4175 SplitInteger(Neg, NegLo, NegHi);
4177 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4179 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4180 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4183void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4187 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4188 EVT NVT =
Lo.getValueType();
4190 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4193 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4196 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4197 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4200 Hi = DAG.getConstant(0, dl, NVT);
4208 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4209 EVT NVT =
Lo.getValueType();
4212 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4213 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4215 SDValue HiCTLS = DAG.getNode(
ISD::CTLS, dl, NVT,
Hi);
4216 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4218 SDValue IsNegative =
4219 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4220 SDValue AdjustedLo =
4221 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4222 SDValue LoCLZ = DAG.getNode(
ISD::CTLZ, dl, NVT, AdjustedLo);
4223 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4224 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4226 Hi = DAG.getConstant(0, dl, NVT);
4230 SDValue
Result = TLI.expandABD(
N, DAG);
4231 SplitInteger(Result,
Lo,
Hi);
4235 SDValue
Op =
N->getOperand(0);
4236 EVT VT =
N->getValueType(0);
4241 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4242 "LibCall explicitly requested, but not available");
4244 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4245 TargetLowering::MakeLibCallOptions CallOptions;
4249 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4250 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4258 GetExpandedInteger(
Op,
Lo,
Hi);
4259 EVT NVT =
Lo.getValueType();
4262 Hi = DAG.getConstant(0,
DL, NVT);
4265void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4269 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4270 EVT NVT =
Lo.getValueType();
4272 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4276 SDValue HiLZ = DAG.
getNode(
N->getOpcode(), dl, NVT,
Hi);
4278 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4279 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4282 Hi = DAG.getConstant(0, dl, NVT);
4288 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4295 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4299 ReplaceValueWith(SDValue(
N, 1), Chain);
4307 Chain =
Op.getValue(1);
4316 EVT VT =
N->getValueType(0);
4320 bool IsStrict =
N->isStrictFPOpcode();
4321 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4322 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4326 Op.getValueType() == MVT::bf16) {
4332 EVT OpVT =
Op.getValueType();
4336 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4337 TargetLowering::MakeLibCallOptions CallOptions;
4342 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4343 CallOptions, dl, Chain);
4344 SplitInteger(Tmp.first,
Lo,
Hi);
4347 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4352 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4353 SplitInteger(Res,
Lo,
Hi);
4359 bool IsStrict =
N->isStrictFPOpcode();
4360 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4361 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4363 EVT VT =
Op.getValueType();
4365 if (VT == MVT::f16) {
4371 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4374 LC = RTLIB::getLROUND(VT);
4375 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4378 LC = RTLIB::getLRINT(VT);
4379 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4382 LC = RTLIB::getLLROUND(VT);
4383 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4386 LC = RTLIB::getLLRINT(VT);
4387 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4391 EVT RetVT =
N->getValueType(0);
4393 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4394 if (LCImpl == RTLIB::Unsupported) {
4395 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4396 N->getOperationName(&DAG));
4397 SDValue
Poison = DAG.getPOISON(
N->getValueType(0));
4399 if (
N->isStrictFPOpcode())
4400 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
4404 TargetLowering::MakeLibCallOptions CallOptions;
4406 std::pair<SDValue, SDValue> Tmp =
4407 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4408 SplitInteger(Tmp.first,
Lo,
Hi);
4410 if (
N->isStrictFPOpcode())
4411 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4414void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4416 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4419 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4425 EVT VT =
N->getValueType(0);
4426 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4427 SDValue Ch =
N->getChain();
4428 SDValue Ptr =
N->getBasePtr();
4431 AAMDNodes AAInfo =
N->getAAInfo();
4436 if (
N->getMemoryVT().bitsLE(NVT)) {
4437 EVT MemVT =
N->getMemoryVT();
4439 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4440 N->getBaseAlign(), MMOFlags, AAInfo);
4448 unsigned LoSize =
Lo.getValueSizeInBits();
4450 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4453 Hi = DAG.getConstant(0, dl, NVT);
4457 Hi = DAG.getUNDEF(NVT);
4459 }
else if (DAG.getDataLayout().isLittleEndian()) {
4461 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4464 unsigned ExcessBits =
4471 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4472 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4473 N->getBaseAlign(), MMOFlags, AAInfo);
4482 EVT MemVT =
N->getMemoryVT();
4485 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4488 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4491 N->getBaseAlign(), MMOFlags, AAInfo);
4497 N->getPointerInfo().getWithOffset(IncrementSize),
4499 N->getBaseAlign(), MMOFlags, AAInfo);
4511 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4515 DAG.getShiftAmountConstant(
4522 ReplaceValueWith(SDValue(
N, 1), Ch);
4525void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4528 SDValue LL, LH, RL, RH;
4529 GetExpandedInteger(
N->getOperand(0), LL, LH);
4530 GetExpandedInteger(
N->getOperand(1), RL, RH);
4534 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4536 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4537 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4540void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4542 EVT VT =
N->getValueType(0);
4543 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4546 SDValue LL, LH, RL, RH;
4547 GetExpandedInteger(
N->getOperand(0), LL, LH);
4548 GetExpandedInteger(
N->getOperand(1), RL, RH);
4550 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4557 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4558 if (LCImpl == RTLIB::Unsupported) {
4561 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4567 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4568 TargetLowering::MakeLibCallOptions CallOptions;
4570 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4577 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4578 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4579 SDValue
R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4582 ReplaceValueWith(SDValue(
N, 1),
R.getValue(2));
4586 SDValue
Result = TLI.expandAVG(
N, DAG);
4587 SplitInteger(Result,
Lo,
Hi);
4592 SDValue
Result = TLI.expandAddSubSat(
N, DAG);
4593 SplitInteger(Result,
Lo,
Hi);
4598 SDValue
Result = TLI.expandShlSat(
N, DAG);
4599 SplitInteger(Result,
Lo,
Hi);
4610 EVT VT =
N->getValueType(0);
4612 SDValue
LHS =
N->getOperand(0);
4613 SDValue
RHS =
N->getOperand(1);
4614 uint64_t Scale =
N->getConstantOperandVal(2);
4626 EVT BoolVT = getSetCCResultType(VT);
4628 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4629 SDValue Product =
Result.getValue(0);
4630 SDValue Overflow =
Result.getValue(1);
4634 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4635 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4636 SDValue
Zero = DAG.getConstant(0, dl, VT);
4640 SDValue ProdNeg = DAG.getSetCC(dl, BoolVT,
Xor, Zero,
ISD::SETLT);
4641 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4642 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4647 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4648 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4651 SplitInteger(Result,
Lo,
Hi);
4657 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4659 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4660 SDValue LL, LH, RL, RH;
4661 GetExpandedInteger(
LHS, LL, LH);
4662 GetExpandedInteger(
RHS, RL, RH);
4666 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4672 SDValue LoTmp, HiTmp;
4673 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4674 SplitInteger(LoTmp, Result[0], Result[1]);
4675 SplitInteger(HiTmp, Result[2], Result[3]);
4677 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4680 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4681 "the size of the current value type");
4703 if (Scale % NVTSize) {
4704 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4707 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4719 if (Scale == VTSize)
4734 SDValue ResultHL =
Result[2];
4735 SDValue ResultHH =
Result[3];
4737 SDValue SatMax, SatMin;
4738 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4739 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4740 EVT BoolNVT = getSetCCResultType(NVT);
4743 if (Scale < NVTSize) {
4745 SDValue HLAdjusted =
4746 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4747 DAG.getShiftAmountConstant(Scale, NVT, dl));
4748 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4749 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4750 }
else if (Scale == NVTSize) {
4752 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4753 }
else if (Scale < VTSize) {
4755 SDValue HLAdjusted =
4757 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4758 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4761 "(and saturation can't happen with Scale==VTSize).");
4763 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4764 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4768 if (Scale < NVTSize) {
4773 unsigned OverflowBits = VTSize - Scale + 1;
4774 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4775 "Extent of overflow bits must start within HL");
4776 SDValue HLHiMask = DAG.getConstant(
4778 SDValue HLLoMask = DAG.getConstant(
4781 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4782 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4783 SDValue HLUGT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLLoMask,
ISD::SETUGT);
4785 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4787 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4788 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4789 SDValue HLULT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLHiMask,
ISD::SETULT);
4791 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4792 }
else if (Scale == NVTSize) {
4794 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4795 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4796 SDValue HLNeg = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETLT);
4798 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4800 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4801 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4802 SDValue HLPos = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETGE);
4804 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4805 }
else if (Scale < VTSize) {
4808 unsigned OverflowBits = VTSize - Scale + 1;
4809 SDValue HHHiMask = DAG.getConstant(
4811 SDValue HHLoMask = DAG.getConstant(
4813 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4814 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4821 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4822 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4825 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4826 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4833 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4835 N->getConstantOperandVal(2), DAG);
4839 N->getConstantOperandVal(2), TLI, DAG);
4840 SplitInteger(Res,
Lo,
Hi);
4843void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4846 "Node has unexpected Opcode");
4847 SDValue
LHS =
Node->getOperand(0);
4848 SDValue
RHS =
Node->getOperand(1);
4856 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4857 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4861 SDValue LHSL, LHSH, RHSL, RHSH;
4862 GetExpandedInteger(
LHS, LHSL, LHSH);
4863 GetExpandedInteger(
RHS, RHSL, RHSH);
4864 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4867 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4876 SplitInteger(Sum,
Lo,
Hi);
4901 EVT VT =
LHS.getValueType();
4904 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4908 EVT OType =
Node->getValueType(1);
4909 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4913 ReplaceValueWith(SDValue(Node, 1), Ovf);
4916void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4918 EVT VT =
N->getValueType(0);
4920 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4929 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4931 TargetLowering::MakeLibCallOptions CallOptions;
4933 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4936void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4939 SDValue Shiftee =
N->getOperand(0);
4941 SDValue ShAmt =
N->getOperand(1);
4946 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4947 }
while (!TLI.isTypeLegal(LoadVT));
4952 "Shifting unit is not a a power of two!");
4954 const bool IsOneStepShift =
4955 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4960 if (!IsOneStepShift)
4961 ShAmt = DAG.getFreeze(ShAmt);
4964 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4965 unsigned VTByteWidth = VTBitWidth / 8;
4967 "Shiftee type size is not a power of two!");
4968 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4969 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4974 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4976 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4977 EVT PtrTy =
StackPtr.getValueType();
4978 SDValue Ch = DAG.getEntryNode();
4981 DAG.getMachineFunction(),
4987 unsigned WideningOpc =
4989 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4992 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4996 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5002 Flags.setExact(IsOneStepShift);
5003 SDValue SrlTmp = DAG.getNode(
5005 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5007 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5008 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5010 SDValue ByteOffset =
5011 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5016 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5023 if (DAG.getDataLayout().isBigEndian())
5024 WillIndexUpwards = !WillIndexUpwards;
5026 SDValue AdjStackPtr;
5027 if (WillIndexUpwards) {
5030 AdjStackPtr = DAG.getMemBasePlusOffset(
5031 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5032 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5036 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5037 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5041 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5046 if (!IsOneStepShift) {
5048 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5049 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5050 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5054 SplitInteger(Res,
Lo,
Hi);
5057void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5059 EVT VT =
N->getValueType(0);
5060 unsigned Opc =
N->getOpcode();
5066 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5070 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5087 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5089 const bool LegalOrCustom =
5093 unsigned ExpansionFactor = 1;
5095 for (EVT TmpVT = NVT;;) {
5096 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5097 if (NewTMPVT == TmpVT)
5104 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5107 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5109 if (LegalOrCustom &&
5113 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5119 SDValue ShiftOp =
N->getOperand(1);
5120 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5122 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5124 SDValue
Ops[] = { LHSL, LHSH, ShiftOp };
5125 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5126 Hi =
Lo.getValue(1);
5131 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5145 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5148 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5149 SDValue
Ops[2] = {
N->getOperand(0), ShAmt};
5150 TargetLowering::MakeLibCallOptions CallOptions;
5153 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5158 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5162void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5164 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5166 SDValue
Op =
N->getOperand(0);
5167 if (
Op.getValueType().bitsLE(NVT)) {
5173 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5177 assert(getTypeAction(
Op.getValueType()) ==
5179 "Only know how to promote this result!");
5180 SDValue Res = GetPromotedInteger(
Op);
5182 "Operand over promoted?");
5184 SplitInteger(Res,
Lo,
Hi);
5192void DAGTypeLegalizer::
5195 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5198 if (EVT.
bitsLE(
Lo.getValueType())) {
5206 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5207 Hi.getValueType(), dl));
5218void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5220 EVT VT =
N->getValueType(0);
5222 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5231 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5233 TargetLowering::MakeLibCallOptions CallOptions;
5235 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5238void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5240 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5250void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5252 EVT VT =
N->getValueType(0);
5270 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
5271 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5272 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5273 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5275 EVT BitVT =
N->getValueType(1);
5276 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5278 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5280 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5281 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5283 SDValue One = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, LHSHigh, RHSLow);
5286 SDValue Two = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, RHSHigh, LHSLow);
5289 SDValue HighSum = DAG.getNode(
ISD::ADD, dl, HalfVT, One, Two);
5297 SDValue Three = DAG.getNode(
ISD::MUL, dl, VT,
5300 SplitInteger(Three,
Lo,
Hi);
5304 ReplaceValueWith(SDValue(
N, 1), Overflow);
5309 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5314 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5318 if (LCImpl == RTLIB::Unsupported ||
5320 DAG.getMachineFunction().getName()) {
5322 SDValue MulLo, MulHi;
5323 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5324 N->getOperand(1), MulLo, MulHi);
5325 SDValue
SRA = DAG.getNode(
5329 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5330 SplitInteger(MulLo,
Lo,
Hi);
5331 ReplaceValueWith(SDValue(
N, 1), Overflow);
5335 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5338 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5339 MachinePointerInfo());
5342 for (
const SDValue &
Op :
N->op_values()) {
5343 EVT ArgVT =
Op.getValueType();
5345 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5346 Entry.IsSExt =
true;
5347 Entry.IsZExt =
false;
5348 Args.push_back(Entry);
5352 TargetLowering::ArgListEntry
Entry(
5354 Entry.IsSExt =
true;
5355 Entry.IsZExt =
false;
5356 Args.push_back(Entry);
5358 SDValue
Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5360 TargetLowering::CallLoweringInfo CLI(DAG);
5363 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5364 Func, std::move(Args))
5367 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5369 SplitInteger(CallInfo.first,
Lo,
Hi);
5371 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5372 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5373 DAG.getConstant(0, dl, PtrVT),
5376 ReplaceValueWith(SDValue(
N, 1), Ofl);
5379void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5381 EVT VT =
N->getValueType(0);
5383 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5393 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5395 if (isTypeLegal(NVT)) {
5397 GetExpandedInteger(
N->getOperand(0), InL, InH);
5399 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5408 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5410 TargetLowering::MakeLibCallOptions CallOptions;
5411 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5414void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5416 EVT VT =
N->getValueType(0);
5418 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5428 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5430 if (isTypeLegal(NVT)) {
5432 GetExpandedInteger(
N->getOperand(0), InL, InH);
5434 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5443 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5445 TargetLowering::MakeLibCallOptions CallOptions;
5446 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5449void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5451 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5453 SDValue
Op =
N->getOperand(0);
5454 if (
Op.getValueType().bitsLE(NVT)) {
5457 Hi = DAG.getConstant(0, dl, NVT);
5461 assert(getTypeAction(
Op.getValueType()) ==
5463 "Only know how to promote this result!");
5464 SDValue Res = GetPromotedInteger(
Op);
5466 "Operand over promoted?");
5468 SplitInteger(Res,
Lo,
Hi);
5470 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5476void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5480 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5481 SDValue
Zero = DAG.getConstant(0, dl, VT);
5482 SDValue
Swap = DAG.getAtomicCmpSwap(
5487 ReplaceValueWith(SDValue(
N, 0),
Swap.getValue(0));
5488 ReplaceValueWith(SDValue(
N, 1),
Swap.getValue(2));
5491void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5495 SDValue Res = TLI.expandVecReduce(
N, DAG);
5496 SplitInteger(Res,
Lo,
Hi);
5499void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5504 SDValue Res = DAG.
getNode(Opcode,
DL,
N->getValueType(0),
N->getOperand(0),
5505 N->getOperand(0),
N->getOperand(1));
5506 SplitInteger(Res,
Lo,
Hi);
5512 SDValue In1, In2, In3, In4;
5513 GetExpandedInteger(
N->getOperand(0), In3, In4);
5514 GetExpandedInteger(
N->getOperand(1), In1, In2);
5518 unsigned Opc =
N->getOpcode();
5521 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5525 SDValue AndNode = DAG.getNode(
ISD::AND,
DL, ShAmtVT, ShAmt,
5526 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5528 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5532 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5533 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5538 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5539 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5544 SDValue Res = TLI.expandCLMUL(
N, DAG);
5545 return SplitInteger(Res,
Lo,
Hi);
5548 SDValue LL, LH, RL, RH;
5549 GetExpandedInteger(
N->getOperand(0), LL, LH);
5550 GetExpandedInteger(
N->getOperand(1), RL, RH);
5561 SDValue HiLoCross1 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LL, RH);
5562 SDValue HiLoCross2 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LH, RL);
5563 SDValue HiLoCross = DAG.getNode(
ISD::XOR,
DL, HalfVT, HiLoCross1, HiLoCross2);
5564 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5568 SDValue Res = TLI.expandPEXT(
N, DAG);
5569 SplitInteger(Res,
Lo,
Hi);
5573 SDValue Res = TLI.expandPDEP(
N, DAG);
5574 SplitInteger(Res,
Lo,
Hi);
5578 SDValue Res = TLI.expandMULH(
N, DAG);
5579 SplitInteger(Res,
Lo,
Hi);
5584 EVT VT =
N->getValueType(0);
5591 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5594 SplitInteger(Res,
Lo,
Hi);
5601 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5602 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
5604 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5605 Lo = DAG.getPOISON(LoVT);
5606 Hi = DAG.getPOISON(HiVT);
5613 EVT VT =
N->getSimpleValueType(0);
5614 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5616 "VectorIdxTy should be smaller than type to be expanded?");
5618 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), IdxVT,
N->getOperand(0));
5620 SplitInteger(Res,
Lo,
Hi);
5631bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5633 SDValue Res = SDValue();
5635 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5638 switch (
N->getOpcode()) {
5641 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5642 N->dump(&DAG);
dbgs() <<
"\n";
5647 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5651 Res = ExpandOp_FAKE_USE(
N);
5655 Res = TLI.expandLoopDependenceMask(
N, DAG);
5661 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5674 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5679 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5683 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5686 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5688 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5689 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5690 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5693 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5698 if (!Res.
getNode())
return false;
5706 "Invalid operand expansion");
5708 ReplaceValueWith(SDValue(
N, 0), Res);
5714void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5718 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5719 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5720 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5733 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5740 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5741 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5769 SDValue LoCmp, HiCmp;
5771 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5772 RHSLo, LowCC,
false, DagCombineInfo, dl);
5774 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5777 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5778 RHSHi, CCCode,
false, DagCombineInfo, dl);
5782 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5791 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5793 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5802 if (LHSHi == RHSHi) {
5811 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5812 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5815 if (HasSETCCCARRY) {
5818 bool FlipOperands =
false;
5835 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5836 SDValue LowCmp = DAG.getNode(
ISD::USUBO, dl, VTList, LHSLo, RHSLo);
5839 DAG.getCondCode(CCCode));
5845 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5846 false, DagCombineInfo, dl);
5849 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5850 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5857 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5862 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5867 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5868 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5869 N->getOperand(4)), 0);
5875 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5880 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5885 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5886 N->getOperand(2),
N->getOperand(3),
5887 DAG.getCondCode(CCCode)), 0);
5893 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5898 "Unexpected setcc expansion!");
5904 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5908 SDValue
LHS =
N->getOperand(0);
5909 SDValue
RHS =
N->getOperand(1);
5911 SDValue
Cond =
N->getOperand(3);
5912 SDLoc dl = SDLoc(
N);
5914 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5915 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5916 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5929 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5939 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5940 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5944 return TLI.expandCMP(
N, DAG);
5952 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5953 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5957 bool IsStrict =
N->isStrictFPOpcode();
5960 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
5961 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
5962 EVT DstVT =
N->getValueType(0);
5965 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5966 "Don't know how to expand this XINT_TO_FP!");
5967 TargetLowering::MakeLibCallOptions CallOptions;
5969 std::pair<SDValue, SDValue> Tmp =
5970 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5975 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
5976 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
5981 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5984 return ExpandOp_NormalStore(
N, OpNo);
5987 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5989 EVT VT =
N->getOperand(1).getValueType();
5990 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5991 SDValue Ch =
N->getChain();
5992 SDValue Ptr =
N->getBasePtr();
5994 AAMDNodes AAInfo =
N->getAAInfo();
6000 if (
N->getMemoryVT().bitsLE(NVT)) {
6001 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6002 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6003 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6007 if (DAG.getDataLayout().isLittleEndian()) {
6009 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6011 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6014 unsigned ExcessBits =
6021 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6022 N->getPointerInfo().getWithOffset(IncrementSize),
6023 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6029 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6031 EVT ExtVT =
N->getMemoryVT();
6034 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6042 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6046 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6050 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6051 N->getBaseAlign(), MMOFlags, AAInfo);
6056 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6057 N->getPointerInfo().getWithOffset(IncrementSize),
6059 N->getBaseAlign(), MMOFlags, AAInfo);
6065 GetExpandedInteger(
N->getOperand(0), InL, InH);
6074 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6076 return Swap.getValue(1);
6079SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6080 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6081 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6085 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6087 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6090SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6093 "cannot use llvm.write_register with illegal type", Fn,
6096 return N->getOperand(0);
6099SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6102 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6103 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6104 EVT OutVT =
V0.getValueType();
6106 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6109SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6111 unsigned Factor =
N->getNumOperands();
6114 for (
unsigned i = 0; i != Factor; i++)
6115 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6118 SDValue Res = DAG.
getNode(
N->getOpcode(),
DL, DAG.getVTList(ResVTs),
Ops);
6120 for (
unsigned i = 0; i != Factor; i++)
6121 SetPromotedInteger(SDValue(
N, i), Res.
getValue(i));
6126SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6128 EVT OutVT =
N->getValueType(0);
6129 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6130 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6134 SDValue BaseIdx =
N->getOperand(1);
6139 SDValue InOp0 =
N->getOperand(0);
6151 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6153 SDValue Step2 = DAG.getNode(
6155 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6161 SDValue
Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6170 SDValue
Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6174 "Promoted operand has an element type greater than result");
6187 InOp0 = GetPromotedInteger(InOp0);
6194 Ops.reserve(OutNumElems);
6195 for (
unsigned i = 0; i != OutNumElems; ++i) {
6200 N->getOperand(0), Index);
6201 SDValue
Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6206 return DAG.getBuildVector(NOutVT, dl,
Ops);
6209SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6210 EVT OutVT =
N->getValueType(0);
6211 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6212 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6224 Vec = GetPromotedInteger(Vec);
6230SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6233 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6234 EVT OutVT =
V0.getValueType();
6239SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6241 EVT VT =
N->getValueType(0);
6246 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6247 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6248 EVT OutVT =
V0.getValueType();
6250 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6254 EVT OutVT =
N->getValueType(0);
6255 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6256 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6257 unsigned NumElems =
N->getNumOperands();
6264 Ops.reserve(NumElems);
6265 for (
unsigned i = 0; i != NumElems; ++i) {
6266 SDValue
Op =
N->getOperand(i);
6267 EVT OpVT =
Op.getValueType();
6272 if (OpVT.
bitsLT(NOutVTElem)) {
6278 ExtOpc = NOutExtOpc;
6279 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6284 return DAG.getBuildVector(NOutVT, dl,
Ops);
6291 assert(!
N->getOperand(0).getValueType().isVector() &&
6292 "Input must be a scalar");
6294 EVT OutVT =
N->getValueType(0);
6295 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6296 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6300 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6305 EVT OutVT =
N->getValueType(0);
6306 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6308 "Type must be promoted to a scalable vector type");
6309 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6310 return DAG.getStepVector(dl, NOutVT,
6314SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6317 EVT OutVT =
N->getValueType(0);
6318 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6319 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6321 unsigned NumOperands =
N->getNumOperands();
6325 EVT OpVT =
N->getOperand(0).getValueType();
6330 "Unhandled legalization type");
6336 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6337 SDValue
Op =
N->getOperand(
I);
6339 Op = GetPromotedInteger(
Op);
6348 *DAG.getContext(),
Ops[0].getValueType().getVectorElementType());
6349 return DAG.getAnyExtOrTrunc(
6353 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6354 assert(NumElem * NumOperands == NumOutElem &&
6355 "Unexpected number of elements");
6359 for (
unsigned i = 0; i < NumOperands; ++i) {
6360 SDValue
Op =
N->getOperand(i);
6362 Op = GetPromotedInteger(
Op);
6363 EVT SclrTy =
Op.getValueType().getVectorElementType();
6364 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6365 "Unexpected number of elements");
6367 for (
unsigned j = 0;
j < NumElem; ++
j) {
6369 DAG.getVectorIdxConstant(j, dl));
6370 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6374 return DAG.getBuildVector(NOutVT, dl,
Ops);
6377SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6378 EVT VT =
N->getValueType(0);
6379 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6380 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6388 if (getTypeAction(
N->getOperand(0).getValueType())
6392 switch(
N->getOpcode()) {
6394 Promoted = SExtPromotedInteger(
N->getOperand(0));
6397 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6400 Promoted = GetPromotedInteger(
N->getOperand(0));
6412 DAG.getVectorIdxConstant(0, dl));
6414 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6418 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6421SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6422 EVT VT =
N->getValueType(0);
6423 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6427SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6428 EVT VT =
N->getValueType(0);
6429 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6434 EVT VT =
N->getValueType(0);
6435 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6437 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6441SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6443 EVT VT =
N->getValueType(0);
6444 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6445 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6446 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6450SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6451 EVT OutVT =
N->getValueType(0);
6452 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6453 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6458 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6461 NOutVTElem,
N->getOperand(1));
6463 V0, ConvElem,
N->getOperand(2));
6470 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6471 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6479 SDValue
Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6480 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6481 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6485 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6488 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6489 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6495 SDValue From[] = {SDValue(
N, 1), SDValue(
N, 2)};
6497 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6502SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6505 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6507 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6508 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
6509 return DAG.getPOISON(NVT);
6512SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6514 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6515 SDValue
V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6516 TLI.getVectorIdxTy(DAG.getDataLayout()));
6518 V0->getValueType(0).getScalarType(), V0,
V1);
6523 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6526SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6530 SDValue
V0 =
N->getOperand(0);
6531 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6534 V1.getValueType().getVectorElementType(),
6535 V0.getValueType().getVectorElementCount());
6536 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6538 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6545 SDValue
V0 =
N->getOperand(0);
6546 SDValue
V1 =
N->getOperand(1);
6547 EVT InVT1 =
V1.getValueType();
6550 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6551 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6554SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6556 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6557 MVT InVT =
V0.getValueType().getSimpleVT();
6564SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6567 EVT ResVT =
N->getValueType(0);
6568 unsigned NumElems =
N->getNumOperands();
6571 SDValue ResVec = DAG.getPOISON(ResVT);
6573 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6574 SDValue
Op =
N->getOperand(OpIdx);
6575 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6577 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6589 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6590 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6594 for (
unsigned i=0; i<NumElem; ++i) {
6597 DAG.getVectorIdxConstant(i, dl));
6603 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6606SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6608 SDValue
Op =
N->getOperand(OpNo);
6619 for (
unsigned I = 0;
I < OpNo;
I++)
6622 EVT Ty =
Op.getValueType();
6623 SDLoc
DL = SDLoc(
N);
6626 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6634 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6637 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6639 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6640 ReplaceValueWith(SDValue(
N, ResNum),
NewNode.getValue(ResNum));
6645SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6647 SDValue
Op =
N->getOperand(OpNo);
6658 for (
unsigned I = 0;
I < OpNo;
I++)
6661 EVT Ty =
Op.getValueType();
6662 SDLoc
DL = SDLoc(
N);
6665 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6673 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6676 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6678 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6679 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_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)