LLVM 22.0.0git
RISCVTargetTransformInfo.h
Go to the documentation of this file.
1//===- RISCVTargetTransformInfo.h - RISC-V 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 defines a TargetTransformInfoImplBase conforming object specific
10/// to the RISC-V 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_RISCV_RISCVTARGETTRANSFORMINFO_H
17#define LLVM_LIB_TARGET_RISCV_RISCVTARGETTRANSFORMINFO_H
18
19#include "RISCVSubtarget.h"
20#include "RISCVTargetMachine.h"
23#include "llvm/IR/Function.h"
24#include <optional>
25
26namespace llvm {
27
28class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
31
32 friend BaseT;
33
34 const RISCVSubtarget *ST;
35 const RISCVTargetLowering *TLI;
36
37 const RISCVSubtarget *getST() const { return ST; }
38 const RISCVTargetLowering *getTLI() const { return TLI; }
39
40 /// This function returns an estimate for VL to be used in VL based terms
41 /// of the cost model. For fixed length vectors, this is simply the
42 /// vector length. For scalable vectors, we return results consistent
43 /// with getVScaleForTuning under the assumption that clients are also
44 /// using that when comparing costs between scalar and vector representation.
45 /// This does unfortunately mean that we can both undershoot and overshot
46 /// the true cost significantly if getVScaleForTuning is wildly off for the
47 /// actual target hardware.
48 unsigned getEstimatedVLFor(VectorType *Ty) const;
49
50 /// This function calculates the costs for one or more RVV opcodes based
51 /// on the vtype and the cost kind.
52 /// \param Opcodes A list of opcodes of the RVV instruction to evaluate.
53 /// \param VT The MVT of vtype associated with the RVV instructions.
54 /// For widening/narrowing instructions where the result and source types
55 /// differ, it is important to check the spec to determine whether the vtype
56 /// refers to the result or source type.
57 /// \param CostKind The type of cost to compute.
58 InstructionCost getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT,
60
61 /// Return the cost of accessing a constant pool entry of the specified
62 /// type.
63 InstructionCost getConstantPoolLoadCost(Type *Ty,
65
66 /// If this shuffle can be lowered as a masked slide pair (at worst),
67 /// return a cost for it.
68 InstructionCost getSlideCost(FixedVectorType *Tp, ArrayRef<int> Mask,
70
71public:
72 explicit RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
73 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
74 TLI(ST->getTargetLowering()) {}
75
76 /// Return the cost of materializing an immediate for a value operand of
77 /// a store instruction.
80
82 TTI::TargetCostKind CostKind) const override;
83 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
84 const APInt &Imm, Type *Ty,
86 Instruction *Inst = nullptr) const override;
88 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
89 Type *Ty, TTI::TargetCostKind CostKind) const override;
90
91 /// \name EVL Support for predicated vectorization.
92 /// Whether the target supports the %evl parameter of VP intrinsic efficiently
93 /// in hardware. (see LLVM Language Reference - "Vector Predication
94 /// Intrinsics",
95 /// https://llvm.org/docs/LangRef.html#vector-predication-intrinsics and
96 /// "IR-level VP intrinsics",
97 /// https://llvm.org/docs/Proposals/VectorPredication.html#ir-level-vp-intrinsics).
98 bool hasActiveVectorLength() const override;
99
101 getPopcntSupport(unsigned TyWidth) const override;
102
104 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
106 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
107 TTI::TargetCostKind CostKind) const override;
108
109 bool shouldExpandReduction(const IntrinsicInst *II) const override;
110 bool supportsScalableVectors() const override {
111 return ST->hasVInstructions();
112 }
113 bool enableOrderedReductions() const override { return true; }
114 bool enableScalableVectorization() const override {
115 return ST->hasVInstructions();
116 }
118 return ST->hasVInstructions();
119 }
121 getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const override {
122 return ST->hasVInstructions() ? TailFoldingStyle::DataWithEVL
124 }
125 std::optional<unsigned> getMaxVScale() const override;
126 std::optional<unsigned> getVScaleForTuning() const override;
127
130
131 unsigned getRegUsageForType(Type *Ty) const override;
132
133 unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const override;
134
135 bool preferAlternateOpcodeVectorization() const override { return false; }
136
137 bool preferEpilogueVectorization() const override {
138 // Epilogue vectorization is usually unprofitable - tail folding or
139 // a smaller VF would have been better. This a blunt hammer - we
140 // should re-examine this once vectorization is better tuned.
141 return false;
142 }
143
145 getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
146 unsigned AddressSpace,
147 TTI::TargetCostKind CostKind) const override;
148
151 const TTI::PointersChainInfo &Info, Type *AccessTy,
152 TTI::TargetCostKind CostKind) const override;
153
156 OptimizationRemarkEmitter *ORE) const override;
157
159 TTI::PeelingPreferences &PP) const override;
160
161 unsigned getMinVectorRegisterBitWidth() const override {
162 return ST->useRVVForFixedLengthVectors() ? 16 : 0;
163 }
164
168 VectorType *SubTp, ArrayRef<const Value *> Args = {},
169 const Instruction *CxtI = nullptr) const override;
170
172 VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
173 TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,
174 ArrayRef<Value *> VL = {}) const override;
175
177 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
178 TTI::TargetCostKind CostKind) const override;
179
181 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
182 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
183 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
184
185 InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
186 const Value *Ptr, bool VariableMask,
187 Align Alignment,
189 const Instruction *I) const override;
190
192 getExpandCompressMemoryOpCost(unsigned Opcode, Type *Src, bool VariableMask,
193 Align Alignment, TTI::TargetCostKind CostKind,
194 const Instruction *I = nullptr) const override;
195
196 InstructionCost getStridedMemoryOpCost(unsigned Opcode, Type *DataTy,
197 const Value *Ptr, bool VariableMask,
198 Align Alignment,
200 const Instruction *I) const override;
201
203 getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const override;
204
206 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
208 const Instruction *I = nullptr) const override;
209
211 getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
212 TTI::TargetCostKind CostKind) const override;
213
215 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
216 std::optional<FastMathFlags> FMF,
217 TTI::TargetCostKind CostKind) const override;
218
220 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
221 VectorType *ValTy, std::optional<FastMathFlags> FMF,
222 TTI::TargetCostKind CostKind) const override;
223
225 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
227 TTI::OperandValueInfo OpdInfo = {TTI::OK_AnyValue, TTI::OP_None},
228 const Instruction *I = nullptr) const override;
229
231 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
233 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
234 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
235 const Instruction *I = nullptr) const override;
236
238 const Instruction *I = nullptr) const override;
239
241 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
243 unsigned Index, const Value *Op0,
244 const Value *Op1) const override;
245
247 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
249 unsigned Index) const override;
250
252 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
253 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
254 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
255 ArrayRef<const Value *> Args = {},
256 const Instruction *CxtI = nullptr) const override;
257
258 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
259 return TLI->isLegalElementTypeForRVV(TLI->getValueType(DL, Ty));
260 }
261
262 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
263 if (!ST->hasVInstructions())
264 return false;
265
266 EVT DataTypeVT = TLI->getValueType(DL, DataType);
267
268 // Only support fixed vectors if we know the minimum vector size.
269 if (DataTypeVT.isFixedLengthVector() && !ST->useRVVForFixedLengthVectors())
270 return false;
271
272 EVT ElemType = DataTypeVT.getScalarType();
273 if (!ST->enableUnalignedVectorMem() && Alignment < ElemType.getStoreSize())
274 return false;
275
276 return TLI->isLegalElementTypeForRVV(ElemType);
277 }
278
279 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
280 unsigned /*AddressSpace*/) const override {
281 return isLegalMaskedLoadStore(DataType, Alignment);
282 }
283 bool isLegalMaskedStore(Type *DataType, Align Alignment,
284 unsigned /*AddressSpace*/) const override {
285 return isLegalMaskedLoadStore(DataType, Alignment);
286 }
287
288 bool isLegalMaskedGatherScatter(Type *DataType, Align Alignment) const {
289 if (!ST->hasVInstructions())
290 return false;
291
292 EVT DataTypeVT = TLI->getValueType(DL, DataType);
293
294 // Only support fixed vectors if we know the minimum vector size.
295 if (DataTypeVT.isFixedLengthVector() && !ST->useRVVForFixedLengthVectors())
296 return false;
297
298 // We also need to check if the vector of address is valid.
299 EVT PointerTypeVT = EVT(TLI->getPointerTy(DL));
300 if (DataTypeVT.isScalableVector() &&
301 !TLI->isLegalElementTypeForRVV(PointerTypeVT))
302 return false;
303
304 EVT ElemType = DataTypeVT.getScalarType();
305 if (!ST->enableUnalignedVectorMem() && Alignment < ElemType.getStoreSize())
306 return false;
307
308 return TLI->isLegalElementTypeForRVV(ElemType);
309 }
310
311 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
312 return isLegalMaskedGatherScatter(DataType, Alignment);
313 }
314 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
315 return isLegalMaskedGatherScatter(DataType, Alignment);
316 }
317
319 Align Alignment) const override {
320 // Scalarize masked gather for RV64 if EEW=64 indices aren't supported.
321 return ST->is64Bit() && !ST->hasVInstructionsI64();
322 }
323
325 Align Alignment) const override {
326 // Scalarize masked scatter for RV64 if EEW=64 indices aren't supported.
327 return ST->is64Bit() && !ST->hasVInstructionsI64();
328 }
329
330 bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const override {
331 EVT DataTypeVT = TLI->getValueType(DL, DataType);
332 return TLI->isLegalStridedLoadStore(DataTypeVT, Alignment);
333 }
334
335 bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
336 Align Alignment,
337 unsigned AddrSpace) const override {
338 return TLI->isLegalInterleavedAccessType(VTy, Factor, Alignment, AddrSpace,
339 DL);
340 }
341
342 bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const override;
343
344 bool isLegalMaskedCompressStore(Type *DataTy, Align Alignment) const override;
345
346 bool isVScaleKnownToBeAPowerOfTwo() const override {
347 return TLI->isVScaleKnownToBeAPowerOfTwo();
348 }
349
350 /// \returns How the target needs this vector-predicated operation to be
351 /// transformed.
353 getVPLegalizationStrategy(const VPIntrinsic &PI) const override {
355 if (!ST->hasVInstructions() ||
356 (PI.getIntrinsicID() == Intrinsic::vp_reduce_mul &&
357 cast<VectorType>(PI.getArgOperand(1)->getType())
358 ->getElementType()
359 ->getIntegerBitWidth() != 1))
362 }
363
365 ElementCount VF) const override {
366 if (!VF.isScalable())
367 return true;
368
369 Type *Ty = RdxDesc.getRecurrenceType();
370 if (!TLI->isLegalElementTypeForRVV(TLI->getValueType(DL, Ty)))
371 return false;
372
373 switch (RdxDesc.getRecurrenceKind()) {
374 case RecurKind::Add:
375 case RecurKind::Sub:
377 case RecurKind::And:
378 case RecurKind::Or:
379 case RecurKind::Xor:
380 case RecurKind::SMin:
381 case RecurKind::SMax:
382 case RecurKind::UMin:
383 case RecurKind::UMax:
384 case RecurKind::FMin:
385 case RecurKind::FMax:
386 return true;
387 case RecurKind::AnyOf:
388 case RecurKind::FAdd:
390 // We can't promote f16/bf16 fadd reductions and scalable vectors can't be
391 // expanded.
392 if (Ty->isBFloatTy() || (Ty->isHalfTy() && !ST->hasVInstructionsF16()))
393 return false;
394 return true;
395 default:
396 return false;
397 }
398 }
399
400 unsigned getMaxInterleaveFactor(ElementCount VF) const override {
401 // Don't interleave if the loop has been vectorized with scalable vectors.
402 if (VF.isScalable())
403 return 1;
404 // If the loop will not be vectorized, don't interleave the loop.
405 // Let regular unroll to unroll the loop.
406 return VF.isScalar() ? 1 : ST->getMaxInterleaveFactor();
407 }
408
409 bool enableInterleavedAccessVectorization() const override { return true; }
410
412 return ST->hasVInstructions();
413 }
414
415 unsigned getMinTripCountTailFoldingThreshold() const override;
416
418 unsigned getNumberOfRegisters(unsigned ClassID) const override {
419 switch (ClassID) {
421 // 31 = 32 GPR - x0 (zero register)
422 // FIXME: Should we exclude fixed registers like SP, TP or GP?
423 return 31;
425 if (ST->hasStdExtF())
426 return 32;
427 return 0;
429 // Although there are 32 vector registers, v0 is special in that it is the
430 // only register that can be used to hold a mask.
431 // FIXME: Should we conservatively return 31 as the number of usable
432 // vector registers?
433 return ST->hasVInstructions() ? 32 : 0;
434 }
435 llvm_unreachable("unknown register class");
436 }
437
439 getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override;
440
442 Type *Ty = nullptr) const override {
443 if (Vector)
445 if (!Ty)
447
448 Type *ScalarTy = Ty->getScalarType();
449 if ((ScalarTy->isHalfTy() && ST->hasStdExtZfhmin()) ||
450 (ScalarTy->isFloatTy() && ST->hasStdExtF()) ||
451 (ScalarTy->isDoubleTy() && ST->hasStdExtD())) {
453 }
454
456 }
457
458 const char *getRegisterClassName(unsigned ClassID) const override {
459 switch (ClassID) {
461 return "RISCV::GPRRC";
463 return "RISCV::FPRRC";
465 return "RISCV::VRRC";
466 }
467 llvm_unreachable("unknown register class");
468 }
469
471 const TargetTransformInfo::LSRCost &C2) const override;
472
474 const Instruction &I,
475 bool &AllowPromotionWithoutCommonHeader) const override;
476 std::optional<unsigned> getMinPageSize() const override { return 4096; }
477 /// Return true if the (vector) instruction I will be lowered to an
478 /// instruction with a scalar splat operand for the given Operand number.
479 bool canSplatOperand(Instruction *I, int Operand) const;
480 /// Return true if a vector instruction will lower to a target instruction
481 /// able to splat the given operand.
482 bool canSplatOperand(unsigned Opcode, int Operand) const;
483
485 SmallVectorImpl<Use *> &Ops) const override;
486
488 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
489};
490
491} // end namespace llvm
492
493#endif // LLVM_LIB_TARGET_RISCV_RISCVTARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint32_t Index
TargetTransformInfo::VPLegalization VPLegalization
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:82
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1292
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:678
constexpr bool isScalar() const
Exactly one element.
Definition: TypeSize.h:323
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:592
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:49
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:56
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:40
Machine Value Type.
The optimization diagnostic interface.
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool supportsScalableVectors() const override
bool preferAlternateOpcodeVectorization() const override
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) 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
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const override
bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
unsigned getMinTripCountTailFoldingThreshold() const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
TTI::AddressingModeKind getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override
bool preferEpilogueVectorization() const override
InstructionCost getStoreImmCost(Type *VecTy, TTI::OperandValueInfo OpInfo, TTI::TargetCostKind CostKind) const
Return the cost of materializing an immediate for a value operand of a store instruction.
bool isElementTypeLegalForScalableVector(Type *Ty) const override
bool enableMaskedInterleavedAccessVectorization() const override
bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace) const override
std::optional< unsigned > getMinPageSize() const override
InstructionCost getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const override
bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const override
bool hasActiveVectorLength() const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) 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 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const override
InstructionCost getExpandCompressMemoryOpCost(unsigned Opcode, Type *Src, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind) const override
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) const override
bool forceScalarizeMaskedScatter(VectorType *VTy, Align Alignment) const override
const char * getRegisterClassName(unsigned ClassID) const override
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
bool canSplatOperand(Instruction *I, int Operand) const
Return true if the (vector) instruction I will be lowered to an instruction with a scalar splat opera...
bool enableInterleavedAccessVectorization() const override
bool isLegalMaskedGatherScatter(Type *DataType, Align Alignment) const
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const override
bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const override
unsigned getRegUsageForType(Type *Ty) 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
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}) const override
TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow) const override
unsigned getMinVectorRegisterBitWidth() const override
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override
bool isLegalMaskedCompressStore(Type *DataTy, Align Alignment) const override
unsigned getMaxInterleaveFactor(ElementCount VF) const override
bool enableOrderedReductions() const override
RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
TargetTransformInfo::VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const override
bool isVScaleKnownToBeAPowerOfTwo() 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...
unsigned getNumberOfRegisters(unsigned ClassID) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
std::optional< unsigned > getMaxVScale() const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
std::optional< unsigned > getVScaleForTuning() const override
bool isLegalMaskedStore(Type *DataType, Align Alignment, unsigned) const override
bool isLegalMaskedGather(Type *DataType, Align Alignment) 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
unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const override
InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, TTI::TargetCostKind CostKind) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) 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) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpdInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc, ElementCount VF) const override
bool enableScalableVectorization() const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const override
See if I should be considered for address type promotion.
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
InstructionCost getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) const override
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment) const override
TargetTransformInfo::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
bool isLegalElementTypeForRVV(EVT ScalarTy) const
bool isVScaleKnownToBeAPowerOfTwo() const override
Return true only if vscale must be a power of two.
bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace, const DataLayout &) const
Returns whether or not generating a interleaved load/store intrinsic for this type will be legal.
bool isLegalStridedLoadStore(EVT DataType, Align Alignment) const
Return true if a stride load store of the given result type and alignment is legal.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Definition: IVDescriptors.h:90
Type * getRecurrenceType() const
Returns the type of the recurrence.
RecurKind getRecurrenceKind() const
The main scalar evolution driver.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
virtual const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
PopcntSupportKind
Flags indicating the kind of support for population count.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
CastContextHint
Represents a hint about the context in which a cast is used.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:352
This is the common base class for vector predication intrinsics.
LLVM Value Representation.
Definition: Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
Base class of all SIMD vector types.
Definition: DerivedTypes.h:430
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:172
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ UMin
Unsigned integer min implemented in terms of select(cmp()).
@ Or
Bitwise or logical OR of integers.
@ AnyOf
AnyOf reduction with select(cmp(),x,y) where one of (x,y) is loop invariant, and both x and y are int...
@ Xor
Bitwise or logical XOR of integers.
@ FMax
FP max implemented in terms of select(cmp()).
@ FMulAdd
Sum of float products with llvm.fmuladd(a * b + sum).
@ SMax
Signed integer max implemented in terms of select(cmp()).
@ And
Bitwise or logical AND of integers.
@ SMin
Signed integer min implemented in terms of select(cmp()).
@ FMin
FP min implemented in terms of select(cmp()).
@ Sub
Subtraction of integers.
@ Add
Sum of integers.
@ AddChainWithSubs
A chain of adds and subs.
@ FAdd
Sum of floats.
@ UMax
Unsigned integer max implemented in terms of select(cmp()).
@ None
Don't use tail folding.
@ DataWithEVL
Use predicated EVL instructions for tail-folding.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Extended Value Type.
Definition: ValueTypes.h:35
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
Definition: ValueTypes.h:390
bool isFixedLengthVector() const
Definition: ValueTypes.h:181
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition: ValueTypes.h:318
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition: ValueTypes.h:174
Returns options for expansion of memcmp. IsZeroCmp is.
Describe known properties for a set of pointers.
Parameters that control the generic loop unrolling transformation.