LLVM 23.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/FMF.h"
25#include "llvm/IR/Function.h"
26#include "llvm/IR/Intrinsics.h"
28#include <cstdint>
29#include <optional>
30
31namespace llvm {
32
33class APInt;
34class Instruction;
35class IntrinsicInst;
36class Loop;
37class SCEV;
38class ScalarEvolution;
39class Type;
40class Value;
41class VectorType;
42
43class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
45 using TTI = TargetTransformInfo;
46
47 friend BaseT;
48
49 const AArch64Subtarget *ST;
50 const AArch64TargetLowering *TLI;
51
52 static const FeatureBitset InlineInverseFeatures;
53
54 const AArch64Subtarget *getST() const { return ST; }
55 const AArch64TargetLowering *getTLI() const { return TLI; }
56
57 /// Given a add/sub/mul operation, detect a widening addl/subl/mull pattern
58 /// where both operands can be treated like extends. Returns the minimal type
59 /// needed to compute the operation.
60 Type *isBinExtWideningInstruction(unsigned Opcode, Type *DstTy,
62 Type *SrcOverrideTy = nullptr) const;
63 /// Given a add/sub operation with a single extend operand, detect a
64 /// widening addw/subw pattern.
65 bool isSingleExtWideningInstruction(unsigned Opcode, Type *DstTy,
67 Type *SrcOverrideTy = nullptr) const;
68
69 // A helper function called by 'getVectorInstrCost'.
70 //
71 // 'Val' and 'Index' are forwarded from 'getVectorInstrCost';
72 // \param ScalarUserAndIdx encodes the information about extracts from a
73 /// vector with 'Scalar' being the value being extracted,'User' being the user
74 /// of the extract(nullptr if user is not known before vectorization) and
75 /// 'Idx' being the extract lane.
76 InstructionCost getVectorInstrCostHelper(
77 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
78 const Instruction *I = nullptr, Value *Scalar = nullptr,
79 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx = {},
81
82public:
83 explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
84 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
85 TLI(ST->getTargetLowering()) {}
86
87 bool areInlineCompatible(const Function *Caller,
88 const Function *Callee) const override;
89
90 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
91 ArrayRef<Type *> Types) const override;
92
93 unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
94 unsigned DefaultCallPenalty) const override;
95
96 APInt getFeatureMask(const Function &F) const override;
97 APInt getPriorityMask(const Function &F) const override;
98
99 bool isMultiversionedFunction(const Function &F) const override;
100
101 /// \name Scalar TTI Implementations
102 /// @{
103
105 InstructionCost getIntImmCost(int64_t Val) const;
106 InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
107 TTI::TargetCostKind CostKind) const override;
108 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
109 const APInt &Imm, Type *Ty,
111 Instruction *Inst = nullptr) const override;
113 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
114 Type *Ty, TTI::TargetCostKind CostKind) const override;
115 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
116
117 /// @}
118
119 /// \name Vector TTI Implementations
120 /// @{
121
122 bool enableInterleavedAccessVectorization() const override { return true; }
123
125 return ST->hasSVE();
126 }
127
128 unsigned getNumberOfRegisters(unsigned ClassID) const override {
129 bool Vector = (ClassID == 1);
130 if (Vector) {
131 if (ST->hasNEON())
132 return 32;
133 return 0;
134 }
135 return 31;
136 }
137
140 TTI::TargetCostKind CostKind) const override;
141
142 std::optional<Instruction *>
144
145 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
146 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
147 APInt &UndefElts2, APInt &UndefElts3,
148 std::function<void(Instruction *, unsigned, APInt, APInt &)>
149 SimplifyAndSetOp) const override;
150
153
154 unsigned getMinVectorRegisterBitWidth() const override {
155 return ST->getMinVectorRegisterBitWidth();
156 }
157
158 std::optional<unsigned> getVScaleForTuning() const override {
159 return ST->getVScaleForTuning();
160 }
161
163 TargetTransformInfo::RegisterKind K) const override;
164
165 /// Try to return an estimate cost factor that can be used as a multiplier
166 /// when scalarizing an operation for a vector with ElementCount \p VF.
167 /// For scalable vectors this currently takes the most pessimistic view based
168 /// upon the maximum possible value for vscale.
169 unsigned getMaxNumElements(ElementCount VF) const {
170 if (!VF.isScalable())
171 return VF.getFixedValue();
172
173 return VF.getKnownMinValue() * ST->getVScaleForTuning();
174 }
175
176 unsigned getMaxInterleaveFactor(ElementCount VF) const override;
177
178 bool prefersVectorizedAddressing() const override;
179
180 /// Check whether Opcode1 has less throughput according to the scheduling
181 /// model than Opcode2.
182 bool hasKnownLowerThroughputFromSchedulingModel(unsigned Opcode1,
183 unsigned Opcode2) const;
184
187 TTI::TargetCostKind CostKind) const override;
188
191
194
195 bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst,
196 Type *Src) const;
197
199 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
201 const Instruction *I = nullptr) const override;
202
204 getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
205 unsigned Index,
206 TTI::TargetCostKind CostKind) const override;
207
209 const Instruction *I = nullptr) const override;
210
213 unsigned Index, const Value *Op0, const Value *Op1,
215 TTI::VectorInstrContext::None) const override;
216
217 /// \param ScalarUserAndIdx encodes the information about extracts from a
218 /// vector with 'Scalar' being the value being extracted,'User' being the user
219 /// of the extract(nullptr if user is not known before vectorization) and
220 /// 'Idx' being the extract lane.
222 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
223 Value *Scalar,
224 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
226 TTI::VectorInstrContext::None) const override;
227
230 TTI::TargetCostKind CostKind, unsigned Index,
232 TTI::VectorInstrContext::None) const override;
233
235 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
237 unsigned Index) const override;
238
241 TTI::TargetCostKind CostKind) const override;
242
244 getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy,
246
249
251 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
255 const Instruction *CxtI = nullptr) const override;
256
258 getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
259 TTI::TargetCostKind CostKind) const override;
260
262 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
266 const Instruction *I = nullptr) const override;
267
269 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
270 bool useNeonVector(const Type *Ty) const;
271
273 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
276 const Instruction *I = nullptr) const override;
277
280
281 bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override;
282
283 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
285 OptimizationRemarkEmitter *ORE) const override;
286
287 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
288 TTI::PeelingPreferences &PP) const override;
289
290 Value *
291 getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType,
292 bool CanCreate = true) const override;
293
294 bool getTgtMemIntrinsic(IntrinsicInst *Inst,
295 MemIntrinsicInfo &Info) const override;
296
297 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
298 if (Ty->isPointerTy())
299 return true;
300
301 if (Ty->isBFloatTy() && ST->hasBF16())
302 return true;
303
304 if (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy())
305 return true;
306
307 if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(16) ||
308 Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
309 return true;
310
311 return false;
312 }
313
314 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
315 if (!ST->isSVEorStreamingSVEAvailable())
316 return false;
317
318 if (isa<FixedVectorType>(DataType) && !ST->useSVEForFixedLengthVectors()) {
319 unsigned Bits = DataType->getPrimitiveSizeInBits();
320 if (Bits != 64 && Bits != 128)
321 return false; // Fall back to scalarization of masked operations.
322 }
323
324 return isElementTypeLegalForScalableVector(DataType->getScalarType());
325 }
326
327 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
328 unsigned /*AddressSpace*/,
329 TTI::MaskKind /*MaskKind*/) const override {
330 return isLegalMaskedLoadStore(DataType, Alignment);
331 }
332
333 bool isLegalMaskedStore(Type *DataType, Align Alignment,
334 unsigned /*AddressSpace*/,
335 TTI::MaskKind /*MaskKind*/) const override {
336 return isLegalMaskedLoadStore(DataType, Alignment);
337 }
338
340 return Ty->isFloatTy() || Ty->isDoubleTy() || Ty->isIntegerTy(32) ||
341 Ty->isIntegerTy(64);
342 }
343
345 Align Alignment) const override {
346 if (!ST->isSVEAvailable())
347 return false;
348
349 if (isa<FixedVectorType>(DataType) &&
350 DataType->getPrimitiveSizeInBits() < 128)
351 return false;
352
353 return isElementTypeLegalForCompressStore(DataType->getScalarType());
354 }
355
356 bool isLegalMaskedGatherScatter(Type *DataType) const {
357 if (!ST->isSVEAvailable())
358 return false;
359
360 // For fixed vectors, scalarize if not using SVE for them.
361 auto *DataTypeFVTy = dyn_cast<FixedVectorType>(DataType);
362 if (DataTypeFVTy && (!ST->useSVEForFixedLengthVectors() ||
363 DataTypeFVTy->getNumElements() < 2))
364 return false;
365
366 return isElementTypeLegalForScalableVector(DataType->getScalarType());
367 }
368
369 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
370 return isLegalMaskedGatherScatter(DataType);
371 }
372
373 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
374 return isLegalMaskedGatherScatter(DataType);
375 }
376
377 bool isLegalBroadcastLoad(Type *ElementTy,
378 ElementCount NumElements) const override {
379 // Return true if we can generate a `ld1r` splat load instruction.
380 if (!ST->hasNEON() || NumElements.isScalable())
381 return false;
382 switch (unsigned ElementBits = ElementTy->getScalarSizeInBits()) {
383 case 8:
384 case 16:
385 case 32:
386 case 64: {
387 // We accept bit-widths >= 64bits and elements {8,16,32,64} bits.
388 unsigned VectorBits = NumElements.getFixedValue() * ElementBits;
389 return VectorBits >= 64;
390 }
391 }
392 return false;
393 }
394
395 std::optional<bool> isLegalNTStoreLoad(Type *DataType,
396 Align Alignment) const {
397 // Currently we only support NT load and store lowering for little-endian
398 // targets.
399 //
400 // Coordinated with LDNP and STNP constraints in
401 // `llvm/lib/Target/AArch64/AArch64InstrInfo.td` and
402 // `AArch64ISelLowering.cpp`
403 if (!ST->isLittleEndian())
404 return false;
405
406 // NOTE: The logic below is mostly geared towards LV, which calls it with
407 // vectors with 2 elements. We might want to improve that, if other
408 // users show up.
409 // Nontemporal vector loads/stores can be directly lowered to LDNP/STNP, if
410 // the vector can be halved so that each half fits into a register. That's
411 // the case if the element type fits into a register and the number of
412 // elements is a power of 2 > 1.
413 if (auto *DataTypeTy = dyn_cast<FixedVectorType>(DataType)) {
414 unsigned NumElements = DataTypeTy->getNumElements();
415 unsigned EltSize = DataTypeTy->getElementType()->getScalarSizeInBits();
416 return NumElements > 1 && isPowerOf2_64(NumElements) && EltSize >= 8 &&
417 EltSize <= 128 && isPowerOf2_64(EltSize);
418 }
419 return std::nullopt;
420 }
421
422 bool isLegalNTStore(Type *DataType, Align Alignment) const override {
423 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
424 return *Result;
425 // Fallback to target independent logic
426 return BaseT::isLegalNTStore(DataType, Alignment);
427 }
428
429 bool isLegalNTLoad(Type *DataType, Align Alignment) const override {
430 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
431 return *Result;
432 // Fallback to target independent logic
433 return BaseT::isLegalNTLoad(DataType, Alignment);
434 }
435
437 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
439 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
441 std::optional<FastMathFlags> FMF) const override;
442
443 bool enableOrderedReductions() const override { return true; }
444
446 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
447 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
448 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
449
451 const Instruction &I,
452 bool &AllowPromotionWithoutCommonHeader) const override;
453
454 bool shouldExpandReduction(const IntrinsicInst *II) const override {
455 return false;
456 }
457
458 unsigned getGISelRematGlobalCost() const override { return 2; }
459
461
462 unsigned getMinTripCountTailFoldingThreshold() const override {
463 return ST->hasSVE() ? 5 : 0;
464 }
465
470
471 bool preferFixedOverScalableIfEqualCost(bool IsEpilogue) const override;
472
473 unsigned getEpilogueVectorizationMinVF() const override;
474
475 bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override;
476
477 bool supportsScalableVectors() const override {
478 return ST->isSVEorStreamingSVEAvailable();
479 }
480
481 bool enableScalableVectorization() const override;
482
484 ElementCount VF) const override;
485
486 bool preferPredicatedReductionSelect() const override { return ST->hasSVE(); }
487
488 /// FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the
489 /// architecture features are not present.
490 std::optional<InstructionCost> getFP16BF16PromoteCost(
492 TTI::OperandValueInfo Op2Info, bool IncludeTrunc, bool CanUseSVE,
493 std::function<InstructionCost(Type *)> InstCost) const;
494
496 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
497 std::optional<FastMathFlags> FMF,
498 TTI::TargetCostKind CostKind) const override;
499
501 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
502 VectorType *ValTy, std::optional<FastMathFlags> FMF,
503 TTI::TargetCostKind CostKind) const override;
504
506 bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty,
508
512 VectorType *SubTp, ArrayRef<const Value *> Args = {},
513 const Instruction *CxtI = nullptr) const override;
514
516 getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
517 bool Insert, bool Extract,
519 bool ForPoisonSrc = true, ArrayRef<Value *> VL = {},
521 TTI::VectorInstrContext::None) const override;
522
523 /// Return the cost of the scaling factor used in the addressing
524 /// mode represented by AM for this target, for a load/store
525 /// of the specified type.
526 /// If the AM is supported, the return value must be >= 0.
527 /// If the AM is not supported, it returns an invalid cost.
528 InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
529 StackOffset BaseOffset, bool HasBaseReg,
530 int64_t Scale,
531 unsigned AddrSpace) const override;
532
533 bool enableSelectOptimize() const override {
534 return ST->enableSelectOptimize();
535 }
536
537 bool shouldTreatInstructionLikeSelect(const Instruction *I) const override;
538
539 unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy,
540 Align Alignment,
541 unsigned AddrSpace) const override {
542 // We can vectorize store v4i8.
543 if (ScalarMemTy->isIntegerTy(8) && isPowerOf2_32(VF) && VF >= 4)
544 return 4;
545
546 return BaseT::getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy, Alignment,
547 AddrSpace);
548 }
549
550 std::optional<unsigned> getMinPageSize() const override { return 4096; }
551
553 const TargetTransformInfo::LSRCost &C2) const override;
554
556 SmallVectorImpl<Use *> &Ops) const override;
557
558 bool enableAggressiveInterleaving(bool) const override {
559 return ST->enableAggressiveInterleaving();
560 }
561 /// @}
562};
563
564} // end namespace llvm
565
566#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...
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")))
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) 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
TailFoldingStyle getPreferredTailFoldingStyle() const override
unsigned getMaxInterleaveFactor(ElementCount VF) const override
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) 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 getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getIntImmCost(int64_t Val) const
Calculate the cost of materializing a 64-bit value.
std::optional< InstructionCost > getFP16BF16PromoteCost(Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info, TTI::OperandValueInfo Op2Info, bool IncludeTrunc, bool CanUseSVE, std::function< InstructionCost(Type *)> InstCost) const
FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the architecture features are not...
bool prefersVectorizedAddressing() const override
unsigned getMinTripCountTailFoldingThreshold() const override
std::optional< unsigned > getVScaleForTuning() 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 enableAggressiveInterleaving(bool) const override
InstructionCost getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind=TTI::TCK_RecipThroughput) const override
bool isLegalMaskedStore(Type *DataType, Align Alignment, unsigned, TTI::MaskKind) const override
bool supportsScalableVectors() 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
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy, Align Alignment, unsigned AddrSpace) const override
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, std::optional< FastMathFlags > FMF) const override
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
bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned, TTI::MaskKind) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const override
bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) 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
APInt getPriorityMask(const Function &F) const override
bool shouldMaximizeVectorBandwidth(TargetTransformInfo::RegisterKind K) const override
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) 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...
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
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
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
bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
bool isElementTypeLegalForCompressStore(Type *Ty) const
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 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
InstructionCost getBranchMispredictPenalty() const override
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 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 areTypesABICompatible(const Function *Caller, const Function *Callee, ArrayRef< Type * > Types) const override
bool enableScalableVectorization() const override
InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) 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 hasKnownLowerThroughputFromSchedulingModel(unsigned Opcode1, unsigned Opcode2) const
Check whether Opcode1 has less throughput according to the scheduling model than Opcode2.
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,...
std::optional< bool > isLegalNTStoreLoad(Type *DataType, Align Alignment) const
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) const override
bool preferFixedOverScalableIfEqualCost(bool IsEpilogue) const override
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy, Align Alignment, unsigned AddrSpace) const override
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
Container class for subtarget features.
The core instruction combiner logic.
A wrapper class for inspecting calls to intrinsic functions.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Information for memory intrinsic cost model.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
VectorInstrContext
Represents a hint about the context in which an insert/extract is used.
@ None
The insert/extract is not used with a load/store.
MaskKind
Some targets only support masked load/store with a constant mask.
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:46
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:232
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:257
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:200
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:168
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:165
CallInst * Call
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition MathExtras.h:284
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:279
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...
Definition Casting.h:547
ArrayRef(const T &OneElt) -> ArrayRef< T >
@ 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
Returns options for expansion of memcmp. IsZeroCmp is.
Parameters that control the generic loop unrolling transformation.