27using namespace PatternMatch;
29#define DEBUG_TYPE "tti"
33 cl::desc(
"Recognize reduction patterns."));
37 cl::desc(
"Use this to override the target cache line size when "
38 "specified by the user."));
42 cl::desc(
"Use this to override the target's minimum page size."));
47 "Use this to override the target's predictable branch threshold (%)."));
61 std::unique_ptr<const TargetTransformInfoImplBase> Impl)
69 if (containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
78 ScalarizationCost(ScalarizationCost), LibInfo(LibInfo) {
80 if (
const auto *FPMO = dyn_cast<FPMathOperator>(&CI))
81 FMF = FPMO->getFastMathFlags();
94 :
II(
I),
RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost) {
95 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
100 :
RetTy(Ty), IID(Id) {
102 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
103 ParamTys.reserve(Arguments.size());
112 :
II(
I),
RetTy(RTy), IID(Id), FMF(Flags), ScalarizationCost(ScalarCost),
114 ParamTys.insert(ParamTys.begin(), Tys.
begin(), Tys.
end());
115 Arguments.insert(Arguments.begin(), Args.begin(), Args.end());
142 if (isa<SCEVCouldNotCompute>(EC))
144 if (
const SCEVConstant *ConstEC = dyn_cast<SCEVConstant>(EC)) {
145 if (ConstEC->getValue()->isZero())
166 bool NotAlways =
false;
185 if (
BranchInst *BI = dyn_cast<BranchInst>(TI)) {
186 if (!BI->isConditional())
206 : TTIImpl(
std::make_unique<NoTTIImpl>(
DL)) {}
211 : TTIImpl(
std::
move(Arg.TTIImpl)) {}
214 TTIImpl = std::move(
RHS.TTIImpl);
219 return TTIImpl->getInliningThresholdMultiplier();
224 return TTIImpl->getInliningCostBenefitAnalysisSavingsMultiplier();
230 return TTIImpl->getInliningCostBenefitAnalysisProfitableMultiplier();
234 return TTIImpl->getInliningLastCallToStaticBonus();
239 return TTIImpl->adjustInliningThreshold(CB);
244 return TTIImpl->getCallerAllocaCost(CB, AI);
248 return TTIImpl->getInlinerVectorBonusPercent();
262 "If pointers have same base address it has to be provided.");
269 return TTIImpl->getEstimatedNumberOfCaseClusters(SI, JTSize, PSI, BFI);
278 "TTI should not produce negative costs!");
285 : TTIImpl->getPredictableBranchThreshold();
289 return TTIImpl->getBranchMispredictPenalty();
293 return TTIImpl->hasBranchDivergence(
F);
297 if (
const auto *Call = dyn_cast<CallBase>(V)) {
298 if (Call->hasFnAttr(Attribute::NoDivergenceSource))
301 return TTIImpl->isSourceOfDivergence(V);
305 return TTIImpl->isAlwaysUniform(V);
309 unsigned ToAS)
const {
310 return TTIImpl->isValidAddrSpaceCast(FromAS, ToAS);
314 unsigned ToAS)
const {
315 return TTIImpl->addrspacesMayAlias(FromAS, ToAS);
319 return TTIImpl->getFlatAddressSpace();
324 return TTIImpl->collectFlatAddressOperands(OpIndexes, IID);
328 unsigned ToAS)
const {
329 return TTIImpl->isNoopAddrSpaceCast(FromAS, ToAS);
334 return TTIImpl->canHaveNonUndefGlobalInitializerInAddressSpace(AS);
338 return TTIImpl->getAssumedAddrSpace(V);
342 return TTIImpl->isSingleThreaded();
345std::pair<const Value *, unsigned>
347 return TTIImpl->getPredicatedAddrSpace(V);
352 return TTIImpl->rewriteIntrinsicWithAddressSpace(
II, OldV, NewV);
356 return TTIImpl->isLoweredToCall(
F);
362 return TTIImpl->isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
366 return TTIImpl->getEpilogueVectorizationMinVF();
371 return TTIImpl->preferPredicateOverEpilogue(TFI);
375 bool IVUpdateMayOverflow)
const {
376 return TTIImpl->getPreferredTailFoldingStyle(IVUpdateMayOverflow);
379std::optional<Instruction *>
382 return TTIImpl->instCombineIntrinsic(IC,
II);
387 bool &KnownBitsComputed)
const {
388 return TTIImpl->simplifyDemandedUseBitsIntrinsic(IC,
II, DemandedMask, Known,
396 SimplifyAndSetOp)
const {
397 return TTIImpl->simplifyDemandedVectorEltsIntrinsic(
398 IC,
II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
405 return TTIImpl->getUnrollingPreferences(L, SE, UP, ORE);
410 return TTIImpl->getPeelingPreferences(L, SE, PP);
414 return TTIImpl->isLegalAddImmediate(Imm);
418 return TTIImpl->isLegalAddScalableImmediate(Imm);
422 return TTIImpl->isLegalICmpImmediate(Imm);
427 bool HasBaseReg, int64_t Scale,
430 int64_t ScalableOffset)
const {
431 return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
432 Scale, AddrSpace,
I, ScalableOffset);
437 return TTIImpl->isLSRCostLess(C1, C2);
441 return TTIImpl->isNumRegsMajorCostOfLSR();
445 return TTIImpl->shouldDropLSRSolutionIfLessProfitable();
449 return TTIImpl->isProfitableLSRChainElement(
I);
453 return TTIImpl->canMacroFuseCmp();
460 return TTIImpl->canSaveCmp(L, BI, SE, LI, DT, AC, LibInfo);
466 return TTIImpl->getPreferredAddressingMode(L, SE);
471 return TTIImpl->isLegalMaskedStore(DataType, Alignment,
AddressSpace);
476 return TTIImpl->isLegalMaskedLoad(DataType, Alignment,
AddressSpace);
480 Align Alignment)
const {
481 return TTIImpl->isLegalNTStore(DataType, Alignment);
485 return TTIImpl->isLegalNTLoad(DataType, Alignment);
490 return TTIImpl->isLegalBroadcastLoad(ElementTy, NumElements);
494 Align Alignment)
const {
495 return TTIImpl->isLegalMaskedGather(DataType, Alignment);
499 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
501 return TTIImpl->isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask);
505 Align Alignment)
const {
506 return TTIImpl->isLegalMaskedScatter(DataType, Alignment);
510 Align Alignment)
const {
511 return TTIImpl->forceScalarizeMaskedGather(DataType, Alignment);
515 Align Alignment)
const {
516 return TTIImpl->forceScalarizeMaskedScatter(DataType, Alignment);
520 Align Alignment)
const {
521 return TTIImpl->isLegalMaskedCompressStore(DataType, Alignment);
525 Align Alignment)
const {
526 return TTIImpl->isLegalMaskedExpandLoad(DataType, Alignment);
530 Align Alignment)
const {
531 return TTIImpl->isLegalStridedLoadStore(DataType, Alignment);
536 unsigned AddrSpace)
const {
537 return TTIImpl->isLegalInterleavedAccessType(VTy, Factor, Alignment,
542 Type *DataType)
const {
543 return TTIImpl->isLegalMaskedVectorHistogram(AddrType, DataType);
547 return TTIImpl->enableOrderedReductions();
551 return TTIImpl->hasDivRemOp(DataType, IsSigned);
555 unsigned AddrSpace)
const {
556 return TTIImpl->hasVolatileVariant(
I, AddrSpace);
560 return TTIImpl->prefersVectorizedAddressing();
565 int64_t Scale,
unsigned AddrSpace)
const {
567 Ty, BaseGV, BaseOffset, HasBaseReg, Scale, AddrSpace);
568 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
573 return TTIImpl->LSRWithInstrQueries();
577 return TTIImpl->isTruncateFree(Ty1, Ty2);
581 return TTIImpl->isProfitableToHoist(
I);
587 return TTIImpl->isTypeLegal(Ty);
591 return TTIImpl->getRegUsageForType(Ty);
595 return TTIImpl->shouldBuildLookupTables();
600 return TTIImpl->shouldBuildLookupTablesForConstant(
C);
604 return TTIImpl->shouldBuildRelLookupTables();
608 return TTIImpl->useColdCCForColdCall(
F);
613 return TTIImpl->isTargetIntrinsicTriviallyScalarizable(
ID);
618 return TTIImpl->isTargetIntrinsicWithScalarOpAtArg(
ID, ScalarOpdIdx);
623 return TTIImpl->isTargetIntrinsicWithOverloadTypeAtArg(
ID, OpdIdx);
628 return TTIImpl->isTargetIntrinsicWithStructReturnOverloadAtField(
ID, RetIdx);
635 return TTIImpl->getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
641 return TTIImpl->getOperandsScalarizationOverhead(Tys,
CostKind);
645 return TTIImpl->supportsEfficientVectorElementLoadStore();
649 return TTIImpl->supportsTailCalls();
653 return TTIImpl->supportsTailCallFor(CB);
657 bool LoopHasReductions)
const {
658 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
663 return TTIImpl->enableMemCmpExpansion(OptSize, IsZeroCmp);
667 return TTIImpl->enableSelectOptimize();
672 return TTIImpl->shouldTreatInstructionLikeSelect(
I);
676 return TTIImpl->enableInterleavedAccessVectorization();
680 return TTIImpl->enableMaskedInterleavedAccessVectorization();
684 return TTIImpl->isFPVectorizationPotentiallyUnsafe();
692 unsigned *
Fast)
const {
699 return TTIImpl->getPopcntSupport(IntTyWidthInBit);
703 return TTIImpl->haveFastSqrt(Ty);
708 return TTIImpl->isExpensiveToSpeculativelyExecute(
I);
712 return TTIImpl->isFCmpOrdCheaperThanFCmpZero(Ty);
717 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
726 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
734 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
739 unsigned Opcode,
unsigned Idx,
const APInt &Imm,
Type *Ty,
742 TTIImpl->getIntImmCostInst(Opcode,
Idx, Imm, Ty,
CostKind, Inst);
743 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
752 TTIImpl->getIntImmCostIntrin(IID,
Idx, Imm, Ty,
CostKind);
753 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
759 return TTIImpl->preferToKeepConstantsAttached(Inst, Fn);
763 return TTIImpl->getNumberOfRegisters(ClassID);
767 bool IsStore)
const {
768 return TTIImpl->hasConditionalLoadStoreForType(Ty, IsStore);
773 return TTIImpl->getRegisterClassForType(
Vector, Ty);
777 return TTIImpl->getRegisterClassName(ClassID);
782 return TTIImpl->getRegisterBitWidth(K);
786 return TTIImpl->getMinVectorRegisterBitWidth();
790 return TTIImpl->getMaxVScale();
794 return TTIImpl->getVScaleForTuning();
798 return TTIImpl->isVScaleKnownToBeAPowerOfTwo();
803 return TTIImpl->shouldMaximizeVectorBandwidth(K);
807 bool IsScalable)
const {
808 return TTIImpl->getMinimumVF(ElemWidth, IsScalable);
812 unsigned Opcode)
const {
813 return TTIImpl->getMaximumVF(ElemWidth, Opcode);
817 Type *ScalarValTy)
const {
818 return TTIImpl->getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy);
822 const Instruction &
I,
bool &AllowPromotionWithoutCommonHeader)
const {
823 return TTIImpl->shouldConsiderAddressTypePromotion(
824 I, AllowPromotionWithoutCommonHeader);
829 : TTIImpl->getCacheLineSize();
832std::optional<unsigned>
834 return TTIImpl->getCacheSize(Level);
837std::optional<unsigned>
839 return TTIImpl->getCacheAssociativity(Level);
844 : TTIImpl->getMinPageSize();
848 return TTIImpl->getPrefetchDistance();
852 unsigned NumMemAccesses,
unsigned NumStridedMemAccesses,
853 unsigned NumPrefetches,
bool HasCall)
const {
854 return TTIImpl->getMinPrefetchStride(NumMemAccesses, NumStridedMemAccesses,
855 NumPrefetches, HasCall);
859 return TTIImpl->getMaxPrefetchIterationsAhead();
863 return TTIImpl->enableWritePrefetching();
867 return TTIImpl->shouldPrefetchAddressSpace(AS);
871 unsigned Opcode,
Type *InputTypeA,
Type *InputTypeB,
Type *AccumType,
875 return TTIImpl->getPartialReductionCost(Opcode, InputTypeA, InputTypeB,
876 AccumType, VF, OpAExtend, OpBExtend,
881 return TTIImpl->getMaxInterleaveFactor(VF);
890 if (isa<UndefValue>(V))
893 if (isa<ConstantInt>(V) || isa<ConstantFP>(V)) {
894 if (
const auto *CI = dyn_cast<ConstantInt>(V)) {
895 if (CI->getValue().isPowerOf2())
897 else if (CI->getValue().isNegatedPowerOf2())
906 if (
const auto *ShuffleInst = dyn_cast<ShuffleVectorInst>(V))
907 if (ShuffleInst->isZeroEltSplat())
917 if (isa<Argument>(
Splat) || isa<GlobalValue>(
Splat)) {
919 }
else if (isa<Constant>(
Splat)) {
921 if (
auto *CI = dyn_cast<ConstantInt>(
Splat)) {
922 if (CI->getValue().isPowerOf2())
924 else if (CI->getValue().isNegatedPowerOf2())
928 }
else if (
const auto *CDS = dyn_cast<ConstantDataSequential>(V)) {
930 bool AllPow2 =
true, AllNegPow2 =
true;
931 for (
uint64_t I = 0, E = CDS->getNumElements();
I != E; ++
I) {
932 if (
auto *CI = dyn_cast<ConstantInt>(CDS->getElementAsConstant(
I))) {
933 AllPow2 &= CI->getValue().isPowerOf2();
934 AllNegPow2 &= CI->getValue().isNegatedPowerOf2();
935 if (AllPow2 || AllNegPow2)
938 AllPow2 = AllNegPow2 =
false;
943 }
else if (isa<ConstantVector>(V) || isa<ConstantDataVector>(V)) {
947 return {OpInfo, OpProps};
959 if (TLibInfo && Opcode == Instruction::FRem) {
970 TTIImpl->getArithmeticInstrCost(Opcode, Ty,
CostKind,
973 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
978 VectorType *VecTy,
unsigned Opcode0,
unsigned Opcode1,
981 TTIImpl->getAltInstrCost(VecTy, Opcode0, Opcode1, OpcodeMask,
CostKind);
982 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
992 "Expected the Mask to match the return size if given");
994 "Expected the same scalar types");
996 Kind, DstTy, SrcTy, Mask,
CostKind, Index, SubTp, Args, CxtI);
997 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1003 if (isa<SExtInst>(
I))
1005 if (isa<ZExtInst>(
I))
1015 auto getLoadStoreKind = [](
const Value *V,
unsigned LdStOp,
unsigned MaskedOp,
1016 unsigned GatScatOp) {
1021 if (
I->getOpcode() == LdStOp)
1025 if (
II->getIntrinsicID() == MaskedOp)
1027 if (
II->getIntrinsicID() == GatScatOp)
1034 switch (
I->getOpcode()) {
1035 case Instruction::ZExt:
1036 case Instruction::SExt:
1037 case Instruction::FPExt:
1038 return getLoadStoreKind(
I->getOperand(0), Instruction::Load,
1039 Intrinsic::masked_load, Intrinsic::masked_gather);
1040 case Instruction::Trunc:
1041 case Instruction::FPTrunc:
1043 return getLoadStoreKind(*
I->user_begin(), Instruction::Store,
1044 Intrinsic::masked_store,
1045 Intrinsic::masked_scatter);
1057 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1058 "Opcode should reflect passed instruction.");
1060 TTIImpl->getCastInstrCost(Opcode, Dst, Src, CCH,
CostKind,
I);
1061 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1069 TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index,
CostKind);
1070 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1076 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1077 "Opcode should reflect passed instruction.");
1079 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1087 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1088 "Opcode should reflect passed instruction.");
1090 Opcode, ValTy, CondTy, VecPred,
CostKind, Op1Info, Op2Info,
I);
1091 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1098 assert((Opcode == Instruction::InsertElement ||
1099 Opcode == Instruction::ExtractElement) &&
1100 "Expecting Opcode to be insertelement/extractelement.");
1102 TTIImpl->getVectorInstrCost(Opcode, Val,
CostKind, Index, Op0, Op1);
1103 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1110 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx)
const {
1111 assert((Opcode == Instruction::InsertElement ||
1112 Opcode == Instruction::ExtractElement) &&
1113 "Expecting Opcode to be insertelement/extractelement.");
1115 Opcode, Val,
CostKind, Index, Scalar, ScalarUserAndIdx);
1116 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1123 unsigned Index)
const {
1128 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1134 unsigned Index)
const {
1136 TTIImpl->getIndexedVectorInstrCostFromEnd(Opcode, Val,
CostKind, Index);
1137 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1143 assert((Opcode == Instruction::InsertValue ||
1144 Opcode == Instruction::ExtractValue) &&
1145 "Expecting Opcode to be insertvalue/extractvalue.");
1147 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1152 Type *EltTy,
int ReplicationFactor,
int VF,
const APInt &DemandedDstElts,
1155 EltTy, ReplicationFactor, VF, DemandedDstElts,
CostKind);
1156 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1164 assert((
I ==
nullptr ||
I->getOpcode() == Opcode) &&
1165 "Opcode should reflect passed instruction.");
1168 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1177 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1182 unsigned Opcode,
Type *DataTy,
const Value *
Ptr,
bool VariableMask,
1185 Opcode, DataTy,
Ptr, VariableMask, Alignment,
CostKind,
I);
1187 "TTI should not produce negative costs!");
1192 unsigned Opcode,
Type *DataTy,
bool VariableMask,
Align Alignment,
1195 Opcode, DataTy, VariableMask, Alignment,
CostKind,
I);
1196 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1201 unsigned Opcode,
Type *DataTy,
const Value *
Ptr,
bool VariableMask,
1204 Opcode, DataTy,
Ptr, VariableMask, Alignment,
CostKind,
I);
1205 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1212 bool UseMaskForCond,
bool UseMaskForGaps)
const {
1215 UseMaskForCond, UseMaskForGaps);
1216 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1224 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1233 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1238 return TTIImpl->getNumberOfParts(Tp);
1245 TTIImpl->getAddressComputationCost(PtrTy, SE,
Ptr,
CostKind);
1246 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1252 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1257 return TTIImpl->getMaxMemIntrinsicInlineSizeThreshold();
1261 unsigned Opcode,
VectorType *Ty, std::optional<FastMathFlags> FMF,
1264 TTIImpl->getArithmeticReductionCost(Opcode, Ty, FMF,
CostKind);
1265 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1273 TTIImpl->getMinMaxReductionCost(IID, Ty, FMF,
CostKind);
1274 assert(
Cost >= 0 &&
"TTI should not produce negative costs!");
1281 return TTIImpl->getExtendedReductionCost(Opcode, IsUnsigned, ResTy, Ty, FMF,
1288 return TTIImpl->getMulAccReductionCost(IsUnsigned, ResTy, Ty,
CostKind);
1293 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
1298 return TTIImpl->getTgtMemIntrinsic(Inst,
Info);
1302 return TTIImpl->getAtomicMemIntrinsicMaxElementSize();
1307 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType,
1313 unsigned DestAddrSpace,
Align SrcAlign,
Align DestAlign,
1314 std::optional<uint32_t> AtomicElementSize)
const {
1315 return TTIImpl->getMemcpyLoopLoweringType(
Context,
Length, SrcAddrSpace,
1316 DestAddrSpace, SrcAlign, DestAlign,
1322 unsigned RemainingBytes,
unsigned SrcAddrSpace,
unsigned DestAddrSpace,
1324 std::optional<uint32_t> AtomicCpySize)
const {
1325 TTIImpl->getMemcpyLoopResidualLoweringType(
1326 OpsOut,
Context, RemainingBytes, SrcAddrSpace, DestAddrSpace, SrcAlign,
1327 DestAlign, AtomicCpySize);
1332 return TTIImpl->areInlineCompatible(Caller, Callee);
1338 unsigned DefaultCallPenalty)
const {
1339 return TTIImpl->getInlineCallPenalty(
F, Call, DefaultCallPenalty);
1345 return TTIImpl->areTypesABICompatible(Caller, Callee, Types);
1350 return TTIImpl->isIndexedLoadLegal(Mode, Ty);
1355 return TTIImpl->isIndexedStoreLegal(Mode, Ty);
1359 return TTIImpl->getLoadStoreVecRegBitWidth(AS);
1363 return TTIImpl->isLegalToVectorizeLoad(LI);
1367 return TTIImpl->isLegalToVectorizeStore(SI);
1371 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1372 return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
1377 unsigned ChainSizeInBytes,
Align Alignment,
unsigned AddrSpace)
const {
1378 return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
1384 return TTIImpl->isLegalToVectorizeReduction(RdxDesc, VF);
1388 return TTIImpl->isElementTypeLegalForScalableVector(Ty);
1393 unsigned ChainSizeInBytes,
1395 return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
1400 unsigned ChainSizeInBytes,
1402 return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
1406 return TTIImpl->preferFixedOverScalableIfEqualCost();
1411 return TTIImpl->preferInLoopReduction(Kind, Ty);
1415 return TTIImpl->preferAlternateOpcodeVectorization();
1419 return TTIImpl->preferPredicatedReductionSelect();
1423 return TTIImpl->preferEpilogueVectorization();
1428 return TTIImpl->getVPLegalizationStrategy(VPI);
1432 return TTIImpl->hasArmWideBranch(Thumb);
1436 return TTIImpl->getFeatureMask(
F);
1440 return TTIImpl->isMultiversionedFunction(
F);
1444 return TTIImpl->getMaxNumArgs();
1448 return TTIImpl->shouldExpandReduction(
II);
1454 return TTIImpl->getPreferredExpandedReductionShuffle(
II);
1458 return TTIImpl->getGISelRematGlobalCost();
1462 return TTIImpl->getMinTripCountTailFoldingThreshold();
1466 return TTIImpl->supportsScalableVectors();
1470 return TTIImpl->enableScalableVectorization();
1474 return TTIImpl->hasActiveVectorLength();
1479 return TTIImpl->isProfitableToSinkOperands(
I, OpsToSink);
1483 return TTIImpl->isVectorShiftByScalarCheap(Ty);
1489 return TTIImpl->getNumBytesToPadGlobalArray(
Size,
ArrayType);
1495 return TTIImpl->collectKernelLaunchBounds(
F, LB);
1499 return TTIImpl->allowVectorElementIndexingUsingGEP();
1508 : TTICallback(
std::
move(TTICallback)) {}
1512 assert(!
F.isIntrinsic() &&
"Should not request TTI for intrinsics");
1513 return TTICallback(
F);
1519 return Result(
F.getDataLayout());
1524 "Target Transform Information",
false,
true)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
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.
mir Rename Register Operands
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static SymbolRef::Type getType(const Symbol *Sym)
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
A container for analyses that lazily runs them and caches their results.
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent array types.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Conditional or Unconditional Branch instruction.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
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.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
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.
Class to represent function types.
param_iterator param_begin() const
param_iterator param_end() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
ImmutablePass class - This class is used to provide information that does not need to be run.
The core instruction combiner logic.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
LLVM_ABI IntrinsicCostAttributes(Intrinsic::ID Id, const CallBase &CI, InstructionCost ScalarCost=InstructionCost::getInvalid(), bool TypeBasedOnly=false, TargetLibraryInfo const *LibInfo=nullptr)
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.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
void getExitingBlocks(SmallVectorImpl< BlockT * > &ExitingBlocks) const
Return all blocks inside the loop that have successors outside of the loop.
BlockT * getHeader() const
bool isLoopLatch(const BlockT *BB) const
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.
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.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
StringRef getName(LibFunc F) const
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
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.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
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.
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)
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.