LLVM 22.0.0git
AArch64TargetTransformInfo.h
Go to the documentation of this file.
1//===- AArch64TargetTransformInfo.h - AArch64 specific TTI ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file a TargetTransformInfoImplBase conforming object specific to the
10/// AArch64 target machine. It uses the target's detailed information to
11/// provide more precise answers to certain TTI queries, while letting the
12/// target independent and default TTI implementations handle the rest.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
17#define LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
18
19#include "AArch64.h"
20#include "AArch64Subtarget.h"
24#include "llvm/IR/Function.h"
25#include "llvm/IR/Intrinsics.h"
27#include <cstdint>
28#include <optional>
29
30namespace llvm {
31
32class APInt;
33class Instruction;
34class IntrinsicInst;
35class Loop;
36class SCEV;
37class ScalarEvolution;
38class Type;
39class Value;
40class VectorType;
41
42class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
45
46 friend BaseT;
47
48 const AArch64Subtarget *ST;
49 const AArch64TargetLowering *TLI;
50
51 static const FeatureBitset InlineInverseFeatures;
52
53 const AArch64Subtarget *getST() const { return ST; }
54 const AArch64TargetLowering *getTLI() const { return TLI; }
55
56 enum MemIntrinsicType {
57 VECTOR_LDST_TWO_ELEMENTS,
58 VECTOR_LDST_THREE_ELEMENTS,
59 VECTOR_LDST_FOUR_ELEMENTS
60 };
61
62 bool isWideningInstruction(Type *DstTy, unsigned Opcode,
64 Type *SrcOverrideTy = nullptr) const;
65
66 // A helper function called by 'getVectorInstrCost'.
67 //
68 // 'Val' and 'Index' are forwarded from 'getVectorInstrCost';
69 // \param ScalarUserAndIdx encodes the information about extracts from a
70 /// vector with 'Scalar' being the value being extracted,'User' being the user
71 /// of the extract(nullptr if user is not known before vectorization) and
72 /// 'Idx' being the extract lane.
73 InstructionCost getVectorInstrCostHelper(
74 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
75 const Instruction *I = nullptr, Value *Scalar = nullptr,
76 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx = {}) const;
77
78public:
79 explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
80 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
81 TLI(ST->getTargetLowering()) {}
82
83 bool areInlineCompatible(const Function *Caller,
84 const Function *Callee) const override;
85
86 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
87 const ArrayRef<Type *> &Types) const override;
88
89 unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
90 unsigned DefaultCallPenalty) const override;
91
92 APInt getFeatureMask(const Function &F) const override;
93
94 bool isMultiversionedFunction(const Function &F) const override;
95
96 /// \name Scalar TTI Implementations
97 /// @{
98
100 InstructionCost getIntImmCost(int64_t Val) const;
101 InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
102 TTI::TargetCostKind CostKind) const override;
103 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
104 const APInt &Imm, Type *Ty,
106 Instruction *Inst = nullptr) const override;
108 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
109 Type *Ty, TTI::TargetCostKind CostKind) const override;
110 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
111
112 /// @}
113
114 /// \name Vector TTI Implementations
115 /// @{
116
117 bool enableInterleavedAccessVectorization() const override { return true; }
118
120 return ST->hasSVE();
121 }
122
123 unsigned getNumberOfRegisters(unsigned ClassID) const override {
124 bool Vector = (ClassID == 1);
125 if (Vector) {
126 if (ST->hasNEON())
127 return 32;
128 return 0;
129 }
130 return 31;
131 }
132
135 TTI::TargetCostKind CostKind) const override;
136
137 std::optional<Instruction *>
139
140 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
141 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
142 APInt &UndefElts2, APInt &UndefElts3,
143 std::function<void(Instruction *, unsigned, APInt, APInt &)>
144 SimplifyAndSetOp) const override;
145
148
149 unsigned getMinVectorRegisterBitWidth() const override {
150 return ST->getMinVectorRegisterBitWidth();
151 }
152
153 std::optional<unsigned> getVScaleForTuning() const override {
154 return ST->getVScaleForTuning();
155 }
156
157 bool isVScaleKnownToBeAPowerOfTwo() const override { return true; }
158
160 TargetTransformInfo::RegisterKind K) const override;
161
162 /// Try to return an estimate cost factor that can be used as a multiplier
163 /// when scalarizing an operation for a vector with ElementCount \p VF.
164 /// For scalable vectors this currently takes the most pessimistic view based
165 /// upon the maximum possible value for vscale.
166 unsigned getMaxNumElements(ElementCount VF) const {
167 if (!VF.isScalable())
168 return VF.getFixedValue();
169
170 return VF.getKnownMinValue() * ST->getVScaleForTuning();
171 }
172
173 unsigned getMaxInterleaveFactor(ElementCount VF) const override;
174
175 bool prefersVectorizedAddressing() const override;
176
178 getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
179 unsigned AddressSpace,
180 TTI::TargetCostKind CostKind) const override;
181
183 getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
184 bool VariableMask, Align Alignment,
186 const Instruction *I = nullptr) const override;
187
188 bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst,
189 Type *Src) const;
190
192 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
194 const Instruction *I = nullptr) const override;
195
197 getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
198 unsigned Index,
199 TTI::TargetCostKind CostKind) const override;
200
202 const Instruction *I = nullptr) const override;
203
204 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
206 unsigned Index, const Value *Op0,
207 const Value *Op1) const override;
208
209 /// \param ScalarUserAndIdx encodes the information about extracts from a
210 /// vector with 'Scalar' being the value being extracted,'User' being the user
211 /// of the extract(nullptr if user is not known before vectorization) and
212 /// 'Idx' being the extract lane.
213 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
215 unsigned Index, Value *Scalar,
216 ArrayRef<std::tuple<Value *, User *, int>>
217 ScalarUserAndIdx) const override;
218
221 unsigned Index) const override;
222
224 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
226 unsigned Index) const override;
227
230 TTI::TargetCostKind CostKind) const override;
231
233 getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy,
235
238
240 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
242 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
243 ArrayRef<const Value *> Args = {},
244 const Instruction *CxtI = nullptr) const override;
245
247 getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
248 TTI::TargetCostKind CostKind) const override;
249
251 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
253 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
254 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
255 const Instruction *I = nullptr) const override;
256
257 TTI::MemCmpExpansionOptions
258 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
259 bool useNeonVector(const Type *Ty) const;
260
262 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
264 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
265 const Instruction *I = nullptr) const override;
266
268 getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const override;
269
270 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
271 TTI::UnrollingPreferences &UP,
272 OptimizationRemarkEmitter *ORE) const override;
273
274 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
275 TTI::PeelingPreferences &PP) const override;
276
277 Value *
278 getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType,
279 bool CanCreate = true) const override;
280
281 bool getTgtMemIntrinsic(IntrinsicInst *Inst,
282 MemIntrinsicInfo &Info) const override;
283
284 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
285 if (Ty->isPointerTy())
286 return true;
287
288 if (Ty->isBFloatTy() && ST->hasBF16())
289 return true;
290
291 if (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())
292 return true;
293
294 if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(16) ||
295 Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
296 return true;
297
298 return false;
299 }
300
301 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
302 if (!ST->hasSVE())
303 return false;
304
305 // For fixed vectors, avoid scalarization if using SVE for them.
306 if (isa<FixedVectorType>(DataType) && !ST->useSVEForFixedLengthVectors() &&
307 DataType->getPrimitiveSizeInBits() != 128)
308 return false; // Fall back to scalarization of masked operations.
309
311 }
312
313 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
314 unsigned /*AddressSpace*/) const override {
315 return isLegalMaskedLoadStore(DataType, Alignment);
316 }
317
318 bool isLegalMaskedStore(Type *DataType, Align Alignment,
319 unsigned /*AddressSpace*/) const override {
320 return isLegalMaskedLoadStore(DataType, Alignment);
321 }
322
323 bool isLegalMaskedGatherScatter(Type *DataType) const {
324 if (!ST->isSVEAvailable())
325 return false;
326
327 // For fixed vectors, scalarize if not using SVE for them.
328 auto *DataTypeFVTy = dyn_cast<FixedVectorType>(DataType);
329 if (DataTypeFVTy && (!ST->useSVEForFixedLengthVectors() ||
330 DataTypeFVTy->getNumElements() < 2))
331 return false;
332
334 }
335
336 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
337 return isLegalMaskedGatherScatter(DataType);
338 }
339
340 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
341 return isLegalMaskedGatherScatter(DataType);
342 }
343
344 bool isLegalBroadcastLoad(Type *ElementTy,
345 ElementCount NumElements) const override {
346 // Return true if we can generate a `ld1r` splat load instruction.
347 if (!ST->hasNEON() || NumElements.isScalable())
348 return false;
349 switch (unsigned ElementBits = ElementTy->getScalarSizeInBits()) {
350 case 8:
351 case 16:
352 case 32:
353 case 64: {
354 // We accept bit-widths >= 64bits and elements {8,16,32,64} bits.
355 unsigned VectorBits = NumElements.getFixedValue() * ElementBits;
356 return VectorBits >= 64;
357 }
358 }
359 return false;
360 }
361
362 bool isLegalNTStoreLoad(Type *DataType, Align Alignment) const {
363 // NOTE: The logic below is mostly geared towards LV, which calls it with
364 // vectors with 2 elements. We might want to improve that, if other
365 // users show up.
366 // Nontemporal vector loads/stores can be directly lowered to LDNP/STNP, if
367 // the vector can be halved so that each half fits into a register. That's
368 // the case if the element type fits into a register and the number of
369 // elements is a power of 2 > 1.
370 if (auto *DataTypeTy = dyn_cast<FixedVectorType>(DataType)) {
371 unsigned NumElements = DataTypeTy->getNumElements();
372 unsigned EltSize = DataTypeTy->getElementType()->getScalarSizeInBits();
373 return NumElements > 1 && isPowerOf2_64(NumElements) && EltSize >= 8 &&
374 EltSize <= 128 && isPowerOf2_64(EltSize);
375 }
376 return BaseT::isLegalNTStore(DataType, Alignment);
377 }
378
379 bool isLegalNTStore(Type *DataType, Align Alignment) const override {
380 return isLegalNTStoreLoad(DataType, Alignment);
381 }
382
383 bool isLegalNTLoad(Type *DataType, Align Alignment) const override {
384 // Only supports little-endian targets.
385 if (ST->isLittleEndian())
386 return isLegalNTStoreLoad(DataType, Alignment);
387 return BaseT::isLegalNTLoad(DataType, Alignment);
388 }
389
391 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
393 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
394 TTI::TargetCostKind CostKind) const override;
395
396 bool enableOrderedReductions() const override { return true; }
397
399 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
400 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
401 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
402
404 const Instruction &I,
405 bool &AllowPromotionWithoutCommonHeader) const override;
406
407 bool shouldExpandReduction(const IntrinsicInst *II) const override {
408 return false;
409 }
410
411 unsigned getGISelRematGlobalCost() const override { return 2; }
412
413 unsigned getMinTripCountTailFoldingThreshold() const override {
414 return ST->hasSVE() ? 5 : 0;
415 }
416
418 getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const override {
419 if (ST->hasSVE())
420 return IVUpdateMayOverflow
423
425 }
426
427 bool preferFixedOverScalableIfEqualCost() const override;
428
429 unsigned getEpilogueVectorizationMinVF() const override;
430
431 bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const override;
432
433 bool supportsScalableVectors() const override {
434 return ST->isSVEorStreamingSVEAvailable();
435 }
436
437 bool enableScalableVectorization() const override;
438
440 ElementCount VF) const override;
441
442 bool preferPredicatedReductionSelect() const override { return ST->hasSVE(); }
443
444 /// FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the
445 /// architecture features are not present.
446 std::optional<InstructionCost>
448 TTI::OperandValueInfo Op1Info,
449 TTI::OperandValueInfo Op2Info, bool IncludeTrunc,
450 std::function<InstructionCost(Type *)> InstCost) const;
451
453 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
454 std::optional<FastMathFlags> FMF,
455 TTI::TargetCostKind CostKind) const override;
456
458 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
459 VectorType *ValTy, std::optional<FastMathFlags> FMF,
460 TTI::TargetCostKind CostKind) const override;
461
463 bool IsUnsigned, Type *ResTy, VectorType *Ty,
465
469 VectorType *SubTp, ArrayRef<const Value *> Args = {},
470 const Instruction *CxtI = nullptr) const override;
471
473 VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
474 TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,
475 ArrayRef<Value *> VL = {}) const override;
476
477 /// Return the cost of the scaling factor used in the addressing
478 /// mode represented by AM for this target, for a load/store
479 /// of the specified type.
480 /// If the AM is supported, the return value must be >= 0.
481 /// If the AM is not supported, it returns an invalid cost.
482 InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
483 StackOffset BaseOffset, bool HasBaseReg,
484 int64_t Scale,
485 unsigned AddrSpace) const override;
486
487 bool enableSelectOptimize() const override {
488 return ST->enableSelectOptimize();
489 }
490
491 bool shouldTreatInstructionLikeSelect(const Instruction *I) const override;
492
493 unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy,
494 Type *ScalarValTy) const override {
495 // We can vectorize store v4i8.
496 if (ScalarMemTy->isIntegerTy(8) && isPowerOf2_32(VF) && VF >= 4)
497 return 4;
498
499 return BaseT::getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy);
500 }
501
502 std::optional<unsigned> getMinPageSize() const override { return 4096; }
503
505 const TargetTransformInfo::LSRCost &C2) const override;
506
508 SmallVectorImpl<Use *> &Ops) const override;
509 /// @}
510};
511
512} // end namespace llvm
513
514#endif // LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
RelocType Type
Definition: COFFYAML.cpp:410
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
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
uint32_t Index
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool isLegalNTLoad(Type *DataType, Align Alignment) 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 *CxtI=nullptr) const override
InstructionCost getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const override
unsigned getMaxInterleaveFactor(ElementCount VF) const override
TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const override
bool isVScaleKnownToBeAPowerOfTwo() const override
bool isLegalNTStoreLoad(Type *DataType, Align Alignment) const
bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const override
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr, TTI::TargetCostKind CostKind) const override
bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst, Type *Src) const
InstructionCost getIntImmCost(int64_t Val) const
Calculate the cost of materializing a 64-bit value.
bool prefersVectorizedAddressing() const override
unsigned getMinTripCountTailFoldingThreshold() const override
std::optional< unsigned > getVScaleForTuning() const override
bool preferFixedOverScalableIfEqualCost() const override
InstructionCost getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override
bool supportsScalableVectors() const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
bool enableSelectOptimize() const override
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
bool isElementTypeLegalForScalableVector(Type *Ty) const override
bool preferPredicatedReductionSelect() const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
std::optional< InstructionCost > getFP16BF16PromoteCost(Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info, TTI::OperandValueInfo Op2Info, bool IncludeTrunc, std::function< InstructionCost(Type *)> InstCost) const
FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the architecture features are not...
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, 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
bool shouldMaximizeVectorBandwidth(TargetTransformInfo::RegisterKind K) const override
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) const override
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const override
bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned) const override
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}) const override
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) 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 areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Types) 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 isLegalNTStore(Type *DataType, Align Alignment) const override
bool useNeonVector(const Type *Ty) const
InstructionCost getMulAccReductionCost(bool IsUnsigned, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const override
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) 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 getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
std::optional< unsigned > getMinPageSize() const override
bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const override
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const
unsigned getMinVectorRegisterBitWidth() const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, TTI::TargetCostKind CostKind) const override
AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
unsigned getInlineCallPenalty(const Function *F, const CallBase &Call, unsigned DefaultCallPenalty) const override
bool areInlineCompatible(const Function *Caller, const Function *Callee) const override
unsigned getMaxNumElements(ElementCount VF) const
Try to return an estimate cost factor that can be used as a multiplier when scalarizing an operation ...
bool shouldTreatInstructionLikeSelect(const Instruction *I) const override
bool isLegalMaskedStore(Type *DataType, Align Alignment, unsigned) const override
bool enableOrderedReductions() const override
bool isMultiversionedFunction(const Function &F) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc, ElementCount VF) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
bool enableInterleavedAccessVectorization() const override
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
bool isLegalMaskedGatherScatter(Type *DataType) const
unsigned getGISelRematGlobalCost() const override
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const override
See if I should be considered for address type promotion.
APInt getFeatureMask(const Function &F) const override
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) 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
bool enableScalableVectorization() const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType, bool CanCreate=true) const override
bool isLegalMaskedGather(Type *DataType, Align Alignment) const override
bool enableMaskedInterleavedAccessVectorization() const override
unsigned getEpilogueVectorizationMinVF() const override
InstructionCost getSpliceCost(VectorType *Tp, int Index, TTI::TargetCostKind CostKind) const
InstructionCost getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy, TTI::TargetCostKind CostKind) const
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const override
Return the cost of the scaling factor used in the addressing mode represented by AM for this target,...
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const override
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:82
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const override
Definition: BasicTTIImpl.h:476
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1116
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:678
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:22
Container class for subtarget features.
The core instruction combiner logic.
Definition: InstCombiner.h:48
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:49
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Definition: IVDescriptors.h:90
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
virtual const DataLayout & getDataLayout() const
virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
virtual bool isLegalNTStore(Type *DataType, Align Alignment) const
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
@ TCK_RecipThroughput
Reciprocal throughput.
PopcntSupportKind
Flags indicating the kind of support for population count.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
CastContextHint
Represents a hint about the context in which a cast is used.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:267
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:240
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:352
LLVM Value Representation.
Definition: Value.h:75
Base class of all SIMD vector types.
Definition: DerivedTypes.h:430
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:203
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:172
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:169
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition: MathExtras.h:293
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:288
@ DataAndControlFlowWithoutRuntimeCheck
Use predicate to control both data and control flow, but modify the trip count so that a runtime over...
@ DataAndControlFlow
Use predicate to control both data and control flow.
@ DataWithoutLaneMask
Same as Data, but avoids using the get.active.lane.mask intrinsic to calculate the mask and instead i...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39