LLVM 24.0.0git
ARMTargetTransformInfo.h
Go to the documentation of this file.
1//===- ARMTargetTransformInfo.h - ARM 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//
9/// \file
10/// This file a TargetTransformInfoImplBase conforming object specific to the
11/// ARM target machine. It uses the target's detailed information to
12/// provide more precise answers to certain TTI queries, while letting the
13/// target independent and default TTI implementations handle the rest.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
18#define LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
19
20#include "ARM.h"
21#include "ARMSubtarget.h"
22#include "ARMTargetMachine.h"
23#include "llvm/ADT/ArrayRef.h"
26#include "llvm/IR/Constant.h"
27#include "llvm/IR/Function.h"
29#include <optional>
30
31namespace llvm {
32
33class APInt;
35class Instruction;
36class Loop;
37class SCEV;
38class ScalarEvolution;
39class Type;
40class Value;
41
42class ARMTTIImpl final : public BasicTTIImplBase<ARMTTIImpl> {
43 using BaseT = BasicTTIImplBase<ARMTTIImpl>;
44 using TTI = TargetTransformInfo;
45
46 friend BaseT;
47
48 const ARMSubtarget *ST;
49 const ARMTargetLowering *TLI;
50
51 const ARMSubtarget *getST() const { return ST; }
52 const ARMTargetLowering *getTLI() const { return TLI; }
53
54public:
55 explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
56 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
57 TLI(ST->getTargetLowering()) {}
58
59 bool enableInterleavedAccessVectorization() const override { return true; }
60
62 getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override;
63
64 /// Floating-point computation using ARMv8 AArch32 Advanced
65 /// SIMD instructions remains unchanged from ARMv7. Only AArch64 SIMD
66 /// and Arm MVE are IEEE-754 compliant.
67 bool isFPVectorizationPotentiallyUnsafe() const override {
68 return !ST->isTargetDarwin() && !ST->hasMVEFloatOps();
69 }
70
71 std::optional<Instruction *>
73 std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
74 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
75 APInt &UndefElts2, APInt &UndefElts3,
76 std::function<void(Instruction *, unsigned, APInt, APInt &)>
77 SimplifyAndSetOp) const override;
78
79 /// \name Scalar TTI Implementations
80 /// @{
81
82 InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
83 const APInt &Imm,
84 Type *Ty) const override;
85
88 TTI::TargetCostKind CostKind) const override;
89
90 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
91 const APInt &Imm, Type *Ty,
92 TTI::TargetCostKind CostKind,
93 Instruction *Inst = nullptr) const override;
94
95 /// @}
96
97 /// \name Vector TTI Implementations
98 /// @{
99
100 unsigned getNumberOfRegisters(unsigned ClassID) const override {
101 bool Vector = (ClassID == 1);
102 if (Vector) {
103 if (ST->hasNEON())
104 return 16;
105 if (ST->hasMVEIntegerOps())
106 return 8;
107 return 0;
108 }
109
110 if (ST->isThumb1Only())
111 return 8;
112 return 13;
113 }
114
117 switch (K) {
119 return TypeSize::getFixed(32);
121 if (ST->hasNEON())
122 return TypeSize::getFixed(128);
123 if (ST->hasMVEIntegerOps())
124 return TypeSize::getFixed(128);
125 return TypeSize::getFixed(0);
127 return TypeSize::getScalable(0);
128 }
129 llvm_unreachable("Unsupported register kind");
130 }
131
133 bool HasUnorderedReductions) const override {
134 return ST->getMaxInterleaveFactor();
135 }
136
137 bool isProfitableLSRChainElement(Instruction *I) const override;
138
139 bool
140 isLegalMaskedLoad(Type *DataTy, Align Alignment, unsigned AddressSpace,
141 TTI::MaskKind MaskKind =
143
144 bool
145 isLegalMaskedStore(Type *DataTy, Align Alignment, unsigned AddressSpace,
146 TTI::MaskKind MaskKind =
148 return isLegalMaskedLoad(DataTy, Alignment, AddressSpace, MaskKind);
149 }
150
152 Align Alignment) const override {
153 // For MVE, we have a custom lowering pass that will already have custom
154 // legalised any gathers that we can lower to MVE intrinsics, and want to
155 // expand all the rest. The pass runs before the masked intrinsic lowering
156 // pass.
157 return true;
158 }
159
161 Align Alignment) const override {
162 return forceScalarizeMaskedGather(VTy, Alignment);
163 }
164
165 bool isLegalMaskedGather(Type *Ty, Align Alignment) const override;
166
167 bool isLegalMaskedScatter(Type *Ty, Align Alignment) const override {
168 return isLegalMaskedGather(Ty, Alignment);
169 }
170
171 InstructionCost getMemcpyCost(const Instruction *I) const override;
172
174 return ST->getMaxInlineSizeThreshold();
175 }
176
177 int getNumMemOps(const IntrinsicInst *I) const;
178
181 TTI::TargetCostKind CostKind, ArrayRef<int> Mask, int Index,
182 VectorType *SubTp, ArrayRef<const Value *> Args = {},
183 const Instruction *CtxI = nullptr,
185 TTI::VectorInstrContext::None) const override;
186
187 bool preferInLoopReduction(RecurKind Kind, Type *Ty) const override;
188
189 bool preferPredicatedReductionSelect() const override;
190
191 bool shouldExpandReduction(const IntrinsicInst *II) const override {
192 return false;
193 }
194
195 InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
196 const Instruction *I = nullptr) const override;
197
199 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
201 const Instruction *I = nullptr) const override;
202
204 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
205 TTI::TargetCostKind CostKind,
208 const Instruction *I = nullptr) const override;
209
212 getVectorInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
213 unsigned Index, const Value *Op0, const Value *Op1,
215 TTI::VectorInstrContext::None) const override;
216
218 getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr,
219 TTI::TargetCostKind CostKind) const override;
220
222 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
225 ArrayRef<const Value *> Args = {}, const Instruction *CtxI = nullptr,
226 const TargetLibraryInfo *TLibInfo = nullptr,
227 ArrayRef<const Value *> Scalars = {}) const override;
228
230 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
231 TTI::TargetCostKind CostKind,
233 const Instruction *I = nullptr) const override;
234
236 getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
237 TTI::TargetCostKind CostKind) const override;
238
239 InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
240 TTI::TargetCostKind CostKind) const;
241
243 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
244 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
245 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
246
247 InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA,
248 TTI::TargetCostKind CostKind) const;
249
251 getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy,
252 std::optional<FastMathFlags> FMF,
253 TTI::TargetCostKind CostKind) const override;
255 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
256 VectorType *ValTy, std::optional<FastMathFlags> FMF,
257 TTI::TargetCostKind CostKind) const override;
259 getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy,
260 VectorType *ValTy,
261 TTI::TargetCostKind CostKind) const override;
262
264 getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
265 TTI::TargetCostKind CostKind) const override;
266
268 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
269 TTI::TargetCostKind CostKind) const override;
270
272 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
274 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
275 TTI::TargetCostKind CostKind,
276 std::optional<FastMathFlags> FMF) const override {
278 }
279
280 /// getScalingFactorCost - Return the cost of the scaling used in
281 /// addressing mode represented by AM.
282 /// If the AM is supported, the return value must be >= 0.
283 /// If the AM is not supported, the return value is an invalid cost.
285 StackOffset BaseOffset, bool HasBaseReg,
286 int64_t Scale,
287 unsigned AddrSpace) const override;
288
289 bool maybeLoweredToCall(Instruction &I) const;
290 bool isLoweredToCall(const Function *F) const override;
293 HardwareLoopInfo &HWLoopInfo) const override;
294 bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override;
297 OptimizationRemarkEmitter *ORE) const override;
298
300
302 TTI::PeelingPreferences &PP) const override;
304 // In the ROPI and RWPI relocation models we can't have pointers to global
305 // variables or functions in constant data, so don't convert switches to
306 // lookup tables if any of the values would need relocation.
307 if (ST->isROPI() || ST->isRWPI())
308 return !C->needsDynamicRelocation();
309
310 return true;
311 }
312
313 bool shouldConsiderVectorizationRegPressure() const override;
314
315 bool hasArmWideBranch(bool Thumb) const override;
316
318 SmallVectorImpl<Use *> &Ops) const override;
319
320 /// @}
321};
322
323/// isVREVMask - Check if a vector shuffle corresponds to a VREV
324/// instruction with the specified blocksize. (The order of the elements
325/// within each block of the vector is reversed.)
326inline bool isVREVMask(ArrayRef<int> M, EVT VT, unsigned BlockSize) {
327 assert((BlockSize == 16 || BlockSize == 32 || BlockSize == 64) &&
328 "Only possible block sizes for VREV are: 16, 32, 64");
329
330 unsigned EltSz = VT.getScalarSizeInBits();
331 if (EltSz != 8 && EltSz != 16 && EltSz != 32)
332 return false;
333
334 unsigned BlockElts = M[0] + 1;
335 // If the first shuffle index is UNDEF, be optimistic.
336 if (M[0] < 0)
337 BlockElts = BlockSize / EltSz;
338
339 if (BlockSize <= EltSz || BlockSize != BlockElts * EltSz)
340 return false;
341
342 for (unsigned i = 0, e = M.size(); i < e; ++i) {
343 if (M[i] < 0)
344 continue; // ignore UNDEF indices
345 if ((unsigned)M[i] != (i - i % BlockElts) + (BlockElts - 1 - i % BlockElts))
346 return false;
347 }
348
349 return true;
350}
351
352inline unsigned SelectPairHalf(unsigned Elements, ArrayRef<int> Mask,
353 unsigned Index) {
354 if (Mask.size() == Elements * 2)
355 return Index / Elements;
356 return Mask[Index] == 0 ? 0 : 1;
357}
358
359// Checks whether the shuffle mask represents a vector transpose (VTRN) by
360// checking that pairs of elements in the shuffle mask represent the same index
361// in each vector, incrementing the expected index by 2 at each step.
362// e.g. For v1,v2 of type v4i32 a valid shuffle mask is: [0, 4, 2, 6]
363// v1={a,b,c,d} => x=shufflevector v1, v2 shufflemask => x={a,e,c,g}
364// v2={e,f,g,h}
365// WhichResult gives the offset for each element in the mask based on which
366// of the two results it belongs to.
367//
368// The transpose can be represented either as:
369// result1 = shufflevector v1, v2, result1_shuffle_mask
370// result2 = shufflevector v1, v2, result2_shuffle_mask
371// where v1/v2 and the shuffle masks have the same number of elements
372// (here WhichResult (see below) indicates which result is being checked)
373//
374// or as:
375// results = shufflevector v1, v2, shuffle_mask
376// where both results are returned in one vector and the shuffle mask has twice
377// as many elements as v1/v2 (here WhichResult will always be 0 if true) here we
378// want to check the low half and high half of the shuffle mask as if it were
379// the other case
380inline bool isVTRNMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) {
381 unsigned EltSz = VT.getScalarSizeInBits();
382 if (EltSz == 64)
383 return false;
384
385 unsigned NumElts = VT.getVectorNumElements();
386 if ((M.size() != NumElts && M.size() != NumElts * 2) || NumElts % 2 != 0)
387 return false;
388
389 // If the mask is twice as long as the input vector then we need to check the
390 // upper and lower parts of the mask with a matching value for WhichResult
391 // FIXME: A mask with only even values will be rejected in case the first
392 // element is undefined, e.g. [-1, 4, 2, 6] will be rejected, because only
393 // M[0] is used to determine WhichResult
394 for (unsigned i = 0; i < M.size(); i += NumElts) {
395 WhichResult = SelectPairHalf(NumElts, M, i);
396 for (unsigned j = 0; j < NumElts; j += 2) {
397 if ((M[i + j] >= 0 && (unsigned)M[i + j] != j + WhichResult) ||
398 (M[i + j + 1] >= 0 &&
399 (unsigned)M[i + j + 1] != j + NumElts + WhichResult))
400 return false;
401 }
402 }
403
404 if (M.size() == NumElts * 2)
405 WhichResult = 0;
406
407 return true;
408}
409
410/// isVTRN_v_undef_Mask - Special case of isVTRNMask for canonical form of
411/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef".
412/// Mask is e.g., <0, 0, 2, 2> instead of <0, 4, 2, 6>.
414 unsigned &WhichResult) {
415 unsigned EltSz = VT.getScalarSizeInBits();
416 if (EltSz == 64)
417 return false;
418
419 unsigned NumElts = VT.getVectorNumElements();
420 if ((M.size() != NumElts && M.size() != NumElts * 2) || NumElts % 2 != 0)
421 return false;
422
423 for (unsigned i = 0; i < M.size(); i += NumElts) {
424 WhichResult = SelectPairHalf(NumElts, M, i);
425 for (unsigned j = 0; j < NumElts; j += 2) {
426 if ((M[i + j] >= 0 && (unsigned)M[i + j] != j + WhichResult) ||
427 (M[i + j + 1] >= 0 && (unsigned)M[i + j + 1] != j + WhichResult))
428 return false;
429 }
430 }
431
432 if (M.size() == NumElts * 2)
433 WhichResult = 0;
434
435 return true;
436}
437
438// Checks whether the shuffle mask represents a vector unzip (VUZP) by checking
439// that the mask elements are either all even and in steps of size 2 or all odd
440// and in steps of size 2.
441// e.g. For v1,v2 of type v4i32 a valid shuffle mask is: [0, 2, 4, 6]
442// v1={a,b,c,d} => x=shufflevector v1, v2 shufflemask => x={a,c,e,g}
443// v2={e,f,g,h}
444// Requires similar checks to that of isVTRNMask with
445// respect the how results are returned.
446inline bool isVUZPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) {
447 unsigned EltSz = VT.getScalarSizeInBits();
448 if (EltSz == 64)
449 return false;
450
451 unsigned NumElts = VT.getVectorNumElements();
452 if (M.size() != NumElts && M.size() != NumElts * 2)
453 return false;
454
455 for (unsigned i = 0; i < M.size(); i += NumElts) {
456 WhichResult = SelectPairHalf(NumElts, M, i);
457 for (unsigned j = 0; j < NumElts; ++j) {
458 if (M[i + j] >= 0 && (unsigned)M[i + j] != 2 * j + WhichResult)
459 return false;
460 }
461 }
462
463 if (M.size() == NumElts * 2)
464 WhichResult = 0;
465
466 // VUZP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32.
467 if (VT.is64BitVector() && EltSz == 32)
468 return false;
469
470 return true;
471}
472
473/// isVUZP_v_undef_Mask - Special case of isVUZPMask for canonical form of
474/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef".
475/// Mask is e.g., <0, 2, 0, 2> instead of <0, 2, 4, 6>,
477 unsigned &WhichResult) {
478 unsigned EltSz = VT.getScalarSizeInBits();
479 if (EltSz == 64)
480 return false;
481
482 unsigned NumElts = VT.getVectorNumElements();
483 if (M.size() != NumElts && M.size() != NumElts * 2)
484 return false;
485
486 unsigned Half = NumElts / 2;
487 for (unsigned i = 0; i < M.size(); i += NumElts) {
488 WhichResult = SelectPairHalf(NumElts, M, i);
489 for (unsigned j = 0; j < NumElts; j += Half) {
490 unsigned Idx = WhichResult;
491 for (unsigned k = 0; k < Half; ++k) {
492 int MIdx = M[i + j + k];
493 if (MIdx >= 0 && (unsigned)MIdx != Idx)
494 return false;
495 Idx += 2;
496 }
497 }
498 }
499
500 if (M.size() == NumElts * 2)
501 WhichResult = 0;
502
503 // VUZP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32.
504 if (VT.is64BitVector() && EltSz == 32)
505 return false;
506
507 return true;
508}
509
510// Checks whether the shuffle mask represents a vector zip (VZIP) by checking
511// that pairs of elements of the shufflemask represent the same index in each
512// vector incrementing sequentially through the vectors.
513// e.g. For v1,v2 of type v4i32 a valid shuffle mask is: [0, 4, 1, 5]
514// v1={a,b,c,d} => x=shufflevector v1, v2 shufflemask => x={a,e,b,f}
515// v2={e,f,g,h}
516// Requires similar checks to that of isVTRNMask with respect the how results
517// are returned.
518inline bool isVZIPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) {
519 unsigned EltSz = VT.getScalarSizeInBits();
520 if (EltSz == 64)
521 return false;
522
523 unsigned NumElts = VT.getVectorNumElements();
524 if ((M.size() != NumElts && M.size() != NumElts * 2) || NumElts % 2 != 0)
525 return false;
526
527 for (unsigned i = 0; i < M.size(); i += NumElts) {
528 WhichResult = SelectPairHalf(NumElts, M, i);
529 unsigned Idx = WhichResult * NumElts / 2;
530 for (unsigned j = 0; j < NumElts; j += 2) {
531 if ((M[i + j] >= 0 && (unsigned)M[i + j] != Idx) ||
532 (M[i + j + 1] >= 0 && (unsigned)M[i + j + 1] != Idx + NumElts))
533 return false;
534 Idx += 1;
535 }
536 }
537
538 if (M.size() == NumElts * 2)
539 WhichResult = 0;
540
541 // VZIP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32.
542 if (VT.is64BitVector() && EltSz == 32)
543 return false;
544
545 return true;
546}
547
548/// isVZIP_v_undef_Mask - Special case of isVZIPMask for canonical form of
549/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef".
550/// Mask is e.g., <0, 0, 1, 1> instead of <0, 4, 1, 5>.
552 unsigned &WhichResult) {
553 unsigned EltSz = VT.getScalarSizeInBits();
554 if (EltSz == 64)
555 return false;
556
557 unsigned NumElts = VT.getVectorNumElements();
558 if ((M.size() != NumElts && M.size() != NumElts * 2) || NumElts % 2 != 0)
559 return false;
560
561 for (unsigned i = 0; i < M.size(); i += NumElts) {
562 WhichResult = SelectPairHalf(NumElts, M, i);
563 unsigned Idx = WhichResult * NumElts / 2;
564 for (unsigned j = 0; j < NumElts; j += 2) {
565 if ((M[i + j] >= 0 && (unsigned)M[i + j] != Idx) ||
566 (M[i + j + 1] >= 0 && (unsigned)M[i + j + 1] != Idx))
567 return false;
568 Idx += 1;
569 }
570 }
571
572 if (M.size() == NumElts * 2)
573 WhichResult = 0;
574
575 // VZIP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32.
576 if (VT.is64BitVector() && EltSz == 32)
577 return false;
578
579 return true;
580}
581
582} // end namespace llvm
583
584#endif // LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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
static const int BlockSize
Definition TarWriter.cpp:33
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition APInt.h:78
InstructionCost getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
bool isFPVectorizationPotentiallyUnsafe() const override
Floating-point computation using ARMv8 AArch32 Advanced SIMD instructions remains unchanged from ARMv...
InstructionCost getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
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
InstructionCost getMemcpyCost(const Instruction *I) const override
bool isLegalMaskedScatter(Type *Ty, Align Alignment) const override
bool maybeLoweredToCall(Instruction &I) const
bool preferInLoopReduction(RecurKind Kind, Type *Ty) 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 getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *ValTy, TTI::TargetCostKind CostKind) 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 getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
bool hasArmWideBranch(bool Thumb) const override
bool shouldConsiderVectorizationRegPressure() const override
bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
bool shouldBuildLookupTablesForConstant(Constant *C) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
int getNumMemOps(const IntrinsicInst *I) const
Given a memcpy/memset/memmove instruction, return the number of memory operations performed,...
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty) 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 *CtxI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
bool isLoweredToCall(const Function *F) const override
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) 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...
uint64_t getMaxMemIntrinsicInlineSizeThreshold() const override
bool isLegalMaskedStore(Type *DataTy, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind=TTI::MaskKind::VariableOrConstantMask) const override
bool forceScalarizeMaskedScatter(VectorType *VTy, Align Alignment) 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 getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
std::optional< Value * > simplifyDemandedVectorEltsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp) const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
bool isLegalMaskedLoad(Type *DataTy, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind=TTI::MaskKind::VariableOrConstantMask) const override
ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
TailFoldingStyle getPreferredTailFoldingStyle() const override
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
TTI::AddressingModeKind getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const override
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const override
bool preferPredicatedReductionSelect() const override
bool isLegalMaskedGather(Type *Ty, Align Alignment) const override
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr, TTI::TargetCostKind CostKind) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
bool isProfitableLSRChainElement(Instruction *I) const override
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
bool enableInterleavedAccessVectorization() const override
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const override
getScalingFactorCost - Return the cost of the scaling used in addressing mode represented by AM.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A cache of @llvm.assume calls within a function.
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)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
This is an important base class in LLVM.
Definition Constant.h:44
The core instruction combiner logic.
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
The optimization diagnostic interface.
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...
StackOffset holds a fixed and a scalable offset in bytes.
Definition TypeSize.h:31
Provides information about what library functions are available for the current target.
virtual const DataLayout & getDataLayout() const
virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) 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.
llvm::VectorInstrContext VectorInstrContext
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.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Definition TypeSize.h:352
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
Definition TypeSize.h:355
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
unsigned SelectPairHalf(unsigned Elements, ArrayRef< int > Mask, unsigned Index)
bool isVTRN_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVTRN_v_undef_Mask - Special case of isVTRNMask for canonical form of "vector_shuffle v,...
bool isVZIPMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
bool isVUZPMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
bool isVTRNMask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
bool isVUZP_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVUZP_v_undef_Mask - Special case of isVUZPMask for canonical form of "vector_shuffle v,...
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool isVREVMask(ArrayRef< int > M, EVT VT, unsigned BlockSize)
isVREVMask - Check if a vector shuffle corresponds to a VREV instruction with the specified blocksize...
bool isVZIP_v_undef_Mask(ArrayRef< int > M, EVT VT, unsigned &WhichResult)
isVZIP_v_undef_Mask - Special case of isVZIPMask for canonical form of "vector_shuffle v,...
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
uint64_t getScalarSizeInBits() const
Definition ValueTypes.h:423
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition ValueTypes.h:374
bool is64BitVector() const
Return true if this is a 64-bit vector type.
Definition ValueTypes.h:240
Attributes of a target dependent hardware loop.
Parameters that control the generic loop unrolling transformation.