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";
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_UNDEF:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
73 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
76 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
77 case ISD::VP_CTTZ_ZERO_UNDEF:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
83 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
84 case ISD::VP_CTTZ_ELTS:
85 Res = PromoteIntRes_VP_CttzElements(
N);
88 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
98 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
104 Res = PromoteIntRes_Select(
N);
109 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
111 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
113 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
116 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
118 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
120 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
122 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
123 case ISD::VP_TRUNCATE:
126 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
127 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
131 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
135 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
137 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
140 Res = PromoteIntRes_VECTOR_SPLICE(
N);
144 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
147 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
149 Res = PromoteIntRes_BUILD_VECTOR(
N);
153 Res = PromoteIntRes_ScalarOp(
N);
157 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
162 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
165 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
169 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
175 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
179 case ISD::VP_SIGN_EXTEND:
181 case ISD::VP_ZERO_EXTEND:
184 case ISD::VP_FP_TO_SINT:
185 case ISD::VP_FP_TO_UINT:
193 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
197 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
201 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
216 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
226 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
236 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
239 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
241 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
243 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
259 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
261 case ISD::VP_SADDSAT:
262 case ISD::VP_UADDSAT:
263 case ISD::VP_SSUBSAT:
264 case ISD::VP_USUBSAT:
265 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
270 Res = PromoteIntRes_CMP(
N);
283 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
316 Res = PromoteIntRes_VECREDUCE(
N);
319 case ISD::VP_REDUCE_ADD:
320 case ISD::VP_REDUCE_MUL:
321 case ISD::VP_REDUCE_AND:
322 case ISD::VP_REDUCE_OR:
323 case ISD::VP_REDUCE_XOR:
324 case ISD::VP_REDUCE_SMAX:
325 case ISD::VP_REDUCE_SMIN:
326 case ISD::VP_REDUCE_UMAX:
327 case ISD::VP_REDUCE_UMIN:
328 Res = PromoteIntRes_VP_REDUCE(
N);
333 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
337 Res = PromoteIntRes_FREEZE(
N);
342 Res = PromoteIntRes_Rotate(
N);
347 Res = PromoteIntRes_FunnelShift(
N);
352 Res = PromoteIntRes_VPFunnelShift(
N);
358 Res = PromoteIntRes_CLMUL(
N);
362 Res = PromoteIntRes_IS_FPCLASS(
N);
365 Res = PromoteIntRes_FFREXP(
N);
370 Res = PromoteIntRes_XRINT(
N);
374 Res = PromoteIntRes_PATCHPOINT(
N);
377 Res = PromoteIntRes_READ_REGISTER(
N);
383 SetPromotedInteger(
SDValue(
N, ResNo), Res);
388 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
389 return GetPromotedInteger(
Op);
392SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
394 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
395 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
400 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
402 Op.getValueType(),
Op,
N->getOperand(1));
407 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
409 Op.getValueType(),
Op,
N->getOperand(1));
413 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
416 switch (TLI.getExtendForAtomicOps()) {
432 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
433 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
443 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
445 Op2 = SExtPromotedInteger(Op2);
448 Op2 = ZExtPromotedInteger(Op2);
451 Op2 = GetPromotedInteger(Op2);
456 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
458 N->getChain(),
N->getBasePtr(),
459 Op2,
N->getMemOperand());
470 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
471 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
475 if (!TLI.isTypeLegal(SVT))
478 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
479 SDValue Res = DAG.getAtomicCmpSwap(
481 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
485 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
491 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
492 switch (TLI.getExtendForAtomicCmpSwapArg()) {
494 Op2 = SExtPromotedInteger(Op2);
497 Op2 = ZExtPromotedInteger(Op2);
500 Op2 = GetPromotedInteger(Op2);
507 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
508 SDValue Res = DAG.getAtomicCmpSwap(
509 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
510 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
512 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
520 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
521 EVT OutVT =
N->getValueType(0);
522 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
525 switch (getTypeAction(InVT)) {
531 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
535 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
538 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
546 BitConvertToInteger(GetScalarizedVector(InOp)));
555 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
556 Lo = BitConvertToInteger(
Lo);
557 Hi = BitConvertToInteger(
Hi);
559 if (DAG.getDataLayout().isBigEndian())
565 JoinIntegers(
Lo,
Hi));
580 if (DAG.getDataLayout().isBigEndian()) {
584 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
599 if (isTypeLegal(WideOutVT)) {
600 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
602 DAG.getVectorIdxConstant(0, dl));
611 DAG.getDataLayout().isLittleEndian()) {
622 if (isTypeLegal(WideVecVT)) {
624 DAG.getUNDEF(WideVecVT), InOp,
625 DAG.getVectorIdxConstant(0, dl));
633 CreateStackStoreLoad(InOp, OutVT));
637 SDValue V = GetPromotedInteger(
N->getOperand(0));
639 V.getValueType(), V);
643 SDValue Op = GetPromotedInteger(
N->getOperand(0));
644 EVT OVT =
N->getValueType(0);
645 EVT NVT =
Op.getValueType();
653 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
654 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
659 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
665 return DAG.getNode(ISD::VP_SRL, dl, NVT,
666 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
671 SDValue Op = GetPromotedInteger(
N->getOperand(0));
672 EVT OVT =
N->getValueType(0);
673 EVT NVT =
Op.getValueType();
682 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
687 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
693 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
694 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
702 TLI.getTypeToTransformTo(*DAG.getContext(),
703 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
708 EVT VT =
N->getValueType(0);
715 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
722 EVT OVT =
N->getValueType(0);
723 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
729 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
730 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
732 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
738 unsigned CtlzOpcode =
N->getOpcode();
739 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
741 SDValue ExtractLeadingBits = DAG.getConstant(
744 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
748 if (!
N->isVPOpcode())
749 return DAG.getNode(
ISD::SUB, dl, NVT,
750 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
754 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
755 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
756 ExtractLeadingBits, Mask, EVL,
760 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
762 SDValue Op = GetPromotedInteger(
N->getOperand(0));
766 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
767 if (!
N->isVPOpcode()) {
769 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
774 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
775 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
781 EVT OVT =
N->getValueType(0);
782 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
785 SDValue ExtractLeadingBits = DAG.getConstant(
788 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
794 EVT OVT =
N->getValueType(0);
795 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
803 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
804 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
811 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
812 if (!
N->isVPOpcode())
813 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
817 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
822 SDValue Op = GetPromotedInteger(
N->getOperand(0));
823 EVT OVT =
N->getValueType(0);
824 EVT NVT =
Op.getValueType();
831 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
832 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
836 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
842 unsigned NewOpc =
N->getOpcode();
843 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
850 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
854 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
855 N->getOperand(1),
N->getOperand(2));
856 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
859 if (!
N->isVPOpcode())
860 return DAG.getNode(NewOpc, dl, NVT,
Op);
861 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
864SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
866 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
867 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
870SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
872 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
879 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
885 EVT SVT =
In.getValueType().getScalarType();
888 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
896 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
898 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
902 if (
N->isStrictFPOpcode()) {
903 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
904 {
N->getOperand(0),
N->getOperand(1)});
908 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
909 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
912 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
924 N->getOpcode() == ISD::VP_FP_TO_UINT)
928 DAG.getValueType(
N->getValueType(0).getScalarType()));
931SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
933 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
935 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
939SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
940 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
943 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
946SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
947 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
950 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
951 N->getOperand(0),
N->getOperand(1));
957 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
959 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
963 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
967 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
976 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
979 if (getTypeAction(
N->getOperand(0).getValueType())
981 SDValue Res = GetPromotedInteger(
N->getOperand(0));
990 DAG.getValueType(
N->getOperand(0).getValueType()));
992 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
999 if (
N->getNumOperands() != 1) {
1000 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1001 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1002 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1003 N->getOperand(1),
N->getOperand(2));
1005 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1010 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1014 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1015 N->getMemoryVT(),
N->getMemOperand());
1024 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1025 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1028 :
N->getExtensionType();
1031 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1032 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1033 N->getMemOperand(),
N->isExpandingLoad());
1041 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1042 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1049 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1050 N->getOffset(),
N->getMask(), ExtPassThru,
1051 N->getMemoryVT(),
N->getMemOperand(),
1052 N->getAddressingMode(), ExtType,
1053 N->isExpandingLoad());
1061 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1062 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1064 "Gather result type and the passThru argument type should be the same");
1071 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1072 N->getIndex(),
N->getScale() };
1073 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1074 N->getMemoryVT(), dl,
Ops,
1075 N->getMemOperand(),
N->getIndexType(),
1083SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1084 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1085 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1087 N->getOperand(1), Passthru);
1094 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1095 EVT VT =
N->getValueType(0);
1096 EVT SVT = getSetCCResultType(VT);
1097 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1098 unsigned NumOps =
N->getNumOperands();
1101 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1109 ReplaceValueWith(
SDValue(
N, 0), Res);
1112 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1115template <
class MatchContextClass>
1127 MatchContextClass matcher(DAG, TLI,
N);
1129 unsigned Opcode = matcher.getRootBaseOpcode();
1135 SExtOrZExtPromotedOperands(Op1, Op2);
1141 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1143 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1144 Op1 = SExtPromotedInteger(Op1);
1145 Op2 = SExtPromotedInteger(Op2);
1146 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1149 Op1 = ZExtPromotedInteger(Op1);
1150 Op2 = ZExtPromotedInteger(Op2);
1153 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1155 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1162 Op1 = GetPromotedInteger(Op1);
1164 Op2 = ZExtPromotedInteger(Op2);
1166 Op1 = SExtPromotedInteger(Op1);
1167 Op2 = SExtPromotedInteger(Op2);
1174 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1187 "addition, subtraction or left shift");
1190 unsigned SHLAmount = NewBits - OldBits;
1192 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1197 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1198 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1204 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1205 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1206 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1207 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1208 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1215 SDValue Op1Promoted, Op2Promoted;
1221 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1222 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1224 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1225 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1227 EVT OldType =
N->getOperand(0).getValueType();
1239 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1240 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1241 Op2Promoted,
N->getOperand(2));
1243 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1244 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1246 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1251 unsigned SatW,
bool Signed,
1254 EVT VT = V.getValueType();
1281 EVT VT =
LHS.getValueType();
1297 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1303 "Tried to saturate to more than the original type?");
1312 SDValue Op1Promoted, Op2Promoted;
1318 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1319 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1321 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1322 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1325 unsigned Scale =
N->getConstantOperandVal(2);
1329 if (TLI.isTypeLegal(PromotedType)) {
1331 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1334 N->getValueType(0).getScalarSizeInBits();
1338 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1339 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1340 Op2Promoted,
N->getOperand(2));
1343 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1349 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1350 Op2Promoted, Scale, DAG)) {
1353 N->getValueType(0).getScalarSizeInBits(),
1361 N->getValueType(0).getScalarSizeInBits());
1364SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1366 return PromoteIntRes_Overflow(
N);
1370 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1371 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1372 EVT OVT =
N->getOperand(0).getValueType();
1373 EVT NVT =
LHS.getValueType();
1383 DAG.getValueType(OVT));
1385 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1388 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1394 EVT PromotedResultTy =
1395 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1396 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1397 N->getOperand(0),
N->getOperand(1));
1403 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1404 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1406 unsigned Opcode =
N->getOpcode();
1407 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1408 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1410 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1414 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1415 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1417 LHS.getValueType(),
N->getOperand(0),
1418 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1423 EVT InVT =
N->getOperand(OpNo).getValueType();
1424 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1426 EVT SVT = getSetCCResultType(InVT);
1433 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1434 SVT = getSetCCResultType(InVT);
1442 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1443 "Vector compare must return a vector result!");
1447 if (
N->isStrictFPOpcode()) {
1448 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1449 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1450 N->getOperand(2),
N->getOperand(3)};
1451 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1456 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1457 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1460 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1467 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1472 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1473 EVT VT =
N->getValueType(0);
1477 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1479 ReplaceValueWith(
SDValue(
N, 0), Res);
1484 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1487 RHS = ZExtPromotedInteger(
RHS);
1488 if (
N->getOpcode() != ISD::VP_SHL)
1489 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1497SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1498 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1500 Op.getValueType(),
Op,
N->getOperand(1));
1503SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1507 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1508 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1509 if (
N->getNumOperands() == 2)
1510 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1511 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1512 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1513 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1514 N->getOperand(2),
N->getOperand(3));
1519 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1520 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1521 if (
N->getNumOperands() == 2)
1522 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1523 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1524 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1533 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1534 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1535 if (
N->getNumOperands() == 2)
1536 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1537 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1538 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1552 SExtOrZExtPromotedOperands(
LHS,
RHS);
1554 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1560 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1563 RHS = ZExtPromotedInteger(
RHS);
1564 if (
N->getOpcode() != ISD::VP_SRA)
1565 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1576 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1578 RHS = ZExtPromotedInteger(
RHS);
1579 if (
N->getOpcode() != ISD::VP_SRL)
1580 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1590 SDValue Res = TLI.expandROT(
N,
true , DAG);
1591 ReplaceValueWith(
SDValue(
N, 0), Res);
1596 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1597 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1600 Amt = ZExtPromotedInteger(Amt);
1604 EVT OldVT =
N->getOperand(0).getValueType();
1605 EVT VT =
Lo.getValueType();
1606 unsigned Opcode =
N->getOpcode();
1613 DAG.getConstant(OldBits,
DL, AmtVT));
1621 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1622 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1624 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1634 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1640 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1642 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1646SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1647 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1648 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1653 Amt = ZExtPromotedInteger(Amt);
1657 EVT OldVT =
N->getOperand(0).getValueType();
1658 EVT VT =
Lo.getValueType();
1659 unsigned Opcode =
N->getOpcode();
1660 bool IsFSHR = Opcode == ISD::VP_FSHR;
1665 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1666 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1674 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1675 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1676 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1677 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1679 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1682 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1687 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1688 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1693 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1695 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1699 unsigned Opcode =
N->getOpcode();
1702 EVT OldVT =
N->getOperand(0).getValueType();
1703 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1706 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1707 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1710 SDValue X = GetPromotedInteger(
N->getOperand(0));
1711 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1715 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1716 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1720 if (NewBits < 2 * OldBits) {
1722 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1724 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1726 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1728 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1733 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1735 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1739 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1751 Res = GetPromotedInteger(InOp);
1758 "Dst and Src must have the same number of elements");
1760 "Promoted vector type must be a power of two");
1763 GetSplitVector(InOp, EOp1, EOp2);
1771 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1772 "Expected VP_TRUNCATE opcode");
1773 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1774 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1775 std::tie(EVLLo, EVLHi) =
1776 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1777 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1778 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1785 SDValue WideInOp = GetWidenedVector(InOp);
1790 N->getValueType(0).getScalarType(), NumElem);
1799 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1805 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1806 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1811SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1813 return PromoteIntRes_Overflow(
N);
1817 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1818 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1819 EVT OVT =
N->getOperand(0).getValueType();
1820 EVT NVT =
LHS.getValueType();
1829 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1831 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1834 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1845 return PromoteIntRes_Overflow(
N);
1857 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1858 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1860 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1863 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1874 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1875 return PromoteIntRes_Overflow(
N);
1879 EVT OVT =
N->getValueType(0);
1880 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1886 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1887 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1888 if (
SDValue Res = TLI.expandABS(
N, DAG))
1892 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1896SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1899 return PromoteIntRes_Overflow(
N);
1903 EVT SmallVT =
LHS.getValueType();
1910 LHS = SExtPromotedInteger(
LHS);
1911 RHS = SExtPromotedInteger(
RHS);
1913 LHS = ZExtPromotedInteger(
LHS);
1914 RHS = ZExtPromotedInteger(
RHS);
1916 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1928 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1929 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1930 DAG.getConstant(0,
DL,
Hi.getValueType()),
1935 Mul, DAG.getValueType(SmallVT));
1945 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1950 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1951 N->getValueType(0)));
1955 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1957 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1964 EVT VT =
N->getValueType(0);
1967 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1968 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1972 for (
unsigned i = 0; i < NumRegs; ++i) {
1973 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1974 N->getConstantOperandVal(3));
1979 if (DAG.getDataLayout().isBigEndian())
1980 std::reverse(Parts.begin(), Parts.end());
1983 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1985 for (
unsigned i = 1; i < NumRegs; ++i) {
1990 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1996 ReplaceValueWith(
SDValue(
N, 1), Chain);
2009bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2012 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2017 switch (
N->getOpcode()) {
2020 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2021 N->dump(&DAG);
dbgs() <<
"\n";
2027 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2033 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2034 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2039 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2043 Res = PromoteIntOp_FAKE_USE(
N);
2046 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2050 Res = PromoteIntOp_ScalarOp(
N);
2053 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2056 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2058 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2059 case ISD::VP_SINT_TO_FP:
2076 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2078 case ISD::VP_TRUNCATE:
2082 case ISD::VP_UINT_TO_FP:
2085 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2090 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2101 Res = PromoteIntOp_Shift(
N);
2105 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2108 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2134 case ISD::VP_REDUCE_ADD:
2135 case ISD::VP_REDUCE_MUL:
2136 case ISD::VP_REDUCE_AND:
2137 case ISD::VP_REDUCE_OR:
2138 case ISD::VP_REDUCE_XOR:
2139 case ISD::VP_REDUCE_SMAX:
2140 case ISD::VP_REDUCE_SMIN:
2141 case ISD::VP_REDUCE_UMAX:
2142 case ISD::VP_REDUCE_UMIN:
2143 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2148 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2151 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2154 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2156 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2157 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2158 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2160 case ISD::EXPERIMENTAL_VP_SPLICE:
2161 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2164 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2169 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2172 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2177 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2182 if (!Res.
getNode())
return false;
2189 const bool IsStrictFp =
N->isStrictFPOpcode();
2191 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2192 "Invalid operand expansion");
2196 ReplaceValueWith(
SDValue(
N, 0), Res);
2210 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2214 unsigned OpLEffectiveBits =
2215 DAG.computeKnownBits(OpL).countMaxActiveBits();
2216 unsigned OpREffectiveBits =
2217 DAG.computeKnownBits(OpR).countMaxActiveBits();
2218 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2219 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2226 LHS = SExtPromotedInteger(
LHS);
2227 RHS = SExtPromotedInteger(
RHS);
2236 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2237 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2238 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2239 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2246 LHS = ZExtPromotedInteger(
LHS);
2247 RHS = ZExtPromotedInteger(
RHS);
2261 LHS = SExtPromotedInteger(
LHS);
2262 RHS = SExtPromotedInteger(
RHS);
2267 "Unknown integer comparison!");
2269 SExtOrZExtPromotedOperands(
LHS,
RHS);
2273 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2277SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2278 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2279 EVT ResVT =
N->getValueType(0);
2280 EVT OpVT =
Op.getValueType();
2283 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2288 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2289 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2290 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2294 EVT OutVT =
N->getValueType(0);
2297 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2300 switch (getTypeAction(InVT)) {
2304 DAG.getDataLayout().isLittleEndian()) {
2314 if (isTypeLegal(WideVecVT)) {
2315 SDValue Promoted = GetPromotedInteger(InOp);
2318 DAG.getVectorIdxConstant(0, dl));
2331 return CreateStackStoreLoad(InOp, OutVT);
2334SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2335 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2343 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2344 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2348SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2349 assert(OpNo == 1 &&
"only know how to promote condition");
2352 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2355 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2356 N->getOperand(2)), 0);
2359SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2360 assert(OpNo == 1 &&
"only know how to promote condition");
2363 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2366 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2371 EVT OVT =
N->getOperand(0).getValueType();
2372 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2373 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2374 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2379 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2380 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2389 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2390 "Legal vector of one illegal element?");
2395 assert(
N->getOperand(0).getValueSizeInBits() >=
2396 N->getValueType(0).getScalarSizeInBits() &&
2397 "Type of inserted value narrower than vector element type!");
2400 for (
unsigned i = 0; i < NumElts; ++i)
2401 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2403 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2406SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2413 assert(
N->getOperand(1).getValueSizeInBits() >=
2414 N->getValueType(0).getScalarSizeInBits() &&
2415 "Type of inserted value narrower than vector element type!");
2416 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2417 GetPromotedInteger(
N->getOperand(1)),
2422 assert(OpNo == 2 &&
"Different operand and result vector types?");
2425 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2426 TLI.getVectorIdxTy(DAG.getDataLayout()));
2427 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2428 N->getOperand(1), Idx), 0);
2432 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2436 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2439SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2440 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2442 EVT OpTy =
N->getOperand(1).getValueType();
2445 if (
SDValue Res = WidenVSELECTMask(
N))
2446 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2447 Res,
N->getOperand(1),
N->getOperand(2));
2451 Cond = PromoteTargetBoolean(
Cond, OpVT);
2453 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2454 N->getOperand(2)), 0);
2457SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2458 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2466 N->getOperand(3),
N->getOperand(4)), 0);
2469SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2470 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2478 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2480 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2483 N->getOperand(3),
N->getOperand(4)),
2488 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2489 ZExtPromotedInteger(
N->getOperand(1))), 0);
2497 LHS = SExtPromotedInteger(
LHS);
2498 RHS = SExtPromotedInteger(
RHS);
2500 SExtOrZExtPromotedOperands(
LHS,
RHS);
2507 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2508 ZExtPromotedInteger(
N->getOperand(2))), 0);
2512 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2516 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2519SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2521 EVT VT =
N->getValueType(0);
2522 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2524 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2528 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2530 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2532 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2537 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2538 return SDValue(DAG.UpdateNodeOperands(
N,
2539 SExtPromotedInteger(
N->getOperand(0)),
2540 N->getOperand(1),
N->getOperand(2)),
2542 return SDValue(DAG.UpdateNodeOperands(
N,
2543 SExtPromotedInteger(
N->getOperand(0))), 0);
2546SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2547 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2548 SExtPromotedInteger(
N->getOperand(1))), 0);
2553 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2556 SDValue Val = GetPromotedInteger(
N->getValue());
2559 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2560 N->getMemoryVT(),
N->getMemOperand());
2566 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2567 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2569 SDValue DataOp = GetPromotedInteger(
N->getValue());
2570 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2571 N->getMask(),
N->getVectorLength(),
2572 N->getMemoryVT(),
N->getMemOperand(),
2573 N->isCompressingStore());
2584 Mask = PromoteTargetBoolean(Mask, DataVT);
2587 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2590 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2591 DataOp = GetPromotedInteger(DataOp);
2593 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2594 N->getOffset(), Mask,
N->getMemoryVT(),
2595 N->getMemOperand(),
N->getAddressingMode(),
2596 true,
N->isCompressingStore());
2601 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2602 EVT DataVT =
N->getValueType(0);
2603 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2605 NewOps[OpNo] =
Mask;
2606 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2622 EVT DataVT =
N->getValueType(0);
2623 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2624 }
else if (OpNo == 4) {
2626 if (
N->isIndexSigned())
2628 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2630 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2632 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2634 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2646 bool TruncateStore =
N->isTruncatingStore();
2651 EVT DataVT =
N->getValue().getValueType();
2652 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2653 }
else if (OpNo == 4) {
2655 if (
N->isIndexSigned())
2657 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2659 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2661 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2662 TruncateStore =
true;
2665 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2666 SDLoc(
N), NewOps,
N->getMemOperand(),
2667 N->getIndexType(), TruncateStore);
2672 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2676 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2681 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2682 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2683 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2684 N->getOperand(1),
N->getOperand(2));
2689 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2690 return SDValue(DAG.UpdateNodeOperands(
N,
2691 ZExtPromotedInteger(
N->getOperand(0)),
2692 N->getOperand(1),
N->getOperand(2)),
2694 return SDValue(DAG.UpdateNodeOperands(
N,
2695 ZExtPromotedInteger(
N->getOperand(0))), 0);
2698SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2699 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2704SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2705 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2706 ZExtPromotedInteger(
N->getOperand(1))), 0);
2713 EVT VT =
N->getValueType(0);
2718 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2719 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2720 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2721 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2726 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2729SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2731 EVT VT =
N->getValueType(0);
2732 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2734 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2736 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2737 N->getOperand(0).getValueType());
2741 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2743 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2746SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2748 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2749 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2758 unsigned OpOffset = IsStrict ? 1 : 0;
2765 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2766 if (LCImpl == RTLIB::Unsupported) {
2772 if (IsPowI &&
N->getValueType(0).isVector())
2773 return DAG.UnrollVectorOp(
N);
2775 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2776 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2786 assert(DAG.getLibInfo().getIntSize() ==
2787 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2788 "POWI exponent should match with sizeof(int) when doing the libcall.");
2789 TargetLowering::MakeLibCallOptions CallOptions;
2791 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2792 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2793 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2794 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2796 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2801 switch (
N->getOpcode()) {
2809 case ISD::VP_REDUCE_ADD:
2810 case ISD::VP_REDUCE_MUL:
2811 case ISD::VP_REDUCE_AND:
2812 case ISD::VP_REDUCE_OR:
2813 case ISD::VP_REDUCE_XOR:
2817 case ISD::VP_REDUCE_SMAX:
2818 case ISD::VP_REDUCE_SMIN:
2822 case ISD::VP_REDUCE_UMAX:
2823 case ISD::VP_REDUCE_UMIN:
2833 return GetPromotedInteger(V);
2835 return SExtPromotedInteger(V);
2837 return ZExtPromotedInteger(V);
2843 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2845 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2846 EVT InVT =
Op.getValueType();
2848 EVT ResVT =
N->getValueType(0);
2849 unsigned Opcode =
N->getOpcode();
2866 switch (TLI.getBooleanContents(InVT)) {
2869 Op = ZExtPromotedInteger(
N->getOperand(0));
2872 Op = SExtPromotedInteger(
N->getOperand(0));
2885 switch (TLI.getBooleanContents(InVT)) {
2888 Op = ZExtPromotedInteger(
N->getOperand(0));
2891 Op = SExtPromotedInteger(
N->getOperand(0));
2897 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2901 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2905SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2912 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2913 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2916 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2918 Op = PromoteIntOpVectorReduction(
N,
Op);
2922 EVT VT =
N->getValueType(0);
2923 EVT EltVT =
Op.getValueType().getScalarType();
2926 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2938 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2939 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2942SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2945 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2946 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2949SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2952 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2953 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2958 const Function &Fn = DAG.getMachineFunction().getFunction();
2960 "cannot use llvm.write_register with illegal type", Fn,
2962 return N->getOperand(0);
2965SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2966 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2967 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2970 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2972 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2975SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2979 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2980 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2983 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2985 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2986 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2989SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2991 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2993 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2994 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2997SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
2999 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3003 if (TLI.getBooleanContents(
Op.getValueType()) ==
3005 NewOp = SExtPromotedInteger(
Op);
3007 NewOp = ZExtPromotedInteger(
Op);
3009 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3012SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3014 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3015 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3016 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3019SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3021 switch (
N->getOpcode()) {
3023 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3024 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3027 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3028 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3031 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3032 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3037 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3048void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3054 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3057 switch (
N->getOpcode()) {
3060 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3061 N->dump(&DAG);
dbgs() <<
"\n";
3139 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3140 SplitInteger(Tmp.first,
Lo,
Hi);
3141 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3146 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3147 SDValue Tmp = DAG.getAtomicCmpSwap(
3149 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3158 SplitInteger(Tmp,
Lo,
Hi);
3237 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3242 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3248 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3252 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3256 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3261 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3271std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3272 unsigned Opc =
Node->getOpcode();
3278 EVT RetVT =
Node->getValueType(0);
3279 TargetLowering::MakeLibCallOptions CallOptions;
3282 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3283 if (LCImpl != RTLIB::Unsupported) {
3285 Ops.push_back(
Node->getOperand(1));
3288 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3289 "Unexpected atomic op or value type!");
3291 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3293 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3294 Node->getOperand(0));
3299void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3304 GetExpandedInteger(
N->getOperand(0), InL, InH);
3319 if (Amt.
uge(VTBits)) {
3320 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3321 }
else if (Amt.
ugt(NVTBits)) {
3322 Lo = DAG.getConstant(0,
DL, NVT);
3324 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3325 }
else if (Amt == NVTBits) {
3326 Lo = DAG.getConstant(0,
DL, NVT);
3330 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3332 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3334 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3339 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3341 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3348 if (Amt.
uge(VTBits)) {
3349 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3350 }
else if (Amt.
ugt(NVTBits)) {
3352 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3353 Hi = DAG.getConstant(0,
DL, NVT);
3354 }
else if (Amt == NVTBits) {
3356 Hi = DAG.getConstant(0,
DL, NVT);
3359 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3361 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3366 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3368 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3371 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3377 if (Amt.
uge(VTBits)) {
3379 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3380 }
else if (Amt.
ugt(NVTBits)) {
3382 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3384 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3385 }
else if (Amt == NVTBits) {
3388 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3391 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3393 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3398 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3400 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3403 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3411bool DAGTypeLegalizer::
3413 unsigned Opc =
N->getOpcode();
3416 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3421 "Expanded integer type size not a power of two!");
3425 KnownBits Known = DAG.computeKnownBits(Amt);
3428 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3433 GetExpandedInteger(In, InL, InH);
3440 DAG.getConstant(~HighBitMask, dl, ShTy));
3445 Lo = DAG.getConstant(0, dl, NVT);
3446 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3449 Hi = DAG.getConstant(0, dl, NVT);
3450 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3454 DAG.getConstant(NVTBits - 1, dl, ShTy));
3455 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3467 DAG.getConstant(NVTBits - 1, dl, ShTy));
3483 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3485 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3487 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3488 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3500bool DAGTypeLegalizer::
3503 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3507 "Expanded integer type size not a power of two!");
3512 GetExpandedInteger(
N->getOperand(0), InL, InH);
3514 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3517 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3520 Amt, DAG.getConstant(0, dl, ShTy),
3524 switch (
N->getOpcode()) {
3530 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3531 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3534 LoL = DAG.getConstant(0, dl, NVT);
3537 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3538 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3539 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3545 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3548 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3551 HiL = DAG.getConstant(0, dl, NVT);
3554 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3555 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3556 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3562 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3563 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3567 DAG.getConstant(NVTBits - 1, dl, ShTy));
3570 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3571 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3572 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3597 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3602 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3603 SplitInteger(Res,
Lo,
Hi);
3606void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3615 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3616 unsigned NumHalfBits = NumBits / 2;
3617 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3618 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3619 SDValue LHSL, LHSH, RHSL, RHSH;
3620 GetExpandedInteger(
LHS, LHSL, LHSH);
3621 GetExpandedInteger(
RHS, RHSL, RHSH);
3624 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3626 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3634 SDValue LHSL, LHSH, RHSL, RHSH;
3635 GetExpandedInteger(
LHS, LHSL, LHSH);
3636 GetExpandedInteger(
RHS, RHSL, RHSH);
3638 EVT CCT = getSetCCResultType(NVT);
3641 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3643 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3645 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3647 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3651 const APInt *RHSVal =
nullptr;
3653 RHSVal = &RHSConst->getAPIntValue();
3660 SDValue LHSL, LHSH, RHSL, RHSH;
3661 GetExpandedInteger(
LHS, LHSL, LHSH);
3662 GetExpandedInteger(
RHS, RHSL, RHSH);
3664 EVT CCT = getSetCCResultType(NVT);
3670 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3673 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3677 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3680 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3682 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3689 switch (
N->getOpcode()) {
3716 EVT VT =
N->getValueType(0);
3717 EVT CCT = getSetCCResultType(VT);
3720 SplitInteger(Result,
Lo,
Hi);
3724 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3725 SplitInteger(ExpandedCMP,
Lo,
Hi);
3728void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3732 SDValue LHSL, LHSH, RHSL, RHSH;
3733 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3734 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3737 SDValue LoOps[2] = { LHSL, RHSL };
3738 SDValue HiOps[3] = { LHSH, RHSH };
3740 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3742 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3744 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3748 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3754 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3767 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3769 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3772 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3786 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3788 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3792 EVT OvfVT = getSetCCResultType(NVT);
3793 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3808 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3811 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3815 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3827 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3831 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3834 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3837 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3842 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3844 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3845 DAG.getConstant(0, dl, NVT));
3848 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3857 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3862 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3864 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3865 DAG.getConstant(0, dl, NVT));
3871void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3874 SDValue LHSL, LHSH, RHSL, RHSH;
3876 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3877 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3878 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3879 SDValue LoOps[2] = { LHSL, RHSL };
3880 SDValue HiOps[3] = { LHSH, RHSH };
3894 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3897void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3900 SDValue LHSL, LHSH, RHSL, RHSH;
3902 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3903 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3904 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3906 SDValue HiOps[3] = { LHSH, RHSH };
3908 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3910 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3914 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3917void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3925 unsigned CarryOp, NoCarryOp;
3927 switch(
N->getOpcode()) {
3942 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3943 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3947 SDValue LHSL, LHSH, RHSL, RHSH;
3948 GetExpandedInteger(
LHS, LHSL, LHSH);
3949 GetExpandedInteger(
RHS, RHSL, RHSH);
3950 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3951 SDValue LoOps[2] = { LHSL, RHSL };
3952 SDValue HiOps[3] = { LHSH, RHSH };
3954 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3956 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3963 SplitInteger(Sum,
Lo,
Hi);
3969 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3970 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3974 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3979 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3985 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3991 SDValue LHSL, LHSH, RHSL, RHSH;
3993 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3994 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3995 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3999 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4001 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4005 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4008void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4011 SDValue LHSL, LHSH, RHSL, RHSH;
4013 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4014 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4015 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4020 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4021 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4025 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4028void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4030 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4033 if (
Op.getValueType().bitsLE(NVT)) {
4036 Hi = DAG.getUNDEF(NVT);
4040 assert(getTypeAction(
Op.getValueType()) ==
4042 "Only know how to promote this result!");
4045 "Operand over promoted?");
4047 SplitInteger(Res,
Lo,
Hi);
4051void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4054 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4055 EVT NVT =
Lo.getValueType();
4060 if (NVTBits < EVTBits) {
4063 EVTBits - NVTBits)));
4068 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4072void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4075 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4076 EVT NVT =
Lo.getValueType();
4081 if (NVTBits < EVTBits) {
4084 EVTBits - NVTBits)));
4088 Hi = DAG.getConstant(0, dl, NVT);
4092void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4095 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4100void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4103 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4112 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4113 EVT NVT =
Lo.getValueType();
4116 Hi = DAG.getConstant(0, dl, NVT);
4119void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4121 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4124 const APInt &Cst =
Constant->getAPIntValue();
4125 bool IsTarget =
Constant->isTargetOpcode();
4126 bool IsOpaque =
Constant->isOpaque();
4128 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4129 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4137 GetExpandedInteger(N0,
Lo,
Hi);
4138 EVT NVT =
Lo.getValueType();
4144 Hi = DAG.getConstant(0, dl, NVT);
4154 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4159 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4160 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4169 EVT VT =
N->getValueType(0);
4171 DAG.getConstant(0, dl, VT), N0);
4173 SplitInteger(Neg, NegLo, NegHi);
4175 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4177 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4178 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4181void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4185 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4186 EVT NVT =
Lo.getValueType();
4188 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4191 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4194 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4195 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4198 Hi = DAG.getConstant(0, dl, NVT);
4206 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4207 EVT NVT =
Lo.getValueType();
4210 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4211 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4214 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4217 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4219 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4221 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4222 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4224 Hi = DAG.getConstant(0, dl, NVT);
4229 SplitInteger(Result,
Lo,
Hi);
4234 EVT VT =
N->getValueType(0);
4239 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4240 "LibCall explicitly requested, but not available");
4242 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4243 TargetLowering::MakeLibCallOptions CallOptions;
4247 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4248 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4256 GetExpandedInteger(
Op,
Lo,
Hi);
4257 EVT NVT =
Lo.getValueType();
4260 Hi = DAG.getConstant(0,
DL, NVT);
4263void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4267 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4268 EVT NVT =
Lo.getValueType();
4270 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4276 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4277 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4280 Hi = DAG.getConstant(0, dl, NVT);
4286 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4293 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4297 ReplaceValueWith(
SDValue(
N, 1), Chain);
4305 Chain =
Op.getValue(1);
4314 EVT VT =
N->getValueType(0);
4318 bool IsStrict =
N->isStrictFPOpcode();
4320 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4324 Op.getValueType() == MVT::bf16) {
4330 EVT OpVT =
Op.getValueType();
4334 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4335 TargetLowering::MakeLibCallOptions CallOptions;
4340 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4341 CallOptions, dl, Chain);
4342 SplitInteger(Tmp.first,
Lo,
Hi);
4345 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4350 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4351 SplitInteger(Res,
Lo,
Hi);
4357 bool IsStrict =
N->isStrictFPOpcode();
4358 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4361 EVT VT =
Op.getValueType();
4363 if (VT == MVT::f16) {
4369 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4373 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4377 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4381 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4385 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4389 EVT RetVT =
N->getValueType(0);
4391 TargetLowering::MakeLibCallOptions CallOptions;
4393 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4394 Op, CallOptions, dl,
4396 SplitInteger(Tmp.first,
Lo,
Hi);
4398 if (
N->isStrictFPOpcode())
4399 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4402void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4404 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4407 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4413 EVT VT =
N->getValueType(0);
4414 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4419 AAMDNodes AAInfo =
N->getAAInfo();
4424 if (
N->getMemoryVT().bitsLE(NVT)) {
4425 EVT MemVT =
N->getMemoryVT();
4427 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4428 N->getBaseAlign(), MMOFlags, AAInfo);
4436 unsigned LoSize =
Lo.getValueSizeInBits();
4438 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4441 Hi = DAG.getConstant(0, dl, NVT);
4445 Hi = DAG.getUNDEF(NVT);
4447 }
else if (DAG.getDataLayout().isLittleEndian()) {
4449 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4452 unsigned ExcessBits =
4459 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4460 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4461 N->getBaseAlign(), MMOFlags, AAInfo);
4470 EVT MemVT =
N->getMemoryVT();
4473 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4476 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4479 N->getBaseAlign(), MMOFlags, AAInfo);
4485 N->getPointerInfo().getWithOffset(IncrementSize),
4487 N->getBaseAlign(), MMOFlags, AAInfo);
4499 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4503 DAG.getShiftAmountConstant(
4510 ReplaceValueWith(
SDValue(
N, 1), Ch);
4513void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4517 GetExpandedInteger(
N->getOperand(0), LL, LH);
4518 GetExpandedInteger(
N->getOperand(1), RL, RH);
4522 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4524 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4525 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4528void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4530 EVT VT =
N->getValueType(0);
4531 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4535 GetExpandedInteger(
N->getOperand(0), LL, LH);
4536 GetExpandedInteger(
N->getOperand(1), RL, RH);
4538 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4545 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4546 if (LCImpl == RTLIB::Unsupported) {
4549 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4555 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4556 TargetLowering::MakeLibCallOptions CallOptions;
4558 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4565 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4566 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4567 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4570 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4575 SplitInteger(Result,
Lo,
Hi);
4581 SplitInteger(Result,
Lo,
Hi);
4587 SplitInteger(Result,
Lo,
Hi);
4598 EVT VT =
N->getValueType(0);
4602 uint64_t Scale =
N->getConstantOperandVal(2);
4614 EVT BoolVT = getSetCCResultType(VT);
4616 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4622 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4623 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4629 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4630 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4635 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4636 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4639 SplitInteger(Result,
Lo,
Hi);
4645 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4647 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4649 GetExpandedInteger(
LHS, LL, LH);
4650 GetExpandedInteger(
RHS, RL, RH);
4654 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4661 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4662 SplitInteger(LoTmp, Result[0], Result[1]);
4663 SplitInteger(HiTmp, Result[2], Result[3]);
4665 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4668 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4669 "the size of the current value type");
4690 uint64_t Part0 = Scale / NVTSize;
4691 if (Scale % NVTSize) {
4692 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4695 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4707 if (Scale == VTSize)
4726 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4727 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4728 EVT BoolNVT = getSetCCResultType(NVT);
4731 if (Scale < NVTSize) {
4734 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4735 DAG.getShiftAmountConstant(Scale, NVT, dl));
4736 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4737 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4738 }
else if (Scale == NVTSize) {
4740 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4741 }
else if (Scale < VTSize) {
4745 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4746 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4749 "(and saturation can't happen with Scale==VTSize).");
4751 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4752 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4756 if (Scale < NVTSize) {
4761 unsigned OverflowBits = VTSize - Scale + 1;
4762 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4763 "Extent of overflow bits must start within HL");
4764 SDValue HLHiMask = DAG.getConstant(
4766 SDValue HLLoMask = DAG.getConstant(
4773 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4779 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4780 }
else if (Scale == NVTSize) {
4786 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4792 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4793 }
else if (Scale < VTSize) {
4796 unsigned OverflowBits = VTSize - Scale + 1;
4797 SDValue HHHiMask = DAG.getConstant(
4799 SDValue HHLoMask = DAG.getConstant(
4801 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4802 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4809 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4810 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4813 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4814 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4821 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4823 N->getConstantOperandVal(2), DAG);
4827 N->getConstantOperandVal(2), TLI, DAG);
4828 SplitInteger(Res,
Lo,
Hi);
4831void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4834 "Node has unexpected Opcode");
4844 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4845 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4849 SDValue LHSL, LHSH, RHSL, RHSH;
4850 GetExpandedInteger(
LHS, LHSL, LHSH);
4851 GetExpandedInteger(
RHS, RHSL, RHSH);
4852 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4855 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4864 SplitInteger(Sum,
Lo,
Hi);
4889 EVT VT =
LHS.getValueType();
4892 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4896 EVT OType =
Node->getValueType(1);
4897 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4901 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4904void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4906 EVT VT =
N->getValueType(0);
4908 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4917 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4919 TargetLowering::MakeLibCallOptions CallOptions;
4921 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4924void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4927 SDValue Shiftee =
N->getOperand(0);
4934 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4935 }
while (!TLI.isTypeLegal(LoadVT));
4940 "Shifting unit is not a a power of two!");
4942 const bool IsOneStepShift =
4943 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4948 if (!IsOneStepShift)
4949 ShAmt = DAG.getFreeze(ShAmt);
4952 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4953 unsigned VTByteWidth = VTBitWidth / 8;
4955 "Shiftee type size is not a power of two!");
4956 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4957 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4962 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4964 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4965 EVT PtrTy =
StackPtr.getValueType();
4966 SDValue Ch = DAG.getEntryNode();
4969 DAG.getMachineFunction(),
4975 unsigned WideningOpc =
4977 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4980 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4984 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4990 Flags.setExact(IsOneStepShift);
4993 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4995 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4996 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4999 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5004 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5011 if (DAG.getDataLayout().isBigEndian())
5012 WillIndexUpwards = !WillIndexUpwards;
5015 if (WillIndexUpwards) {
5018 AdjStackPtr = DAG.getMemBasePlusOffset(
5019 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5020 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5024 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5025 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5029 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5034 if (!IsOneStepShift) {
5036 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5037 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5038 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5042 SplitInteger(Res,
Lo,
Hi);
5045void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5047 EVT VT =
N->getValueType(0);
5048 unsigned Opc =
N->getOpcode();
5054 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5058 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5075 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5077 const bool LegalOrCustom =
5081 unsigned ExpansionFactor = 1;
5083 for (EVT TmpVT = NVT;;) {
5084 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5085 if (NewTMPVT == TmpVT)
5092 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5095 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5097 if (LegalOrCustom &&
5101 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5107 SDValue ShiftOp =
N->getOperand(1);
5108 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5110 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5113 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5114 Hi =
Lo.getValue(1);
5119 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5133 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5136 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5138 TargetLowering::MakeLibCallOptions CallOptions;
5141 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5146 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5150void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5152 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5155 if (
Op.getValueType().bitsLE(NVT)) {
5161 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5165 assert(getTypeAction(
Op.getValueType()) ==
5167 "Only know how to promote this result!");
5170 "Operand over promoted?");
5172 SplitInteger(Res,
Lo,
Hi);
5180void DAGTypeLegalizer::
5183 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5186 if (EVT.
bitsLE(
Lo.getValueType())) {
5194 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5195 Hi.getValueType(), dl));
5206void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5208 EVT VT =
N->getValueType(0);
5210 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5219 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5221 TargetLowering::MakeLibCallOptions CallOptions;
5223 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5226void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5228 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5238void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5240 EVT VT =
N->getValueType(0);
5259 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5260 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5261 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5263 EVT BitVT =
N->getValueType(1);
5264 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5266 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5268 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5269 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5288 SplitInteger(Three,
Lo,
Hi);
5292 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5297 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5302 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5306 if (LCImpl == RTLIB::Unsupported ||
5308 DAG.getMachineFunction().getName()) {
5311 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5312 N->getOperand(1), MulLo, MulHi);
5317 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5318 SplitInteger(MulLo,
Lo,
Hi);
5319 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5323 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5326 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5327 MachinePointerInfo());
5331 EVT ArgVT =
Op.getValueType();
5333 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5334 Entry.IsSExt =
true;
5335 Entry.IsZExt =
false;
5336 Args.push_back(Entry);
5340 TargetLowering::ArgListEntry
Entry(
5342 Entry.IsSExt =
true;
5343 Entry.IsZExt =
false;
5344 Args.push_back(Entry);
5346 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5348 TargetLowering::CallLoweringInfo CLI(DAG);
5351 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5352 Func, std::move(Args))
5355 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5357 SplitInteger(CallInfo.first,
Lo,
Hi);
5359 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5360 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5361 DAG.getConstant(0, dl, PtrVT),
5364 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5367void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5369 EVT VT =
N->getValueType(0);
5371 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5381 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5383 if (isTypeLegal(NVT)) {
5385 GetExpandedInteger(
N->getOperand(0), InL, InH);
5387 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5396 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5398 TargetLowering::MakeLibCallOptions CallOptions;
5399 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5402void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5404 EVT VT =
N->getValueType(0);
5406 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5416 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5418 if (isTypeLegal(NVT)) {
5420 GetExpandedInteger(
N->getOperand(0), InL, InH);
5422 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5431 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5433 TargetLowering::MakeLibCallOptions CallOptions;
5434 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5437void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5439 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5442 if (
Op.getValueType().bitsLE(NVT)) {
5445 Hi = DAG.getConstant(0, dl, NVT);
5449 assert(getTypeAction(
Op.getValueType()) ==
5451 "Only know how to promote this result!");
5454 "Operand over promoted?");
5456 SplitInteger(Res,
Lo,
Hi);
5458 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5464void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5468 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5470 SDValue Swap = DAG.getAtomicCmpSwap(
5479void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5483 SDValue Res = TLI.expandVecReduce(
N, DAG);
5484 SplitInteger(Res,
Lo,
Hi);
5487void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5493 N->getOperand(0),
N->getOperand(1));
5494 SplitInteger(Res,
Lo,
Hi);
5501 GetExpandedInteger(
N->getOperand(0), In3, In4);
5502 GetExpandedInteger(
N->getOperand(1), In1, In2);
5506 unsigned Opc =
N->getOpcode();
5509 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5514 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5516 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5520 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5521 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5526 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5527 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5532 SDValue Res = TLI.expandCLMUL(
N, DAG);
5533 return SplitInteger(Res,
Lo,
Hi);
5537 GetExpandedInteger(
N->getOperand(0), LL, LH);
5538 GetExpandedInteger(
N->getOperand(1), RL, RH);
5552 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5557 EVT VT =
N->getValueType(0);
5564 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5567 SplitInteger(Res,
Lo,
Hi);
5574 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5575 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5577 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5578 Lo = DAG.getPOISON(LoVT);
5579 Hi = DAG.getPOISON(HiVT);
5586 EVT VT =
N->getSimpleValueType(0);
5587 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5589 "VectorIdxTy should be smaller than type to be expanded?");
5593 SplitInteger(Res,
Lo,
Hi);
5604bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5608 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5611 switch (
N->getOpcode()) {
5614 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5615 N->dump(&DAG);
dbgs() <<
"\n";
5620 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5624 Res = ExpandOp_FAKE_USE(
N);
5630 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5643 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5648 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5652 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5655 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5657 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5658 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5659 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5662 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5667 if (!Res.
getNode())
return false;
5675 "Invalid operand expansion");
5677 ReplaceValueWith(
SDValue(
N, 0), Res);
5683void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5687 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5688 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5689 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5702 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5709 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5710 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5741 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5742 RHSLo, LowCC,
false, DagCombineInfo, dl);
5744 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5748 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5749 RHSHi, CCCode,
false, DagCombineInfo, dl);
5753 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5762 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5764 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5773 if (LHSHi == RHSHi) {
5782 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5783 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5786 if (HasSETCCCARRY) {
5789 bool FlipOperands =
false;
5806 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5810 DAG.getCondCode(CCCode));
5816 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5817 false, DagCombineInfo, dl);
5820 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5821 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5828 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5833 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5838 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5839 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5840 N->getOperand(4)), 0);
5846 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5851 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5856 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5857 N->getOperand(2),
N->getOperand(3),
5858 DAG.getCondCode(CCCode)), 0);
5864 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5869 "Unexpected setcc expansion!");
5875 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5883 SDLoc dl = SDLoc(
N);
5885 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5886 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5887 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5900 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5910 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5911 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5915 return TLI.expandCMP(
N, DAG);
5923 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5924 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5928 bool IsStrict =
N->isStrictFPOpcode();
5932 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5933 EVT DstVT =
N->getValueType(0);
5936 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5937 "Don't know how to expand this XINT_TO_FP!");
5938 TargetLowering::MakeLibCallOptions CallOptions;
5940 std::pair<SDValue, SDValue> Tmp =
5941 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5946 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5947 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5952 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5955 return ExpandOp_NormalStore(
N, OpNo);
5958 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5960 EVT VT =
N->getOperand(1).getValueType();
5961 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5965 AAMDNodes AAInfo =
N->getAAInfo();
5971 if (
N->getMemoryVT().bitsLE(NVT)) {
5972 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5973 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5974 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5978 if (DAG.getDataLayout().isLittleEndian()) {
5980 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5982 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5985 unsigned ExcessBits =
5992 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5993 N->getPointerInfo().getWithOffset(IncrementSize),
5994 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
6000 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6002 EVT ExtVT =
N->getMemoryVT();
6005 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6013 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6017 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6021 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6022 N->getBaseAlign(), MMOFlags, AAInfo);
6027 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6028 N->getPointerInfo().getWithOffset(IncrementSize),
6030 N->getBaseAlign(), MMOFlags, AAInfo);
6036 GetExpandedInteger(
N->getOperand(0), InL, InH);
6045 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6050SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6051 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6052 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6056 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6058 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6061SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6064 "cannot use llvm.write_register with illegal type", Fn,
6067 return N->getOperand(0);
6070SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6073 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6074 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6077 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6080SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6082 unsigned Factor =
N->getNumOperands();
6085 for (
unsigned i = 0; i != Factor; i++)
6086 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6091 for (
unsigned i = 0; i != Factor; i++)
6097SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6099 EVT OutVT =
N->getValueType(0);
6100 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6101 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6105 SDValue BaseIdx =
N->getOperand(1);
6122 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6126 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6132 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6141 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6145 "Promoted operand has an element type greater than result");
6158 InOp0 = GetPromotedInteger(InOp0);
6165 Ops.reserve(OutNumElems);
6166 for (
unsigned i = 0; i != OutNumElems; ++i) {
6171 N->getOperand(0), Index);
6172 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6177 return DAG.getBuildVector(NOutVT, dl,
Ops);
6180SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6181 EVT OutVT =
N->getValueType(0);
6182 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6183 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6195 Vec = GetPromotedInteger(Vec);
6201SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6204 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6210SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6212 EVT VT =
N->getValueType(0);
6217 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6218 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6221 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6225 EVT OutVT =
N->getValueType(0);
6226 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6227 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6228 unsigned NumElems =
N->getNumOperands();
6235 Ops.reserve(NumElems);
6236 for (
unsigned i = 0; i != NumElems; ++i) {
6238 EVT OpVT =
Op.getValueType();
6243 if (OpVT.
bitsLT(NOutVTElem)) {
6249 ExtOpc = NOutExtOpc;
6250 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6255 return DAG.getBuildVector(NOutVT, dl,
Ops);
6262 assert(!
N->getOperand(0).getValueType().isVector() &&
6263 "Input must be a scalar");
6265 EVT OutVT =
N->getValueType(0);
6266 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6267 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6271 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6276 EVT OutVT =
N->getValueType(0);
6277 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6279 "Type must be promoted to a scalable vector type");
6280 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6281 return DAG.getStepVector(dl, NOutVT,
6285SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6288 EVT OutVT =
N->getValueType(0);
6289 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6290 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6292 unsigned NumOperands =
N->getNumOperands();
6297 SDUse *MaxSizedValue = std::max_element(
6299 EVT AVT = A.getValueType().getVectorElementType();
6300 EVT BVT = B.getValueType().getVectorElementType();
6301 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6307 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6309 EVT OpVT =
Op.getValueType();
6311 Op = GetPromotedInteger(
Op);
6314 "Unhandled legalization type");
6318 Op = DAG.getAnyExtOrTrunc(
6326 return DAG.getAnyExtOrTrunc(
6334 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6335 assert(NumElem * NumOperands == NumOutElem &&
6336 "Unexpected number of elements");
6340 for (
unsigned i = 0; i < NumOperands; ++i) {
6343 Op = GetPromotedInteger(
Op);
6344 EVT SclrTy =
Op.getValueType().getVectorElementType();
6345 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6346 "Unexpected number of elements");
6348 for (
unsigned j = 0;
j < NumElem; ++
j) {
6350 DAG.getVectorIdxConstant(j, dl));
6351 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6355 return DAG.getBuildVector(NOutVT, dl,
Ops);
6358SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6359 EVT VT =
N->getValueType(0);
6360 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6361 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6369 if (getTypeAction(
N->getOperand(0).getValueType())
6373 switch(
N->getOpcode()) {
6375 Promoted = SExtPromotedInteger(
N->getOperand(0));
6378 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6381 Promoted = GetPromotedInteger(
N->getOperand(0));
6393 DAG.getVectorIdxConstant(0, dl));
6395 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6399 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6402SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6403 EVT VT =
N->getValueType(0);
6404 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6408SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6409 EVT VT =
N->getValueType(0);
6410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6414SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6416 EVT VT =
N->getValueType(0);
6417 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6418 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6419 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6423SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6424 EVT OutVT =
N->getValueType(0);
6425 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6426 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6431 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6434 NOutVTElem,
N->getOperand(1));
6436 V0, ConvElem,
N->getOperand(2));
6443 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6444 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6452 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6453 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6454 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6458 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6461 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6462 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6470 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6475SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6478 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6480 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6481 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6482 return DAG.getPOISON(NVT);
6485SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6487 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6488 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6489 TLI.getVectorIdxTy(DAG.getDataLayout()));
6496 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6499SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6504 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6509 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6511 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6523 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6524 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6527SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6529 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6537SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6540 EVT ResVT =
N->getValueType(0);
6541 unsigned NumElems =
N->getNumOperands();
6544 SDValue ResVec = DAG.getUNDEF(ResVT);
6548 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6550 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6562 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6563 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6567 for (
unsigned i=0; i<NumElem; ++i) {
6570 DAG.getVectorIdxConstant(i, dl));
6576 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6579SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6592 for (
unsigned I = 0;
I < OpNo;
I++)
6595 EVT Ty =
Op.getValueType();
6596 SDLoc
DL = SDLoc(
N);
6599 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6607 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6612 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6618SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6631 for (
unsigned I = 0;
I < OpNo;
I++)
6634 EVT Ty =
Op.getValueType();
6635 SDLoc
DL = SDLoc(
N);
6638 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6646 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6651 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
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.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return 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(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getValueType() const
Convenience function for get().getValueType().
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
ArrayRef< int > getMask() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ 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.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ 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 ...
@ 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.
@ 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.
@ 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_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,...
@ 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.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
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 getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
LLVM_ABI Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLRINT(EVT RetVT)
LLVM_ABI Libcall getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getLLRINT(EVT RetVT)
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
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)