LLVM 24.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 LoopInfo;
38class SCEV;
39class ScalarEvolution;
40class Type;
41class Value;
42class VectorType;
43
44class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
46 using TTI = TargetTransformInfo;
47
48 friend BaseT;
49
50 const AArch64Subtarget *ST;
51 const AArch64TargetLowering *TLI;
52
53 const AArch64Subtarget *getST() const { return ST; }
54 const AArch64TargetLowering *getTLI() const { return TLI; }
55
56 /// Given a add/sub/mul operation, detect a widening addl/subl/mull pattern
57 /// where both operands can be treated like extends. Returns the minimal type
58 /// needed to compute the operation.
59 Type *isBinExtWideningInstruction(unsigned Opcode, Type *DstTy,
61 Type *SrcOverrideTy = nullptr) const;
62 /// Given a add/sub operation with a single extend operand, detect a
63 /// widening addw/subw pattern.
64 bool isSingleExtWideningInstruction(unsigned Opcode, Type *DstTy,
66 Type *SrcOverrideTy = nullptr) const;
67
68 // A helper function called by 'getVectorInstrCost'.
69 //
70 // 'Val' and 'Index' are forwarded from 'getVectorInstrCost';
71 // \param ScalarUserAndIdx encodes the information about extracts from a
72 /// vector with 'Scalar' being the value being extracted,'User' being the user
73 /// of the extract(nullptr if user is not known before vectorization) and
74 /// 'Idx' being the extract lane.
75 InstructionCost getVectorInstrCostHelper(
76 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index,
77 const Instruction *I = nullptr, Value *Scalar = nullptr,
78 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx = {},
80
81public:
82 explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
83 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
84 TLI(ST->getTargetLowering()) {}
85
86 bool areInlineCompatible(const Function *Caller,
87 const Function *Callee) const override;
88
89 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
90 ArrayRef<Type *> Types) const override;
91
92 unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
93 unsigned DefaultCallPenalty) const override;
94
95 APInt getFeatureMask(const Function &F) const override;
96 APInt getPriorityMask(const Function &F) const override;
97
98 bool isMultiversionedFunction(const Function &F) const override;
99
100 /// \name Scalar TTI Implementations
101 /// @{
102
104 InstructionCost getIntImmCost(int64_t Val) const;
106 TTI::TargetCostKind CostKind) const override;
107 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
108 const APInt &Imm, Type *Ty,
109 TTI::TargetCostKind CostKind,
110 Instruction *Inst = nullptr) const override;
112 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
113 Type *Ty, TTI::TargetCostKind CostKind) const override;
114
115 /// @}
116
117 /// \name Vector TTI Implementations
118 /// @{
119
120 bool enableInterleavedAccessVectorization() const override { return true; }
121
123 return ST->hasSVE();
124 }
125
126 unsigned getNumberOfRegisters(unsigned ClassID) const override {
127 bool Vector = (ClassID == 1);
128 if (Vector) {
129 if (ST->hasNEON())
130 return 32;
131 return 0;
132 }
133 return 31;
134 }
135
136 /// Gets the cost for a histogram operation, consisting of at least one
137 /// set of gather + histcnt + scatter instructions.
139 const IntrinsicCostAttributes &ICA,
140 TTI::TargetCostKind CostKind) const;
141
144 TTI::TargetCostKind CostKind) const override;
145
146 std::optional<Instruction *>
148
149 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
150 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
151 APInt &UndefElts2, APInt &UndefElts3,
152 std::function<void(Instruction *, unsigned, APInt, APInt &)>
153 SimplifyAndSetOp) const override;
154
157
158 unsigned getMinVectorRegisterBitWidth() const override {
159 return ST->getMinVectorRegisterBitWidth();
160 }
161
162 std::optional<unsigned> getVScaleForTuning() const override {
163 return ST->getVScaleForTuning();
164 }
165
167 Type *ElementTy) const override;
168
169 /// Try to return an estimate cost factor that can be used as a multiplier
170 /// when scalarizing an operation for a vector with ElementCount \p VF.
171 /// For scalable vectors this currently takes the most pessimistic view based
172 /// upon the maximum possible value for vscale.
173 unsigned getMaxNumElements(ElementCount VF) const {
174 if (!VF.isScalable())
175 return VF.getFixedValue();
176
177 return VF.getKnownMinValue() * ST->getVScaleForTuning();
178 }
179
181 bool HasUnorderedReductions) const override;
182
183 bool prefersVectorizedAddressing() const override;
184
185 /// Check whether Opcode1 has less throughput according to the scheduling
186 /// model than Opcode2. For variant scheduling classes, the lowest throughput
187 /// of Opcode1 and the highest throughput of Opcode2 are compared among all
188 /// the scheduling classes they may be resolved to.
189 bool hasKnownLowerThroughputFromSchedulingModel(unsigned Opcode1,
190 unsigned Opcode2) const;
191
194 TTI::TargetCostKind CostKind) const override;
195
197 TTI::TargetCostKind CostKind) const;
198
200 TTI::TargetCostKind CostKind) const;
201
202 bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst,
203 Type *Src) const;
204
206 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
208 const Instruction *I = nullptr) const override;
209
211 getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
212 unsigned Index,
213 TTI::TargetCostKind CostKind) const override;
214
215 InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
216 const Instruction *I = nullptr) const override;
217
219 getVectorInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
220 unsigned Index, const Value *Op0, const Value *Op1,
222 TTI::VectorInstrContext::None) const override;
223
225 ArrayRef<int> Mask, ArrayRef<Value *> Scalars,
228 GatherUseOps) const override;
229
230 /// \param ScalarUserAndIdx encodes the information about extracts from a
231 /// vector with 'Scalar' being the value being extracted,'User' being the user
232 /// of the extract(nullptr if user is not known before vectorization) and
233 /// 'Idx' being the extract lane.
235 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index,
236 Value *Scalar,
237 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
239 TTI::VectorInstrContext::None) const override;
240
243 TTI::TargetCostKind CostKind, unsigned Index,
245 TTI::VectorInstrContext::None) const override;
246
248 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Ty,
249 TTI::TargetCostKind CostKind,
250 unsigned Index) const override;
251
254 TTI::TargetCostKind CostKind) const override;
255
257 getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy,
258 TTI::TargetCostKind CostKind) const;
259
261 TTI::TargetCostKind CostKind) const;
262
264 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
267 ArrayRef<const Value *> Args = {}, const Instruction *CtxI = nullptr,
268 const TargetLibraryInfo *TLibInfo = nullptr,
269 ArrayRef<const Value *> Scalars = {}) const override;
270
272 getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
273 TTI::TargetCostKind CostKind) const override;
274
276 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
277 TTI::TargetCostKind CostKind,
280 const Instruction *I = nullptr) const override;
281
283 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
284 bool useNeonVector(const Type *Ty) const;
285
286 // The expansion uses overlapping unaligned accesses, which are split up under
287 // strict alignment, and MOPS has its own variable-length lowering.
289 return ST->requiresStrictAlign() || ST->hasMOPS() ? 0 : 64;
290 }
291
293 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
294 TTI::TargetCostKind CostKind,
296 const Instruction *I = nullptr) const override;
297
300
301 bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override;
302
303 bool isLegalSpeculativeLoad(Type *DataType,
304 unsigned AddressSpace) const override;
305
307 unsigned NumVectors, TTI::MaskSource Mask, VectorType *VectorTy,
308 bool IsStore,
309 std::optional<Instruction::CastOps> CastHint) const override;
310
311 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
313 OptimizationRemarkEmitter *ORE) const override;
314
315 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
316 TTI::PeelingPreferences &PP) const override;
317
318 Value *
319 getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType,
320 bool CanCreate = true) const override;
321
322 bool getTgtMemIntrinsic(IntrinsicInst *Inst,
323 MemIntrinsicInfo &Info) const override;
324
325 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
326 if (Ty->isPointerTy())
327 return true;
328
329 if (Ty->isBFloatTy() || Ty->isHalfTy() || Ty->isFloatTy() ||
330 Ty->isDoubleTy())
331 return true;
332
333 if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(16) ||
334 Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
335 return true;
336
337 return false;
338 }
339
340 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
341 if (!ST->isSVEorStreamingSVEAvailable())
342 return false;
343
344 // Type legalization cannot scalarize the data of a masked load/store.
345 // Reject types that would be legalized to a scalar (e.g. <1 x half>).
346 if (isa<FixedVectorType>(DataType) &&
347 !getTypeLegalizationCost(DataType).second.isVector())
348 return false;
349
350 return isElementTypeLegalForScalableVector(DataType->getScalarType());
351 }
352
353 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
354 unsigned /*AddressSpace*/,
355 TTI::MaskKind /*MaskKind*/) const override {
356 return isLegalMaskedLoadStore(DataType, Alignment);
357 }
358
359 bool isLegalMaskedStore(Type *DataType, Align Alignment,
360 unsigned /*AddressSpace*/,
361 TTI::MaskKind /*MaskKind*/) const override {
362 return isLegalMaskedLoadStore(DataType, Alignment);
363 }
364
366 assert(Ty->isIntegerTy() || Ty->isFloatingPointTy());
367 // 32-bit and 64-bit element types are legal if we have SVE.
368 if (is_contained({32u, 64u}, Ty->getScalarSizeInBits()))
369 return true;
370
371 // 8-bit and 16-bit types require +sve2p2 or +sme2p2.
372 if (is_contained({8u, 16u}, Ty->getScalarSizeInBits()))
373 return ST->hasSVE2p2() || ST->hasSME2p2();
374
375 return false;
376 }
377
378 bool isLegalMaskedCompressStore(Type *DataType,
379 Align Alignment) const override;
380
381 bool isLegalMaskedGatherScatter(Type *DataType) const {
382 if (!ST->isSVEAvailable())
383 return false;
384
385 auto *DataTypeFVTy = dyn_cast<FixedVectorType>(DataType);
386 if (DataTypeFVTy && (DataTypeFVTy->getNumElements() < 2 ||
387 DataType->getScalarType()->isIntegerTy(1)))
388 return false;
389
390 return isElementTypeLegalForScalableVector(DataType->getScalarType());
391 }
392
393 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
394 return isLegalMaskedGatherScatter(DataType);
395 }
396
397 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
398 return isLegalMaskedGatherScatter(DataType);
399 }
400
401 bool isLegalBroadcastLoad(Type *ElementTy,
402 ElementCount NumElements) const override {
403 // Return true if we can generate a `ld1r` splat load instruction.
404 if (!ST->hasNEON() || NumElements.isScalable())
405 return false;
406 switch (unsigned ElementBits = ElementTy->getScalarSizeInBits()) {
407 case 8:
408 case 16:
409 case 32:
410 case 64: {
411 // We accept bit-widths >= 64bits and elements {8,16,32,64} bits.
412 unsigned VectorBits = NumElements.getFixedValue() * ElementBits;
413 return VectorBits >= 64;
414 }
415 }
416 return false;
417 }
418
419 std::optional<bool> isLegalNTStoreLoad(Type *DataType,
420 Align Alignment) const {
421 // Currently we only support NT load and store lowering for little-endian
422 // targets.
423 //
424 // Coordinated with LDNP and STNP constraints in
425 // `llvm/lib/Target/AArch64/AArch64InstrInfo.td` and
426 // `AArch64ISelLowering.cpp`
427 if (!ST->isLittleEndian())
428 return false;
429
430 // NOTE: The logic below is mostly geared towards LV, which calls it with
431 // vectors with 2 elements. We might want to improve that, if other
432 // users show up.
433 // Nontemporal vector loads/stores can be directly lowered to LDNP/STNP, if
434 // the vector can be halved so that each half fits into a register. That's
435 // the case if the element type fits into a register and the number of
436 // elements is a power of 2 > 1.
437 if (auto *DataTypeTy = dyn_cast<FixedVectorType>(DataType)) {
438 unsigned NumElements = DataTypeTy->getNumElements();
439 unsigned EltSize = DataTypeTy->getElementType()->getScalarSizeInBits();
440 return NumElements > 1 && isPowerOf2_64(NumElements) && EltSize >= 8 &&
441 EltSize <= 128 && isPowerOf2_64(EltSize);
442 }
443 return std::nullopt;
444 }
445
446 bool isLegalNTStore(Type *DataType, Align Alignment) const override {
447 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
448 return *Result;
449 // Fallback to target independent logic
450 return BaseT::isLegalNTStore(DataType, Alignment);
451 }
452
453 bool isLegalNTLoad(Type *DataType, Align Alignment) const override {
454 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
455 return *Result;
456 // Fallback to target independent logic
457 return BaseT::isLegalNTLoad(DataType, Alignment);
458 }
459
461 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
463 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
464 TTI::TargetCostKind CostKind,
465 std::optional<FastMathFlags> FMF) const override;
466
467 bool enableOrderedReductions() const override { return true; }
468
470 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
471 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
472 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
473
475 const Instruction &I,
476 bool &AllowPromotionWithoutCommonHeader) const override;
477
478 bool shouldExpandReduction(const IntrinsicInst *II) const override {
479 return false;
480 }
481
482 unsigned getGISelRematGlobalCost() const override { return 2; }
483
485
486 unsigned getMinTripCountTailFoldingThreshold() const override {
487 return ST->hasSVE() ? 5 : 0;
488 }
489
494
495 bool preferFixedOverScalableIfEqualCost() const override;
496
497 unsigned getEpilogueVectorizationMinVF() const override;
498
499 bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override;
500
501 bool supportsScalableVectors() const override {
502 return ST->isSVEorStreamingSVEAvailable();
503 }
504
505 bool enableScalableVectorization() const override;
506
508 ElementCount VF) const override;
509
510 bool preferPredicatedReductionSelect() const override { return ST->hasSVE(); }
511
512 /// FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the
513 /// architecture features are not present.
514 std::optional<InstructionCost> getFP16BF16PromoteCost(
515 Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info,
516 TTI::OperandValueInfo Op2Info, bool IncludeTrunc, bool CanUseSVE,
517 std::function<InstructionCost(Type *)> InstCost) const;
518
520 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
521 std::optional<FastMathFlags> FMF,
522 TTI::TargetCostKind CostKind) const override;
523
525 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
526 VectorType *ValTy, std::optional<FastMathFlags> FMF,
527 TTI::TargetCostKind CostKind) const override;
528
530 bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty,
531 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const override;
532
535 TTI::TargetCostKind CostKind, ArrayRef<int> Mask, int Index,
536 VectorType *SubTp, ArrayRef<const Value *> Args = {},
537 const Instruction *CtxI = nullptr,
539 TTI::VectorInstrContext::None) const override;
540
542 getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
543 bool Insert, bool Extract,
544 TTI::TargetCostKind CostKind,
545 bool ForPoisonSrc = true, ArrayRef<Value *> VL = {},
547 TTI::VectorInstrContext::None) const override;
548
549 /// Return the cost of the scaling factor used in the addressing
550 /// mode represented by AM for this target, for a load/store
551 /// of the specified type.
552 /// If the AM is supported, the return value must be >= 0.
553 /// If the AM is not supported, it returns an invalid cost.
554 InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
555 StackOffset BaseOffset, bool HasBaseReg,
556 int64_t Scale,
557 unsigned AddrSpace) const override;
558
559 bool LSRWithInstrQueries() const override { return true; }
560
561 bool enableSelectOptimize() const override {
562 return ST->enableSelectOptimize();
563 }
564
565 bool shouldTreatInstructionLikeSelect(const Instruction *I) const override;
566
567 unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy,
568 Align Alignment,
569 unsigned AddrSpace) const override {
570 // We can vectorize store v4i8.
571 if (ScalarMemTy->isIntegerTy(8) && isPowerOf2_32(VF) && VF >= 4)
572 return 4;
573
574 return BaseT::getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy, Alignment,
575 AddrSpace);
576 }
577
578 std::optional<unsigned> getMinPageSize() const override { return 4096; }
579
581 const TargetTransformInfo::LSRCost &C2) const override;
582
584 const LoopInfo *LI) const override;
585
586 bool enableAggressiveInterleaving(bool) const override {
587 return ST->enableAggressiveInterleaving();
588 }
589 /// @}
590
591 bool hasPossibleIncompatibleOps(const Function *F, bool ConsiderZA,
592 bool ConsiderZT, bool ConsiderSM) const;
593};
594
595} // end namespace llvm
596
597#endif // LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
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
int64_t C1
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 getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const override
TailFoldingStyle getPreferredTailFoldingStyle() const override
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
bool hasPossibleIncompatibleOps(const Function *F, bool ConsiderZA, bool ConsiderZT, bool ConsiderSM) const
Returns true if the function has explicit operations that can only be lowered using incompatible inst...
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.
InstructionCost getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index) const override
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
bool preferFixedOverScalableIfEqualCost() const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops, const LoopInfo *LI) const override
Check if sinking I's operands to I's basic block is profitable, because the operands can be folded in...
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 getVectorInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
bool shouldMaximizeVectorBandwidth(TargetTransformInfo::VectorKind K, Type *ElementTy) 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 hasMultiVectorLoadStore(unsigned NumVectors, TTI::MaskSource Mask, VectorType *VectorTy, bool IsStore, std::optional< Instruction::CastOps > CastHint) 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
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) 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
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 getHistogramCost(const AArch64Subtarget *ST, const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const
Gets the cost for a histogram operation, consisting of at least one set of gather + histcnt + scatter...
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
bool isLegalSpeculativeLoad(Type *DataType, unsigned AddressSpace) const override
unsigned getMinVectorRegisterBitWidth() const override
bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override
bool isElementTypeLegalForCompressStore(Type *Ty) const
bool LSRWithInstrQueries() 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
The compiler must not inline when that may alter the behavior of the program.
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
uint64_t getMaxBoundedMemSetInlineSize() const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
bool enableInterleavedAccessVectorization() const override
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) 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
TargetTransformInfo::VectorInstrContext getBuildVectorContextHint(ArrayRef< int > Mask, ArrayRef< Value * > Scalars, function_ref< bool(SmallVectorImpl< TargetTransformInfo::BuildVectorUseOp > &)> GatherUseOps) 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
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 *CtxI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) 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
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
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
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.
MaskKind
Some targets only support masked load/store with a constant mask.
TargetCostKind
The kind of cost model.
@ TCK_RecipThroughput
Reciprocal throughput.
MaskSource
Enum describing the source/producer of a mask.
llvm::VectorInstrContext VectorInstrContext
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
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.h:354
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:252
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:201
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:169
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
An efficient, type-erasing, non-owning reference to a callable.
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.
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:285
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
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 >
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963
@ 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.