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 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 const AArch64Subtarget *getST() const { return ST; }
53 const AArch64TargetLowering *getTLI() const { return TLI; }
54
55 /// Given a add/sub/mul operation, detect a widening addl/subl/mull pattern
56 /// where both operands can be treated like extends. Returns the minimal type
57 /// needed to compute the operation.
58 Type *isBinExtWideningInstruction(unsigned Opcode, Type *DstTy,
60 Type *SrcOverrideTy = nullptr) const;
61 /// Given a add/sub operation with a single extend operand, detect a
62 /// widening addw/subw pattern.
63 bool isSingleExtWideningInstruction(unsigned Opcode, Type *DstTy,
65 Type *SrcOverrideTy = nullptr) const;
66
67 // A helper function called by 'getVectorInstrCost'.
68 //
69 // 'Val' and 'Index' are forwarded from 'getVectorInstrCost';
70 // \param ScalarUserAndIdx encodes the information about extracts from a
71 /// vector with 'Scalar' being the value being extracted,'User' being the user
72 /// of the extract(nullptr if user is not known before vectorization) and
73 /// 'Idx' being the extract lane.
74 InstructionCost getVectorInstrCostHelper(
75 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index,
76 const Instruction *I = nullptr, Value *Scalar = nullptr,
77 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx = {},
79
80public:
81 explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
82 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
83 TLI(ST->getTargetLowering()) {}
84
85 bool areInlineCompatible(const Function *Caller,
86 const Function *Callee) const override;
87
88 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
89 ArrayRef<Type *> Types) const override;
90
91 unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
92 unsigned DefaultCallPenalty) const override;
93
94 APInt getFeatureMask(const Function &F) const override;
95 APInt getPriorityMask(const Function &F) const override;
96
97 bool isMultiversionedFunction(const Function &F) const override;
98
99 /// \name Scalar TTI Implementations
100 /// @{
101
103 InstructionCost getIntImmCost(int64_t Val) const;
105 TTI::TargetCostKind CostKind) const override;
106 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
107 const APInt &Imm, Type *Ty,
109 Instruction *Inst = nullptr) const override;
111 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
112 Type *Ty, TTI::TargetCostKind CostKind) const override;
113 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) 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
138 TTI::TargetCostKind CostKind) const override;
139
140 std::optional<Instruction *>
142
143 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
144 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
145 APInt &UndefElts2, APInt &UndefElts3,
146 std::function<void(Instruction *, unsigned, APInt, APInt &)>
147 SimplifyAndSetOp) const override;
148
151
152 unsigned getMinVectorRegisterBitWidth() const override {
153 return ST->getMinVectorRegisterBitWidth();
154 }
155
156 std::optional<unsigned> getVScaleForTuning() const override {
157 return ST->getVScaleForTuning();
158 }
159
161 TargetTransformInfo::RegisterKind K) const override;
162
163 /// Try to return an estimate cost factor that can be used as a multiplier
164 /// when scalarizing an operation for a vector with ElementCount \p VF.
165 /// For scalable vectors this currently takes the most pessimistic view based
166 /// upon the maximum possible value for vscale.
167 unsigned getMaxNumElements(ElementCount VF) const {
168 if (!VF.isScalable())
169 return VF.getFixedValue();
170
171 return VF.getKnownMinValue() * ST->getVScaleForTuning();
172 }
173
175 bool HasUnorderedReductions) const override;
176
177 bool prefersVectorizedAddressing() const override;
178
179 /// Check whether Opcode1 has less throughput according to the scheduling
180 /// model than Opcode2.
181 bool hasKnownLowerThroughputFromSchedulingModel(unsigned Opcode1,
182 unsigned Opcode2) const;
183
186 TTI::TargetCostKind CostKind) const override;
187
190
193
194 bool isExtPartOfAvgExpr(const Instruction *ExtUser, Type *Dst,
195 Type *Src) const;
196
198 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
200 const Instruction *I = nullptr) const override;
201
203 getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
204 unsigned Index,
205 TTI::TargetCostKind CostKind) const override;
206
208 const Instruction *I = nullptr) const override;
209
212 unsigned Index, const Value *Op0, const Value *Op1,
214 TTI::VectorInstrContext::None) const override;
215
216 /// \param ScalarUserAndIdx encodes the information about extracts from a
217 /// vector with 'Scalar' being the value being extracted,'User' being the user
218 /// of the extract(nullptr if user is not known before vectorization) and
219 /// 'Idx' being the extract lane.
221 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index,
222 Value *Scalar,
223 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
225 TTI::VectorInstrContext::None) const override;
226
229 TTI::TargetCostKind CostKind, unsigned Index,
231 TTI::VectorInstrContext::None) const override;
232
234 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Ty,
236 unsigned Index) const override;
237
240 TTI::TargetCostKind CostKind) const override;
241
243 getArithmeticReductionCostSVE(unsigned Opcode, VectorType *ValTy,
245
248
250 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
254 const Instruction *CxtI = nullptr) const override;
255
257 getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr,
258 TTI::TargetCostKind CostKind) const override;
259
261 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
265 const Instruction *I = nullptr) const override;
266
268 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
269 bool useNeonVector(const Type *Ty) const;
270
272 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
275 const Instruction *I = nullptr) const override;
276
279
280 bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override;
281
282 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
284 OptimizationRemarkEmitter *ORE) const override;
285
286 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
287 TTI::PeelingPreferences &PP) const override;
288
289 Value *
290 getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType,
291 bool CanCreate = true) const override;
292
293 bool getTgtMemIntrinsic(IntrinsicInst *Inst,
294 MemIntrinsicInfo &Info) const override;
295
296 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
297 if (Ty->isPointerTy())
298 return true;
299
300 if (Ty->isBFloatTy() || Ty->isHalfTy() || Ty->isFloatTy() ||
301 Ty->isDoubleTy())
302 return true;
303
304 if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(16) ||
305 Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
306 return true;
307
308 return false;
309 }
310
311 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
312 if (!ST->isSVEorStreamingSVEAvailable())
313 return false;
314
315 if (isa<FixedVectorType>(DataType) && !ST->useSVEForFixedLengthVectors()) {
316 unsigned Bits = DataType->getPrimitiveSizeInBits();
317 if (Bits != 64 && Bits != 128)
318 return false; // Fall back to scalarization of masked operations.
319 }
320
321 return isElementTypeLegalForScalableVector(DataType->getScalarType());
322 }
323
324 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
325 unsigned /*AddressSpace*/,
326 TTI::MaskKind /*MaskKind*/) const override {
327 return isLegalMaskedLoadStore(DataType, Alignment);
328 }
329
330 bool isLegalMaskedStore(Type *DataType, Align Alignment,
331 unsigned /*AddressSpace*/,
332 TTI::MaskKind /*MaskKind*/) const override {
333 return isLegalMaskedLoadStore(DataType, Alignment);
334 }
335
337 assert(Ty->isIntegerTy() || Ty->isFloatingPointTy());
338 // 32-bit and 64-bit element types are legal if we have SVE.
339 if (is_contained({32u, 64u}, Ty->getScalarSizeInBits()))
340 return true;
341
342 // 8-bit and 16-bit types require +sve2p2 or +sme2p2.
343 if (is_contained({8u, 16u}, Ty->getScalarSizeInBits()))
344 return ST->hasSVE2p2() || ST->hasSME2p2();
345
346 return false;
347 }
348
350 Align Alignment) const override {
351 if (!(ST->isSVEAvailable() ||
352 (ST->isSVEorStreamingSVEAvailable() && ST->hasSME2p2())))
353 return false;
354
355 if (isa<FixedVectorType>(DataType) &&
356 DataType->getPrimitiveSizeInBits() < 128)
357 return false;
358
359 return isElementTypeLegalForCompressStore(DataType->getScalarType());
360 }
361
362 bool isLegalMaskedGatherScatter(Type *DataType) const {
363 if (!ST->isSVEAvailable())
364 return false;
365
366 // For fixed vectors, scalarize if not using SVE for them.
367 auto *DataTypeFVTy = dyn_cast<FixedVectorType>(DataType);
368 if (DataTypeFVTy && (!ST->useSVEForFixedLengthVectors() ||
369 DataTypeFVTy->getNumElements() < 2))
370 return false;
371
372 return isElementTypeLegalForScalableVector(DataType->getScalarType());
373 }
374
375 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
376 return isLegalMaskedGatherScatter(DataType);
377 }
378
379 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
380 return isLegalMaskedGatherScatter(DataType);
381 }
382
383 bool isLegalBroadcastLoad(Type *ElementTy,
384 ElementCount NumElements) const override {
385 // Return true if we can generate a `ld1r` splat load instruction.
386 if (!ST->hasNEON() || NumElements.isScalable())
387 return false;
388 switch (unsigned ElementBits = ElementTy->getScalarSizeInBits()) {
389 case 8:
390 case 16:
391 case 32:
392 case 64: {
393 // We accept bit-widths >= 64bits and elements {8,16,32,64} bits.
394 unsigned VectorBits = NumElements.getFixedValue() * ElementBits;
395 return VectorBits >= 64;
396 }
397 }
398 return false;
399 }
400
401 std::optional<bool> isLegalNTStoreLoad(Type *DataType,
402 Align Alignment) const {
403 // Currently we only support NT load and store lowering for little-endian
404 // targets.
405 //
406 // Coordinated with LDNP and STNP constraints in
407 // `llvm/lib/Target/AArch64/AArch64InstrInfo.td` and
408 // `AArch64ISelLowering.cpp`
409 if (!ST->isLittleEndian())
410 return false;
411
412 // NOTE: The logic below is mostly geared towards LV, which calls it with
413 // vectors with 2 elements. We might want to improve that, if other
414 // users show up.
415 // Nontemporal vector loads/stores can be directly lowered to LDNP/STNP, if
416 // the vector can be halved so that each half fits into a register. That's
417 // the case if the element type fits into a register and the number of
418 // elements is a power of 2 > 1.
419 if (auto *DataTypeTy = dyn_cast<FixedVectorType>(DataType)) {
420 unsigned NumElements = DataTypeTy->getNumElements();
421 unsigned EltSize = DataTypeTy->getElementType()->getScalarSizeInBits();
422 return NumElements > 1 && isPowerOf2_64(NumElements) && EltSize >= 8 &&
423 EltSize <= 128 && isPowerOf2_64(EltSize);
424 }
425 return std::nullopt;
426 }
427
428 bool isLegalNTStore(Type *DataType, Align Alignment) const override {
429 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
430 return *Result;
431 // Fallback to target independent logic
432 return BaseT::isLegalNTStore(DataType, Alignment);
433 }
434
435 bool isLegalNTLoad(Type *DataType, Align Alignment) const override {
436 if (auto Result = isLegalNTStoreLoad(DataType, Alignment))
437 return *Result;
438 // Fallback to target independent logic
439 return BaseT::isLegalNTLoad(DataType, Alignment);
440 }
441
443 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
445 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
447 std::optional<FastMathFlags> FMF) const override;
448
449 bool enableOrderedReductions() const override { return true; }
450
452 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
453 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
454 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
455
457 const Instruction &I,
458 bool &AllowPromotionWithoutCommonHeader) const override;
459
460 bool shouldExpandReduction(const IntrinsicInst *II) const override {
461 return false;
462 }
463
464 unsigned getGISelRematGlobalCost() const override { return 2; }
465
467
468 unsigned getMinTripCountTailFoldingThreshold() const override {
469 return ST->hasSVE() ? 5 : 0;
470 }
471
476
477 bool preferFixedOverScalableIfEqualCost() const override;
478
479 unsigned getEpilogueVectorizationMinVF() const override;
480
481 bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override;
482
483 bool supportsScalableVectors() const override {
484 return ST->isSVEorStreamingSVEAvailable();
485 }
486
487 bool enableScalableVectorization() const override;
488
490 ElementCount VF) const override;
491
492 bool preferPredicatedReductionSelect() const override { return ST->hasSVE(); }
493
494 /// FP16 and BF16 operations are lowered to fptrunc(op(fpext, fpext) if the
495 /// architecture features are not present.
496 std::optional<InstructionCost> getFP16BF16PromoteCost(
498 TTI::OperandValueInfo Op2Info, bool IncludeTrunc, bool CanUseSVE,
499 std::function<InstructionCost(Type *)> InstCost) const;
500
502 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
503 std::optional<FastMathFlags> FMF,
504 TTI::TargetCostKind CostKind) const override;
505
507 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
508 VectorType *ValTy, std::optional<FastMathFlags> FMF,
509 TTI::TargetCostKind CostKind) const override;
510
512 bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty,
514
518 VectorType *SubTp, ArrayRef<const Value *> Args = {},
519 const Instruction *CxtI = nullptr) const override;
520
522 getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
523 bool Insert, bool Extract,
525 bool ForPoisonSrc = true, ArrayRef<Value *> VL = {},
527 TTI::VectorInstrContext::None) const override;
528
529 /// Return the cost of the scaling factor used in the addressing
530 /// mode represented by AM for this target, for a load/store
531 /// of the specified type.
532 /// If the AM is supported, the return value must be >= 0.
533 /// If the AM is not supported, it returns an invalid cost.
534 InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
535 StackOffset BaseOffset, bool HasBaseReg,
536 int64_t Scale,
537 unsigned AddrSpace) const override;
538
539 bool enableSelectOptimize() const override {
540 return ST->enableSelectOptimize();
541 }
542
543 bool shouldTreatInstructionLikeSelect(const Instruction *I) const override;
544
545 unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy,
546 Align Alignment,
547 unsigned AddrSpace) const override {
548 // We can vectorize store v4i8.
549 if (ScalarMemTy->isIntegerTy(8) && isPowerOf2_32(VF) && VF >= 4)
550 return 4;
551
552 return BaseT::getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy, Alignment,
553 AddrSpace);
554 }
555
556 std::optional<unsigned> getMinPageSize() const override { return 4096; }
557
559 const TargetTransformInfo::LSRCost &C2) const override;
560
562 SmallVectorImpl<Use *> &Ops) const override;
563
564 bool enableAggressiveInterleaving(bool) const override {
565 return ST->enableAggressiveInterleaving();
566 }
567 /// @}
568};
569
570} // end namespace llvm
571
572#endif // LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Imm
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
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
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 *CxtI=nullptr) const override
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 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 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
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
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
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
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.
PopcntSupportKind
Flags indicating the kind of support for population count.
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.
@ None
The cast is not used with a load/store of any kind.
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.
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
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
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:1947
@ 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.