LLVM 23.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> {
30 using TTI = TargetTransformInfo;
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 generating a PC relative address
63 getStaticDataAddrGenerationCost(const TTI::TargetCostKind CostKind) const;
64
65 /// Return the cost of accessing a constant pool entry of the specified
66 /// type.
67 InstructionCost getConstantPoolLoadCost(Type *Ty,
69
70 /// If this shuffle can be lowered as a masked slide pair (at worst),
71 /// return a cost for it.
72 InstructionCost getSlideCost(FixedVectorType *Tp, ArrayRef<int> Mask,
74
75public:
76 explicit RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
77 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
78 TLI(ST->getTargetLowering()) {}
79
80 /// Return the cost of materializing an immediate for a value operand of
81 /// a store instruction.
84
86 TTI::TargetCostKind CostKind) const override;
87 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
88 const APInt &Imm, Type *Ty,
90 Instruction *Inst = nullptr) const override;
92 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
93 Type *Ty, TTI::TargetCostKind CostKind) const override;
94
95 /// \name EVL Support for predicated vectorization.
96 /// Whether the target supports the %evl parameter of VP intrinsic efficiently
97 /// in hardware. (see LLVM Language Reference - "Vector Predication
98 /// Intrinsics",
99 /// https://llvm.org/docs/LangRef.html#vector-predication-intrinsics and
100 /// "IR-level VP intrinsics",
101 /// https://llvm.org/docs/Proposals/VectorPredication.html#ir-level-vp-intrinsics).
102 bool hasActiveVectorLength() const override;
103
105 getPopcntSupport(unsigned TyWidth) const override;
106
108 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
110 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
112 std::optional<FastMathFlags> FMF) const override;
113
114 bool shouldExpandReduction(const IntrinsicInst *II) const override;
115 bool supportsScalableVectors() const override {
116 // VLEN=32 support is incomplete.
117 return ST->hasVInstructions() &&
118 (ST->getRealMinVLen() >= RISCV::RVVBitsPerBlock);
119 }
120 bool enableOrderedReductions() const override { return true; }
121 bool enableScalableVectorization() const override {
122 return ST->hasVInstructions();
123 }
125 return ST->hasVInstructions();
126 }
128 return ST->hasVInstructions() ? TailFoldingStyle::DataWithEVL
130 }
131 std::optional<unsigned> getMaxVScale() const override;
132 std::optional<unsigned> getVScaleForTuning() const override;
133
136
137 unsigned getRegUsageForType(Type *Ty) const override;
138
139 unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const override;
140
141 bool preferAlternateOpcodeVectorization() const override;
142
143 bool preferEpilogueVectorization(ElementCount Iters) const override {
144 // Epilogue vectorization is usually unprofitable - tail folding or
145 // a smaller VF would have been better. This a blunt hammer - we
146 // should re-examine this once vectorization is better tuned.
147 return false;
148 }
149
150 bool shouldConsiderVectorizationRegPressure() const override { return true; }
151
154 TTI::TargetCostKind CostKind) const override;
155
158
161 const TTI::PointersChainInfo &Info, Type *AccessTy,
162 TTI::TargetCostKind CostKind) const override;
163
166 OptimizationRemarkEmitter *ORE) const override;
167
169 TTI::PeelingPreferences &PP) const override;
170
172 MemIntrinsicInfo &Info) const override;
173
174 unsigned getMinVectorRegisterBitWidth() const override {
175 return ST->useRVVForFixedLengthVectors() ? 16 : 0;
176 }
177
181 VectorType *SubTp, ArrayRef<const Value *> Args = {},
182 const Instruction *CxtI = nullptr) const override;
183
185 getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
186 bool Insert, bool Extract,
188 bool ForPoisonSrc = true, ArrayRef<Value *> VL = {},
190 TTI::VectorInstrContext::None) const override;
191
193 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
194 TTI::TargetCostKind CostKind) const override;
195
197 getAddressComputationCost(Type *PTy, ScalarEvolution *SE, const SCEV *Ptr,
198 TTI::TargetCostKind CostKind) const override;
199
201 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
202 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
203 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
204
205 InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA,
207
209 getExpandCompressMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
211
212 InstructionCost getStridedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
214
217
219 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
221 const Instruction *I = nullptr) const override;
222
224 getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
225 TTI::TargetCostKind CostKind) const override;
226
228 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
229 std::optional<FastMathFlags> FMF,
230 TTI::TargetCostKind CostKind) const override;
231
233 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
234 VectorType *ValTy, std::optional<FastMathFlags> FMF,
235 TTI::TargetCostKind CostKind) const override;
236
238 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
241 const Instruction *I = nullptr) const override;
242
244 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
248 const Instruction *I = nullptr) const override;
249
251 const Instruction *I = nullptr) const override;
252
256 unsigned Index, const Value *Op0, const Value *Op1,
258 TTI::VectorInstrContext::None) const override;
259
261 getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
263 unsigned Index) const override;
264
266 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
270 const Instruction *CxtI = nullptr) const override;
271
272 bool isElementTypeLegalForScalableVector(Type *Ty) const override {
273 return TLI->isLegalElementTypeForRVV(TLI->getValueType(DL, Ty));
274 }
275
276 bool isLegalMaskedLoadStore(Type *DataType, Align Alignment) const {
277 if (!ST->hasVInstructions())
278 return false;
279
280 EVT DataTypeVT = TLI->getValueType(DL, DataType);
281
282 // Only support fixed vectors if we know the minimum vector size.
283 if (DataTypeVT.isFixedLengthVector() && !ST->useRVVForFixedLengthVectors())
284 return false;
285
286 EVT ElemType = DataTypeVT.getScalarType();
287 if (!ST->enableUnalignedVectorMem() && Alignment < ElemType.getStoreSize())
288 return false;
289
290 return TLI->isLegalElementTypeForRVV(ElemType);
291 }
292
293 bool isLegalMaskedLoad(Type *DataType, Align Alignment,
294 unsigned /*AddressSpace*/,
295 TTI::MaskKind /*MaskKind*/) const override {
296 return isLegalMaskedLoadStore(DataType, Alignment);
297 }
298 bool isLegalMaskedStore(Type *DataType, Align Alignment,
299 unsigned /*AddressSpace*/,
300 TTI::MaskKind /*MaskKind*/) const override {
301 return isLegalMaskedLoadStore(DataType, Alignment);
302 }
303
304 bool isLegalMaskedGatherScatter(Type *DataType, Align Alignment) const {
305 if (!ST->hasVInstructions())
306 return false;
307
308 EVT DataTypeVT = TLI->getValueType(DL, DataType);
309
310 // Only support fixed vectors if we know the minimum vector size.
311 if (DataTypeVT.isFixedLengthVector() && !ST->useRVVForFixedLengthVectors())
312 return false;
313
314 // We also need to check if the vector of address is valid.
315 EVT PointerTypeVT = EVT(TLI->getPointerTy(DL));
316 if (DataTypeVT.isScalableVector() &&
317 !TLI->isLegalElementTypeForRVV(PointerTypeVT))
318 return false;
319
320 EVT ElemType = DataTypeVT.getScalarType();
321 if (!ST->enableUnalignedVectorMem() && Alignment < ElemType.getStoreSize())
322 return false;
323
324 return TLI->isLegalElementTypeForRVV(ElemType);
325 }
326
327 bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
328 return isLegalMaskedGatherScatter(DataType, Alignment);
329 }
330 bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
331 return isLegalMaskedGatherScatter(DataType, Alignment);
332 }
333
335 Align Alignment) const override {
336 // Scalarize masked gather for RV64 if EEW=64 indices aren't supported.
337 return ST->is64Bit() && !ST->hasVInstructionsI64();
338 }
339
341 Align Alignment) const override {
342 // Scalarize masked scatter for RV64 if EEW=64 indices aren't supported.
343 return ST->is64Bit() && !ST->hasVInstructionsI64();
344 }
345
346 bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const override {
347 EVT DataTypeVT = TLI->getValueType(DL, DataType);
348 return TLI->isLegalStridedLoadStore(DataTypeVT, Alignment);
349 }
350
351 bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
352 Align Alignment,
353 unsigned AddrSpace) const override {
354 return TLI->isLegalInterleavedAccessType(VTy, Factor, Alignment, AddrSpace,
355 DL);
356 }
357
358 bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const override;
359
360 bool isLegalMaskedCompressStore(Type *DataTy, Align Alignment) const override;
361
362 /// \returns How the target needs this vector-predicated operation to be
363 /// transformed.
365 getVPLegalizationStrategy(const VPIntrinsic &PI) const override {
367 static const Intrinsic::ID Supported[] = {
368 Intrinsic::experimental_vp_strided_load,
369 Intrinsic::experimental_vp_strided_store,
370 Intrinsic::experimental_vp_reverse,
371 Intrinsic::experimental_vp_splice,
372 Intrinsic::vp_abs,
373 Intrinsic::vp_add,
374 Intrinsic::vp_and,
375 Intrinsic::vp_ashr,
376 Intrinsic::vp_bitreverse,
377 Intrinsic::vp_bswap,
378 Intrinsic::vp_ceil,
379 Intrinsic::vp_copysign,
380 Intrinsic::vp_ctlz,
381 Intrinsic::vp_ctpop,
382 Intrinsic::vp_cttz,
383 Intrinsic::vp_cttz_elts,
384 Intrinsic::vp_fabs,
385 Intrinsic::vp_fadd,
386 Intrinsic::vp_fcmp,
387 Intrinsic::vp_fdiv,
388 Intrinsic::vp_floor,
389 Intrinsic::vp_fma,
390 Intrinsic::vp_fmul,
391 Intrinsic::vp_fmuladd,
392 Intrinsic::vp_fneg,
393 Intrinsic::vp_fpext,
394 Intrinsic::vp_fptosi,
395 Intrinsic::vp_fptoui,
396 Intrinsic::vp_fptrunc,
397 Intrinsic::vp_frem,
398 Intrinsic::vp_fshl,
399 Intrinsic::vp_fshr,
400 Intrinsic::vp_fsub,
401 Intrinsic::vp_gather,
402 Intrinsic::vp_icmp,
403 Intrinsic::vp_inttoptr,
404 Intrinsic::vp_is_fpclass,
405 Intrinsic::vp_load,
406 Intrinsic::vp_load_ff,
407 Intrinsic::vp_lshr,
408 Intrinsic::vp_maxnum,
409 Intrinsic::vp_merge,
410 Intrinsic::vp_minnum,
411 Intrinsic::vp_mul,
412 Intrinsic::vp_nearbyint,
413 Intrinsic::vp_or,
414 Intrinsic::vp_ptrtoint,
415 Intrinsic::vp_reduce_add,
416 Intrinsic::vp_reduce_and,
417 Intrinsic::vp_reduce_fadd,
418 Intrinsic::vp_reduce_fmax,
419 Intrinsic::vp_reduce_fmaximum,
420 Intrinsic::vp_reduce_fmin,
421 Intrinsic::vp_reduce_fminimum,
422 Intrinsic::vp_reduce_fmul,
423 Intrinsic::vp_reduce_mul,
424 Intrinsic::vp_reduce_or,
425 Intrinsic::vp_reduce_smax,
426 Intrinsic::vp_reduce_smin,
427 Intrinsic::vp_reduce_umax,
428 Intrinsic::vp_reduce_umin,
429 Intrinsic::vp_reduce_xor,
430 Intrinsic::vp_rint,
431 Intrinsic::vp_round,
432 Intrinsic::vp_roundeven,
433 Intrinsic::vp_roundtozero,
434 Intrinsic::vp_sadd_sat,
435 Intrinsic::vp_scatter,
436 Intrinsic::vp_sdiv,
437 Intrinsic::vp_select,
438 Intrinsic::vp_sext,
439 Intrinsic::vp_shl,
440 Intrinsic::vp_sitofp,
441 Intrinsic::vp_smax,
442 Intrinsic::vp_smin,
443 Intrinsic::vp_sqrt,
444 Intrinsic::vp_srem,
445 Intrinsic::vp_ssub_sat,
446 Intrinsic::vp_store,
447 Intrinsic::vp_sub,
448 Intrinsic::vp_trunc,
449 Intrinsic::vp_uadd_sat,
450 Intrinsic::vp_udiv,
451 Intrinsic::vp_uitofp,
452 Intrinsic::vp_umax,
453 Intrinsic::vp_umin,
454 Intrinsic::vp_urem,
455 Intrinsic::vp_usub_sat,
456 Intrinsic::vp_xor,
457 Intrinsic::vp_zext};
458 if (!ST->hasVInstructions() ||
459 (PI.getIntrinsicID() == Intrinsic::vp_reduce_mul &&
461 ->getElementType()
462 ->getIntegerBitWidth() != 1) ||
463 !is_contained(Supported, PI.getIntrinsicID()))
466 }
467
469 ElementCount VF) const override {
470 if (!VF.isScalable())
471 return true;
472
473 Type *Ty = RdxDesc.getRecurrenceType();
474 if (!TLI->isLegalElementTypeForRVV(TLI->getValueType(DL, Ty)))
475 return false;
476
477 switch (RdxDesc.getRecurrenceKind()) {
478 case RecurKind::Add:
479 case RecurKind::Sub:
481 case RecurKind::And:
482 case RecurKind::Or:
483 case RecurKind::Xor:
484 case RecurKind::SMin:
485 case RecurKind::SMax:
486 case RecurKind::UMin:
487 case RecurKind::UMax:
488 case RecurKind::FMin:
489 case RecurKind::FMax:
490 return true;
491 case RecurKind::AnyOf:
492 case RecurKind::FAdd:
494 // We can't promote f16/bf16 fadd reductions and scalable vectors can't be
495 // expanded.
496 if (Ty->isBFloatTy() || (Ty->isHalfTy() && !ST->hasVInstructionsF16()))
497 return false;
498 return true;
499 default:
500 return false;
501 }
502 }
503
504 unsigned getMaxInterleaveFactor(ElementCount VF) const override {
505 // Don't interleave if the loop has been vectorized with scalable vectors.
506 if (VF.isScalable())
507 return 1;
508 // If the loop will not be vectorized, don't interleave the loop.
509 // Let regular unroll to unroll the loop.
510 return VF.isScalar() ? 1 : ST->getMaxInterleaveFactor();
511 }
512
513 bool enableInterleavedAccessVectorization() const override { return true; }
514
516 return ST->hasVInstructions();
517 }
518
519 unsigned getMinTripCountTailFoldingThreshold() const override;
520
522 unsigned getNumberOfRegisters(unsigned ClassID) const override {
523 switch (ClassID) {
525 // 31 = 32 GPR - x0 (zero register)
526 // FIXME: Should we exclude fixed registers like SP, TP or GP?
527 return 31;
529 if (ST->hasStdExtF())
530 return 32;
531 return 0;
533 // Although there are 32 vector registers, v0 is special in that it is the
534 // only register that can be used to hold a mask.
535 // FIXME: Should we conservatively return 31 as the number of usable
536 // vector registers?
537 return ST->hasVInstructions() ? 32 : 0;
538 }
539 llvm_unreachable("unknown register class");
540 }
541
543 getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override;
544
546 Type *Ty = nullptr) const override {
547 if (Vector)
549 if (!Ty)
551
552 Type *ScalarTy = Ty->getScalarType();
553 if ((ScalarTy->isHalfTy() && ST->hasStdExtZfhmin()) ||
554 (ScalarTy->isFloatTy() && ST->hasStdExtF()) ||
555 (ScalarTy->isDoubleTy() && ST->hasStdExtD())) {
557 }
558
560 }
561
562 const char *getRegisterClassName(unsigned ClassID) const override {
563 switch (ClassID) {
565 return "RISCV::GPRRC";
567 return "RISCV::FPRRC";
569 return "RISCV::VRRC";
570 }
571 llvm_unreachable("unknown register class");
572 }
573
575 const TargetTransformInfo::LSRCost &C2) const override;
576
578 const Instruction &I,
579 bool &AllowPromotionWithoutCommonHeader) const override;
580 std::optional<unsigned> getMinPageSize() const override { return 4096; }
581 /// Return true if the (vector) instruction I will be lowered to an
582 /// instruction with a scalar splat operand for the given Operand number.
583 bool canSplatOperand(Instruction *I, int Operand) const;
584 /// Return true if a vector instruction will lower to a target instruction
585 /// able to splat the given operand.
586 bool canSplatOperand(unsigned Opcode, int Operand) const;
587
589 SmallVectorImpl<Use *> &Ops) const override;
590
592 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
593
594 bool enableSelectOptimize() const override {
595 return ST->enableSelectOptimize();
596 }
597
598 bool shouldTreatInstructionLikeSelect(const Instruction *I) const override;
599
600 bool
602 const Attribute &Attr) const override;
603
604 std::optional<Instruction *>
606};
607
608} // end namespace llvm
609
610#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...
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")))
TargetTransformInfo::VPLegalization VPLegalization
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.
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:40
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
Value * getArgOperand(unsigned i) const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:676
constexpr bool isScalar() const
Exactly one element.
Definition TypeSize.h:320
Class to represent fixed width SIMD vectors.
The core instruction combiner logic.
A wrapper class for inspecting calls to intrinsic functions.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Machine Value Type.
Information for memory intrinsic cost model.
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
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 shouldCopyAttributeWhenOutliningFrom(const Function *Caller, const Attribute &Attr) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const override
InstructionCost getStridedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
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
InstructionCost getAddressComputationCost(Type *PTy, ScalarEvolution *SE, const SCEV *Ptr, TTI::TargetCostKind CostKind) 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 isLegalMaskedStore(Type *DataType, Align Alignment, unsigned, TTI::MaskKind) const override
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const override
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 enableSelectOptimize() 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
bool shouldConsiderVectorizationRegPressure() 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
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) 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
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
Try to calculate op costs for min/max reduction operations.
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
TailFoldingStyle getPreferredTailFoldingStyle() 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
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
InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
bool enableOrderedReductions() 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
bool shouldTreatInstructionLikeSelect(const Instruction *I) const override
InstructionCost getExpandCompressMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
TargetTransformInfo::VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const override
bool preferEpilogueVectorization(ElementCount Iters) const override
bool preferAlternateOpcodeVectorization() 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
std::optional< unsigned > getMaxVScale() const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
std::optional< unsigned > getVScaleForTuning() const override
InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const override
Get memory intrinsic cost based on arguments.
bool isLegalMaskedGather(Type *DataType, Align Alignment) const override
bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned, TTI::MaskKind) 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 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
Estimate the overhead of scalarizing an instruction.
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
Get intrinsic cost based on arguments.
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
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
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) 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
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment) const override
TargetTransformInfo::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
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...
virtual const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
VectorInstrContext
Represents a hint about the context in which an insert/extract is used.
@ None
The insert/extract is not used with a load/store.
MaskKind
Some targets only support masked load/store with a constant mask.
TargetCostKind
The kind of cost model.
PopcntSupportKind
Flags indicating the kind of support for population count.
AddressingModeKind
Which addressing mode Loop Strength Reduction will try to generate.
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
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition Type.h:155
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:370
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition Type.h:144
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition Type.h:158
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.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:168
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
static constexpr unsigned RVVBitsPerBlock
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
@ 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()).
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1947
@ 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:403
bool isFixedLengthVector() const
Definition ValueTypes.h:189
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition ValueTypes.h:331
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition ValueTypes.h:182
Information about a load/store intrinsic defined by the target.
Returns options for expansion of memcmp. IsZeroCmp is.
Describe known properties for a set of pointers.
Parameters that control the generic loop unrolling transformation.