31#define DEBUG_TYPE "tti"
35 cl::desc(
"Use this to override the target cache line size when "
36 "specified by the user."));
40 cl::desc(
"Use this to override the target's minimum page size."));
45 "Use this to override the target's predictable branch threshold (%)."));
59 std::unique_ptr<const TargetTransformInfoImplBase> Impl)
76 ScalarizationCost(ScalarizationCost) {
79 FMF = FPMO->getFastMathFlags();
84 ParamTys.push_back(Arg->getType());
92 : II(
I), RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost) {
93 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
98 : RetTy(Ty), IID(Id) {
100 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
101 ParamTys.reserve(Arguments.size());
110 : II(
I), RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost),
112 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
113 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
126 bool ForceNestedLoop,
127 bool ForceHardwareLoopPHI) {
129 L->getExitingBlocks(ExitingBlocks);
134 if (!
L->isLoopLatch(BB)) {
143 if (ConstEC->getValue()->isZero())
164 bool NotAlways =
false;
166 if (!
L->contains(Pred))
197 : TTIImpl(
std::make_unique<NoTTIImpl>(
DL)) {}
202 : TTIImpl(
std::
move(Arg.TTIImpl)) {}
205 TTIImpl = std::move(RHS.TTIImpl);
210 return TTIImpl->getInliningThresholdMultiplier();
215 return TTIImpl->getInliningCostBenefitAnalysisSavingsMultiplier();
221 return TTIImpl->getInliningCostBenefitAnalysisProfitableMultiplier();
225 return TTIImpl->getInliningLastCallToStaticBonus();
230 return TTIImpl->adjustInliningThreshold(CB);
235 return TTIImpl->getCallerAllocaCost(CB, AI);
239 return TTIImpl->getInlinerVectorBonusPercent();
245 return TTIImpl->getGEPCost(PointeeType, Ptr,
Operands, CostKind, AccessType);
253 "If pointers have same base address it has to be provided.");
254 return TTIImpl->getPointersChainCost(Ptrs,
Base, Info, AccessTy, CostKind);
260 return TTIImpl->getEstimatedNumberOfCaseClusters(
SI, JTSize, PSI, BFI);
269 "TTI should not produce negative costs!");
276 : TTIImpl->getPredictableBranchThreshold();
280 return TTIImpl->getBranchMispredictPenalty();
284 return TTIImpl->hasBranchDivergence(
F);
291 if (
Call->hasFnAttr(Attribute::AlwaysUniform))
294 Call->hasFnAttr(Attribute::NoDivergenceSource))
301 unsigned ToAS)
const {
302 return TTIImpl->isValidAddrSpaceCast(FromAS, ToAS);
306 unsigned ToAS)
const {
307 return TTIImpl->addrspacesMayAlias(FromAS, ToAS);
311 return TTIImpl->getFlatAddressSpace();
315 unsigned AS2)
const {
316 assert(AS1 != AS2 &&
"Expected distinct address spaces");
317 return TTIImpl->getAddressSpaceJoin(AS1, AS2);
322 return TTIImpl->collectFlatAddressOperands(OpIndexes, IID);
326 unsigned ToAS)
const {
327 return TTIImpl->isNoopAddrSpaceCast(FromAS, ToAS);
330std::pair<KnownBits, KnownBits>
332 const Value &PtrOp)
const {
333 return TTIImpl->computeKnownBitsAddrSpaceCast(ToAS, PtrOp);
337 unsigned FromAS,
unsigned ToAS,
const KnownBits &FromPtrBits)
const {
338 return TTIImpl->computeKnownBitsAddrSpaceCast(FromAS, ToAS, FromPtrBits);
342 unsigned SrcAS,
unsigned DstAS)
const {
343 return TTIImpl->getAddrSpaceCastPreservedPtrMask(SrcAS, DstAS);
348 return TTIImpl->canHaveNonUndefGlobalInitializerInAddressSpace(AS);
352 return TTIImpl->getAssumedAddrSpace(V);
355std::pair<const Value *, unsigned>
357 return TTIImpl->getPredicatedAddrSpace(V);
362 return TTIImpl->rewriteIntrinsicWithAddressSpace(
II, OldV, NewV);
366 return TTIImpl->isLoweredToCall(
F);
372 return TTIImpl->isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
376 return TTIImpl->getEpilogueVectorizationMinVF();
381 return TTIImpl->preferTailFoldingOverEpilogue(TFI);
385 return TTIImpl->getPreferredTailFoldingStyle();
388std::optional<Instruction *>
391 return TTIImpl->instCombineIntrinsic(IC,
II);
396 bool &KnownBitsComputed)
const {
397 return TTIImpl->simplifyDemandedUseBitsIntrinsic(IC,
II, DemandedMask,
Known,
405 SimplifyAndSetOp)
const {
406 return TTIImpl->simplifyDemandedVectorEltsIntrinsic(
407 IC,
II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
414 return TTIImpl->getUnrollingPreferences(L, SE, UP, ORE);
419 return TTIImpl->getPeelingPreferences(L, SE, PP);
423 return TTIImpl->isLegalAddImmediate(
Imm);
427 return TTIImpl->isLegalAddScalableImmediate(
Imm);
431 return TTIImpl->isLegalICmpImmediate(
Imm);
436 return TTIImpl->preferLoopExitWithEqualityComparison(
Cond, PostIncExitValue);
441 bool HasBaseReg, int64_t Scale,
444 int64_t ScalableOffset)
const {
445 return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
446 Scale, AddrSpace,
I, ScalableOffset);
451 return TTIImpl->isLSRCostLess(
C1, C2);
455 return TTIImpl->isNumRegsMajorCostOfLSR();
459 return TTIImpl->shouldDropLSRSolutionIfLessProfitable();
463 return TTIImpl->isProfitableLSRChainElement(
I);
467 return TTIImpl->canMacroFuseCmp();
474 return TTIImpl->canSaveCmp(L, BI, SE, LI, DT, AC, LibInfo);
480 return TTIImpl->getPreferredAddressingMode(L, SE);
486 return TTIImpl->isLegalMaskedStore(DataType, Alignment,
AddressSpace,
493 return TTIImpl->isLegalMaskedLoad(DataType, Alignment,
AddressSpace,
499 return TTIImpl->isLegalSpeculativeLoad(DataType,
AddressSpace);
503 Align Alignment)
const {
504 return TTIImpl->isLegalNTStore(DataType, Alignment);
508 return TTIImpl->isLegalNTLoad(DataType, Alignment);
513 return TTIImpl->isLegalBroadcastLoad(ElementTy, NumElements);
517 Align Alignment)
const {
518 return TTIImpl->isLegalMaskedGather(DataType, Alignment);
522 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
524 return TTIImpl->isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask, Scalars);
528 Align Alignment)
const {
529 return TTIImpl->isLegalMaskedScatter(DataType, Alignment);
533 Align Alignment)
const {
534 return TTIImpl->forceScalarizeMaskedGather(DataType, Alignment);
538 Align Alignment)
const {
539 return TTIImpl->forceScalarizeMaskedScatter(DataType, Alignment);
543 Align Alignment)
const {
544 return TTIImpl->isLegalMaskedCompressStore(DataType, Alignment);
548 Align Alignment)
const {
549 return TTIImpl->isLegalMaskedExpandLoad(DataType, Alignment);
553 Align Alignment)
const {
554 return TTIImpl->isLegalStridedLoadStore(DataType, Alignment);
559 bool IsStore, std::optional<Instruction::CastOps> CastHint)
const {
560 return TTIImpl->hasMultiVectorLoadStore(NumVectors, Mask, VectorTy, IsStore,
566 unsigned AddrSpace)
const {
567 return TTIImpl->isLegalInterleavedAccessType(VTy, Factor, Alignment,
572 Type *DataType)
const {
573 return TTIImpl->isLegalMaskedVectorHistogram(AddrType, DataType);
577 return TTIImpl->enableOrderedReductions();
581 return TTIImpl->hasDivRemOp(DataType, IsSigned);
585 unsigned AddrSpace)
const {
586 return TTIImpl->hasVolatileVariant(
I, AddrSpace);
590 return TTIImpl->prefersVectorizedAddressing();
595 int64_t Scale,
unsigned AddrSpace)
const {
597 Ty, BaseGV, BaseOffset, HasBaseReg, Scale, AddrSpace);
598 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
603 return TTIImpl->LSRWithInstrQueries();
607 return TTIImpl->isTruncateFree(Ty1, Ty2);
611 return TTIImpl->isProfitableToHoist(
I);
617 return TTIImpl->isTypeLegal(Ty);
621 return TTIImpl->getRegUsageForType(Ty);
625 return TTIImpl->shouldBuildLookupTables();
630 return TTIImpl->shouldBuildLookupTablesForConstant(
C);
634 return TTIImpl->getMinimumLookupTableEntryBitWidth();
638 return TTIImpl->shouldBuildRelLookupTables();
642 return TTIImpl->useColdCCForColdCall(
F);
646 return TTIImpl->useFastCCForInternalCall(
F);
651 return TTIImpl->isTargetIntrinsicWithScalarOpAtArg(ID, ScalarOpdIdx);
656 return TTIImpl->isTargetIntrinsicWithOverloadTypeAtArg(ID, OpdIdx);
661 return TTIImpl->isTargetIntrinsicWithStructReturnOverloadAtField(ID, RetIdx);
668 return Ctx1 == Ctx2 ? Ctx1 : TargetTransformInfo::VectorInstrContext::None;
679 I->getOperand(1)->hasOneUse())
692 const APInt &DemandedElts) {
695 if (!DemandedElts[
I])
719 return TTIImpl->getBuildVectorContextHint(Mask, Scalars, GatherUseOps);
744 return TTIImpl->getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
745 CostKind, ForPoisonSrc, VL, VIC);
751 return TTIImpl->getOperandsScalarizationOverhead(Tys, CostKind, VIC);
755 return TTIImpl->supportsEfficientVectorElementLoadStore();
759 return TTIImpl->supportsTailCalls();
763 return TTIImpl->supportsTailCallFor(CB);
767 bool LoopHasReductions)
const {
768 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
773 return TTIImpl->enableMemCmpExpansion(OptSize, IsZeroCmp);
777 return TTIImpl->enableSelectOptimize();
782 return TTIImpl->shouldTreatInstructionLikeSelect(
I);
786 return TTIImpl->enableInterleavedAccessVectorization();
790 return TTIImpl->enableMaskedInterleavedAccessVectorization();
794 return TTIImpl->isFPVectorizationPotentiallyUnsafe();
802 unsigned *
Fast)
const {
808 return TTIImpl->haveFastSqrt(Ty);
813 return TTIImpl->isExpensiveToSpeculativelyExecute(
I);
817 return TTIImpl->isFCmpOrdCheaperThanFCmpZero(Ty);
822 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
835 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
843 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
848 unsigned Opcode,
unsigned Idx,
const APInt &
Imm,
Type *Ty,
851 TTIImpl->getIntImmCostInst(Opcode, Idx,
Imm, Ty, CostKind, Inst);
852 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
861 TTIImpl->getIntImmCostIntrin(IID, Idx,
Imm, Ty, CostKind);
862 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
868 return TTIImpl->preferToKeepConstantsAttached(Inst, Fn);
872 return TTIImpl->getNumberOfRegisters(ClassID);
876 bool IsStore)
const {
877 return TTIImpl->hasConditionalLoadStoreForType(Ty, IsStore);
882 return TTIImpl->getRegisterClassForType(
Vector, Ty);
886 return TTIImpl->getRegisterClassName(ClassID);
891 return TTIImpl->getRegisterClassSpillCost(ClassID, CostKind);
896 return TTIImpl->getRegisterClassReloadCost(ClassID, CostKind);
901 return TTIImpl->getRegisterBitWidth(
K);
905 return TTIImpl->getMinVectorRegisterBitWidth();
909 return TTIImpl->getVScaleForTuning();
914 return TTIImpl->shouldMaximizeVectorBandwidth(
K, ElementTy);
919 return TTIImpl->getMinimumVF(ElemWidth,
IsScalable);
923 unsigned Opcode)
const {
924 return TTIImpl->getMaximumVF(ElemWidth, Opcode);
930 unsigned AddrSpace)
const {
931 return TTIImpl->getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy, Alignment,
936 const Instruction &
I,
bool &AllowPromotionWithoutCommonHeader)
const {
937 return TTIImpl->shouldConsiderAddressTypePromotion(
938 I, AllowPromotionWithoutCommonHeader);
943 : TTIImpl->getCacheLineSize();
946std::optional<unsigned>
948 return TTIImpl->getCacheSize(Level);
951std::optional<unsigned>
953 return TTIImpl->getCacheAssociativity(Level);
958 : TTIImpl->getMinPageSize();
962 return TTIImpl->getPrefetchDistance();
966 unsigned NumMemAccesses,
unsigned NumStridedMemAccesses,
967 unsigned NumPrefetches,
bool HasCall)
const {
968 return TTIImpl->getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
969 NumPrefetches, HasCall);
973 return TTIImpl->getMaxPrefetchIterationsAhead();
977 return TTIImpl->enableWritePrefetching();
981 return TTIImpl->shouldPrefetchAddressSpace(AS);
985 unsigned Opcode,
Type *InputTypeA,
Type *InputTypeB,
Type *AccumType,
989 return TTIImpl->getPartialReductionCost(Opcode, InputTypeA, InputTypeB,
990 AccumType, VF, OpAExtend, OpBExtend,
991 BinOp, CostKind, FMF);
996 bool HasUnorderedReductions)
const {
997 return TTIImpl->getMaxInterleaveFactor(VF, HasUnorderedReductions);
1011 if (CI->getValue().isPowerOf2())
1013 else if (CI->getValue().isNegatedPowerOf2())
1023 if (ShuffleInst->isZeroEltSplat())
1038 if (CI->getValue().isPowerOf2())
1040 else if (CI->getValue().isNegatedPowerOf2())
1046 bool AllPow2 =
true, AllNegPow2 =
true;
1047 for (uint64_t
I = 0, E = CDS->getNumElements();
I != E; ++
I) {
1049 AllPow2 &= CI->getValue().isPowerOf2();
1050 AllNegPow2 &= CI->getValue().isNegatedPowerOf2();
1051 if (AllPow2 || AllNegPow2)
1054 AllPow2 = AllNegPow2 =
false;
1063 return {OpInfo, OpProps};
1069 const auto *Op0 =
Ops.front();
1083 return CI->getValue().isPowerOf2();
1089 return CI->getValue().isNegatedPowerOf2();
1094 if (IsConstant && IsUniform)
1096 else if (IsConstant)
1125 if (TLibInfo && Opcode == Instruction::FRem) {
1127 LibFunc Func = TLibInfo->
getLibFunc(Instruction::FRem, Ty->getScalarType());
1128 if (VecTy && Func != NotLibFunc &&
1135 Opcode, Ty, CostKind, Op1Info, Op2Info, Args, CtxI, TLibInfo, Scalars);
1136 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1141 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
1145 VecTy, Opcode0, Opcode1, OpcodeMask, CostKind, Scalars);
1146 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1157 "Expected the Mask to match the return size if given");
1159 "Expected the same scalar types");
1161 Kind, DstTy, SrcTy, CostKind, Mask, Index, SubTp, Args, CtxI, VIC);
1162 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1178 return Instruction::CastOps::ZExt;
1180 return Instruction::CastOps::SExt;
1182 return Instruction::CastOps::FPExt;
1193 case Instruction::CastOps::ZExt:
1195 case Instruction::CastOps::SExt:
1197 case Instruction::CastOps::FPExt:
1210 auto getLoadStoreKind = [](
const Value *V,
unsigned LdStOp,
unsigned MaskedOp,
1211 unsigned GatScatOp) {
1216 if (
I->getOpcode() == LdStOp)
1220 if (
II->getIntrinsicID() == MaskedOp)
1222 if (
II->getIntrinsicID() == GatScatOp)
1229 switch (
I->getOpcode()) {
1230 case Instruction::ZExt:
1231 case Instruction::SExt:
1232 case Instruction::FPExt:
1233 return getLoadStoreKind(
I->getOperand(0), Instruction::Load,
1234 Intrinsic::masked_load, Intrinsic::masked_gather);
1235 case Instruction::Trunc:
1236 case Instruction::FPTrunc:
1238 return getLoadStoreKind(*
I->user_begin(), Instruction::Store,
1239 Intrinsic::masked_store,
1240 Intrinsic::masked_scatter);
1252 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1253 "Opcode should reflect passed instruction.");
1255 TTIImpl->getCastInstrCost(Opcode, Dst, Src, CCH, CostKind,
I);
1256 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1264 TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index, CostKind);
1265 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1271 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1272 "Opcode should reflect passed instruction.");
1274 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1282 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1283 "Opcode should reflect passed instruction.");
1285 Opcode, ValTy, CondTy, VecPred, CostKind, Op1Info, Op2Info,
I);
1286 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1293 assert((Opcode == Instruction::InsertElement ||
1294 Opcode == Instruction::ExtractElement) &&
1295 "Expecting Opcode to be insertelement/extractelement.");
1297 TTIImpl->getVectorInstrCost(Opcode, Val, CostKind, Index, Op0, Op1, VIC);
1298 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1304 Value *Scalar,
ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
1306 assert((Opcode == Instruction::InsertElement ||
1307 Opcode == Instruction::ExtractElement) &&
1308 "Expecting Opcode to be insertelement/extractelement.");
1310 Opcode, Val, CostKind, Index, Scalar, ScalarUserAndIdx, VIC);
1311 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1322 TTIImpl->getVectorInstrCost(
I, Val, CostKind, Index, VIC);
1323 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1329 unsigned Index)
const {
1331 TTIImpl->getIndexedVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
1332 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1338 assert((Opcode == Instruction::InsertValue ||
1339 Opcode == Instruction::ExtractValue) &&
1340 "Expecting Opcode to be insertvalue/extractvalue.");
1342 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1350 assert((CtxI ==
nullptr || CtxI->
getOpcode() == Instruction::BitInsert) &&
1351 "Opcode should reflect passed instruction.");
1353 TTIImpl->getBitInsertCost(
Base, Val, CostKind, OffsetInfo, Args, CtxI);
1354 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1362 assert((CtxI ==
nullptr || CtxI->
getOpcode() == Instruction::BitExtract) &&
1363 "Opcode should reflect passed instruction.");
1365 TTIImpl->getBitExtractCost(Dst, Src, CostKind, OffsetInfo, Args, CtxI);
1366 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1371 Type *EltTy,
int ReplicationFactor,
int VF,
const APInt &DemandedDstElts,
1374 EltTy, ReplicationFactor, VF, DemandedDstElts, CostKind);
1375 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1383 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1384 "Opcode should reflect passed instruction.");
1387 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1394 bool UseMaskForCond,
bool UseMaskForGaps)
const {
1396 Opcode, VecTy, Factor, Indices, Alignment,
AddressSpace, CostKind,
1397 UseMaskForCond, UseMaskForGaps);
1398 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1406 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1414 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1423 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1428 return TTIImpl->getNumberOfParts(Tp);
1435 TTIImpl->getAddressComputationCost(PtrTy, SE, Ptr, CostKind);
1436 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1442 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1447 return TTIImpl->getMaxMemIntrinsicInlineSizeThreshold();
1451 return TTIImpl->getMaxBoundedMemSetInlineSize();
1455 unsigned Opcode,
VectorType *Ty, std::optional<FastMathFlags> FMF,
1458 TTIImpl->getArithmeticReductionCost(Opcode, Ty, FMF, CostKind);
1459 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1467 TTIImpl->getMinMaxReductionCost(IID, Ty, FMF, CostKind);
1468 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1475 return TTIImpl->getExtendedReductionCost(Opcode, IsUnsigned, ResTy, Ty, FMF,
1480 bool IsUnsigned,
unsigned RedOpcode,
Type *ResTy,
VectorType *Ty,
1482 return TTIImpl->getMulAccReductionCost(IsUnsigned, RedOpcode, ResTy, Ty,
1488 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
1493 return TTIImpl->getTgtMemIntrinsic(Inst, Info);
1497 return TTIImpl->getAtomicMemIntrinsicMaxElementSize();
1502 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType,
1508 unsigned DestAddrSpace,
Align SrcAlign,
Align DestAlign,
1509 std::optional<uint32_t> AtomicElementSize)
const {
1510 return TTIImpl->getMemcpyLoopLoweringType(
Context,
Length, SrcAddrSpace,
1511 DestAddrSpace, SrcAlign, DestAlign,
1517 unsigned RemainingBytes,
unsigned SrcAddrSpace,
unsigned DestAddrSpace,
1519 std::optional<uint32_t> AtomicCpySize)
const {
1520 TTIImpl->getMemcpyLoopResidualLoweringType(
1521 OpsOut,
Context, RemainingBytes, SrcAddrSpace, DestAddrSpace, SrcAlign,
1522 DestAlign, AtomicCpySize);
1527 return TTIImpl->areInlineCompatible(Caller, Callee);
1533 unsigned DefaultCallPenalty)
const {
1534 return TTIImpl->getInlineCallPenalty(
F,
Call, DefaultCallPenalty);
1539 return TTIImpl->shouldCopyAttributeWhenOutliningFrom(Caller, Attr);
1544 return TTIImpl->areTypesABICompatible(Caller, Callee, Types);
1549 return TTIImpl->isIndexedLoadLegal(Mode, Ty);
1554 return TTIImpl->isIndexedStoreLegal(Mode, Ty);
1558 return TTIImpl->getLoadStoreVecRegBitWidth(AS);
1562 return TTIImpl->isLegalToVectorizeLoad(LI);
1566 return TTIImpl->isLegalToVectorizeStore(
SI);
1570 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1571 return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
1576 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1577 return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
1583 return TTIImpl->isLegalToVectorizeReduction(RdxDesc, VF);
1587 return TTIImpl->isElementTypeLegalForScalableVector(Ty);
1592 unsigned ChainSizeInBytes,
1594 return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
1599 unsigned ChainSizeInBytes,
1601 return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
1605 return TTIImpl->preferFixedOverScalableIfEqualCost();
1610 return TTIImpl->preferInLoopReduction(Kind, Ty);
1614 return TTIImpl->preferAlternateOpcodeVectorization();
1618 return TTIImpl->preferSLPInstCountCheck();
1622 return TTIImpl->preferPredicatedReductionSelect();
1627 return TTIImpl->preferEpilogueVectorization(Iters);
1631 return TTIImpl->shouldConsiderVectorizationRegPressure();
1636 return TTIImpl->getVPLegalizationStrategy(VPI);
1640 return TTIImpl->hasArmWideBranch(Thumb);
1644 return TTIImpl->getFeatureMask(
F);
1648 return TTIImpl->getPriorityMask(
F);
1652 return TTIImpl->isMultiversionedFunction(
F);
1656 return TTIImpl->getMaxNumArgs();
1660 return TTIImpl->shouldExpandReduction(
II);
1666 return TTIImpl->getPreferredExpandedReductionShuffle(
II);
1670 return TTIImpl->getGISelRematGlobalCost();
1674 return TTIImpl->getMinTripCountTailFoldingThreshold();
1678 return TTIImpl->supportsScalableVectors();
1682 return TTIImpl->enableScalableVectorization();
1686 return TTIImpl->hasActiveVectorLength();
1692 return TTIImpl->isProfitableToSinkOperands(
I, OpsToSink, LI);
1696 return TTIImpl->isVectorShiftByScalarCheap(Ty);
1702 return TTIImpl->collectKernelLaunchBounds(
F, LB);
1706 return TTIImpl->allowVectorElementIndexingUsingGEP();
1711 return TTIImpl->isUniform(
I, UniformArgs);
1720 : TTICallback(
std::
move(TTICallback)) {}
1724 assert(!
F.isIntrinsic() &&
"Should not request TTI for intrinsics");
1725 return TTICallback(
F);
1731 return Result(
F.getDataLayout());
1736 "Target Transform Information",
false,
true)
1750 TTI = TIRA.run(
F, DummyFAM);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
SmallVector< MachineOperand, 4 > Cond
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static SymbolRef::Type getType(const Symbol *Sym)
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
A cache of @llvm.assume calls within a function.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM Basic Block Representation.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Conditional Branch instruction.
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.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
Convenience struct for specifying and reasoning about fast-math flags.
This instruction compares its operands according to the predicate given to the constructor.
ImmutablePass class - This class is used to provide information that does not need to be run.
The core instruction combiner logic.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
LLVM_ABI IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI, InstructionCost ScalarCost=InstructionCost::getInvalid(), bool TypeBasedOnly=false)
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
Wrapper class to LoopBlocksDFS that provides a standard begin()/end() interface for the DFS reverse p...
void perform(const LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
Represents a single loop in the control flow graph.
Information for memory intrinsic cost model.
Analysis providing profile information.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
This class represents a constant integer value.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
LLVM_ABI uint64_t getTypeSizeInBits(Type *Ty) const
Return the size in bits of the specified type, for which isSCEVable must return true.
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 const SCEV * getExitCount(const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
Return the number of times the backedge executes before the given exit would be taken; if not exactly...
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
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.
An instruction for storing to memory.
Analysis pass providing the TargetTransformInfo.
LLVM_ABI Result run(const Function &F, FunctionAnalysisManager &)
TargetTransformInfo Result
LLVM_ABI TargetIRAnalysis()
Default construct a target IR analysis.
Provides information about what library functions are available for the current target.
StringRef getName(LibFunc F) const
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
LibFunc getLibFunc(StringRef funcName) const
Searches for a particular function name.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI bool isScalableTy() const
Return true if this is a type whose size is a known multiple of vscale.
This is the common base class for vector predication intrinsics.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
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...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
@ Known
Known to have no common set bits.
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.
VectorInstrContext
Represents a hint about the context in which a vector instruction or intrinsic is used.
@ None
The instruction is not folded.
@ SplatOpFolded
All of the value's users support splatting the value.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool containsIrreducibleCFG(RPOTraversalT &RPOTraversal, const LoopInfoT &LI)
Return true if the control flow in RPOTraversal is irreducible.
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...
constexpr int PoisonMaskElem
LLVM_ABI ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
RecurKind
These are the kinds of recurrences that we support.
@ Fast
Assign the register banks as fast as possible (default).
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
auto predecessors(const MachineBasicBlock *BB)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
ValueUniformity
Enum describing how values behave with respect to uniformity and divergence, to answer the question: ...
@ AlwaysUniform
The result value is always uniform.
@ NeverUniform
The result value can never be assumed to be uniform.
@ Default
The result value is uniform if and only if all operands are uniform.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Attributes of a target dependent hardware loop.
LLVM_ABI bool canAnalyze(LoopInfo &LI)
HardwareLoopInfo()=delete
LLVM_ABI bool isHardwareLoopCandidate(ScalarEvolution &SE, LoopInfo &LI, DominatorTree &DT, bool ForceNestedLoop=false, bool ForceHardwareLoopPHI=false)
Information about a load/store intrinsic defined by the target.