30#define DEBUG_TYPE "tti"
34 cl::desc(
"Use this to override the target cache line size when "
35 "specified by the user."));
39 cl::desc(
"Use this to override the target's minimum page size."));
44 "Use this to override the target's predictable branch threshold (%)."));
58 std::unique_ptr<const TargetTransformInfoImplBase> Impl)
75 ScalarizationCost(ScalarizationCost) {
78 FMF = FPMO->getFastMathFlags();
83 ParamTys.push_back(Arg->getType());
91 : II(
I), RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost) {
92 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
97 : RetTy(Ty), IID(Id) {
99 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
100 ParamTys.reserve(Arguments.size());
109 : II(
I), RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost),
111 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
112 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
128 L->getExitingBlocks(ExitingBlocks);
133 if (!
L->isLoopLatch(BB)) {
142 if (ConstEC->getValue()->isZero())
163 bool NotAlways =
false;
165 if (!
L->contains(Pred))
196 : TTIImpl(
std::make_unique<NoTTIImpl>(
DL)) {}
201 : TTIImpl(
std::
move(Arg.TTIImpl)) {}
204 TTIImpl = std::move(RHS.TTIImpl);
209 return TTIImpl->getInliningThresholdMultiplier();
214 return TTIImpl->getInliningCostBenefitAnalysisSavingsMultiplier();
220 return TTIImpl->getInliningCostBenefitAnalysisProfitableMultiplier();
224 return TTIImpl->getInliningLastCallToStaticBonus();
229 return TTIImpl->adjustInliningThreshold(CB);
234 return TTIImpl->getCallerAllocaCost(CB, AI);
238 return TTIImpl->getInlinerVectorBonusPercent();
244 return TTIImpl->getGEPCost(PointeeType, Ptr,
Operands, CostKind, AccessType);
252 "If pointers have same base address it has to be provided.");
253 return TTIImpl->getPointersChainCost(Ptrs,
Base, Info, AccessTy, CostKind);
259 return TTIImpl->getEstimatedNumberOfCaseClusters(
SI, JTSize, PSI, BFI);
268 "TTI should not produce negative costs!");
275 : TTIImpl->getPredictableBranchThreshold();
279 return TTIImpl->getBranchMispredictPenalty();
283 return TTIImpl->hasBranchDivergence(
F);
291 Call->hasFnAttr(Attribute::NoDivergenceSource))
298 unsigned ToAS)
const {
299 return TTIImpl->isValidAddrSpaceCast(FromAS, ToAS);
303 unsigned ToAS)
const {
304 return TTIImpl->addrspacesMayAlias(FromAS, ToAS);
308 return TTIImpl->getFlatAddressSpace();
312 unsigned AS2)
const {
313 assert(AS1 != AS2 &&
"Expected distinct address spaces");
314 return TTIImpl->getAddressSpaceJoin(AS1, AS2);
319 return TTIImpl->collectFlatAddressOperands(OpIndexes, IID);
323 unsigned ToAS)
const {
324 return TTIImpl->isNoopAddrSpaceCast(FromAS, ToAS);
327std::pair<KnownBits, KnownBits>
329 const Value &PtrOp)
const {
330 return TTIImpl->computeKnownBitsAddrSpaceCast(ToAS, PtrOp);
334 unsigned FromAS,
unsigned ToAS,
const KnownBits &FromPtrBits)
const {
335 return TTIImpl->computeKnownBitsAddrSpaceCast(FromAS, ToAS, FromPtrBits);
339 unsigned SrcAS,
unsigned DstAS)
const {
340 return TTIImpl->getAddrSpaceCastPreservedPtrMask(SrcAS, DstAS);
345 return TTIImpl->canHaveNonUndefGlobalInitializerInAddressSpace(AS);
349 return TTIImpl->getAssumedAddrSpace(V);
352std::pair<const Value *, unsigned>
354 return TTIImpl->getPredicatedAddrSpace(V);
359 return TTIImpl->rewriteIntrinsicWithAddressSpace(
II, OldV, NewV);
363 return TTIImpl->isLoweredToCall(
F);
369 return TTIImpl->isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
373 return TTIImpl->getEpilogueVectorizationMinVF();
378 return TTIImpl->preferTailFoldingOverEpilogue(TFI);
382 return TTIImpl->getPreferredTailFoldingStyle();
385std::optional<Instruction *>
388 return TTIImpl->instCombineIntrinsic(IC,
II);
393 bool &KnownBitsComputed)
const {
394 return TTIImpl->simplifyDemandedUseBitsIntrinsic(IC,
II, DemandedMask,
Known,
402 SimplifyAndSetOp)
const {
403 return TTIImpl->simplifyDemandedVectorEltsIntrinsic(
404 IC,
II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
411 return TTIImpl->getUnrollingPreferences(L, SE, UP, ORE);
416 return TTIImpl->getPeelingPreferences(L, SE, PP);
420 return TTIImpl->isLegalAddImmediate(
Imm);
424 return TTIImpl->isLegalAddScalableImmediate(
Imm);
428 return TTIImpl->isLegalICmpImmediate(
Imm);
433 return TTIImpl->preferLoopExitWithEqualityComparison(
Cond, PostIncExitValue);
438 bool HasBaseReg, int64_t Scale,
441 int64_t ScalableOffset)
const {
442 return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
443 Scale, AddrSpace,
I, ScalableOffset);
448 return TTIImpl->isLSRCostLess(
C1, C2);
452 return TTIImpl->isNumRegsMajorCostOfLSR();
456 return TTIImpl->shouldDropLSRSolutionIfLessProfitable();
460 return TTIImpl->isProfitableLSRChainElement(
I);
464 return TTIImpl->canMacroFuseCmp();
471 return TTIImpl->canSaveCmp(L, BI, SE, LI, DT, AC, LibInfo);
477 return TTIImpl->getPreferredAddressingMode(L, SE);
483 return TTIImpl->isLegalMaskedStore(DataType, Alignment,
AddressSpace,
490 return TTIImpl->isLegalMaskedLoad(DataType, Alignment,
AddressSpace,
496 return TTIImpl->isLegalSpeculativeLoad(DataType,
AddressSpace);
500 Align Alignment)
const {
501 return TTIImpl->isLegalNTStore(DataType, Alignment);
505 return TTIImpl->isLegalNTLoad(DataType, Alignment);
510 return TTIImpl->isLegalBroadcastLoad(ElementTy, NumElements);
514 Align Alignment)
const {
515 return TTIImpl->isLegalMaskedGather(DataType, Alignment);
519 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
521 return TTIImpl->isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask, Scalars);
525 Align Alignment)
const {
526 return TTIImpl->isLegalMaskedScatter(DataType, Alignment);
530 Align Alignment)
const {
531 return TTIImpl->forceScalarizeMaskedGather(DataType, Alignment);
535 Align Alignment)
const {
536 return TTIImpl->forceScalarizeMaskedScatter(DataType, Alignment);
540 Align Alignment)
const {
541 return TTIImpl->isLegalMaskedCompressStore(DataType, Alignment);
545 Align Alignment)
const {
546 return TTIImpl->isLegalMaskedExpandLoad(DataType, Alignment);
550 Align Alignment)
const {
551 return TTIImpl->isLegalStridedLoadStore(DataType, Alignment);
556 bool IsStore, std::optional<Instruction::CastOps> CastHint)
const {
557 return TTIImpl->hasMultiVectorLoadStore(NumVectors, Mask, VectorTy, IsStore,
563 unsigned AddrSpace)
const {
564 return TTIImpl->isLegalInterleavedAccessType(VTy, Factor, Alignment,
569 Type *DataType)
const {
570 return TTIImpl->isLegalMaskedVectorHistogram(AddrType, DataType);
574 return TTIImpl->enableOrderedReductions();
578 return TTIImpl->hasDivRemOp(DataType, IsSigned);
582 unsigned AddrSpace)
const {
583 return TTIImpl->hasVolatileVariant(
I, AddrSpace);
587 return TTIImpl->prefersVectorizedAddressing();
592 int64_t Scale,
unsigned AddrSpace)
const {
594 Ty, BaseGV, BaseOffset, HasBaseReg, Scale, AddrSpace);
595 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
600 return TTIImpl->LSRWithInstrQueries();
604 return TTIImpl->isTruncateFree(Ty1, Ty2);
608 return TTIImpl->isProfitableToHoist(
I);
614 return TTIImpl->isTypeLegal(Ty);
618 return TTIImpl->getRegUsageForType(Ty);
622 return TTIImpl->shouldBuildLookupTables();
627 return TTIImpl->shouldBuildLookupTablesForConstant(
C);
631 return TTIImpl->getMinimumLookupTableEntryBitWidth();
635 return TTIImpl->shouldBuildRelLookupTables();
639 return TTIImpl->useColdCCForColdCall(
F);
643 return TTIImpl->useFastCCForInternalCall(
F);
648 return TTIImpl->isTargetIntrinsicWithScalarOpAtArg(ID, ScalarOpdIdx);
653 return TTIImpl->isTargetIntrinsicWithOverloadTypeAtArg(ID, OpdIdx);
658 return TTIImpl->isTargetIntrinsicWithStructReturnOverloadAtField(ID, RetIdx);
665 return Ctx1 == Ctx2 ? Ctx1 : TargetTransformInfo::VectorInstrContext::None;
676 I->getOperand(1)->hasOneUse())
692 return TTIImpl->getBuildVectorContextHint(Mask, Scalars, GatherUseOps);
699 return TTIImpl->getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
700 CostKind, ForPoisonSrc, VL, VIC);
706 return TTIImpl->getOperandsScalarizationOverhead(Tys, CostKind, VIC);
710 return TTIImpl->supportsEfficientVectorElementLoadStore();
714 return TTIImpl->supportsTailCalls();
718 return TTIImpl->supportsTailCallFor(CB);
722 bool LoopHasReductions)
const {
723 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
728 return TTIImpl->enableMemCmpExpansion(OptSize, IsZeroCmp);
732 return TTIImpl->enableSelectOptimize();
737 return TTIImpl->shouldTreatInstructionLikeSelect(
I);
741 return TTIImpl->enableInterleavedAccessVectorization();
745 return TTIImpl->enableMaskedInterleavedAccessVectorization();
749 return TTIImpl->isFPVectorizationPotentiallyUnsafe();
757 unsigned *
Fast)
const {
758 return TTIImpl->allowsMisalignedMemoryAccesses(Context,
BitWidth,
764 return TTIImpl->getPopcntSupport(IntTyWidthInBit);
768 return TTIImpl->haveFastSqrt(Ty);
773 return TTIImpl->isExpensiveToSpeculativelyExecute(
I);
777 return TTIImpl->isFCmpOrdCheaperThanFCmpZero(Ty);
782 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
791 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
799 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
804 unsigned Opcode,
unsigned Idx,
const APInt &
Imm,
Type *Ty,
807 TTIImpl->getIntImmCostInst(Opcode, Idx,
Imm, Ty, CostKind, Inst);
808 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
817 TTIImpl->getIntImmCostIntrin(IID, Idx,
Imm, Ty, CostKind);
818 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
824 return TTIImpl->preferToKeepConstantsAttached(Inst, Fn);
828 return TTIImpl->getNumberOfRegisters(ClassID);
832 bool IsStore)
const {
833 return TTIImpl->hasConditionalLoadStoreForType(Ty, IsStore);
838 return TTIImpl->getRegisterClassForType(
Vector, Ty);
842 return TTIImpl->getRegisterClassName(ClassID);
847 return TTIImpl->getRegisterClassSpillCost(ClassID, CostKind);
852 return TTIImpl->getRegisterClassReloadCost(ClassID, CostKind);
857 return TTIImpl->getRegisterBitWidth(
K);
861 return TTIImpl->getMinVectorRegisterBitWidth();
865 return TTIImpl->getVScaleForTuning();
870 return TTIImpl->shouldMaximizeVectorBandwidth(
K);
874 bool IsScalable)
const {
875 return TTIImpl->getMinimumVF(ElemWidth, IsScalable);
879 unsigned Opcode)
const {
880 return TTIImpl->getMaximumVF(ElemWidth, Opcode);
886 unsigned AddrSpace)
const {
887 return TTIImpl->getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy, Alignment,
892 const Instruction &
I,
bool &AllowPromotionWithoutCommonHeader)
const {
893 return TTIImpl->shouldConsiderAddressTypePromotion(
894 I, AllowPromotionWithoutCommonHeader);
899 : TTIImpl->getCacheLineSize();
902std::optional<unsigned>
904 return TTIImpl->getCacheSize(Level);
907std::optional<unsigned>
909 return TTIImpl->getCacheAssociativity(Level);
914 : TTIImpl->getMinPageSize();
918 return TTIImpl->getPrefetchDistance();
922 unsigned NumMemAccesses,
unsigned NumStridedMemAccesses,
923 unsigned NumPrefetches,
bool HasCall)
const {
924 return TTIImpl->getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
925 NumPrefetches, HasCall);
929 return TTIImpl->getMaxPrefetchIterationsAhead();
933 return TTIImpl->enableWritePrefetching();
937 return TTIImpl->shouldPrefetchAddressSpace(AS);
941 unsigned Opcode,
Type *InputTypeA,
Type *InputTypeB,
Type *AccumType,
945 return TTIImpl->getPartialReductionCost(Opcode, InputTypeA, InputTypeB,
946 AccumType, VF, OpAExtend, OpBExtend,
947 BinOp, CostKind, FMF);
952 bool HasUnorderedReductions)
const {
953 return TTIImpl->getMaxInterleaveFactor(VF, HasUnorderedReductions);
967 if (CI->getValue().isPowerOf2())
969 else if (CI->getValue().isNegatedPowerOf2())
979 if (ShuffleInst->isZeroEltSplat())
994 if (CI->getValue().isPowerOf2())
996 else if (CI->getValue().isNegatedPowerOf2())
1002 bool AllPow2 =
true, AllNegPow2 =
true;
1003 for (uint64_t
I = 0, E = CDS->getNumElements();
I != E; ++
I) {
1005 AllPow2 &= CI->getValue().isPowerOf2();
1006 AllNegPow2 &= CI->getValue().isNegatedPowerOf2();
1007 if (AllPow2 || AllNegPow2)
1010 AllPow2 = AllNegPow2 =
false;
1019 return {OpInfo, OpProps};
1025 const auto *Op0 =
Ops.front();
1039 return CI->getValue().isPowerOf2();
1045 return CI->getValue().isNegatedPowerOf2();
1050 if (IsConstant && IsUniform)
1052 else if (IsConstant)
1081 if (TLibInfo && Opcode == Instruction::FRem) {
1083 LibFunc Func = TLibInfo->
getLibFunc(Instruction::FRem, Ty->getScalarType());
1084 if (VecTy && Func != NotLibFunc &&
1091 Opcode, Ty, CostKind, Op1Info, Op2Info, Args, CtxI);
1092 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1097 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
1101 VecTy, Opcode0, Opcode1, OpcodeMask, CostKind, Scalars);
1102 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1113 "Expected the Mask to match the return size if given");
1115 "Expected the same scalar types");
1117 Kind, DstTy, SrcTy, CostKind, Mask, Index, SubTp, Args, CtxI, VIC);
1118 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1134 return Instruction::CastOps::ZExt;
1136 return Instruction::CastOps::SExt;
1138 return Instruction::CastOps::FPExt;
1149 case Instruction::CastOps::ZExt:
1151 case Instruction::CastOps::SExt:
1153 case Instruction::CastOps::FPExt:
1166 auto getLoadStoreKind = [](
const Value *V,
unsigned LdStOp,
unsigned MaskedOp,
1167 unsigned GatScatOp) {
1172 if (
I->getOpcode() == LdStOp)
1176 if (
II->getIntrinsicID() == MaskedOp)
1178 if (
II->getIntrinsicID() == GatScatOp)
1185 switch (
I->getOpcode()) {
1186 case Instruction::ZExt:
1187 case Instruction::SExt:
1188 case Instruction::FPExt:
1189 return getLoadStoreKind(
I->getOperand(0), Instruction::Load,
1190 Intrinsic::masked_load, Intrinsic::masked_gather);
1191 case Instruction::Trunc:
1192 case Instruction::FPTrunc:
1194 return getLoadStoreKind(*
I->user_begin(), Instruction::Store,
1195 Intrinsic::masked_store,
1196 Intrinsic::masked_scatter);
1208 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1209 "Opcode should reflect passed instruction.");
1211 TTIImpl->getCastInstrCost(Opcode, Dst, Src, CCH, CostKind,
I);
1212 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1220 TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index, CostKind);
1221 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1227 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1228 "Opcode should reflect passed instruction.");
1230 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1238 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1239 "Opcode should reflect passed instruction.");
1241 Opcode, ValTy, CondTy, VecPred, CostKind, Op1Info, Op2Info,
I);
1242 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1249 assert((Opcode == Instruction::InsertElement ||
1250 Opcode == Instruction::ExtractElement) &&
1251 "Expecting Opcode to be insertelement/extractelement.");
1253 TTIImpl->getVectorInstrCost(Opcode, Val, CostKind, Index, Op0, Op1, VIC);
1254 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1260 Value *Scalar,
ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
1262 assert((Opcode == Instruction::InsertElement ||
1263 Opcode == Instruction::ExtractElement) &&
1264 "Expecting Opcode to be insertelement/extractelement.");
1266 Opcode, Val, CostKind, Index, Scalar, ScalarUserAndIdx, VIC);
1267 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1278 TTIImpl->getVectorInstrCost(
I, Val, CostKind, Index, VIC);
1279 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1285 unsigned Index)
const {
1287 TTIImpl->getIndexedVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
1288 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1294 assert((Opcode == Instruction::InsertValue ||
1295 Opcode == Instruction::ExtractValue) &&
1296 "Expecting Opcode to be insertvalue/extractvalue.");
1298 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1303 Type *EltTy,
int ReplicationFactor,
int VF,
const APInt &DemandedDstElts,
1306 EltTy, ReplicationFactor, VF, DemandedDstElts, CostKind);
1307 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1315 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1316 "Opcode should reflect passed instruction.");
1319 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1326 bool UseMaskForCond,
bool UseMaskForGaps)
const {
1328 Opcode, VecTy, Factor, Indices, Alignment,
AddressSpace, CostKind,
1329 UseMaskForCond, UseMaskForGaps);
1330 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1338 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1346 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1355 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1360 return TTIImpl->getNumberOfParts(Tp);
1367 TTIImpl->getAddressComputationCost(PtrTy, SE, Ptr, CostKind);
1368 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1374 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1379 return TTIImpl->getMaxMemIntrinsicInlineSizeThreshold();
1383 unsigned Opcode,
VectorType *Ty, std::optional<FastMathFlags> FMF,
1386 TTIImpl->getArithmeticReductionCost(Opcode, Ty, FMF, CostKind);
1387 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1395 TTIImpl->getMinMaxReductionCost(IID, Ty, FMF, CostKind);
1396 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1403 return TTIImpl->getExtendedReductionCost(Opcode, IsUnsigned, ResTy, Ty, FMF,
1408 bool IsUnsigned,
unsigned RedOpcode,
Type *ResTy,
VectorType *Ty,
1410 return TTIImpl->getMulAccReductionCost(IsUnsigned, RedOpcode, ResTy, Ty,
1416 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
1421 return TTIImpl->getTgtMemIntrinsic(Inst, Info);
1425 return TTIImpl->getAtomicMemIntrinsicMaxElementSize();
1430 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType,
1436 unsigned DestAddrSpace,
Align SrcAlign,
Align DestAlign,
1437 std::optional<uint32_t> AtomicElementSize)
const {
1438 return TTIImpl->getMemcpyLoopLoweringType(Context,
Length, SrcAddrSpace,
1439 DestAddrSpace, SrcAlign, DestAlign,
1445 unsigned RemainingBytes,
unsigned SrcAddrSpace,
unsigned DestAddrSpace,
1447 std::optional<uint32_t> AtomicCpySize)
const {
1448 TTIImpl->getMemcpyLoopResidualLoweringType(
1449 OpsOut, Context, RemainingBytes, SrcAddrSpace, DestAddrSpace, SrcAlign,
1450 DestAlign, AtomicCpySize);
1455 return TTIImpl->areInlineCompatible(Caller, Callee);
1461 unsigned DefaultCallPenalty)
const {
1462 return TTIImpl->getInlineCallPenalty(
F,
Call, DefaultCallPenalty);
1467 return TTIImpl->shouldCopyAttributeWhenOutliningFrom(Caller, Attr);
1472 return TTIImpl->areTypesABICompatible(Caller, Callee, Types);
1477 return TTIImpl->isIndexedLoadLegal(Mode, Ty);
1482 return TTIImpl->isIndexedStoreLegal(Mode, Ty);
1486 return TTIImpl->getLoadStoreVecRegBitWidth(AS);
1490 return TTIImpl->isLegalToVectorizeLoad(LI);
1494 return TTIImpl->isLegalToVectorizeStore(
SI);
1498 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1499 return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
1504 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1505 return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
1511 return TTIImpl->isLegalToVectorizeReduction(RdxDesc, VF);
1515 return TTIImpl->isElementTypeLegalForScalableVector(Ty);
1520 unsigned ChainSizeInBytes,
1522 return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
1527 unsigned ChainSizeInBytes,
1529 return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
1533 return TTIImpl->preferFixedOverScalableIfEqualCost();
1538 return TTIImpl->preferInLoopReduction(Kind, Ty);
1542 return TTIImpl->preferAlternateOpcodeVectorization();
1546 return TTIImpl->preferSLPInstCountCheck();
1550 return TTIImpl->preferPredicatedReductionSelect();
1555 return TTIImpl->preferEpilogueVectorization(Iters);
1559 return TTIImpl->shouldConsiderVectorizationRegPressure();
1564 return TTIImpl->getVPLegalizationStrategy(VPI);
1568 return TTIImpl->hasArmWideBranch(Thumb);
1572 return TTIImpl->getFeatureMask(
F);
1576 return TTIImpl->getPriorityMask(
F);
1580 return TTIImpl->isMultiversionedFunction(
F);
1584 return TTIImpl->getMaxNumArgs();
1588 return TTIImpl->shouldExpandReduction(
II);
1594 return TTIImpl->getPreferredExpandedReductionShuffle(
II);
1598 return TTIImpl->getGISelRematGlobalCost();
1602 return TTIImpl->getMinTripCountTailFoldingThreshold();
1606 return TTIImpl->supportsScalableVectors();
1610 return TTIImpl->enableScalableVectorization();
1614 return TTIImpl->hasActiveVectorLength();
1619 return TTIImpl->isProfitableToSinkOperands(
I, OpsToSink);
1623 return TTIImpl->isVectorShiftByScalarCheap(Ty);
1629 return TTIImpl->collectKernelLaunchBounds(
F, LB);
1633 return TTIImpl->allowVectorElementIndexingUsingGEP();
1638 return TTIImpl->isUniform(
I, UniformArgs);
1647 : TTICallback(
std::
move(TTICallback)) {}
1651 assert(!
F.isIntrinsic() &&
"Should not request TTI for intrinsics");
1652 return TTICallback(
F);
1658 return Result(
F.getDataLayout());
1663 "Target Transform Information",
false,
true)
1677 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")
static cl::opt< bool > ForceNestedLoop("force-nested-hardware-loop", cl::Hidden, cl::init(false), cl::desc("Force allowance of nested hardware loops"))
static cl::opt< bool > ForceHardwareLoopPHI("force-hardware-loop-phi", cl::Hidden, cl::init(false), cl::desc("Force hardware loop counter to be updated through a phi"))
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[]
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
SmallVector< MachineOperand, 4 > Cond
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),...
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.
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.
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.
@ 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...
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.
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: ...
@ 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.