26#include "llvm/IR/IntrinsicsARM.h"
45#define DEBUG_TYPE "armtti"
57 unsigned Alignment = IntrAlign->getLimitedValue() < MemAlign
59 : IntrAlign->getLimitedValue();
64 return Builder.CreateAlignedLoad(
II.getType(),
II.getArgOperand(0),
71 if (ST->hasMVEIntegerOps())
74 if (L->getHeader()->getParent()->hasOptSize())
77 if (ST->isMClass() && ST->isThumb2() &&
78 L->getNumBlocks() == 1)
84std::optional<Instruction *>
91 case Intrinsic::arm_neon_vld1: {
101 case Intrinsic::arm_neon_vld2:
102 case Intrinsic::arm_neon_vld3:
103 case Intrinsic::arm_neon_vld4:
104 case Intrinsic::arm_neon_vld2lane:
105 case Intrinsic::arm_neon_vld3lane:
106 case Intrinsic::arm_neon_vld4lane:
107 case Intrinsic::arm_neon_vst1:
108 case Intrinsic::arm_neon_vst2:
109 case Intrinsic::arm_neon_vst3:
110 case Intrinsic::arm_neon_vst4:
111 case Intrinsic::arm_neon_vst2lane:
112 case Intrinsic::arm_neon_vst3lane:
113 case Intrinsic::arm_neon_vst4lane: {
117 unsigned AlignArg =
II.arg_size() - 1;
118 Value *AlignArgOp =
II.getArgOperand(AlignArg);
129 case Intrinsic::arm_neon_vld1x2:
130 case Intrinsic::arm_neon_vld1x3:
131 case Intrinsic::arm_neon_vld1x4:
132 case Intrinsic::arm_neon_vst1x2:
133 case Intrinsic::arm_neon_vst1x3:
134 case Intrinsic::arm_neon_vst1x4: {
138 Align OldAlign =
II.getParamAlign(0).valueOrOne();
139 if (NewAlign > OldAlign)
145 case Intrinsic::arm_mve_pred_i2v: {
146 Value *Arg =
II.getArgOperand(0);
159 if (CI->getValue().trunc(16).isAllOnes()) {
174 case Intrinsic::arm_mve_pred_v2i: {
175 Value *Arg =
II.getArgOperand(0);
182 if (
II.getMetadata(LLVMContext::MD_range))
187 if (
auto CurrentRange =
II.getRange()) {
189 if (
Range == CurrentRange)
194 II.addRetAttr(Attribute::NoUndef);
197 case Intrinsic::arm_mve_vadc:
198 case Intrinsic::arm_mve_vadc_predicated: {
200 (
II.getIntrinsicID() == Intrinsic::arm_mve_vadc_predicated) ? 3 : 2;
201 assert(
II.getArgOperand(CarryOp)->getType()->getScalarSizeInBits() == 32 &&
202 "Bad type for intrinsic!");
211 case Intrinsic::arm_mve_vmldava: {
213 if (
I->hasOneUse()) {
214 auto *
User = *
I->user_begin();
218 Value *OpX =
I->getOperand(4);
219 Value *OpY =
I->getOperand(5);
225 {
I->getOperand(0),
I->getOperand(1),
226 I->getOperand(2), OpZ, OpX, OpY});
242 SimplifyAndSetOp)
const {
247 auto SimplifyNarrowInstrTopBottom =[&](
unsigned TopOpc) {
256 SimplifyAndSetOp(&
II, 0, OrigDemandedElts & DemandedElts, UndefElts);
263 switch (
II.getIntrinsicID()) {
266 case Intrinsic::arm_mve_vcvt_narrow:
267 SimplifyNarrowInstrTopBottom(2);
269 case Intrinsic::arm_mve_vqmovn:
270 SimplifyNarrowInstrTopBottom(4);
272 case Intrinsic::arm_mve_vshrn:
273 SimplifyNarrowInstrTopBottom(7);
282 assert(Ty->isIntegerTy());
284 unsigned Bits = Ty->getPrimitiveSizeInBits();
285 if (Bits == 0 ||
Imm.getActiveBits() >= 64)
288 int64_t SImmVal =
Imm.getSExtValue();
289 uint64_t ZImmVal =
Imm.getZExtValue();
290 if (!ST->isThumb()) {
291 if ((SImmVal >= 0 && SImmVal < 65536) ||
295 return ST->hasV6T2Ops() ? 2 : 3;
297 if (ST->isThumb2()) {
298 if ((SImmVal >= 0 && SImmVal < 65536) ||
302 return ST->hasV6T2Ops() ? 2 : 3;
305 if (Bits == 8 || (SImmVal >= 0 && SImmVal < 256))
318 if (
Imm.isNonNegative() &&
Imm.getLimitedValue() < 256)
334 C->getValue() ==
Imm &&
Imm.isNegative() &&
Imm.isNegatedPowerOf2()) {
336 auto isSSatMin = [&](
Value *MinInst) {
338 Value *MinLHS, *MinRHS;
362 if (
Imm.getBitWidth() != 64 ||
381 if ((Opcode == Instruction::SDiv || Opcode == Instruction::UDiv ||
382 Opcode == Instruction::SRem || Opcode == Instruction::URem) &&
388 if (Opcode == Instruction::GetElementPtr && Idx != 0)
391 if (Opcode == Instruction::And) {
393 if (
Imm == 255 ||
Imm == 65535)
400 if (Opcode == Instruction::Add)
405 if (Opcode == Instruction::ICmp &&
Imm.isNegative() &&
406 Ty->getIntegerBitWidth() == 32) {
407 int64_t NegImm = -
Imm.getSExtValue();
408 if (ST->isThumb2() && NegImm < 1<<12)
411 if (ST->isThumb() && NegImm < 1<<8)
417 if (Opcode == Instruction::Xor &&
Imm.isAllOnes())
422 if (Inst && ((ST->hasV6Ops() && !ST->isThumb()) || ST->isThumb2()) &&
423 Ty->getIntegerBitWidth() <= 32) {
434 if (Inst && Opcode == Instruction::ICmp && Idx == 1 &&
Imm.isAllOnes()) {
448 (ST->hasNEON() || ST->hasMVEIntegerOps())) {
463 int ISD = TLI->InstructionOpcodeToISD(Opcode);
469 return Cost == 0 ? 0 : 1;
472 auto IsLegalFPType = [
this](
EVT VT) {
474 return (EltVT == MVT::f32 && ST->hasVFP2Base()) ||
475 (EltVT == MVT::f64 && ST->hasFP64()) ||
476 (EltVT == MVT::f16 && ST->hasFullFP16());
479 EVT SrcTy = TLI->getValueType(
DL, Src);
480 EVT DstTy = TLI->getValueType(
DL, Dst);
482 if (!SrcTy.isSimple() || !DstTy.
isSimple())
489 if ((ST->hasMVEIntegerOps() &&
490 (Opcode == Instruction::Trunc || Opcode == Instruction::ZExt ||
491 Opcode == Instruction::SExt)) ||
492 (ST->hasMVEFloatOps() &&
493 (Opcode == Instruction::FPExt || Opcode == Instruction::FPTrunc) &&
494 IsLegalFPType(SrcTy) && IsLegalFPType(DstTy)))
497 ST->getMVEVectorCostFactor(CostKind);
517 LoadConversionTbl,
ISD, DstTy.
getSimpleVT(), SrcTy.getSimpleVT()))
518 return AdjustCost(Entry->Cost);
537 if (SrcTy.isVector() && ST->hasMVEIntegerOps()) {
538 if (
const auto *Entry =
541 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
549 if (SrcTy.isVector() && ST->hasMVEFloatOps()) {
550 if (
const auto *Entry =
553 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
566 if (SrcTy.isVector() && ST->hasMVEIntegerOps()) {
567 if (
const auto *Entry =
570 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
577 if (SrcTy.isVector() && ST->hasMVEFloatOps()) {
578 if (
const auto *Entry =
581 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
587 I &&
I->hasOneUse() && ST->hasNEON() && SrcTy.isVector()) {
590 {
ISD::ADD, MVT::v4i32, MVT::v4i16, 0 },
591 {
ISD::ADD, MVT::v8i16, MVT::v8i8, 0 },
593 {
ISD::SUB, MVT::v4i32, MVT::v4i16, 0 },
594 {
ISD::SUB, MVT::v8i16, MVT::v8i8, 0 },
596 {
ISD::MUL, MVT::v4i32, MVT::v4i16, 0 },
597 {
ISD::MUL, MVT::v8i16, MVT::v8i8, 0 },
599 {
ISD::SHL, MVT::v4i32, MVT::v4i16, 0 },
600 {
ISD::SHL, MVT::v8i16, MVT::v8i8, 0 },
603 auto *
User = *
I->user_begin();
604 int UserISD = TLI->InstructionOpcodeToISD(
User->getOpcode());
607 SrcTy.getSimpleVT())) {
608 return AdjustCost(Entry->Cost);
613 if (Src->isVectorTy() && ST->hasNEON() &&
626 return AdjustCost(LT.first * Entry->Cost);
715 if (SrcTy.isVector() && ST->hasNEON()) {
718 SrcTy.getSimpleVT()))
719 return AdjustCost(Entry->Cost);
745 if (SrcTy.isFloatingPoint() && ST->hasNEON()) {
748 SrcTy.getSimpleVT()))
749 return AdjustCost(Entry->Cost);
776 if (SrcTy.isInteger() && ST->hasNEON()) {
779 SrcTy.getSimpleVT()))
780 return AdjustCost(Entry->Cost);
801 if (SrcTy.isVector() && ST->hasMVEIntegerOps()) {
804 SrcTy.getSimpleVT()))
805 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
815 if (SrcTy.isFixedLengthVector())
816 Lanes = SrcTy.getVectorNumElements();
818 if (IsLegalFPType(SrcTy) && IsLegalFPType(DstTy))
821 return Lanes * CallCost;
825 SrcTy.isFixedLengthVector()) {
828 if ((SrcTy.getScalarType() == MVT::i8 ||
829 SrcTy.getScalarType() == MVT::i16 ||
830 SrcTy.getScalarType() == MVT::i32) &&
831 SrcTy.getSizeInBits() > 128 &&
833 return SrcTy.getVectorNumElements() * 2;
848 if (SrcTy.isInteger()) {
851 SrcTy.getSimpleVT()))
852 return AdjustCost(Entry->Cost);
855 int BaseCost = ST->hasMVEIntegerOps() && Src->isVectorTy()
856 ? ST->getMVEVectorCostFactor(CostKind)
867 if (ST->hasSlowLoadDSubregister() && Opcode == Instruction::InsertElement &&
871 if (ST->hasNEON() && (Opcode == Instruction::InsertElement ||
872 Opcode == Instruction::ExtractElement)) {
882 return std::max<InstructionCost>(
888 if (ST->hasMVEIntegerOps() && (Opcode == Instruction::InsertElement ||
889 Opcode == Instruction::ExtractElement)) {
893 std::pair<InstructionCost, MVT> LT =
895 return LT.first * (ValTy->
getScalarType()->isIntegerTy() ? 4 : 1);
906 int ISD = TLI->InstructionOpcodeToISD(Opcode);
912 if (TLI->getValueType(
DL, ValTy,
true) == MVT::Other)
936 if ((Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) && Sel &&
941 const Value *LHS, *RHS;
946 IID = Intrinsic::abs;
949 IID = Intrinsic::smin;
952 IID = Intrinsic::smax;
955 IID = Intrinsic::umin;
958 IID = Intrinsic::umax;
961 IID = Intrinsic::minnum;
964 IID = Intrinsic::maxnum;
982 {
ISD::SELECT, MVT::v4i1, MVT::v4i64, 4*4 + 1*2 + 1 },
987 EVT SelCondTy = TLI->getValueType(
DL, CondTy);
988 EVT SelValTy = TLI->getValueType(
DL, ValTy);
1000 if (ST->hasMVEIntegerOps() && ValTy->
isVectorTy() &&
1001 (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) &&
1009 if (Opcode == Instruction::FCmp && !ST->hasMVEFloatOps()) {
1019 CostKind, Op1Info, Op2Info,
I);
1023 int BaseCost = ST->getMVEVectorCostFactor(CostKind);
1029 if (LT.second.isVector() && LT.second.getVectorNumElements() > 2) {
1031 return LT.first * BaseCost +
1041 if (ST->hasMVEIntegerOps() && ValTy->
isVectorTy())
1042 BaseCost = ST->getMVEVectorCostFactor(CostKind);
1045 CostKind, Op1Info, Op2Info,
I);
1056 unsigned NumVectorInstToHideOverhead = 10;
1057 int MaxMergeDistance = 64;
1059 if (ST->hasNEON()) {
1062 return NumVectorInstToHideOverhead;
1075 switch (
II->getIntrinsicID()) {
1076 case Intrinsic::arm_mve_vctp8:
1077 case Intrinsic::arm_mve_vctp16:
1078 case Intrinsic::arm_mve_vctp32:
1079 case Intrinsic::arm_mve_vctp64:
1091 if (!ST->getCLOpts().maskedldst || !ST->hasMVEIntegerOps())
1096 if (VecTy->getNumElements() == 2)
1101 if (VecWidth != 128 && VecTy->getElementType()->isFloatingPointTy())
1106 return (EltWidth == 32 && Alignment >= 4) ||
1107 (EltWidth == 16 && Alignment >= 2) || (EltWidth == 8);
1111 if (!ST->getCLOpts().maskedgatscat || !ST->hasMVEIntegerOps())
1114 unsigned EltWidth = Ty->getScalarSizeInBits();
1115 return ((EltWidth == 32 && Alignment >= 4) ||
1116 (EltWidth == 16 && Alignment >= 2) || EltWidth == 8);
1124 unsigned DstAddrSpace = ~0u;
1125 unsigned SrcAddrSpace = ~0u;
1126 const Function *
F =
I->getParent()->getParent();
1134 const unsigned Size =
C->getValue().getZExtValue();
1135 const Align DstAlign = MC->getDestAlign().valueOrOne();
1136 const Align SrcAlign = MC->getSourceAlign().valueOrOne();
1141 DstAddrSpace = MC->getDestAddressSpace();
1142 SrcAddrSpace = MC->getSourceAddressSpace();
1150 const unsigned Size =
C->getValue().getZExtValue();
1151 const Align DstAlign = MS->getDestAlign().valueOrOne();
1155 DstAddrSpace = MS->getDestAddressSpace();
1160 unsigned Limit, Factor = 2;
1161 switch(
I->getIntrinsicID()) {
1162 case Intrinsic::memcpy:
1163 Limit = TLI->getMaxStoresPerMemcpy(
F->hasMinSize());
1165 case Intrinsic::memmove:
1166 Limit = TLI->getMaxStoresPerMemmove(
F->hasMinSize());
1168 case Intrinsic::memset:
1169 Limit = TLI->getMaxStoresPerMemset(
F->hasMinSize());
1179 std::vector<EVT> MemOps;
1181 if (getTLI()->findOptimalMemOpLowering(
C, MemOps, Limit, MOp, DstAddrSpace,
1182 SrcAddrSpace,
F->getAttributes(),
1184 return MemOps.size() * Factor;
1207 "Expected the Mask to match the return size if given");
1209 "Expected the same scalar types");
1214 if (IsExtractSubvector)
1216 if (ST->hasNEON()) {
1233 if (
const auto *Entry =
1235 return LT.first * Entry->Cost;
1254 if (
const auto *Entry =
1256 return LT.first * Entry->Cost;
1280 return LT.first * Entry->Cost;
1285 if (!Mask.empty()) {
1288 if (LT.second.isVector() &&
1289 Mask.size() <= LT.second.getVectorNumElements() &&
1301 if (ST->hasMVEIntegerOps()) {
1314 return LT.first * Entry->Cost * ST->getMVEVectorCostFactor(CostKind);
1317 if (!Mask.empty()) {
1324 (LT.second.getScalarSizeInBits() == 8 ||
1325 LT.second.getScalarSizeInBits() == 16 ||
1326 LT.second.getScalarSizeInBits() == 32) &&
1327 LT.second.getSizeInBits() == 128 &&
1328 ((TLI->getMaxSupportedInterleaveFactor() >= 2 &&
1330 (TLI->getMaxSupportedInterleaveFactor() == 4 &&
1332 return ST->getMVEVectorCostFactor(CostKind) *
1333 std::max<InstructionCost>(1, LT.first / 4);
1340 (LT.second.getScalarSizeInBits() == 8 ||
1341 LT.second.getScalarSizeInBits() == 16 ||
1342 LT.second.getScalarSizeInBits() == 32) &&
1343 LT.second.getSizeInBits() == 128 &&
1344 ((TLI->getMaxSupportedInterleaveFactor() >= 2 &&
1346 Mask, 2, SrcTy->getElementCount().getKnownMinValue() * 2)) ||
1347 (TLI->getMaxSupportedInterleaveFactor() == 4 &&
1349 Mask, 4, SrcTy->getElementCount().getKnownMinValue() * 2))))
1350 return ST->getMVEVectorCostFactor(CostKind) * LT.first;
1352 if (LT.second.isVector() &&
1353 Mask.size() <= LT.second.getVectorNumElements() &&
1356 return ST->getMVEVectorCostFactor(CostKind) * LT.first;
1361 if (IsExtractSubvector)
1363 int BaseCost = ST->hasMVEIntegerOps() && SrcTy->isVectorTy()
1364 ? ST->getMVEVectorCostFactor(CostKind)
1375 int ISDOpcode = TLI->InstructionOpcodeToISD(Opcode);
1380 switch (ISDOpcode) {
1393 if (ST->hasNEON()) {
1394 const unsigned FunctionCallDivCost = 20;
1395 const unsigned ReciprocalDivCost = 10;
1401 {
ISD::SDIV, MVT::v1i64, 1 * FunctionCallDivCost},
1402 {
ISD::UDIV, MVT::v1i64, 1 * FunctionCallDivCost},
1403 {
ISD::SREM, MVT::v1i64, 1 * FunctionCallDivCost},
1404 {
ISD::UREM, MVT::v1i64, 1 * FunctionCallDivCost},
1405 {
ISD::SDIV, MVT::v2i32, 2 * FunctionCallDivCost},
1406 {
ISD::UDIV, MVT::v2i32, 2 * FunctionCallDivCost},
1407 {
ISD::SREM, MVT::v2i32, 2 * FunctionCallDivCost},
1408 {
ISD::UREM, MVT::v2i32, 2 * FunctionCallDivCost},
1409 {
ISD::SDIV, MVT::v4i16, ReciprocalDivCost},
1410 {
ISD::UDIV, MVT::v4i16, ReciprocalDivCost},
1411 {
ISD::SREM, MVT::v4i16, 4 * FunctionCallDivCost},
1412 {
ISD::UREM, MVT::v4i16, 4 * FunctionCallDivCost},
1413 {
ISD::SDIV, MVT::v8i8, ReciprocalDivCost},
1414 {
ISD::UDIV, MVT::v8i8, ReciprocalDivCost},
1415 {
ISD::SREM, MVT::v8i8, 8 * FunctionCallDivCost},
1416 {
ISD::UREM, MVT::v8i8, 8 * FunctionCallDivCost},
1418 {
ISD::SDIV, MVT::v2i64, 2 * FunctionCallDivCost},
1419 {
ISD::UDIV, MVT::v2i64, 2 * FunctionCallDivCost},
1420 {
ISD::SREM, MVT::v2i64, 2 * FunctionCallDivCost},
1421 {
ISD::UREM, MVT::v2i64, 2 * FunctionCallDivCost},
1422 {
ISD::SDIV, MVT::v4i32, 4 * FunctionCallDivCost},
1423 {
ISD::UDIV, MVT::v4i32, 4 * FunctionCallDivCost},
1424 {
ISD::SREM, MVT::v4i32, 4 * FunctionCallDivCost},
1425 {
ISD::UREM, MVT::v4i32, 4 * FunctionCallDivCost},
1426 {
ISD::SDIV, MVT::v8i16, 8 * FunctionCallDivCost},
1427 {
ISD::UDIV, MVT::v8i16, 8 * FunctionCallDivCost},
1428 {
ISD::SREM, MVT::v8i16, 8 * FunctionCallDivCost},
1429 {
ISD::UREM, MVT::v8i16, 8 * FunctionCallDivCost},
1430 {
ISD::SDIV, MVT::v16i8, 16 * FunctionCallDivCost},
1431 {
ISD::UDIV, MVT::v16i8, 16 * FunctionCallDivCost},
1432 {
ISD::SREM, MVT::v16i8, 16 * FunctionCallDivCost},
1433 {
ISD::UREM, MVT::v16i8, 16 * FunctionCallDivCost},
1437 if (
const auto *Entry =
CostTableLookup(CostTbl, ISDOpcode, LT.second))
1438 return LT.first * Entry->Cost;
1441 Opcode, Ty, CostKind, Op1Info, Op2Info);
1458 auto LooksLikeAFreeShift = [&]() {
1459 if (ST->isThumb1Only() || Ty->isVectorTy())
1469 case Instruction::Add:
1470 case Instruction::Sub:
1471 case Instruction::And:
1472 case Instruction::Xor:
1473 case Instruction::Or:
1474 case Instruction::ICmp:
1480 if (LooksLikeAFreeShift())
1490 auto MulInDSPMLALPattern = [&](
const Instruction *
I,
unsigned Opcode,
1498 if (Opcode != Instruction::Mul)
1501 if (Ty->isVectorTy())
1504 auto ValueOpcodesEqual = [](
const Value *LHS,
const Value *RHS) ->
bool {
1508 auto IsExtInst = [](
const Value *V) ->
bool {
1511 auto IsExtensionFromHalf = [](
const Value *V) ->
bool {
1519 Value *Op0 = BinOp->getOperand(0);
1520 Value *Op1 = BinOp->getOperand(1);
1521 if (IsExtInst(Op0) && IsExtInst(Op1) && ValueOpcodesEqual(Op0, Op1)) {
1523 if (!
I->getType()->isIntegerTy(32) || !IsExtensionFromHalf(Op0) ||
1524 !IsExtensionFromHalf(Op1))
1528 for (
auto *U :
I->users())
1537 if (MulInDSPMLALPattern(CtxI, Opcode, Ty))
1543 if (ST->hasMVEIntegerOps() && Ty->isVectorTy())
1544 BaseCost = ST->getMVEVectorCostFactor(CostKind);
1550 if (TLI->isOperationLegalOrCustomOrPromote(ISDOpcode, LT.second))
1551 return LT.first * BaseCost;
1555 unsigned Num = VTy->getNumElements();
1577 CostKind, OpInfo,
I);
1584 if (TLI->getValueType(
DL, Src,
true) == MVT::Other)
1588 if (ST->hasNEON() && Src->isVectorTy() && Alignment !=
Align(16) &&
1593 return LT.first * 4;
1599 ((Opcode == Instruction::Load &&
I->hasOneUse() &&
1604 Opcode == Instruction::Load
1605 ? (*
I->user_begin())->getType()
1609 return ST->getMVEVectorCostFactor(CostKind);
1612 int BaseCost = ST->hasMVEIntegerOps() && Src->isVectorTy()
1613 ? ST->getMVEVectorCostFactor(CostKind)
1616 CostKind, OpInfo,
I);
1622 switch (MICA.
getID()) {
1623 case Intrinsic::masked_scatter:
1624 case Intrinsic::masked_gather:
1626 case Intrinsic::masked_load:
1627 case Intrinsic::masked_store:
1636 unsigned IID = MICA.
getID();
1640 if (ST->hasMVEIntegerOps()) {
1641 if (IID == Intrinsic::masked_load &&
1643 return ST->getMVEVectorCostFactor(CostKind);
1644 if (IID == Intrinsic::masked_store &&
1646 return ST->getMVEVectorCostFactor(CostKind);
1658 bool UseMaskForCond,
bool UseMaskForGaps)
const {
1659 assert(Factor >= 2 &&
"Invalid interleave factor");
1663 bool EltIs64Bits =
DL.getTypeSizeInBits(VecTy->
getScalarType()) == 64;
1665 if (Factor <= TLI->getMaxSupportedInterleaveFactor() && !EltIs64Bits &&
1666 !UseMaskForCond && !UseMaskForGaps) {
1675 ST->hasMVEIntegerOps() ? ST->getMVEVectorCostFactor(CostKind) : 1;
1676 if (NumElts % Factor == 0 &&
1677 TLI->isLegalInterleavedAccessType(Factor,
SubVecTy, Alignment,
DL))
1678 return Factor * BaseCost * TLI->getNumInterleavedAccesses(
SubVecTy,
DL);
1685 if (ST->hasMVEIntegerOps() && Factor == 2 && NumElts / Factor > 2 &&
1687 DL.getTypeSizeInBits(
SubVecTy).getFixedValue() <= 64)
1688 return 2 * BaseCost;
1693 UseMaskForCond, UseMaskForGaps);
1707 if (!ST->hasMVEIntegerOps() || !ST->getCLOpts().maskedgatscat)
1715 unsigned NumElems = VTy->getNumElements();
1716 unsigned EltSize = VTy->getScalarSizeInBits();
1725 NumElems * LT.first * ST->getMVEVectorCostFactor(CostKind);
1731 NumElems * LT.first + (VariableMask ? NumElems * 5 : 0) +
1737 if (EltSize < 8 || Alignment < EltSize / 8)
1740 unsigned ExtSize = EltSize;
1746 if ((
I->getOpcode() == Instruction::Load ||
1749 const User *Us = *
I->users().begin();
1754 if (((
TypeSize == 32 && (EltSize == 8 || EltSize == 16)) ||
1755 (
TypeSize == 16 && EltSize == 8)) &&
1763 if ((
I->getOpcode() == Instruction::Store ||
1767 unsigned TypeSize =
T->getOperand(0)->getType()->getScalarSizeInBits();
1768 if (((EltSize == 16 &&
TypeSize == 32) ||
1775 if (ExtSize * NumElems != 128 || NumElems < 4)
1784 if (ExtSize != 8 && ExtSize != 16)
1788 Ptr = BC->getOperand(0);
1790 if (
GEP->getNumOperands() != 2)
1792 unsigned Scale =
DL.getTypeAllocSize(
GEP->getResultElementType());
1794 if (Scale != 1 && Scale * 8 != ExtSize)
1798 if (ZExt->getOperand(0)->getType()->getScalarSizeInBits() <= ExtSize)
1808 std::optional<FastMathFlags> FMF,
1811 EVT ValVT = TLI->getValueType(
DL, ValTy);
1812 int ISD = TLI->InstructionOpcodeToISD(Opcode);
1819 ((EltSize == 32 && ST->hasVFP2Base()) ||
1820 (EltSize == 64 && ST->hasFP64()) ||
1821 (EltSize == 16 && ST->hasFullFP16()))) {
1823 unsigned VecLimit = ST->hasMVEFloatOps() ? 128 : (ST->hasNEON() ? 64 : -1);
1826 NumElts * EltSize > VecLimit) {
1837 VecCost += ST->getMVEVectorCostFactor(CostKind) * 2;
1840 ExtractCost = NumElts / 2;
1842 return VecCost + ExtractCost +
1848 (EltSize == 64 || EltSize == 32 || EltSize == 16 || EltSize == 8)) {
1851 ST->hasMVEIntegerOps() ? 128 : (ST->hasNEON() ? 64 : -1);
1853 while (
isPowerOf2_32(NumElts) && NumElts * EltSize > VecLimit) {
1861 NumElts * EltSize == 64) {
1863 VecCost += ST->getMVEVectorCostFactor(CostKind) +
1870 return VecCost + ExtractCost +
1887 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind) * LT.first;
1893 unsigned Opcode,
bool IsUnsigned,
Type *ResTy,
VectorType *ValTy,
1895 EVT ValVT = TLI->getValueType(
DL, ValTy);
1896 EVT ResVT = TLI->getValueType(
DL, ResTy);
1898 int ISD = TLI->InstructionOpcodeToISD(Opcode);
1913 ((LT.second == MVT::v16i8 && RevVTSize <= 32) ||
1914 (LT.second == MVT::v8i16 && RevVTSize <= 32) ||
1915 (LT.second == MVT::v4i32 && RevVTSize <= 64)))
1916 return ST->getMVEVectorCostFactor(CostKind) * LT.first;
1930 if (RedOpcode != Instruction::Add)
1932 EVT ValVT = TLI->getValueType(
DL, ValTy);
1933 EVT ResVT = TLI->getValueType(
DL, ResTy);
1946 ((LT.second == MVT::v16i8 && RevVTSize <= 32) ||
1947 (LT.second == MVT::v8i16 && RevVTSize <= 64) ||
1948 (LT.second == MVT::v4i32 && RevVTSize <= 64)))
1949 return ST->getMVEVectorCostFactor(CostKind) * LT.first;
1960 EVT ValVT = TLI->getValueType(
DL, Ty);
1965 if ((IID == Intrinsic::minnum || IID == Intrinsic::maxnum) &&
1971 unsigned VecLimit = ST->hasMVEFloatOps() ? 128 : (ST->hasNEON() ? 64 : -1);
1973 while (
isPowerOf2_32(NumElts) && NumElts * EltSize > VecLimit) {
1985 VecCost += ST->getMVEVectorCostFactor(CostKind) * 2;
1991 {Ty->getElementType(), Ty->getElementType()},
1993 return VecCost + ExtractCost +
1997 if (IID == Intrinsic::smin || IID == Intrinsic::smax ||
1998 IID == Intrinsic::umin || IID == Intrinsic::umax) {
2010 return Entry->Cost * ST->getMVEVectorCostFactor(CostKind) * LT.first;
2021 case Intrinsic::get_active_lane_mask:
2029 if (ST->hasMVEIntegerOps())
2032 case Intrinsic::sadd_sat:
2033 case Intrinsic::ssub_sat:
2034 case Intrinsic::uadd_sat:
2035 case Intrinsic::usub_sat: {
2036 bool IsAdd = (
Opc == Intrinsic::sadd_sat ||
Opc == Intrinsic::ssub_sat);
2037 bool IsSigned = (
Opc == Intrinsic::sadd_sat ||
Opc == Intrinsic::ssub_sat);
2041 if (IsSigned && ST->hasDSP() && ITy->getBitWidth() == 32)
2043 if (ST->hasDSP() && (ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16))
2057 if (!ST->hasMVEIntegerOps())
2061 if (LT.second == MVT::v4i32 || LT.second == MVT::v8i16 ||
2062 LT.second == MVT::v16i8) {
2068 return LT.first * ST->getMVEVectorCostFactor(CostKind) * Instrs;
2072 case Intrinsic::abs:
2073 case Intrinsic::smin:
2074 case Intrinsic::smax:
2075 case Intrinsic::umin:
2076 case Intrinsic::umax: {
2077 if (!ST->hasMVEIntegerOps())
2082 if (LT.second == MVT::v4i32 || LT.second == MVT::v8i16 ||
2083 LT.second == MVT::v16i8)
2084 return LT.first * ST->getMVEVectorCostFactor(CostKind);
2087 case Intrinsic::minnum:
2088 case Intrinsic::maxnum: {
2089 if (!ST->hasMVEFloatOps())
2093 if (LT.second == MVT::v4f32 || LT.second == MVT::v8f16)
2094 return LT.first * ST->getMVEVectorCostFactor(CostKind);
2097 case Intrinsic::fptosi_sat:
2098 case Intrinsic::fptoui_sat: {
2101 bool IsSigned =
Opc == Intrinsic::fptosi_sat;
2105 if ((ST->hasVFP2Base() && LT.second == MVT::f32 && MTy == MVT::i32) ||
2106 (ST->hasFP64() && LT.second == MVT::f64 && MTy == MVT::i32) ||
2107 (ST->hasFullFP16() && LT.second == MVT::f16 && MTy == MVT::i32))
2111 if (ST->hasMVEFloatOps() &&
2112 (LT.second == MVT::v4f32 || LT.second == MVT::v8f16) &&
2114 return LT.first * ST->getMVEVectorCostFactor(CostKind);
2117 if (((ST->hasVFP2Base() && LT.second == MVT::f32) ||
2118 (ST->hasFP64() && LT.second == MVT::f64) ||
2119 (ST->hasFullFP16() && LT.second == MVT::f16) ||
2120 (ST->hasMVEFloatOps() &&
2121 (LT.second == MVT::v4f32 || LT.second == MVT::v8f16))) &&
2124 LT.second.getScalarSizeInBits());
2126 LT.second.isVector() ? ST->getMVEVectorCostFactor(CostKind) : 1;
2129 LegalTy, {LegalTy, LegalTy});
2133 LegalTy, {LegalTy, LegalTy});
2135 return LT.first *
Cost;
2163 if (!
F->isIntrinsic())
2167 if (
F->getName().starts_with(
"llvm.arm"))
2170 switch (
F->getIntrinsicID()) {
2172 case Intrinsic::powi:
2173 case Intrinsic::sin:
2174 case Intrinsic::cos:
2175 case Intrinsic::sincos:
2176 case Intrinsic::pow:
2177 case Intrinsic::log:
2178 case Intrinsic::log10:
2179 case Intrinsic::log2:
2180 case Intrinsic::exp:
2181 case Intrinsic::exp2:
2183 case Intrinsic::sqrt:
2184 case Intrinsic::fabs:
2185 case Intrinsic::copysign:
2186 case Intrinsic::floor:
2187 case Intrinsic::ceil:
2188 case Intrinsic::trunc:
2189 case Intrinsic::rint:
2190 case Intrinsic::nearbyint:
2191 case Intrinsic::round:
2192 case Intrinsic::canonicalize:
2193 case Intrinsic::lround:
2194 case Intrinsic::llround:
2195 case Intrinsic::lrint:
2196 case Intrinsic::llrint:
2197 if (
F->getReturnType()->isDoubleTy() && !ST->hasFP64())
2199 if (
F->getReturnType()->isHalfTy() && !ST->hasFullFP16())
2204 return !ST->hasFPARMv8Base() && !ST->hasVFP2Base();
2205 case Intrinsic::masked_store:
2206 case Intrinsic::masked_load:
2207 case Intrinsic::masked_gather:
2208 case Intrinsic::masked_scatter:
2209 return !ST->hasMVEIntegerOps();
2210 case Intrinsic::sadd_with_overflow:
2211 case Intrinsic::uadd_with_overflow:
2212 case Intrinsic::ssub_with_overflow:
2213 case Intrinsic::usub_with_overflow:
2214 case Intrinsic::sadd_sat:
2215 case Intrinsic::uadd_sat:
2216 case Intrinsic::ssub_sat:
2217 case Intrinsic::usub_sat:
2225 unsigned ISD = TLI->InstructionOpcodeToISD(
I.getOpcode());
2226 EVT VT = TLI->getValueType(
DL,
I.getType(),
true);
2234 switch(
II->getIntrinsicID()) {
2235 case Intrinsic::memcpy:
2236 case Intrinsic::memset:
2237 case Intrinsic::memmove:
2249 switch (
I.getOpcode()) {
2252 case Instruction::FPToSI:
2253 case Instruction::FPToUI:
2254 case Instruction::SIToFP:
2255 case Instruction::UIToFP:
2256 case Instruction::FPTrunc:
2257 case Instruction::FPExt:
2258 return !ST->hasFPARMv8Base();
2286 if (TLI->useSoftFloat()) {
2287 switch (
I.getOpcode()) {
2290 case Instruction::Alloca:
2291 case Instruction::Load:
2292 case Instruction::Store:
2293 case Instruction::Select:
2294 case Instruction::PHI:
2301 if (
I.getType()->isDoubleTy() && !ST->hasFP64())
2305 if (
I.getType()->isHalfTy() && !ST->hasFullFP16())
2317 if (!ST->hasV8_1MMainlineOps() || !ST->hasLOB() || !ST->getCLOpts().loloops) {
2333 const SCEV *TripCountSCEV =
2339 LLVM_DEBUG(
dbgs() <<
"ARMHWLoops: Trip count does not fit into 32bits\n");
2348 switch (
Call->getIntrinsicID()) {
2351 case Intrinsic::start_loop_iterations:
2352 case Intrinsic::test_start_loop_iterations:
2353 case Intrinsic::loop_decrement:
2354 case Intrinsic::loop_decrement_reg:
2364 bool IsTailPredLoop =
false;
2365 auto ScanLoop = [&](
Loop *L) {
2366 for (
auto *BB : L->getBlocks()) {
2367 for (
auto &
I : *BB) {
2375 II->getIntrinsicID() == Intrinsic::get_active_lane_mask ||
2376 II->getIntrinsicID() == Intrinsic::arm_mve_vctp8 ||
2377 II->getIntrinsicID() == Intrinsic::arm_mve_vctp16 ||
2378 II->getIntrinsicID() == Intrinsic::arm_mve_vctp32 ||
2379 II->getIntrinsicID() == Intrinsic::arm_mve_vctp64;
2386 for (
auto *Inner : *L)
2387 if (!ScanLoop(Inner))
2401 ST->getCLOpts().allow_wlsloops && !IsTailPredLoop;
2420 if ((
II->getIntrinsicID() == Intrinsic::smin ||
2421 II->getIntrinsicID() == Intrinsic::smax ||
2422 II->getIntrinsicID() == Intrinsic::umin ||
2423 II->getIntrinsicID() == Intrinsic::umax) &&
2463 LLVM_DEBUG(
dbgs() <<
"Tail-predication: checking allowed instructions\n");
2474 bool ReductionsDisabled =
2478 for (
auto *
I : LiveOuts) {
2479 if (!
I->getType()->isIntegerTy() && !
I->getType()->isFloatTy() &&
2480 !
I->getType()->isHalfTy()) {
2481 LLVM_DEBUG(
dbgs() <<
"Don't tail-predicate loop with non-integer/float "
2482 "live-out value\n");
2485 if (ReductionsDisabled) {
2505 if (
T->getScalarSizeInBits() > 32) {
2512 int64_t NextStride =
2514 if (NextStride == 1) {
2519 }
else if (NextStride == -1 ||
2520 (NextStride == 2 && CLOpts.mve_max_interleave_factor >= 2) ||
2521 (NextStride == 4 && CLOpts.mve_max_interleave_factor >= 4)) {
2523 <<
"Consecutive strides of 2 found, vld2/vstr2 can't "
2524 "be tail-predicated\n.");
2527 }
else if (CLOpts.maskedgatscat) {
2534 const SCEV *Step = AR->getStepRecurrence(*PSE.
getSE());
2540 "tail-predicate\n.");
2546 LLVM_DEBUG(
dbgs() <<
"tail-predication: all instructions allowed!\n");
2559 if (!ST->hasMVEIntegerOps())
2566 if (L->getNumBlocks() > 1) {
2567 LLVM_DEBUG(
dbgs() <<
"preferTailFoldingOverEpilogue: not a single block "
2572 assert(L->isInnermost() &&
2573 "preferTailFoldingOverEpilogue: inner-loop expected");
2578 LLVM_DEBUG(
dbgs() <<
"preferTailFoldingOverEpilogue: hardware-loop is not "
2589 LLVM_DEBUG(
dbgs() <<
"preferTailFoldingOverEpilogue: hardware-loop is not "
2596 LLVM_DEBUG(
dbgs() <<
"preferTailFoldingOverEpilogue: hardware-loop is not "
2606 if (!ST->hasMVEIntegerOps() ||
2624 return isa<IntrinsicInst>(I) &&
2625 cast<IntrinsicInst>(I).getIntrinsicID() ==
2626 Intrinsic::get_active_lane_mask;
2630 if (!ST->isMClass())
2636 if (L->getHeader()->getParent()->hasOptSize())
2640 L->getExitingBlocks(ExitingBlocks);
2642 <<
"Blocks: " << L->getNumBlocks() <<
"\n"
2643 <<
"Exit blocks: " << ExitingBlocks.
size() <<
"\n");
2647 if (ExitingBlocks.
size() > 2)
2652 if (ST->hasBranchPredictor() && L->getNumBlocks() > 4)
2662 for (
auto *BB : L->getBlocks()) {
2663 for (
auto &
I : *BB) {
2666 if (
I.getType()->isVectorTy())
2689 unsigned UnrollCount = 4;
2690 if (ST->isThumb1Only()) {
2691 unsigned ExitingValues = 0;
2693 L->getExitBlocks(ExitBlocks);
2694 for (
auto *Exit : ExitBlocks) {
2697 unsigned LiveOuts =
count_if(Exit->phis(), [](
auto &PH) {
2698 return PH.getNumOperands() != 1 ||
2699 !isa<GetElementPtrInst>(PH.getOperand(0));
2701 ExitingValues = ExitingValues < LiveOuts ? LiveOuts : ExitingValues;
2704 UnrollCount /= ExitingValues;
2705 if (UnrollCount <= 1)
2722 auto *Outer = L->getOutermostLoop();
2723 if ((L != Outer && Outer != L->getParentLoop()) ||
2731 LLVM_DEBUG(
dbgs() <<
"Default Runtime Unroll Count: " << UnrollCount <<
"\n");
2742 if (
Cost < ST->getCLOpts().force_unroll_threshold)
2752 if (!ST->hasMVEIntegerOps())
2755 unsigned ScalarBits = Ty->getScalarSizeInBits();
2758 return ScalarBits <= 64;
2765 if (!ST->hasMVEIntegerOps())
2772 bool HasBaseReg, int64_t Scale,
2773 unsigned AddrSpace)
const {
2782 return AM.
Scale < 0 ? 1 : 0;
2792 return ST->hasMVEIntegerOps();
2800 return ST->isThumb2() || ST->hasV8MBaselineOps();
2804 return ST->hasARMOps();
2814 return Ext->getType()->getScalarSizeInBits() ==
2815 2 * Ext->getOperand(0)->getType()->getScalarSizeInBits();
2834 if (!
I->getType()->isVectorTy())
2837 if (ST->hasNEON()) {
2838 switch (
I->getOpcode()) {
2839 case Instruction::Sub:
2840 case Instruction::Add: {
2843 Ops.push_back(&
I->getOperandUse(0));
2844 Ops.push_back(&
I->getOperandUse(1));
2852 if (!ST->hasMVEIntegerOps())
2856 if (!
I->hasOneUse())
2858 auto *
Sub = *
I->users().begin();
2859 return Sub->getOpcode() == Instruction::FSub &&
Sub->getOperand(1) ==
I;
2870 switch (
I->getOpcode()) {
2871 case Instruction::Add:
2872 case Instruction::Mul:
2873 case Instruction::FAdd:
2874 case Instruction::ICmp:
2875 case Instruction::FCmp:
2877 case Instruction::FMul:
2878 return !IsFMSMul(
I);
2879 case Instruction::Sub:
2880 case Instruction::FSub:
2881 case Instruction::Shl:
2882 case Instruction::LShr:
2883 case Instruction::AShr:
2884 return Operand == 1;
2885 case Instruction::Call:
2887 switch (
II->getIntrinsicID()) {
2888 case Intrinsic::fma:
2890 case Intrinsic::sadd_sat:
2891 case Intrinsic::uadd_sat:
2892 case Intrinsic::arm_mve_add_predicated:
2893 case Intrinsic::arm_mve_mul_predicated:
2894 case Intrinsic::arm_mve_qadd_predicated:
2895 case Intrinsic::arm_mve_vhadd:
2896 case Intrinsic::arm_mve_hadd_predicated:
2897 case Intrinsic::arm_mve_vqdmull:
2898 case Intrinsic::arm_mve_vqdmull_predicated:
2899 case Intrinsic::arm_mve_vqdmulh:
2900 case Intrinsic::arm_mve_qdmulh_predicated:
2901 case Intrinsic::arm_mve_vqrdmulh:
2902 case Intrinsic::arm_mve_qrdmulh_predicated:
2903 case Intrinsic::arm_mve_fma_predicated:
2905 case Intrinsic::ssub_sat:
2906 case Intrinsic::usub_sat:
2907 case Intrinsic::arm_mve_sub_predicated:
2908 case Intrinsic::arm_mve_qsub_predicated:
2909 case Intrinsic::arm_mve_hsub_predicated:
2910 case Intrinsic::arm_mve_vhsub:
2911 return Operand == 1;
2922 for (
auto OpIdx :
enumerate(
I->operands())) {
2929 if (Shuffle->
getOpcode() == Instruction::BitCast)
2936 if (!IsSinker(
I, OpIdx.index()))
2941 for (
Use &U :
Op->uses()) {
2943 if (!IsSinker(Insn, U.getOperandNo()))
2949 Ops.push_back(&
Op->getOperandUse(0));
2950 Ops.push_back(&OpIdx.value());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Cost tables and simple lookup functions.
This file provides the interface for the instcombine pass implementation.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file defines the LoopVectorizationLegality class.
static const Function * getCalledFunction(const MachineInstr &MI)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
This file defines the SmallVector class.
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static LLVM_ABI APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
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.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getMemcpyCost(const Instruction *I) const override
bool maybeLoweredToCall(Instruction &I) const
bool preferInLoopReduction(RecurKind Kind, Type *Ty) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *ValTy, TTI::TargetCostKind CostKind) const override
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
bool hasArmWideBranch(bool Thumb) const override
bool shouldConsiderVectorizationRegPressure() const override
bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
int getNumMemOps(const IntrinsicInst *I) const
Given a memcpy/memset/memmove instruction, return the number of memory operations performed,...
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
bool isLoweredToCall(const Function *F) const override
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const override
Check if sinking I's operands to I's basic block is profitable, because the operands can be folded in...
bool isLegalMaskedStore(Type *DataTy, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind=TTI::MaskKind::VariableOrConstantMask) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
std::optional< Value * > simplifyDemandedVectorEltsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp) const override
bool isLegalMaskedLoad(Type *DataTy, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind=TTI::MaskKind::VariableOrConstantMask) const override
TailFoldingStyle getPreferredTailFoldingStyle() const override
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
TTI::AddressingModeKind getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override
InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const override
bool preferPredicatedReductionSelect() const override
bool isLegalMaskedGather(Type *Ty, Align Alignment) const override
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr, TTI::TargetCostKind CostKind) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
bool isProfitableLSRChainElement(Instruction *I) const override
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const override
getScalingFactorCost - Return the cost of the scaling used in addressing mode represented by AM.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
A cache of @llvm.assume calls within a function.
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM Basic Block Representation.
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *SrcTy, int &Index, VectorType *&SubTy) const
bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace, Instruction *I=nullptr, int64_t ScalableOffset=0) const override
InstructionCost getScalarizationOverhead(VectorType *InTy, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *, const SCEV *, TTI::TargetCostKind) const override
InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLE
signed less or equal
@ ICMP_SGT
signed greater than
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
This class represents a range of values.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Convenience struct for specifying and reasoning about fast-math flags.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
LLVM_ABI Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
ConstantInt * getTrue()
Get the constant value for i1 true.
LLVM_ABI Value * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={}, function_ref< void(CallInst *)> SetFn=[](CallInst *) {})
Variant to create a possibly constant-folded intrinsic.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
The core instruction combiner logic.
const DataLayout & getDataLayout() const
virtual Instruction * eraseInstFromFunction(Instruction &I)=0
Combiner aware instruction erasure.
DominatorTree & getDominatorTree() const
Instruction * replaceInstUsesWith(Instruction &I, Value *V)
A combiner-aware RAUW-like routine.
virtual bool SimplifyDemandedBits(Instruction *I, unsigned OpNo, const APInt &DemandedMask, KnownBits &Known, const SimplifyQuery &Q, unsigned Depth=0)=0
IRBuilder< TargetFolder, IRBuilderInstCombineInserter > BuilderTy
An IRBuilder that automatically inserts new instructions into the worklist.
Instruction * replaceOperand(Instruction &I, unsigned OpNum, Value *V)
Replace operand of instruction and add old operand to the worklist.
AssumptionCache & getAssumptionCache() const
static InstructionCost getInvalid(CostType Val=0)
Instruction * user_back()
user_iterator user_begin()
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
const SmallVectorImpl< Type * > & getArgTypes() const
Type * getReturnType() const
Intrinsic::ID getID() const
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Drive the analysis of memory accesses in the loop.
const PredicatedScalarEvolution & getPSE() const
Used to add runtime SCEV checks.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor...
LoopInfo * getLoopInfo() const
DominatorTree * getDominatorTree() const
AssumptionCache * getAssumptionCache() const
const LoopAccessInfo * getLAI() const
ScalarEvolution * getScalarEvolution() const
Represents a single loop in the control flow graph.
Information for memory intrinsic cost model.
Align getAlignment() const
unsigned getAddressSpace() const
Type * getDataType() const
const Value * getPointer() const
bool getVariableMask() const
Intrinsic::ID getID() const
const Instruction * getInst() const
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
This class represents an analyzed expression in the program.
Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
LLVM_ABI const SCEV * getBackedgeTakenCount(const Loop *L, ExitCountKind Kind=Exact)
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCould...
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
const SCEV * getOne(Type *Ty)
Return a SCEV for the constant 1 of a specific type.
LLVM_ABI bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
LLVM_ABI SCEVUse getAddExpr(SmallVectorImpl< SCEVUse > &Ops, SCEVFlagsPair Flags={}, unsigned Depth=0)
Get a canonical add expression, or something simpler if possible.
LLVM_ABI bool hasLoopInvariantBackedgeTakenCount(const Loop *L)
Return true if the specified loop has an analyzable loop-invariant backedge-taken count.
APInt getUnsignedRangeMax(const SCEV *S)
Determine the max of the unsigned range for a particular SCEV.
static LLVM_ABI bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Check if the mask is a DE-interleave mask of the given factor Factor like: <Index,...
static LLVM_ABI bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts, SmallVectorImpl< unsigned > &StartIndexes)
Return true if the mask interleaves one or more input vectors together.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
Provides information about what library functions are available for the current target.
This class represents a truncation of integer types.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
LLVM_ABI bool isScalableTy() const
Return true if this is a type whose size is a known multiple of vscale.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
A Use represents the edge between a Value definition and its users.
const Use & getOperandUse(unsigned i) const
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVM_ABI bool hasNUses(unsigned N) const
Return true if this Value has exactly N uses.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Type * getElementType() const
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
bool isThumbImmShiftedVal(unsigned V)
isThumbImmShiftedVal - Return true if the specified value can be obtained by left shifting a 8-bit im...
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
ISD namespace - This namespace contains an enum which represents all of the SelectionDAG node types a...
@ ADD
Simple integer binary arithmetic operators.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ FADD
Simple binary floating point operators.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ SIGN_EXTEND
Conversion operators.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
SpecificConstantMatch m_ZeroInt()
Convenience matchers for specific integer values.
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_Constant()
Match an arbitrary Constant and ignore it.
TwoOps_match< V1_t, V2_t, Instruction::ShuffleVector > m_Shuffle(const V1_t &v1, const V2_t &v2)
Matches ShuffleVectorInst independently of mask value.
is_zero< true > m_Zero()
Match any null constant or a vector with all elements equal to 0.
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
FNeg_match< OpTy, true > m_FNegOrFSubNegZero(const OpTy &X)
Match fneg X or fsub -0.0, X.
match_combine_or< CastInst_match< OpTy, ZExtInst >, CastInst_match< OpTy, SExtInst > > m_ZExtOrSExt(const OpTy &Op)
auto m_Undef()
Match an arbitrary undef constant.
ThreeOps_match< Val_t, Elt_t, Idx_t, Instruction::InsertElement > m_InsertElt(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx)
Matches InsertElementInst.
auto m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
bool isVTRN_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVTRN_v_undef_Mask - Special case of isVTRNMask for canonical form of "vector_shuffle v,...
const CostTblEntryT< CostType > * CostTableLookup(ArrayRef< CostTblEntryT< CostType > > Tbl, int ISD, MVT Ty)
Find in cost table.
LLVM_ABI bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
bool isVZIPMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Runtime
Detect stack use after return if not disabled runtime with (ASAN_OPTIONS=detect_stack_use_after_retur...
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
@ ForceEnabledNoReductions
LLVM_ABI std::optional< int64_t > getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr, const Loop *Lp, const DominatorTree &DT, const SymbolicStrideMap &StridesMap=SymbolicStrideMap(), bool ShouldCheckWrap=true, SmallVectorImpl< const SCEVPredicate * > *Predicates=nullptr)
If the pointer has a constant stride return it in units of the access type size.
auto dyn_cast_or_null(const Y &Val)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI SmallVector< Instruction *, 8 > findDefsUsedOutsideOfLoop(Loop *L)
Returns the instructions that use values defined in the loop.
SelectPatternFlavor
Specific patterns of select instructions we can match.
@ SPF_ABS
Floating point maxnum.
@ SPF_FMAXNUM
Floating point minnum.
@ SPF_UMIN
Signed minimum.
@ SPF_UMAX
Signed maximum.
@ SPF_SMAX
Unsigned minimum.
@ SPF_FMINNUM
Unsigned maximum.
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.
bool isVUZPMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
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...
bool isVTRNMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
RecurKind
These are the kinds of recurrences that we support.
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
bool isVUZP_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVUZP_v_undef_Mask - Special case of isVUZPMask for canonical form of "vector_shuffle v,...
TypeConversionCostTblEntryT< uint16_t > TypeConversionCostTblEntry
CostTblEntryT< uint16_t > CostTblEntry
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Align getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to infer an alignment for the specified pointer.
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
bool isVREVMask(ArrayRef< int > M, EVT VT, unsigned BlockSize)
isVREVMask - Check if a vector shuffle corresponds to a VREV instruction with the specified blocksize...
@ DataWithoutLaneMask
Same as Data, but avoids using the get.active.lane.mask intrinsic to calculate the mask and instead i...
@ Data
Use predicate only to mask operations on data in the loop.
LLVM_ABI SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
const TypeConversionCostTblEntryT< CostType > * ConvertCostTableLookup(ArrayRef< TypeConversionCostTblEntryT< CostType > > Tbl, int ISD, MVT Dst, MVT Src)
Find in type conversion cost table.
bool isVZIP_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVZIP_v_undef_Mask - Special case of isVZIPMask for canonical form of "vector_shuffle v,...
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
uint64_t getScalarSizeInBits() const
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool isInteger() const
Return true if this is an integer or a vector integer type.
Attributes of a target dependent hardware loop.
LLVM_ABI bool canAnalyze(LoopInfo &LI)
LLVM_ABI bool isHardwareLoopCandidate(ScalarEvolution &SE, LoopInfo &LI, DominatorTree &DT, bool ForceNestedLoop=false, bool ForceHardwareLoopPHI=false)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static MemOp Set(uint64_t Size, bool DstAlignCanChange, Align DstAlign, bool IsZeroMemset, bool IsVolatile)
static MemOp Move(uint64_t Size, bool DstAlignCanChange, Align DstAlign, Align SrcAlign, bool IsVolatile)
SelectPatternFlavor Flavor
LoopVectorizationLegality * LVL
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...