LLVM 20.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 TargetTransformInfo::Concept 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 : public BasicTTIImplBase<AArch64TTIImpl> {
45
46 friend BaseT;
47
48 const AArch64Subtarget *ST;
49 const AArch64TargetLowering *TLI;
50
51 const AArch64Subtarget *getST() const { return ST; }
52 const AArch64TargetLowering *getTLI() const { return TLI; }
53
54 enum MemIntrinsicType {
55 VECTOR_LDST_TWO_ELEMENTS,
56 VECTOR_LDST_THREE_ELEMENTS,
57 VECTOR_LDST_FOUR_ELEMENTS
58 };
59
60 bool isWideningInstruction(Type *DstTy, unsigned Opcode,
62 Type *SrcOverrideTy = nullptr);
63
64 // A helper function called by 'getVectorInstrCost'.
65 //
66 // 'Val' and 'Index' are forwarded from 'getVectorInstrCost'; 'HasRealUse'
67 // indicates whether the vector instruction is available in the input IR or
68 // just imaginary in vectorizer passes.
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, unsigned Index, bool HasRealUse,
75 const Instruction *I = nullptr, Value *Scalar = nullptr,
76 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx = {});
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;
85
86 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
87 const ArrayRef<Type *> &Types) const;
88
89 unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
90 unsigned DefaultCallPenalty) const;
91
92 /// \name Scalar TTI Implementations
93 /// @{
94
96 InstructionCost getIntImmCost(int64_t Val);
99 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
100 const APInt &Imm, Type *Ty,
102 Instruction *Inst = nullptr);
104 const APInt &Imm, Type *Ty,
107
108 /// @}
109
110 /// \name Vector TTI Implementations
111 /// @{
112
114
115 bool enableMaskedInterleavedAccessVectorization() { return ST->hasSVE(); }
116
117 unsigned getNumberOfRegisters(unsigned ClassID) const {
118 bool Vector = (ClassID == 1);
119 if (Vector) {
120 if (ST->hasNEON())
121 return 32;
122 return 0;
123 }
124 return 31;
125 }
126
129
130 std::optional<Instruction *> instCombineIntrinsic(InstCombiner &IC,
131 IntrinsicInst &II) const;
132
133 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
134 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
135 APInt &UndefElts2, APInt &UndefElts3,
136 std::function<void(Instruction *, unsigned, APInt, APInt &)>
137 SimplifyAndSetOp) const;
138
140
142 return ST->getMinVectorRegisterBitWidth();
143 }
144
145 std::optional<unsigned> getVScaleForTuning() const {
146 return ST->getVScaleForTuning();
147 }
148
149 bool isVScaleKnownToBeAPowerOfTwo() const { return true; }
150
152
153 /// Try to return an estimate cost factor that can be used as a multiplier
154 /// when scalarizing an operation for a vector with ElementCount \p VF.
155 /// For scalable vectors this currently takes the most pessimistic view based
156 /// upon the maximum possible value for vscale.
157 unsigned getMaxNumElements(ElementCount VF) const {
158 if (!VF.isScalable())
159 return VF.getFixedValue();
160
161 return VF.getKnownMinValue() * ST->getVScaleForTuning();
162 }
163
165
166 bool prefersVectorizedAddressing() const;
167
168 InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
169 Align Alignment, unsigned AddressSpace,
171
172 InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
173 const Value *Ptr, bool VariableMask,
174 Align Alignment,
176 const Instruction *I = nullptr);
177
178 bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst, Type *Src);
179
180 InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
183 const Instruction *I = nullptr);
184
185 InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst,
186 VectorType *VecTy, unsigned Index);
187
189 const Instruction *I = nullptr);
190
191 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
193 unsigned Index, Value *Op0, Value *Op1);
194
195 /// \param ScalarUserAndIdx encodes the information about extracts from a
196 /// vector with 'Scalar' being the value being extracted,'User' being the user
197 /// of the extract(nullptr if user is not known before vectorization) and
198 /// 'Idx' being the extract lane.
200 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
201 Value *Scalar,
202 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx);
203
206 unsigned Index);
207
209 FastMathFlags FMF,
211
213 VectorType *ValTy,
215
217
219 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
221 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
222 ArrayRef<const Value *> Args = {}, const Instruction *CxtI = nullptr);
223
224 InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
225 const SCEV *Ptr);
226
227 InstructionCost getCmpSelInstrCost(
228 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
230 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
231 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
232 const Instruction *I = nullptr);
233
234 TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize,
235 bool IsZeroCmp) const;
236 bool useNeonVector(const Type *Ty) const;
237
238 InstructionCost
239 getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
241 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
242 const Instruction *I = nullptr);
243
244 InstructionCost getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);
245
246 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
247 TTI::UnrollingPreferences &UP,
248 OptimizationRemarkEmitter *ORE);
249
250 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
251 TTI::PeelingPreferences &PP);
252
253 Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
254 Type *ExpectedType);
255
256 bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info);
257
259 if (Ty->isPointerTy())
260 return true;
261
262 if (Ty->isBFloatTy() && ST->hasBF16())
263 return true;
264
265 if (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())
266 return true;
267
268 if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(16) ||
269 Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
270 return true;
271
272 return false;
273 }
274
275 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) {
276 if (!ST->hasSVE())
277 return false;
278
279 // For fixed vectors, avoid scalarization if using SVE for them.
280 if (isa<FixedVectorType>(DataType) && !ST->useSVEForFixedLengthVectors() &&
281 DataType->getPrimitiveSizeInBits() != 128)
282 return false; // Fall back to scalarization of masked operations.
283
285 }
286
287 bool isLegalMaskedLoad(Type *DataType, Align Alignment) {
288 return isLegalMaskedLoadStore(DataType, Alignment);
289 }
290
291 bool isLegalMaskedStore(Type *DataType, Align Alignment) {
292 return isLegalMaskedLoadStore(DataType, Alignment);
293 }
294
295 bool isLegalMaskedGatherScatter(Type *DataType) const {
296 if (!ST->isSVEAvailable())
297 return false;
298
299 // For fixed vectors, scalarize if not using SVE for them.
300 auto *DataTypeFVTy = dyn_cast<FixedVectorType>(DataType);
301 if (DataTypeFVTy && (!ST->useSVEForFixedLengthVectors() ||
302 DataTypeFVTy->getNumElements() < 2))
303 return false;
304
306 }
307
308 bool isLegalMaskedGather(Type *DataType, Align Alignment) const {
309 return isLegalMaskedGatherScatter(DataType);
310 }
311
312 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const {
313 return isLegalMaskedGatherScatter(DataType);
314 }
315
316 bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const {
317 // Return true if we can generate a `ld1r` splat load instruction.
318 if (!ST->hasNEON() || NumElements.isScalable())
319 return false;
320 switch (unsigned ElementBits = ElementTy->getScalarSizeInBits()) {
321 case 8:
322 case 16:
323 case 32:
324 case 64: {
325 // We accept bit-widths >= 64bits and elements {8,16,32,64} bits.
326 unsigned VectorBits = NumElements.getFixedValue() * ElementBits;
327 return VectorBits >= 64;
328 }
329 }
330 return false;
331 }
332
333 bool isLegalNTStoreLoad(Type *DataType, Align Alignment) {
334 // NOTE: The logic below is mostly geared towards LV, which calls it with
335 // vectors with 2 elements. We might want to improve that, if other
336 // users show up.
337 // Nontemporal vector loads/stores can be directly lowered to LDNP/STNP, if
338 // the vector can be halved so that each half fits into a register. That's
339 // the case if the element type fits into a register and the number of
340 // elements is a power of 2 > 1.
341 if (auto *DataTypeTy = dyn_cast<FixedVectorType>(DataType)) {
342 unsigned NumElements = DataTypeTy->getNumElements();
343 unsigned EltSize = DataTypeTy->getElementType()->getScalarSizeInBits();
344 return NumElements > 1 && isPowerOf2_64(NumElements) && EltSize >= 8 &&
345 EltSize <= 128 && isPowerOf2_64(EltSize);
346 }
347 return BaseT::isLegalNTStore(DataType, Alignment);
348 }
349
350 bool isLegalNTStore(Type *DataType, Align Alignment) {
351 return isLegalNTStoreLoad(DataType, Alignment);
352 }
353
354 bool isLegalNTLoad(Type *DataType, Align Alignment) {
355 // Only supports little-endian targets.
356 if (ST->isLittleEndian())
357 return isLegalNTStoreLoad(DataType, Alignment);
358 return BaseT::isLegalNTLoad(DataType, Alignment);
359 }
360
362 getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB,
363 Type *AccumType, ElementCount VF,
366 std::optional<unsigned> BinOp) const {
367
370
371 if (Opcode != Instruction::Add)
372 return Invalid;
373
374 if (InputTypeA != InputTypeB)
375 return Invalid;
376
377 EVT InputEVT = EVT::getEVT(InputTypeA);
378 EVT AccumEVT = EVT::getEVT(AccumType);
379
380 if (VF.isScalable() && !ST->isSVEorStreamingSVEAvailable())
381 return Invalid;
382 if (VF.isFixed() && (!ST->isNeonAvailable() || !ST->hasDotProd()))
383 return Invalid;
384
385 if (InputEVT == MVT::i8) {
386 switch (VF.getKnownMinValue()) {
387 default:
388 return Invalid;
389 case 8:
390 if (AccumEVT == MVT::i32)
391 Cost *= 2;
392 else if (AccumEVT != MVT::i64)
393 return Invalid;
394 break;
395 case 16:
396 if (AccumEVT == MVT::i64)
397 Cost *= 2;
398 else if (AccumEVT != MVT::i32)
399 return Invalid;
400 break;
401 }
402 } else if (InputEVT == MVT::i16) {
403 // FIXME: Allow i32 accumulator but increase cost, as we would extend
404 // it to i64.
405 if (VF.getKnownMinValue() != 8 || AccumEVT != MVT::i64)
406 return Invalid;
407 } else
408 return Invalid;
409
410 // AArch64 supports lowering mixed extensions to a usdot but only if the
411 // i8mm or sve/streaming features are available.
412 if (OpAExtend == TTI::PR_None || OpBExtend == TTI::PR_None ||
413 (OpAExtend != OpBExtend && !ST->hasMatMulInt8() &&
414 !ST->isSVEorStreamingSVEAvailable()))
415 return Invalid;
416
417 if (!BinOp || *BinOp != Instruction::Mul)
418 return Invalid;
419
420 return Cost;
421 }
422
423 bool enableOrderedReductions() const { return true; }
424
426 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
427 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
428 bool UseMaskForCond = false, bool UseMaskForGaps = false);
429
430 bool
432 bool &AllowPromotionWithoutCommonHeader);
433
434 bool shouldExpandReduction(const IntrinsicInst *II) const { return false; }
435
436 unsigned getGISelRematGlobalCost() const {
437 return 2;
438 }
439
441 return ST->hasSVE() ? 5 : 0;
442 }
443
444 TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const {
445 if (ST->hasSVE())
446 return IVUpdateMayOverflow
449
451 }
452
454
455 unsigned getEpilogueVectorizationMinVF() const;
456
458
460 return ST->isSVEorStreamingSVEAvailable();
461 }
462
463 bool enableScalableVectorization() const;
464
466 ElementCount VF) const;
467
468 bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
469 TTI::ReductionFlags Flags) const {
470 return ST->hasSVE();
471 }
472
474 std::optional<FastMathFlags> FMF,
476
478 ArrayRef<int> Mask,
480 VectorType *SubTp,
481 ArrayRef<const Value *> Args = {},
482 const Instruction *CxtI = nullptr);
483
484 InstructionCost getScalarizationOverhead(VectorType *Ty,
485 const APInt &DemandedElts,
486 bool Insert, bool Extract,
488 ArrayRef<Value *> VL = {});
489
490 /// Return the cost of the scaling factor used in the addressing
491 /// mode represented by AM for this target, for a load/store
492 /// of the specified type.
493 /// If the AM is supported, the return value must be >= 0.
494 /// If the AM is not supported, it returns a negative value.
495 InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
496 StackOffset BaseOffset, bool HasBaseReg,
497 int64_t Scale, unsigned AddrSpace) const;
498
499 bool enableSelectOptimize() { return ST->enableSelectOptimize(); }
500
502
503 unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy,
504 Type *ScalarValTy) const {
505 // We can vectorize store v4i8.
506 if (ScalarMemTy->isIntegerTy(8) && isPowerOf2_32(VF) && VF >= 4)
507 return 4;
508
509 return BaseT::getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy);
510 }
511
512 std::optional<unsigned> getMinPageSize() const { return 4096; }
513
516
518 SmallVectorImpl<Use *> &Ops) const;
519 /// @}
520};
521
522} // end namespace llvm
523
524#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< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
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 getSpliceCost(VectorType *Tp, int Index)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const
Return the cost of the scaling factor used in the addressing mode represented by AM for this target,...
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind)
unsigned getMinTripCountTailFoldingThreshold() const
bool isLegalNTStoreLoad(Type *DataType, Align Alignment)
unsigned getGISelRematGlobalCost() const
bool shouldTreatInstructionLikeSelect(const Instruction *I)
bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const
std::optional< unsigned > getVScaleForTuning() const
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr)
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index)
bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const
Check if sinking I's operands to I's basic block is profitable, because the operands can be folded in...
bool isLegalMaskedStore(Type *DataType, Align Alignment)
unsigned getInlineCallPenalty(const Function *F, const CallBase &Call, unsigned DefaultCallPenalty) const
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc, ElementCount VF) const
unsigned getEpilogueVectorizationMinVF() const
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader)
See if I should be considered for address type promotion.
InstructionCost getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy, TTI::TargetCostKind CostKind)
std::optional< unsigned > getMinPageSize() const
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp) const
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)
bool shouldExpandReduction(const IntrinsicInst *II) const
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const
unsigned getMinVectorRegisterBitWidth() const
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const
bool shouldMaximizeVectorBandwidth(TargetTransformInfo::RegisterKind K) const
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
bool isElementTypeLegalForScalableVector(Type *Ty) const
InstructionCost getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys)
bool isLegalMaskedLoadStore(Type *DataType, Align Alignment)
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
bool useNeonVector(const Type *Ty) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
bool areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Types) const
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool isLegalMaskedLoad(Type *DataType, Align Alignment)
AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
unsigned getMaxNumElements(ElementCount VF) const
Try to return an estimate cost factor that can be used as a multiplier when scalarizing an operation ...
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, ArrayRef< Value * > VL={})
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)
bool isLegalNTLoad(Type *DataType, Align Alignment)
bool preferPredicateOverEpilogue(TailFoldingInfo *TFI)
TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const
bool isLegalMaskedGatherScatter(Type *DataType) const
unsigned getMaxInterleaveFactor(ElementCount VF)
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr)
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
unsigned getNumberOfRegisters(unsigned ClassID) const
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
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
bool isLegalMaskedGather(Type *DataType, Align Alignment) const
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
bool isLegalNTStore(Type *DataType, Align Alignment)
bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst, Type *Src)
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
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:80
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const
Definition: BasicTTIImpl.h:397
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1112
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:673
Convenience struct for specifying and reasoning about fast-math flags.
Definition: FMF.h:20
The core instruction combiner logic.
Definition: InstCombiner.h:48
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:48
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Definition: IVDescriptors.h:77
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
const DataLayout & getDataLayout() const
bool isLegalNTStore(Type *DataType, Align Alignment) const
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
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.
PopcntSupportKind
Flags indicating the kind of support for population count.
@ TCC_Basic
The cost of a typical 'add' instruction.
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
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:264
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
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
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
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:237
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:355
LLVM Value Representation.
Definition: Value.h:74
Base class of all SIMD vector types.
Definition: DerivedTypes.h:427
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:202
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:171
constexpr bool isFixed() const
Returns true if the quantity is not scaled by vscale.
Definition: TypeSize.h:174
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:168
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:296
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:291
InstructionCost Cost
@ 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
Extended Value Type.
Definition: ValueTypes.h:35
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
Definition: ValueTypes.cpp:289
Flags describing the kind of vector reduction.