Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Line
Count
Source (jump to first uncovered line)
1
//===- TargetTransformInfoImpl.h --------------------------------*- 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 provides helpers for the implementation of
10
/// a TargetTransformInfo-conforming class.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
15
#define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
16
17
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
18
#include "llvm/Analysis/TargetTransformInfo.h"
19
#include "llvm/Analysis/VectorUtils.h"
20
#include "llvm/IR/CallSite.h"
21
#include "llvm/IR/DataLayout.h"
22
#include "llvm/IR/Function.h"
23
#include "llvm/IR/GetElementPtrTypeIterator.h"
24
#include "llvm/IR/Operator.h"
25
#include "llvm/IR/Type.h"
26
27
namespace llvm {
28
29
/// Base class for use as a mix-in that aids implementing
30
/// a TargetTransformInfo-compatible class.
31
class TargetTransformInfoImplBase {
32
protected:
33
  typedef TargetTransformInfo TTI;
34
35
  const DataLayout &DL;
36
37
16.6M
  explicit TargetTransformInfoImplBase(const DataLayout &DL) : DL(DL) {}
38
39
public:
40
  // Provide value semantics. MSVC requires that we spell all of these out.
41
  TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)
42
16.5M
      : DL(Arg.DL) {}
43
16.6M
  TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) : DL(Arg.DL) {}
44
45
8.63M
  const DataLayout &getDataLayout() const { return DL; }
46
47
25.4M
  unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) {
48
25.4M
    switch (Opcode) {
49
25.4M
    default:
50
22.1M
      // By default, just classify everything as 'basic'.
51
22.1M
      return TTI::TCC_Basic;
52
25.4M
53
25.4M
    case Instruction::GetElementPtr:
54
0
      llvm_unreachable("Use getGEPCost for GEP operations!");
55
25.4M
56
25.4M
    case Instruction::BitCast:
57
1.93M
      assert(OpTy && "Cast instructions must provide the operand type");
58
1.93M
      if (Ty == OpTy || 
(1.93M
Ty->isPointerTy()1.93M
&&
OpTy->isPointerTy()1.93M
))
59
1.93M
        // Identity and pointer-to-pointer casts are free.
60
1.93M
        return TTI::TCC_Free;
61
3.40k
62
3.40k
      // Otherwise, the default basic cost is used.
63
3.40k
      return TTI::TCC_Basic;
64
3.40k
65
281k
    case Instruction::FDiv:
66
281k
    case Instruction::FRem:
67
281k
    case Instruction::SDiv:
68
281k
    case Instruction::SRem:
69
281k
    case Instruction::UDiv:
70
281k
    case Instruction::URem:
71
281k
      return TTI::TCC_Expensive;
72
281k
73
396k
    case Instruction::IntToPtr: {
74
396k
      // An inttoptr cast is free so long as the input is a legal integer type
75
396k
      // which doesn't contain values outside the range of a pointer.
76
396k
      unsigned OpSize = OpTy->getScalarSizeInBits();
77
396k
      if (DL.isLegalInteger(OpSize) &&
78
396k
          
OpSize <= DL.getPointerTypeSizeInBits(Ty)396k
)
79
396k
        return TTI::TCC_Free;
80
5
81
5
      // Otherwise it's not a no-op.
82
5
      return TTI::TCC_Basic;
83
5
    }
84
629k
    case Instruction::PtrToInt: {
85
629k
      // A ptrtoint cast is free so long as the result is large enough to store
86
629k
      // the pointer, and a legal integer type.
87
629k
      unsigned DestSize = Ty->getScalarSizeInBits();
88
629k
      if (DL.isLegalInteger(DestSize) &&
89
629k
          
DestSize >= DL.getPointerTypeSizeInBits(OpTy)629k
)
90
629k
        return TTI::TCC_Free;
91
31
92
31
      // Otherwise it's not a no-op.
93
31
      return TTI::TCC_Basic;
94
31
    }
95
71
    case Instruction::Trunc:
96
71
      // trunc to a native type is free (assuming the target has compare and
97
71
      // shift-right of the same width).
98
71
      if (DL.isLegalInteger(DL.getTypeSizeInBits(Ty)))
99
34
        return TTI::TCC_Free;
100
37
101
37
      return TTI::TCC_Basic;
102
25.4M
    }
103
25.4M
  }
104
105
  int getGEPCost(Type *PointeeType, const Value *Ptr,
106
0
                 ArrayRef<const Value *> Operands) {
107
0
    // In the basic model, we just assume that all-constant GEPs will be folded
108
0
    // into their uses via addressing modes.
109
0
    for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
110
0
      if (!isa<Constant>(Operands[Idx]))
111
0
        return TTI::TCC_Basic;
112
0
113
0
    return TTI::TCC_Free;
114
0
  }
115
116
  unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
117
2
                                            unsigned &JTSize) {
118
2
    JTSize = 0;
119
2
    return SI.getNumCases();
120
2
  }
121
122
2.30k
  int getExtCost(const Instruction *I, const Value *Src) {
123
2.30k
    return TTI::TCC_Basic;
124
2.30k
  }
125
126
4.36M
  unsigned getCallCost(FunctionType *FTy, int NumArgs, const User *U) {
127
4.36M
    assert(FTy && "FunctionType must be provided to this routine.");
128
4.36M
129
4.36M
    // The target-independent implementation just measures the size of the
130
4.36M
    // function by approximating that each argument will take on average one
131
4.36M
    // instruction to prepare.
132
4.36M
133
4.36M
    if (NumArgs < 0)
134
0
      // Set the argument number to the number of explicit arguments in the
135
0
      // function.
136
0
      NumArgs = FTy->getNumParams();
137
4.36M
138
4.36M
    return TTI::TCC_Basic * (NumArgs + 1);
139
4.36M
  }
140
141
835
  unsigned getInliningThresholdMultiplier() { return 1; }
142
143
835
  int getInlinerVectorBonusPercent() { return 150; }
144
145
44.7k
  unsigned getMemcpyCost(const Instruction *I) {
146
44.7k
    return TTI::TCC_Expensive;
147
44.7k
  }
148
149
1.43k
  bool hasBranchDivergence() { return false; }
150
151
0
  bool isSourceOfDivergence(const Value *V) { return false; }
152
153
0
  bool isAlwaysUniform(const Value *V) { return false; }
154
155
0
  unsigned getFlatAddressSpace () {
156
0
    return -1;
157
0
  }
158
159
8.05M
  bool isLoweredToCall(const Function *F) {
160
8.05M
    assert(F && "A concrete function must be provided to this routine.");
161
8.05M
162
8.05M
    // FIXME: These should almost certainly not be handled here, and instead
163
8.05M
    // handled with the help of TLI or the target itself. This was largely
164
8.05M
    // ported from existing analysis heuristics here so that such refactorings
165
8.05M
    // can take place in the future.
166
8.05M
167
8.05M
    if (F->isIntrinsic())
168
236k
      return false;
169
7.81M
170
7.81M
    if (F->hasLocalLinkage() || 
!F->hasName()7.13M
)
171
684k
      return true;
172
7.13M
173
7.13M
    StringRef Name = F->getName();
174
7.13M
175
7.13M
    // These will all likely lower to a single selection DAG node.
176
7.13M
    if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
177
7.13M
        
Name == "fabs"7.13M
||
Name == "fabsf"7.13M
||
Name == "fabsl"7.13M
||
Name == "sin"7.13M
||
178
7.13M
        
Name == "fmin"7.13M
||
Name == "fminf"7.13M
||
Name == "fminl"7.13M
||
179
7.13M
        
Name == "fmax"7.13M
||
Name == "fmaxf"7.13M
||
Name == "fmaxl"7.13M
||
180
7.13M
        
Name == "sinf"7.13M
||
Name == "sinl"7.13M
||
Name == "cos"7.13M
||
Name == "cosf"7.13M
||
181
7.13M
        
Name == "cosl"7.13M
||
Name == "sqrt"7.13M
||
Name == "sqrtf"7.13M
||
Name == "sqrtl"7.13M
)
182
126
      return false;
183
7.13M
184
7.13M
    // These are all likely to be optimized into something smaller.
185
7.13M
    if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
186
7.13M
        Name == "exp2l" || Name == "exp2f" || Name == "floor" ||
187
7.13M
        Name == "floorf" || Name == "ceil" || Name == "round" ||
188
7.13M
        Name == "ffs" || Name == "ffsl" || Name == "abs" || 
Name == "labs"7.13M
||
189
7.13M
        
Name == "llabs"7.13M
)
190
2
      return false;
191
7.13M
192
7.13M
    return true;
193
7.13M
  }
194
195
  bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
196
                                AssumptionCache &AC,
197
                                TargetLibraryInfo *LibInfo,
198
82
                                HardwareLoopInfo &HWLoopInfo) {
199
82
    return false;
200
82
  }
201
202
  void getUnrollingPreferences(Loop *, ScalarEvolution &,
203
635
                               TTI::UnrollingPreferences &) {}
204
205
12.8k
  bool isLegalAddImmediate(int64_t Imm) { return false; }
206
207
1.28k
  bool isLegalICmpImmediate(int64_t Imm) { return false; }
208
209
  bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
210
                             bool HasBaseReg, int64_t Scale,
211
116k
                             unsigned AddrSpace, Instruction *I = nullptr) {
212
116k
    // Guess that only reg and reg+reg addressing is allowed. This heuristic is
213
116k
    // taken from the implementation of LSR.
214
116k
    return !BaseGV && 
BaseOffset == 0111k
&&
(103k
Scale == 0103k
||
Scale == 1103k
);
215
116k
  }
216
217
4.25M
  bool isLSRCostLess(TTI::LSRCost &C1, TTI::LSRCost &C2) {
218
4.25M
    return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
219
4.25M
                    C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
220
4.25M
           std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
221
4.25M
                    C2.ScaleCost, C2.ImmCost, C2.SetupCost);
222
4.25M
  }
223
224
752k
  bool canMacroFuseCmp() { return false; }
225
226
  bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI,
227
                  DominatorTree *DT, AssumptionCache *AC,
228
103k
                  TargetLibraryInfo *LibInfo) {
229
103k
    return false;
230
103k
  }
231
232
11.9M
  bool shouldFavorPostInc() const { return false; }
233
234
7.17M
  bool shouldFavorBackedgeIndex(const Loop *L) const { return false; }
235
236
2.55k
  bool isLegalMaskedStore(Type *DataType) { return false; }
237
238
1.63k
  bool isLegalMaskedLoad(Type *DataType) { return false; }
239
240
0
  bool isLegalNTStore(Type *DataType, unsigned Alignment) {
241
0
    // By default, assume nontemporal memory stores are available for stores
242
0
    // that are aligned and have a size that is a power of 2.
243
0
    unsigned DataSize = DL.getTypeStoreSize(DataType);
244
0
    return Alignment >= DataSize && isPowerOf2_32(DataSize);
245
0
  }
246
247
1
  bool isLegalNTLoad(Type *DataType, unsigned Alignment) {
248
1
    // By default, assume nontemporal memory loads are available for loads that
249
1
    // are aligned and have a size that is a power of 2.
250
1
    unsigned DataSize = DL.getTypeStoreSize(DataType);
251
1
    return Alignment >= DataSize && 
isPowerOf2_32(DataSize)0
;
252
1
  }
253
254
9.59k
  bool isLegalMaskedScatter(Type *DataType) { return false; }
255
256
13.2k
  bool isLegalMaskedGather(Type *DataType) { return false; }
257
258
0
  bool isLegalMaskedCompressStore(Type *DataType) { return false; }
259
260
0
  bool isLegalMaskedExpandLoad(Type *DataType) { return false; }
261
262
1.34k
  bool hasDivRemOp(Type *DataType, bool IsSigned) { return false; }
263
264
257
  bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) { return false; }
265
266
42.5k
  bool prefersVectorizedAddressing() { return true; }
267
268
  int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
269
29.3k
                           bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
270
29.3k
    // Guess that all legal addressing mode are free.
271
29.3k
    if (isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
272
29.3k
                              Scale, AddrSpace))
273
29.3k
      return 0;
274
0
    return -1;
275
0
  }
276
277
4.66M
  bool LSRWithInstrQueries() { return false; }
278
279
17.7k
  bool isTruncateFree(Type *Ty1, Type *Ty2) { return false; }
280
281
76
  bool isProfitableToHoist(Instruction *I) { return true; }
282
283
0
  bool useAA() { return false; }
284
285
443
  bool isTypeLegal(Type *Ty) { return false; }
286
287
0
  unsigned getJumpBufAlignment() { return 0; }
288
289
0
  unsigned getJumpBufSize() { return 0; }
290
291
42
  bool shouldBuildLookupTables() { return true; }
292
74.6k
  bool shouldBuildLookupTablesForConstant(Constant *C) { return true; }
293
294
24.8k
  bool useColdCCForColdCall(Function &F) { return false; }
295
296
382
  unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) {
297
382
    return 0;
298
382
  }
299
300
  unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
301
347
                                            unsigned VF) { return 0; }
302
303
16.5k
  bool supportsEfficientVectorElementLoadStore() { return false; }
304
305
1.31k
  bool enableAggressiveInterleaving(bool LoopHasReductions) { return false; }
306
307
  TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize,
308
344k
                                                    bool IsZeroCmp) const {
309
344k
    return {};
310
344k
  }
311
312
571
  bool enableInterleavedAccessVectorization() { return false; }
313
314
19.5k
  bool enableMaskedInterleavedAccessVectorization() { return false; }
315
316
10.7k
  bool isFPVectorizationPotentiallyUnsafe() { return false; }
317
318
  bool allowsMisalignedMemoryAccesses(LLVMContext &Context,
319
                                      unsigned BitWidth,
320
                                      unsigned AddressSpace,
321
                                      unsigned Alignment,
322
0
                                      bool *Fast) { return false; }
323
324
3.90k
  TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) {
325
3.90k
    return TTI::PSK_Software;
326
3.90k
  }
327
328
4
  bool haveFastSqrt(Type *Ty) { return false; }
329
330
0
  bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) { return true; }
331
332
1
  unsigned getFPOpCost(Type *Ty) { return TargetTransformInfo::TCC_Basic; }
333
334
  int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
335
795
                            Type *Ty) {
336
795
    return 0;
337
795
  }
338
339
41
  unsigned getIntImmCost(const APInt &Imm, Type *Ty) { return TTI::TCC_Basic; }
340
341
  unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
342
47.1k
                         Type *Ty) {
343
47.1k
    return TTI::TCC_Free;
344
47.1k
  }
345
346
  unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
347
48.2k
                         Type *Ty) {
348
48.2k
    return TTI::TCC_Free;
349
48.2k
  }
350
351
67.6k
  unsigned getNumberOfRegisters(bool Vector) { return 8; }
352
353
1.27k
  unsigned getRegisterBitWidth(bool Vector) const { return 32; }
354
355
34.0k
  unsigned getMinVectorRegisterBitWidth() { return 128; }
356
357
19.8k
  bool shouldMaximizeVectorBandwidth(bool OptSize) const { return false; }
358
359
0
  unsigned getMinimumVF(unsigned ElemWidth) const { return 0; }
360
361
  bool
362
  shouldConsiderAddressTypePromotion(const Instruction &I,
363
75.4k
                                     bool &AllowPromotionWithoutCommonHeader) {
364
75.4k
    AllowPromotionWithoutCommonHeader = false;
365
75.4k
    return false;
366
75.4k
  }
367
368
0
  unsigned getCacheLineSize() { return 0; }
369
370
2
  llvm::Optional<unsigned> getCacheSize(TargetTransformInfo::CacheLevel Level) {
371
2
    switch (Level) {
372
2
    case TargetTransformInfo::CacheLevel::L1D:
373
1
      LLVM_FALLTHROUGH;
374
2
    case TargetTransformInfo::CacheLevel::L2D:
375
2
      return llvm::Optional<unsigned>();
376
0
    }
377
0
378
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
379
0
  }
380
381
  llvm::Optional<unsigned> getCacheAssociativity(
382
1
    TargetTransformInfo::CacheLevel Level) {
383
1
    switch (Level) {
384
1
    case TargetTransformInfo::CacheLevel::L1D:
385
0
      LLVM_FALLTHROUGH;
386
1
    case TargetTransformInfo::CacheLevel::L2D:
387
1
      return llvm::Optional<unsigned>();
388
0
    }
389
0
390
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
391
0
  }
392
393
0
  unsigned getPrefetchDistance() { return 0; }
394
395
29
  unsigned getMinPrefetchStride() { return 1; }
396
397
179
  unsigned getMaxPrefetchIterationsAhead() { return UINT_MAX; }
398
399
507
  unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
400
401
  unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
402
                                  TTI::OperandValueKind Opd1Info,
403
                                  TTI::OperandValueKind Opd2Info,
404
                                  TTI::OperandValueProperties Opd1PropInfo,
405
                                  TTI::OperandValueProperties Opd2PropInfo,
406
1.39k
                                  ArrayRef<const Value *> Args) {
407
1.39k
    return 1;
408
1.39k
  }
409
410
  unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Ty, int Index,
411
83
                          Type *SubTp) {
412
83
    return 1;
413
83
  }
414
415
  unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
416
426
                            const Instruction *I) { return 1; }
417
418
  unsigned getExtractWithExtendCost(unsigned Opcode, Type *Dst,
419
0
                                    VectorType *VecTy, unsigned Index) {
420
0
    return 1;
421
0
  }
422
423
1.49k
  unsigned getCFInstrCost(unsigned Opcode) { return 1; }
424
425
  unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
426
766
                              const Instruction *I) {
427
766
    return 1;
428
766
  }
429
430
105
  unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
431
105
    return 1;
432
105
  }
433
434
  unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
435
999
                           unsigned AddressSpace, const Instruction *I) {
436
999
    return 1;
437
999
  }
438
439
  unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
440
0
                                 unsigned AddressSpace) {
441
0
    return 1;
442
0
  }
443
444
  unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
445
                                  bool VariableMask,
446
0
                                  unsigned Alignment) {
447
0
    return 1;
448
0
  }
449
450
  unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
451
                                      unsigned Factor,
452
                                      ArrayRef<unsigned> Indices,
453
                                      unsigned Alignment, unsigned AddressSpace,
454
                                      bool UseMaskForCond = false,
455
37
                                      bool UseMaskForGaps = false) {
456
37
    return 1;
457
37
  }
458
459
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
460
                                 ArrayRef<Type *> Tys, FastMathFlags FMF,
461
0
                                 unsigned ScalarizationCostPassed) {
462
0
    return 1;
463
0
  }
464
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
465
157
            ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) {
466
157
    return 1;
467
157
  }
468
469
157
  unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys) {
470
157
    return 1;
471
157
  }
472
473
2.07k
  unsigned getNumberOfParts(Type *Tp) { return 0; }
474
475
  unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *,
476
304
                                     const SCEV *) {
477
304
    return 0;
478
304
  }
479
480
0
  unsigned getArithmeticReductionCost(unsigned, Type *, bool) { return 1; }
481
482
0
  unsigned getMinMaxReductionCost(Type *, Type *, bool, bool) { return 1; }
483
484
13.8k
  unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) { return 0; }
485
486
133k
  bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) {
487
133k
    return false;
488
133k
  }
489
490
1
  unsigned getAtomicMemIntrinsicMaxElementSize() const {
491
1
    // Note for overrides: You must ensure for all element unordered-atomic
492
1
    // memory intrinsics that all power-of-2 element sizes up to, and
493
1
    // including, the return value of this method have a corresponding
494
1
    // runtime lib call. These runtime lib call definitions can be found
495
1
    // in RuntimeLibcalls.h
496
1
    return 0;
497
1
  }
498
499
  Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
500
12
                                           Type *ExpectedType) {
501
12
    return nullptr;
502
12
  }
503
504
  Type *getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length,
505
15
                                  unsigned SrcAlign, unsigned DestAlign) const {
506
15
    return Type::getInt8Ty(Context);
507
15
  }
508
509
  void getMemcpyLoopResidualLoweringType(SmallVectorImpl<Type *> &OpsOut,
510
                                         LLVMContext &Context,
511
                                         unsigned RemainingBytes,
512
                                         unsigned SrcAlign,
513
0
                                         unsigned DestAlign) const {
514
0
    for (unsigned i = 0; i != RemainingBytes; ++i)
515
0
      OpsOut.push_back(Type::getInt8Ty(Context));
516
0
  }
517
518
  bool areInlineCompatible(const Function *Caller,
519
1.01k
                           const Function *Callee) const {
520
1.01k
    return (Caller->getFnAttribute("target-cpu") ==
521
1.01k
            Callee->getFnAttribute("target-cpu")) &&
522
1.01k
           (Caller->getFnAttribute("target-features") ==
523
1.01k
            Callee->getFnAttribute("target-features"));
524
1.01k
  }
525
526
  bool areFunctionArgsABICompatible(const Function *Caller, const Function *Callee,
527
27.8k
                                    SmallPtrSetImpl<Argument *> &Args) const {
528
27.8k
    return (Caller->getFnAttribute("target-cpu") ==
529
27.8k
            Callee->getFnAttribute("target-cpu")) &&
530
27.8k
           (Caller->getFnAttribute("target-features") ==
531
27.8k
            Callee->getFnAttribute("target-features"));
532
27.8k
  }
533
534
  bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty,
535
51.0k
                          const DataLayout &DL) const {
536
51.0k
    return false;
537
51.0k
  }
538
539
  bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty,
540
51.0k
                           const DataLayout &DL) const {
541
51.0k
    return false;
542
51.0k
  }
543
544
688
  unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const { return 128; }
545
546
52.1k
  bool isLegalToVectorizeLoad(LoadInst *LI) const { return true; }
547
548
20.0k
  bool isLegalToVectorizeStore(StoreInst *SI) const { return true; }
549
550
  bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes,
551
                                   unsigned Alignment,
552
41
                                   unsigned AddrSpace) const {
553
41
    return true;
554
41
  }
555
556
  bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
557
                                    unsigned Alignment,
558
16
                                    unsigned AddrSpace) const {
559
16
    return true;
560
16
  }
561
562
  unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize,
563
                               unsigned ChainSizeInBytes,
564
544
                               VectorType *VecTy) const {
565
544
    return VF;
566
544
  }
567
568
  unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize,
569
                                unsigned ChainSizeInBytes,
570
386
                                VectorType *VecTy) const {
571
386
    return VF;
572
386
  }
573
574
  bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
575
435
                             TTI::ReductionFlags Flags) const {
576
435
    return false;
577
435
  }
578
579
154k
  bool shouldExpandReduction(const IntrinsicInst *II) const {
580
154k
    return true;
581
154k
  }
582
583
3
  unsigned getGISelRematGlobalCost() const {
584
3
    return 1;
585
3
  }
586
587
protected:
588
  // Obtain the minimum required size to hold the value (without the sign)
589
  // In case of a vector it returns the min required size for one element.
590
48
  unsigned minRequiredElementSize(const Value* Val, bool &isSigned) {
591
48
    if (isa<ConstantDataVector>(Val) || 
isa<ConstantVector>(Val)36
) {
592
12
      const auto* VectorValue = cast<Constant>(Val);
593
12
594
12
      // In case of a vector need to pick the max between the min
595
12
      // required size for each element
596
12
      auto *VT = cast<VectorType>(Val->getType());
597
12
598
12
      // Assume unsigned elements
599
12
      isSigned = false;
600
12
601
12
      // The max required size is the total vector width divided by num
602
12
      // of elements in the vector
603
12
      unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
604
12
605
12
      unsigned MinRequiredSize = 0;
606
60
      for(unsigned i = 0, e = VT->getNumElements(); i < e; 
++i48
) {
607
48
        if (auto* IntElement =
608
48
              dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
609
48
          bool signedElement = IntElement->getValue().isNegative();
610
48
          // Get the element min required size.
611
48
          unsigned ElementMinRequiredSize =
612
48
            IntElement->getValue().getMinSignedBits() - 1;
613
48
          // In case one element is signed then all the vector is signed.
614
48
          isSigned |= signedElement;
615
48
          // Save the max required bit size between all the elements.
616
48
          MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
617
48
        }
618
0
        else {
619
0
          // not an int constant element
620
0
          return MaxRequiredSize;
621
0
        }
622
48
      }
623
12
      return MinRequiredSize;
624
36
    }
625
36
626
36
    if (const auto* CI = dyn_cast<ConstantInt>(Val)) {
627
0
      isSigned = CI->getValue().isNegative();
628
0
      return CI->getValue().getMinSignedBits() - 1;
629
0
    }
630
36
631
36
    if (const auto* Cast = dyn_cast<SExtInst>(Val)) {
632
6
      isSigned = true;
633
6
      return Cast->getSrcTy()->getScalarSizeInBits() - 1;
634
6
    }
635
30
636
30
    if (const auto* Cast = dyn_cast<ZExtInst>(Val)) {
637
6
      isSigned = false;
638
6
      return Cast->getSrcTy()->getScalarSizeInBits();
639
6
    }
640
24
641
24
    isSigned = false;
642
24
    return Val->getType()->getScalarSizeInBits();
643
24
  }
644
645
17.0k
  bool isStridedAccess(const SCEV *Ptr) {
646
17.0k
    return Ptr && 
isa<SCEVAddRecExpr>(Ptr)9.52k
;
647
17.0k
  }
648
649
  const SCEVConstant *getConstantStrideStep(ScalarEvolution *SE,
650
16.0k
                                            const SCEV *Ptr) {
651
16.0k
    if (!isStridedAccess(Ptr))
652
8.39k
      return nullptr;
653
7.69k
    const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
654
7.69k
    return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
655
7.69k
  }
656
657
  bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
658
15.3k
                                       int64_t MergeDistance) {
659
15.3k
    const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
660
15.3k
    if (!Step)
661
8.42k
      return false;
662
6.92k
    APInt StrideVal = Step->getAPInt();
663
6.92k
    if (StrideVal.getBitWidth() > 64)
664
0
      return false;
665
6.92k
    // FIXME: Need to take absolute value for negative stride case.
666
6.92k
    return StrideVal.getSExtValue() < MergeDistance;
667
6.92k
  }
668
};
669
670
/// CRTP base class for use as a mix-in that aids implementing
671
/// a TargetTransformInfo-compatible class.
672
template <typename T>
673
class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
674
private:
675
  typedef TargetTransformInfoImplBase BaseT;
676
677
protected:
678
16.6M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
11.9M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
37.9k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AMDGPUTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
551k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
513k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
656k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
30.6k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
648
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
19.6k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
97.9k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
23.8k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
107k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
33.7k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
2.43M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
1.89k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
18.6k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
678
95.5k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
679
680
public:
681
  using BaseT::getCallCost;
682
683
5.09M
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
5.09M
    assert(F && "A concrete function must be provided to this routine.");
685
5.09M
686
5.09M
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
5.09M
691
5.09M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
969k
      FunctionType *FTy = F->getFunctionType();
693
969k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
969k
      return static_cast<T *>(this)
695
969k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
969k
    }
697
4.12M
698
4.12M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
75
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
4.12M
                             // directly.
701
4.12M
702
4.12M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
4.12M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
4.08M
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
4.08M
    assert(F && "A concrete function must be provided to this routine.");
685
4.08M
686
4.08M
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
4.08M
691
4.08M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
755k
      FunctionType *FTy = F->getFunctionType();
693
755k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
755k
      return static_cast<T *>(this)
695
755k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
755k
    }
697
3.32M
698
3.32M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
16
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
3.32M
                             // directly.
701
3.32M
702
3.32M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
3.32M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
2
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
2
    assert(F && "A concrete function must be provided to this routine.");
685
2
686
2
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
2
691
2
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
2
      FunctionType *FTy = F->getFunctionType();
693
2
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
2
      return static_cast<T *>(this)
695
2
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
2
    }
697
0
698
0
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
0
                             // directly.
701
0
702
0
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
608
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
608
    assert(F && "A concrete function must be provided to this routine.");
685
608
686
608
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
608
691
608
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
537
      FunctionType *FTy = F->getFunctionType();
693
537
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
537
      return static_cast<T *>(this)
695
537
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
537
    }
697
71
698
71
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
71
                             // directly.
701
71
702
71
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
71
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
274k
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
274k
    assert(F && "A concrete function must be provided to this routine.");
685
274k
686
274k
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
274k
691
274k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
57.5k
      FunctionType *FTy = F->getFunctionType();
693
57.5k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
57.5k
      return static_cast<T *>(this)
695
57.5k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
57.5k
    }
697
217k
698
217k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
217k
                             // directly.
701
217k
702
217k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
217k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
28
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
28
    assert(F && "A concrete function must be provided to this routine.");
685
28
686
28
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
28
691
28
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
14
      FunctionType *FTy = F->getFunctionType();
693
14
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
14
      return static_cast<T *>(this)
695
14
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
14
    }
697
14
698
14
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
14
                             // directly.
701
14
702
14
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
14
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
5
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
5
    assert(F && "A concrete function must be provided to this routine.");
685
5
686
5
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
5
691
5
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
5
      FunctionType *FTy = F->getFunctionType();
693
5
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
5
      return static_cast<T *>(this)
695
5
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
5
    }
697
0
698
0
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
0
                             // directly.
701
0
702
0
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
20
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
20
    assert(F && "A concrete function must be provided to this routine.");
685
20
686
20
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
20
691
20
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
16
      FunctionType *FTy = F->getFunctionType();
693
16
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
16
      return static_cast<T *>(this)
695
16
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
16
    }
697
4
698
4
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
4
                             // directly.
701
4
702
4
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
4
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
223
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
223
    assert(F && "A concrete function must be provided to this routine.");
685
223
686
223
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
223
691
223
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
59
      FunctionType *FTy = F->getFunctionType();
693
59
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
59
      return static_cast<T *>(this)
695
59
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
59
    }
697
164
698
164
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
26
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
138
                             // directly.
701
138
702
138
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
138
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
52
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
52
    assert(F && "A concrete function must be provided to this routine.");
685
52
686
52
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
52
691
52
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
20
      FunctionType *FTy = F->getFunctionType();
693
20
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
20
      return static_cast<T *>(this)
695
20
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
20
    }
697
32
698
32
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
32
                             // directly.
701
32
702
32
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
32
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
727k
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
727k
    assert(F && "A concrete function must be provided to this routine.");
685
727k
686
727k
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
727k
691
727k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
155k
      FunctionType *FTy = F->getFunctionType();
693
155k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
155k
      return static_cast<T *>(this)
695
155k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
155k
    }
697
572k
698
572k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
29
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
572k
                             // directly.
701
572k
702
572k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
572k
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getCallCost(llvm::Function const*, int, llvm::User const*)
Line
Count
Source
683
7.12k
  unsigned getCallCost(const Function *F, int NumArgs, const User *U) {
684
7.12k
    assert(F && "A concrete function must be provided to this routine.");
685
7.12k
686
7.12k
    if (NumArgs < 0)
687
0
      // Set the argument number to the number of explicit arguments in the
688
0
      // function.
689
0
      NumArgs = F->arg_size();
690
7.12k
691
7.12k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
692
489
      FunctionType *FTy = F->getFunctionType();
693
489
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
694
489
      return static_cast<T *>(this)
695
489
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys, U);
696
489
    }
697
6.63k
698
6.63k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
699
4
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
700
6.63k
                             // directly.
701
6.63k
702
6.63k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs, U);
703
6.63k
  }
704
705
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments,
706
5.09M
                       const User *U) {
707
5.09M
    // Simply delegate to generic handling of the call.
708
5.09M
    // FIXME: We should use instsimplify or something else to catch calls which
709
5.09M
    // will constant fold with these arguments.
710
5.09M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
5.09M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
4.08M
                       const User *U) {
707
4.08M
    // Simply delegate to generic handling of the call.
708
4.08M
    // FIXME: We should use instsimplify or something else to catch calls which
709
4.08M
    // will constant fold with these arguments.
710
4.08M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
4.08M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
2
                       const User *U) {
707
2
    // Simply delegate to generic handling of the call.
708
2
    // FIXME: We should use instsimplify or something else to catch calls which
709
2
    // will constant fold with these arguments.
710
2
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
2
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
608
                       const User *U) {
707
608
    // Simply delegate to generic handling of the call.
708
608
    // FIXME: We should use instsimplify or something else to catch calls which
709
608
    // will constant fold with these arguments.
710
608
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
608
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
274k
                       const User *U) {
707
274k
    // Simply delegate to generic handling of the call.
708
274k
    // FIXME: We should use instsimplify or something else to catch calls which
709
274k
    // will constant fold with these arguments.
710
274k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
274k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
28
                       const User *U) {
707
28
    // Simply delegate to generic handling of the call.
708
28
    // FIXME: We should use instsimplify or something else to catch calls which
709
28
    // will constant fold with these arguments.
710
28
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
28
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
5
                       const User *U) {
707
5
    // Simply delegate to generic handling of the call.
708
5
    // FIXME: We should use instsimplify or something else to catch calls which
709
5
    // will constant fold with these arguments.
710
5
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
5
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
20
                       const User *U) {
707
20
    // Simply delegate to generic handling of the call.
708
20
    // FIXME: We should use instsimplify or something else to catch calls which
709
20
    // will constant fold with these arguments.
710
20
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
20
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
223
                       const User *U) {
707
223
    // Simply delegate to generic handling of the call.
708
223
    // FIXME: We should use instsimplify or something else to catch calls which
709
223
    // will constant fold with these arguments.
710
223
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
223
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
52
                       const User *U) {
707
52
    // Simply delegate to generic handling of the call.
708
52
    // FIXME: We should use instsimplify or something else to catch calls which
709
52
    // will constant fold with these arguments.
710
52
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
52
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
727k
                       const User *U) {
707
727k
    // Simply delegate to generic handling of the call.
708
727k
    // FIXME: We should use instsimplify or something else to catch calls which
709
727k
    // will constant fold with these arguments.
710
727k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
727k
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
706
7.12k
                       const User *U) {
707
7.12k
    // Simply delegate to generic handling of the call.
708
7.12k
    // FIXME: We should use instsimplify or something else to catch calls which
709
7.12k
    // will constant fold with these arguments.
710
7.12k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size(), U);
711
7.12k
  }
712
713
  using BaseT::getGEPCost;
714
715
  int getGEPCost(Type *PointeeType, const Value *Ptr,
716
6.07M
                 ArrayRef<const Value *> Operands) {
717
6.07M
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
6.07M
    // TODO: will remove this when pointers have an opaque type.
719
6.07M
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
6.07M
               PointeeType &&
721
6.07M
           "explicit pointee type doesn't match operand's pointee type");
722
6.07M
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
6.07M
    bool HasBaseReg = (BaseGV == nullptr);
724
6.07M
725
6.07M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
6.07M
    APInt BaseOffset(PtrSizeBits, 0);
727
6.07M
    int64_t Scale = 0;
728
6.07M
729
6.07M
    auto GTI = gep_type_begin(PointeeType, Operands);
730
6.07M
    Type *TargetType = nullptr;
731
6.07M
732
6.07M
    // Handle the case where the GEP instruction has a single operand,
733
6.07M
    // the basis, therefore TargetType is a nullptr.
734
6.07M
    if (Operands.empty())
735
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
736
6.07M
737
17.8M
    
for (auto I = Operands.begin(); 6.07M
I != Operands.end();
++I, ++GTI11.7M
) {
738
11.8M
      TargetType = GTI.getIndexedType();
739
11.8M
      // We assume that the cost of Scalar GEP with constant index and the
740
11.8M
      // cost of Vector GEP with splat constant index are the same.
741
11.8M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
11.8M
      if (!ConstIdx)
743
3.11M
        if (auto Splat = getSplatValue(*I))
744
2.02k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
11.8M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
4.39M
        // For structures the index is always splat or scalar constant
747
4.39M
        assert(ConstIdx && "Unexpected GEP index");
748
4.39M
        uint64_t Field = ConstIdx->getZExtValue();
749
4.39M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
7.49M
      } else {
751
7.49M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
7.49M
        if (ConstIdx) {
753
4.38M
          BaseOffset +=
754
4.38M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
4.38M
        } else {
756
3.11M
          // Needs scale register.
757
3.11M
          if (Scale != 0)
758
122k
            // No addressing mode takes two scale registers.
759
122k
            return TTI::TCC_Basic;
760
2.98M
          Scale = ElementSize;
761
2.98M
        }
762
7.49M
      }
763
11.8M
    }
764
6.07M
765
6.07M
    
if (5.95M
static_cast<T *>(this)->isLegalAddressingMode(
766
5.95M
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
5.95M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
5.95M
            Ptr->getType()->getPointerAddressSpace()))
769
4.64M
      return TTI::TCC_Free;
770
1.30M
    return TTI::TCC_Basic;
771
1.30M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
5.47M
                 ArrayRef<const Value *> Operands) {
717
5.47M
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
5.47M
    // TODO: will remove this when pointers have an opaque type.
719
5.47M
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
5.47M
               PointeeType &&
721
5.47M
           "explicit pointee type doesn't match operand's pointee type");
722
5.47M
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
5.47M
    bool HasBaseReg = (BaseGV == nullptr);
724
5.47M
725
5.47M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
5.47M
    APInt BaseOffset(PtrSizeBits, 0);
727
5.47M
    int64_t Scale = 0;
728
5.47M
729
5.47M
    auto GTI = gep_type_begin(PointeeType, Operands);
730
5.47M
    Type *TargetType = nullptr;
731
5.47M
732
5.47M
    // Handle the case where the GEP instruction has a single operand,
733
5.47M
    // the basis, therefore TargetType is a nullptr.
734
5.47M
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
5.47M
737
15.8M
    
for (auto I = Operands.begin(); 5.47M
I != Operands.end();
++I, ++GTI10.3M
) {
738
10.4M
      TargetType = GTI.getIndexedType();
739
10.4M
      // We assume that the cost of Scalar GEP with constant index and the
740
10.4M
      // cost of Vector GEP with splat constant index are the same.
741
10.4M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
10.4M
      if (!ConstIdx)
743
2.80M
        if (auto Splat = getSplatValue(*I))
744
18
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
10.4M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
3.76M
        // For structures the index is always splat or scalar constant
747
3.76M
        assert(ConstIdx && "Unexpected GEP index");
748
3.76M
        uint64_t Field = ConstIdx->getZExtValue();
749
3.76M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
6.72M
      } else {
751
6.72M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
6.72M
        if (ConstIdx) {
753
3.92M
          BaseOffset +=
754
3.92M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
3.92M
        } else {
756
2.80M
          // Needs scale register.
757
2.80M
          if (Scale != 0)
758
110k
            // No addressing mode takes two scale registers.
759
110k
            return TTI::TCC_Basic;
760
2.69M
          Scale = ElementSize;
761
2.69M
        }
762
6.72M
      }
763
10.4M
    }
764
5.47M
765
5.47M
    
if (5.36M
static_cast<T *>(this)->isLegalAddressingMode(
766
5.36M
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
5.36M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
5.36M
            Ptr->getType()->getPointerAddressSpace()))
769
4.21M
      return TTI::TCC_Free;
770
1.14M
    return TTI::TCC_Basic;
771
1.14M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
1.84k
                 ArrayRef<const Value *> Operands) {
717
1.84k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
1.84k
    // TODO: will remove this when pointers have an opaque type.
719
1.84k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
1.84k
               PointeeType &&
721
1.84k
           "explicit pointee type doesn't match operand's pointee type");
722
1.84k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
1.84k
    bool HasBaseReg = (BaseGV == nullptr);
724
1.84k
725
1.84k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
1.84k
    APInt BaseOffset(PtrSizeBits, 0);
727
1.84k
    int64_t Scale = 0;
728
1.84k
729
1.84k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
1.84k
    Type *TargetType = nullptr;
731
1.84k
732
1.84k
    // Handle the case where the GEP instruction has a single operand,
733
1.84k
    // the basis, therefore TargetType is a nullptr.
734
1.84k
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
1.84k
737
4.62k
    
for (auto I = Operands.begin(); 1.84k
I != Operands.end();
++I, ++GTI2.78k
) {
738
2.78k
      TargetType = GTI.getIndexedType();
739
2.78k
      // We assume that the cost of Scalar GEP with constant index and the
740
2.78k
      // cost of Vector GEP with splat constant index are the same.
741
2.78k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
2.78k
      if (!ConstIdx)
743
1.03k
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
2.78k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
112
        // For structures the index is always splat or scalar constant
747
112
        assert(ConstIdx && "Unexpected GEP index");
748
112
        uint64_t Field = ConstIdx->getZExtValue();
749
112
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
2.66k
      } else {
751
2.66k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
2.66k
        if (ConstIdx) {
753
1.63k
          BaseOffset +=
754
1.63k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
1.63k
        } else {
756
1.03k
          // Needs scale register.
757
1.03k
          if (Scale != 0)
758
0
            // No addressing mode takes two scale registers.
759
0
            return TTI::TCC_Basic;
760
1.03k
          Scale = ElementSize;
761
1.03k
        }
762
2.66k
      }
763
2.78k
    }
764
1.84k
765
1.84k
    if (static_cast<T *>(this)->isLegalAddressingMode(
766
1.84k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
1.84k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
1.84k
            Ptr->getType()->getPointerAddressSpace()))
769
892
      return TTI::TCC_Free;
770
948
    return TTI::TCC_Basic;
771
948
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
38.1k
                 ArrayRef<const Value *> Operands) {
717
38.1k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
38.1k
    // TODO: will remove this when pointers have an opaque type.
719
38.1k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
38.1k
               PointeeType &&
721
38.1k
           "explicit pointee type doesn't match operand's pointee type");
722
38.1k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
38.1k
    bool HasBaseReg = (BaseGV == nullptr);
724
38.1k
725
38.1k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
38.1k
    APInt BaseOffset(PtrSizeBits, 0);
727
38.1k
    int64_t Scale = 0;
728
38.1k
729
38.1k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
38.1k
    Type *TargetType = nullptr;
731
38.1k
732
38.1k
    // Handle the case where the GEP instruction has a single operand,
733
38.1k
    // the basis, therefore TargetType is a nullptr.
734
38.1k
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
38.1k
737
81.1k
    
for (auto I = Operands.begin(); 38.1k
I != Operands.end();
++I, ++GTI43.0k
) {
738
43.1k
      TargetType = GTI.getIndexedType();
739
43.1k
      // We assume that the cost of Scalar GEP with constant index and the
740
43.1k
      // cost of Vector GEP with splat constant index are the same.
741
43.1k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
43.1k
      if (!ConstIdx)
743
22.0k
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
43.1k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
450
        // For structures the index is always splat or scalar constant
747
450
        assert(ConstIdx && "Unexpected GEP index");
748
450
        uint64_t Field = ConstIdx->getZExtValue();
749
450
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
42.7k
      } else {
751
42.7k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
42.7k
        if (ConstIdx) {
753
20.6k
          BaseOffset +=
754
20.6k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
22.0k
        } else {
756
22.0k
          // Needs scale register.
757
22.0k
          if (Scale != 0)
758
155
            // No addressing mode takes two scale registers.
759
155
            return TTI::TCC_Basic;
760
21.9k
          Scale = ElementSize;
761
21.9k
        }
762
42.7k
      }
763
43.1k
    }
764
38.1k
765
38.1k
    
if (37.9k
static_cast<T *>(this)->isLegalAddressingMode(
766
37.9k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
37.9k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
37.9k
            Ptr->getType()->getPointerAddressSpace()))
769
11.7k
      return TTI::TCC_Free;
770
26.1k
    return TTI::TCC_Basic;
771
26.1k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
92.2k
                 ArrayRef<const Value *> Operands) {
717
92.2k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
92.2k
    // TODO: will remove this when pointers have an opaque type.
719
92.2k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
92.2k
               PointeeType &&
721
92.2k
           "explicit pointee type doesn't match operand's pointee type");
722
92.2k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
92.2k
    bool HasBaseReg = (BaseGV == nullptr);
724
92.2k
725
92.2k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
92.2k
    APInt BaseOffset(PtrSizeBits, 0);
727
92.2k
    int64_t Scale = 0;
728
92.2k
729
92.2k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
92.2k
    Type *TargetType = nullptr;
731
92.2k
732
92.2k
    // Handle the case where the GEP instruction has a single operand,
733
92.2k
    // the basis, therefore TargetType is a nullptr.
734
92.2k
    if (Operands.empty())
735
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
736
92.2k
737
297k
    
for (auto I = Operands.begin(); 92.2k
I != Operands.end();
++I, ++GTI205k
) {
738
210k
      TargetType = GTI.getIndexedType();
739
210k
      // We assume that the cost of Scalar GEP with constant index and the
740
210k
      // cost of Vector GEP with splat constant index are the same.
741
210k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
210k
      if (!ConstIdx)
743
62.6k
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
210k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
78.8k
        // For structures the index is always splat or scalar constant
747
78.8k
        assert(ConstIdx && "Unexpected GEP index");
748
78.8k
        uint64_t Field = ConstIdx->getZExtValue();
749
78.8k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
131k
      } else {
751
131k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
131k
        if (ConstIdx) {
753
68.6k
          BaseOffset +=
754
68.6k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
68.6k
        } else {
756
62.6k
          // Needs scale register.
757
62.6k
          if (Scale != 0)
758
4.42k
            // No addressing mode takes two scale registers.
759
4.42k
            return TTI::TCC_Basic;
760
58.1k
          Scale = ElementSize;
761
58.1k
        }
762
131k
      }
763
210k
    }
764
92.2k
765
92.2k
    
if (87.8k
static_cast<T *>(this)->isLegalAddressingMode(
766
87.8k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
87.8k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
87.8k
            Ptr->getType()->getPointerAddressSpace()))
769
56.6k
      return TTI::TCC_Free;
770
31.2k
    return TTI::TCC_Basic;
771
31.2k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
29
                 ArrayRef<const Value *> Operands) {
717
29
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
29
    // TODO: will remove this when pointers have an opaque type.
719
29
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
29
               PointeeType &&
721
29
           "explicit pointee type doesn't match operand's pointee type");
722
29
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
29
    bool HasBaseReg = (BaseGV == nullptr);
724
29
725
29
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
29
    APInt BaseOffset(PtrSizeBits, 0);
727
29
    int64_t Scale = 0;
728
29
729
29
    auto GTI = gep_type_begin(PointeeType, Operands);
730
29
    Type *TargetType = nullptr;
731
29
732
29
    // Handle the case where the GEP instruction has a single operand,
733
29
    // the basis, therefore TargetType is a nullptr.
734
29
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
29
737
94
    
for (auto I = Operands.begin(); 29
I != Operands.end();
++I, ++GTI65
) {
738
65
      TargetType = GTI.getIndexedType();
739
65
      // We assume that the cost of Scalar GEP with constant index and the
740
65
      // cost of Vector GEP with splat constant index are the same.
741
65
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
65
      if (!ConstIdx)
743
5
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
65
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
18
        // For structures the index is always splat or scalar constant
747
18
        assert(ConstIdx && "Unexpected GEP index");
748
18
        uint64_t Field = ConstIdx->getZExtValue();
749
18
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
47
      } else {
751
47
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
47
        if (ConstIdx) {
753
42
          BaseOffset +=
754
42
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
42
        } else {
756
5
          // Needs scale register.
757
5
          if (Scale != 0)
758
0
            // No addressing mode takes two scale registers.
759
0
            return TTI::TCC_Basic;
760
5
          Scale = ElementSize;
761
5
        }
762
47
      }
763
65
    }
764
29
765
29
    if (static_cast<T *>(this)->isLegalAddressingMode(
766
29
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
29
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
29
            Ptr->getType()->getPointerAddressSpace()))
769
24
      return TTI::TCC_Free;
770
5
    return TTI::TCC_Basic;
771
5
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
335
                 ArrayRef<const Value *> Operands) {
717
335
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
335
    // TODO: will remove this when pointers have an opaque type.
719
335
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
335
               PointeeType &&
721
335
           "explicit pointee type doesn't match operand's pointee type");
722
335
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
335
    bool HasBaseReg = (BaseGV == nullptr);
724
335
725
335
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
335
    APInt BaseOffset(PtrSizeBits, 0);
727
335
    int64_t Scale = 0;
728
335
729
335
    auto GTI = gep_type_begin(PointeeType, Operands);
730
335
    Type *TargetType = nullptr;
731
335
732
335
    // Handle the case where the GEP instruction has a single operand,
733
335
    // the basis, therefore TargetType is a nullptr.
734
335
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
335
737
768
    
for (auto I = Operands.begin(); 335
I != Operands.end();
++I, ++GTI433
) {
738
505
      TargetType = GTI.getIndexedType();
739
505
      // We assume that the cost of Scalar GEP with constant index and the
740
505
      // cost of Vector GEP with splat constant index are the same.
741
505
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
505
      if (!ConstIdx)
743
276
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
505
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
10
        // For structures the index is always splat or scalar constant
747
10
        assert(ConstIdx && "Unexpected GEP index");
748
10
        uint64_t Field = ConstIdx->getZExtValue();
749
10
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
495
      } else {
751
495
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
495
        if (ConstIdx) {
753
219
          BaseOffset +=
754
219
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
276
        } else {
756
276
          // Needs scale register.
757
276
          if (Scale != 0)
758
72
            // No addressing mode takes two scale registers.
759
72
            return TTI::TCC_Basic;
760
204
          Scale = ElementSize;
761
204
        }
762
495
      }
763
505
    }
764
335
765
335
    
if (263
static_cast<T *>(this)->isLegalAddressingMode(
766
263
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
263
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
263
            Ptr->getType()->getPointerAddressSpace()))
769
126
      return TTI::TCC_Free;
770
137
    return TTI::TCC_Basic;
771
137
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
1.08k
                 ArrayRef<const Value *> Operands) {
717
1.08k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
1.08k
    // TODO: will remove this when pointers have an opaque type.
719
1.08k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
1.08k
               PointeeType &&
721
1.08k
           "explicit pointee type doesn't match operand's pointee type");
722
1.08k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
1.08k
    bool HasBaseReg = (BaseGV == nullptr);
724
1.08k
725
1.08k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
1.08k
    APInt BaseOffset(PtrSizeBits, 0);
727
1.08k
    int64_t Scale = 0;
728
1.08k
729
1.08k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
1.08k
    Type *TargetType = nullptr;
731
1.08k
732
1.08k
    // Handle the case where the GEP instruction has a single operand,
733
1.08k
    // the basis, therefore TargetType is a nullptr.
734
1.08k
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
1.08k
737
2.36k
    
for (auto I = Operands.begin(); 1.08k
I != Operands.end();
++I, ++GTI1.27k
) {
738
1.27k
      TargetType = GTI.getIndexedType();
739
1.27k
      // We assume that the cost of Scalar GEP with constant index and the
740
1.27k
      // cost of Vector GEP with splat constant index are the same.
741
1.27k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
1.27k
      if (!ConstIdx)
743
573
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
1.27k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
81
        // For structures the index is always splat or scalar constant
747
81
        assert(ConstIdx && "Unexpected GEP index");
748
81
        uint64_t Field = ConstIdx->getZExtValue();
749
81
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
1.19k
      } else {
751
1.19k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
1.19k
        if (ConstIdx) {
753
624
          BaseOffset +=
754
624
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
624
        } else {
756
573
          // Needs scale register.
757
573
          if (Scale != 0)
758
6
            // No addressing mode takes two scale registers.
759
6
            return TTI::TCC_Basic;
760
567
          Scale = ElementSize;
761
567
        }
762
1.19k
      }
763
1.27k
    }
764
1.08k
765
1.08k
    
if (1.08k
static_cast<T *>(this)->isLegalAddressingMode(
766
1.08k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
1.08k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
1.08k
            Ptr->getType()->getPointerAddressSpace()))
769
728
      return TTI::TCC_Free;
770
354
    return TTI::TCC_Basic;
771
354
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
132
                 ArrayRef<const Value *> Operands) {
717
132
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
132
    // TODO: will remove this when pointers have an opaque type.
719
132
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
132
               PointeeType &&
721
132
           "explicit pointee type doesn't match operand's pointee type");
722
132
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
132
    bool HasBaseReg = (BaseGV == nullptr);
724
132
725
132
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
132
    APInt BaseOffset(PtrSizeBits, 0);
727
132
    int64_t Scale = 0;
728
132
729
132
    auto GTI = gep_type_begin(PointeeType, Operands);
730
132
    Type *TargetType = nullptr;
731
132
732
132
    // Handle the case where the GEP instruction has a single operand,
733
132
    // the basis, therefore TargetType is a nullptr.
734
132
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
132
737
264
    
for (auto I = Operands.begin(); 132
I != Operands.end();
++I, ++GTI132
) {
738
132
      TargetType = GTI.getIndexedType();
739
132
      // We assume that the cost of Scalar GEP with constant index and the
740
132
      // cost of Vector GEP with splat constant index are the same.
741
132
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
132
      if (!ConstIdx)
743
12
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
132
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
0
        // For structures the index is always splat or scalar constant
747
0
        assert(ConstIdx && "Unexpected GEP index");
748
0
        uint64_t Field = ConstIdx->getZExtValue();
749
0
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
132
      } else {
751
132
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
132
        if (ConstIdx) {
753
120
          BaseOffset +=
754
120
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
120
        } else {
756
12
          // Needs scale register.
757
12
          if (Scale != 0)
758
0
            // No addressing mode takes two scale registers.
759
0
            return TTI::TCC_Basic;
760
12
          Scale = ElementSize;
761
12
        }
762
132
      }
763
132
    }
764
132
765
132
    if (static_cast<T *>(this)->isLegalAddressingMode(
766
132
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
132
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
132
            Ptr->getType()->getPointerAddressSpace()))
769
88
      return TTI::TCC_Free;
770
44
    return TTI::TCC_Basic;
771
44
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
75
                 ArrayRef<const Value *> Operands) {
717
75
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
75
    // TODO: will remove this when pointers have an opaque type.
719
75
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
75
               PointeeType &&
721
75
           "explicit pointee type doesn't match operand's pointee type");
722
75
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
75
    bool HasBaseReg = (BaseGV == nullptr);
724
75
725
75
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
75
    APInt BaseOffset(PtrSizeBits, 0);
727
75
    int64_t Scale = 0;
728
75
729
75
    auto GTI = gep_type_begin(PointeeType, Operands);
730
75
    Type *TargetType = nullptr;
731
75
732
75
    // Handle the case where the GEP instruction has a single operand,
733
75
    // the basis, therefore TargetType is a nullptr.
734
75
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
75
737
211
    
for (auto I = Operands.begin(); 75
I != Operands.end();
++I, ++GTI136
) {
738
136
      TargetType = GTI.getIndexedType();
739
136
      // We assume that the cost of Scalar GEP with constant index and the
740
136
      // cost of Vector GEP with splat constant index are the same.
741
136
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
136
      if (!ConstIdx)
743
54
        if (auto Splat = getSplatValue(*I))
744
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
136
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
39
        // For structures the index is always splat or scalar constant
747
39
        assert(ConstIdx && "Unexpected GEP index");
748
39
        uint64_t Field = ConstIdx->getZExtValue();
749
39
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
97
      } else {
751
97
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
97
        if (ConstIdx) {
753
43
          BaseOffset +=
754
43
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
54
        } else {
756
54
          // Needs scale register.
757
54
          if (Scale != 0)
758
0
            // No addressing mode takes two scale registers.
759
0
            return TTI::TCC_Basic;
760
54
          Scale = ElementSize;
761
54
        }
762
97
      }
763
136
    }
764
75
765
75
    if (static_cast<T *>(this)->isLegalAddressingMode(
766
75
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
75
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
75
            Ptr->getType()->getPointerAddressSpace()))
769
21
      return TTI::TCC_Free;
770
54
    return TTI::TCC_Basic;
771
54
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
461k
                 ArrayRef<const Value *> Operands) {
717
461k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
461k
    // TODO: will remove this when pointers have an opaque type.
719
461k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
461k
               PointeeType &&
721
461k
           "explicit pointee type doesn't match operand's pointee type");
722
461k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
461k
    bool HasBaseReg = (BaseGV == nullptr);
724
461k
725
461k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
461k
    APInt BaseOffset(PtrSizeBits, 0);
727
461k
    int64_t Scale = 0;
728
461k
729
461k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
461k
    Type *TargetType = nullptr;
731
461k
732
461k
    // Handle the case where the GEP instruction has a single operand,
733
461k
    // the basis, therefore TargetType is a nullptr.
734
461k
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
461k
737
1.58M
    
for (auto I = Operands.begin(); 461k
I != Operands.end();
++I, ++GTI1.11M
) {
738
1.12M
      TargetType = GTI.getIndexedType();
739
1.12M
      // We assume that the cost of Scalar GEP with constant index and the
740
1.12M
      // cost of Vector GEP with splat constant index are the same.
741
1.12M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
1.12M
      if (!ConstIdx)
743
213k
        if (auto Splat = getSplatValue(*I))
744
4
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
1.12M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
547k
        // For structures the index is always splat or scalar constant
747
547k
        assert(ConstIdx && "Unexpected GEP index");
748
547k
        uint64_t Field = ConstIdx->getZExtValue();
749
547k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
578k
      } else {
751
578k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
578k
        if (ConstIdx) {
753
365k
          BaseOffset +=
754
365k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
365k
        } else {
756
213k
          // Needs scale register.
757
213k
          if (Scale != 0)
758
7.67k
            // No addressing mode takes two scale registers.
759
7.67k
            return TTI::TCC_Basic;
760
205k
          Scale = ElementSize;
761
205k
        }
762
578k
      }
763
1.12M
    }
764
461k
765
461k
    
if (454k
static_cast<T *>(this)->isLegalAddressingMode(
766
454k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
454k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
454k
            Ptr->getType()->getPointerAddressSpace()))
769
360k
      return TTI::TCC_Free;
770
93.1k
    return TTI::TCC_Basic;
771
93.1k
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
716
9.88k
                 ArrayRef<const Value *> Operands) {
717
9.88k
    assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
718
9.88k
    // TODO: will remove this when pointers have an opaque type.
719
9.88k
    assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
720
9.88k
               PointeeType &&
721
9.88k
           "explicit pointee type doesn't match operand's pointee type");
722
9.88k
    auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
723
9.88k
    bool HasBaseReg = (BaseGV == nullptr);
724
9.88k
725
9.88k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
726
9.88k
    APInt BaseOffset(PtrSizeBits, 0);
727
9.88k
    int64_t Scale = 0;
728
9.88k
729
9.88k
    auto GTI = gep_type_begin(PointeeType, Operands);
730
9.88k
    Type *TargetType = nullptr;
731
9.88k
732
9.88k
    // Handle the case where the GEP instruction has a single operand,
733
9.88k
    // the basis, therefore TargetType is a nullptr.
734
9.88k
    if (Operands.empty())
735
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
736
9.88k
737
24.6k
    
for (auto I = Operands.begin(); 9.88k
I != Operands.end();
++I, ++GTI14.7k
) {
738
14.8k
      TargetType = GTI.getIndexedType();
739
14.8k
      // We assume that the cost of Scalar GEP with constant index and the
740
14.8k
      // cost of Vector GEP with splat constant index are the same.
741
14.8k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
742
14.8k
      if (!ConstIdx)
743
9.62k
        if (auto Splat = getSplatValue(*I))
744
2.00k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
745
14.8k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
746
241
        // For structures the index is always splat or scalar constant
747
241
        assert(ConstIdx && "Unexpected GEP index");
748
241
        uint64_t Field = ConstIdx->getZExtValue();
749
241
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
750
14.5k
      } else {
751
14.5k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
752
14.5k
        if (ConstIdx) {
753
6.93k
          BaseOffset +=
754
6.93k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
755
7.62k
        } else {
756
7.62k
          // Needs scale register.
757
7.62k
          if (Scale != 0)
758
22
            // No addressing mode takes two scale registers.
759
22
            return TTI::TCC_Basic;
760
7.60k
          Scale = ElementSize;
761
7.60k
        }
762
14.5k
      }
763
14.8k
    }
764
9.88k
765
9.88k
    
if (9.86k
static_cast<T *>(this)->isLegalAddressingMode(
766
9.86k
            TargetType, const_cast<GlobalValue *>(BaseGV),
767
9.86k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
768
9.86k
            Ptr->getType()->getPointerAddressSpace()))
769
40
      return TTI::TCC_Free;
770
9.82k
    return TTI::TCC_Basic;
771
9.82k
  }
772
773
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
774
952k
                            ArrayRef<Type *> ParamTys, const User *U) {
775
952k
    switch (IID) {
776
952k
    default:
777
183k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
183k
      // Model them as having a basic instruction cost.
779
183k
      return TTI::TCC_Basic;
780
952k
781
952k
    // TODO: other libc intrinsics.
782
952k
    case Intrinsic::memcpy:
783
46.2k
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
952k
785
952k
    case Intrinsic::annotation:
786
722k
    case Intrinsic::assume:
787
722k
    case Intrinsic::sideeffect:
788
722k
    case Intrinsic::dbg_declare:
789
722k
    case Intrinsic::dbg_value:
790
722k
    case Intrinsic::dbg_label:
791
722k
    case Intrinsic::invariant_start:
792
722k
    case Intrinsic::invariant_end:
793
722k
    case Intrinsic::launder_invariant_group:
794
722k
    case Intrinsic::strip_invariant_group:
795
722k
    case Intrinsic::is_constant:
796
722k
    case Intrinsic::lifetime_start:
797
722k
    case Intrinsic::lifetime_end:
798
722k
    case Intrinsic::objectsize:
799
722k
    case Intrinsic::ptr_annotation:
800
722k
    case Intrinsic::var_annotation:
801
722k
    case Intrinsic::experimental_gc_result:
802
722k
    case Intrinsic::experimental_gc_relocate:
803
722k
    case Intrinsic::coro_alloc:
804
722k
    case Intrinsic::coro_begin:
805
722k
    case Intrinsic::coro_free:
806
722k
    case Intrinsic::coro_end:
807
722k
    case Intrinsic::coro_frame:
808
722k
    case Intrinsic::coro_size:
809
722k
    case Intrinsic::coro_suspend:
810
722k
    case Intrinsic::coro_param:
811
722k
    case Intrinsic::coro_subfn_addr:
812
722k
      // These intrinsics don't actually represent code after lowering.
813
722k
      return TTI::TCC_Free;
814
952k
    }
815
952k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
753k
                            ArrayRef<Type *> ParamTys, const User *U) {
775
753k
    switch (IID) {
776
753k
    default:
777
138k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
138k
      // Model them as having a basic instruction cost.
779
138k
      return TTI::TCC_Basic;
780
753k
781
753k
    // TODO: other libc intrinsics.
782
753k
    case Intrinsic::memcpy:
783
37.2k
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
753k
785
753k
    case Intrinsic::annotation:
786
577k
    case Intrinsic::assume:
787
577k
    case Intrinsic::sideeffect:
788
577k
    case Intrinsic::dbg_declare:
789
577k
    case Intrinsic::dbg_value:
790
577k
    case Intrinsic::dbg_label:
791
577k
    case Intrinsic::invariant_start:
792
577k
    case Intrinsic::invariant_end:
793
577k
    case Intrinsic::launder_invariant_group:
794
577k
    case Intrinsic::strip_invariant_group:
795
577k
    case Intrinsic::is_constant:
796
577k
    case Intrinsic::lifetime_start:
797
577k
    case Intrinsic::lifetime_end:
798
577k
    case Intrinsic::objectsize:
799
577k
    case Intrinsic::ptr_annotation:
800
577k
    case Intrinsic::var_annotation:
801
577k
    case Intrinsic::experimental_gc_result:
802
577k
    case Intrinsic::experimental_gc_relocate:
803
577k
    case Intrinsic::coro_alloc:
804
577k
    case Intrinsic::coro_begin:
805
577k
    case Intrinsic::coro_free:
806
577k
    case Intrinsic::coro_end:
807
577k
    case Intrinsic::coro_frame:
808
577k
    case Intrinsic::coro_size:
809
577k
    case Intrinsic::coro_suspend:
810
577k
    case Intrinsic::coro_param:
811
577k
    case Intrinsic::coro_subfn_addr:
812
577k
      // These intrinsics don't actually represent code after lowering.
813
577k
      return TTI::TCC_Free;
814
753k
    }
815
753k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
2
                            ArrayRef<Type *> ParamTys, const User *U) {
775
2
    switch (IID) {
776
2
    default:
777
2
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
2
      // Model them as having a basic instruction cost.
779
2
      return TTI::TCC_Basic;
780
2
781
2
    // TODO: other libc intrinsics.
782
2
    case Intrinsic::memcpy:
783
0
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
2
785
2
    case Intrinsic::annotation:
786
0
    case Intrinsic::assume:
787
0
    case Intrinsic::sideeffect:
788
0
    case Intrinsic::dbg_declare:
789
0
    case Intrinsic::dbg_value:
790
0
    case Intrinsic::dbg_label:
791
0
    case Intrinsic::invariant_start:
792
0
    case Intrinsic::invariant_end:
793
0
    case Intrinsic::launder_invariant_group:
794
0
    case Intrinsic::strip_invariant_group:
795
0
    case Intrinsic::is_constant:
796
0
    case Intrinsic::lifetime_start:
797
0
    case Intrinsic::lifetime_end:
798
0
    case Intrinsic::objectsize:
799
0
    case Intrinsic::ptr_annotation:
800
0
    case Intrinsic::var_annotation:
801
0
    case Intrinsic::experimental_gc_result:
802
0
    case Intrinsic::experimental_gc_relocate:
803
0
    case Intrinsic::coro_alloc:
804
0
    case Intrinsic::coro_begin:
805
0
    case Intrinsic::coro_free:
806
0
    case Intrinsic::coro_end:
807
0
    case Intrinsic::coro_frame:
808
0
    case Intrinsic::coro_size:
809
0
    case Intrinsic::coro_suspend:
810
0
    case Intrinsic::coro_param:
811
0
    case Intrinsic::coro_subfn_addr:
812
0
      // These intrinsics don't actually represent code after lowering.
813
0
      return TTI::TCC_Free;
814
2
    }
815
2
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
513
                            ArrayRef<Type *> ParamTys, const User *U) {
775
513
    switch (IID) {
776
513
    default:
777
437
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
437
      // Model them as having a basic instruction cost.
779
437
      return TTI::TCC_Basic;
780
513
781
513
    // TODO: other libc intrinsics.
782
513
    case Intrinsic::memcpy:
783
0
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
513
785
513
    case Intrinsic::annotation:
786
76
    case Intrinsic::assume:
787
76
    case Intrinsic::sideeffect:
788
76
    case Intrinsic::dbg_declare:
789
76
    case Intrinsic::dbg_value:
790
76
    case Intrinsic::dbg_label:
791
76
    case Intrinsic::invariant_start:
792
76
    case Intrinsic::invariant_end:
793
76
    case Intrinsic::launder_invariant_group:
794
76
    case Intrinsic::strip_invariant_group:
795
76
    case Intrinsic::is_constant:
796
76
    case Intrinsic::lifetime_start:
797
76
    case Intrinsic::lifetime_end:
798
76
    case Intrinsic::objectsize:
799
76
    case Intrinsic::ptr_annotation:
800
76
    case Intrinsic::var_annotation:
801
76
    case Intrinsic::experimental_gc_result:
802
76
    case Intrinsic::experimental_gc_relocate:
803
76
    case Intrinsic::coro_alloc:
804
76
    case Intrinsic::coro_begin:
805
76
    case Intrinsic::coro_free:
806
76
    case Intrinsic::coro_end:
807
76
    case Intrinsic::coro_frame:
808
76
    case Intrinsic::coro_size:
809
76
    case Intrinsic::coro_suspend:
810
76
    case Intrinsic::coro_param:
811
76
    case Intrinsic::coro_subfn_addr:
812
76
      // These intrinsics don't actually represent code after lowering.
813
76
      return TTI::TCC_Free;
814
513
    }
815
513
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
51.2k
                            ArrayRef<Type *> ParamTys, const User *U) {
775
51.2k
    switch (IID) {
776
51.2k
    default:
777
15.9k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
15.9k
      // Model them as having a basic instruction cost.
779
15.9k
      return TTI::TCC_Basic;
780
51.2k
781
51.2k
    // TODO: other libc intrinsics.
782
51.2k
    case Intrinsic::memcpy:
783
1.55k
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
51.2k
785
51.2k
    case Intrinsic::annotation:
786
33.7k
    case Intrinsic::assume:
787
33.7k
    case Intrinsic::sideeffect:
788
33.7k
    case Intrinsic::dbg_declare:
789
33.7k
    case Intrinsic::dbg_value:
790
33.7k
    case Intrinsic::dbg_label:
791
33.7k
    case Intrinsic::invariant_start:
792
33.7k
    case Intrinsic::invariant_end:
793
33.7k
    case Intrinsic::launder_invariant_group:
794
33.7k
    case Intrinsic::strip_invariant_group:
795
33.7k
    case Intrinsic::is_constant:
796
33.7k
    case Intrinsic::lifetime_start:
797
33.7k
    case Intrinsic::lifetime_end:
798
33.7k
    case Intrinsic::objectsize:
799
33.7k
    case Intrinsic::ptr_annotation:
800
33.7k
    case Intrinsic::var_annotation:
801
33.7k
    case Intrinsic::experimental_gc_result:
802
33.7k
    case Intrinsic::experimental_gc_relocate:
803
33.7k
    case Intrinsic::coro_alloc:
804
33.7k
    case Intrinsic::coro_begin:
805
33.7k
    case Intrinsic::coro_free:
806
33.7k
    case Intrinsic::coro_end:
807
33.7k
    case Intrinsic::coro_frame:
808
33.7k
    case Intrinsic::coro_size:
809
33.7k
    case Intrinsic::coro_suspend:
810
33.7k
    case Intrinsic::coro_param:
811
33.7k
    case Intrinsic::coro_subfn_addr:
812
33.7k
      // These intrinsics don't actually represent code after lowering.
813
33.7k
      return TTI::TCC_Free;
814
51.2k
    }
815
51.2k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
14
                            ArrayRef<Type *> ParamTys, const User *U) {
775
14
    switch (IID) {
776
14
    default:
777
14
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
14
      // Model them as having a basic instruction cost.
779
14
      return TTI::TCC_Basic;
780
14
781
14
    // TODO: other libc intrinsics.
782
14
    case Intrinsic::memcpy:
783
0
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
14
785
14
    case Intrinsic::annotation:
786
0
    case Intrinsic::assume:
787
0
    case Intrinsic::sideeffect:
788
0
    case Intrinsic::dbg_declare:
789
0
    case Intrinsic::dbg_value:
790
0
    case Intrinsic::dbg_label:
791
0
    case Intrinsic::invariant_start:
792
0
    case Intrinsic::invariant_end:
793
0
    case Intrinsic::launder_invariant_group:
794
0
    case Intrinsic::strip_invariant_group:
795
0
    case Intrinsic::is_constant:
796
0
    case Intrinsic::lifetime_start:
797
0
    case Intrinsic::lifetime_end:
798
0
    case Intrinsic::objectsize:
799
0
    case Intrinsic::ptr_annotation:
800
0
    case Intrinsic::var_annotation:
801
0
    case Intrinsic::experimental_gc_result:
802
0
    case Intrinsic::experimental_gc_relocate:
803
0
    case Intrinsic::coro_alloc:
804
0
    case Intrinsic::coro_begin:
805
0
    case Intrinsic::coro_free:
806
0
    case Intrinsic::coro_end:
807
0
    case Intrinsic::coro_frame:
808
0
    case Intrinsic::coro_size:
809
0
    case Intrinsic::coro_suspend:
810
0
    case Intrinsic::coro_param:
811
0
    case Intrinsic::coro_subfn_addr:
812
0
      // These intrinsics don't actually represent code after lowering.
813
0
      return TTI::TCC_Free;
814
14
    }
815
14
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
3
                            ArrayRef<Type *> ParamTys, const User *U) {
775
3
    switch (IID) {
776
3
    default:
777
0
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
0
      // Model them as having a basic instruction cost.
779
0
      return TTI::TCC_Basic;
780
3
781
3
    // TODO: other libc intrinsics.
782
3
    case Intrinsic::memcpy:
783
0
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
3
785
3
    case Intrinsic::annotation:
786
3
    case Intrinsic::assume:
787
3
    case Intrinsic::sideeffect:
788
3
    case Intrinsic::dbg_declare:
789
3
    case Intrinsic::dbg_value:
790
3
    case Intrinsic::dbg_label:
791
3
    case Intrinsic::invariant_start:
792
3
    case Intrinsic::invariant_end:
793
3
    case Intrinsic::launder_invariant_group:
794
3
    case Intrinsic::strip_invariant_group:
795
3
    case Intrinsic::is_constant:
796
3
    case Intrinsic::lifetime_start:
797
3
    case Intrinsic::lifetime_end:
798
3
    case Intrinsic::objectsize:
799
3
    case Intrinsic::ptr_annotation:
800
3
    case Intrinsic::var_annotation:
801
3
    case Intrinsic::experimental_gc_result:
802
3
    case Intrinsic::experimental_gc_relocate:
803
3
    case Intrinsic::coro_alloc:
804
3
    case Intrinsic::coro_begin:
805
3
    case Intrinsic::coro_free:
806
3
    case Intrinsic::coro_end:
807
3
    case Intrinsic::coro_frame:
808
3
    case Intrinsic::coro_size:
809
3
    case Intrinsic::coro_suspend:
810
3
    case Intrinsic::coro_param:
811
3
    case Intrinsic::coro_subfn_addr:
812
3
      // These intrinsics don't actually represent code after lowering.
813
3
      return TTI::TCC_Free;
814
3
    }
815
3
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
16
                            ArrayRef<Type *> ParamTys, const User *U) {
775
16
    switch (IID) {
776
16
    default:
777
0
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
0
      // Model them as having a basic instruction cost.
779
0
      return TTI::TCC_Basic;
780
16
781
16
    // TODO: other libc intrinsics.
782
16
    case Intrinsic::memcpy:
783
0
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
16
785
16
    case Intrinsic::annotation:
786
16
    case Intrinsic::assume:
787
16
    case Intrinsic::sideeffect:
788
16
    case Intrinsic::dbg_declare:
789
16
    case Intrinsic::dbg_value:
790
16
    case Intrinsic::dbg_label:
791
16
    case Intrinsic::invariant_start:
792
16
    case Intrinsic::invariant_end:
793
16
    case Intrinsic::launder_invariant_group:
794
16
    case Intrinsic::strip_invariant_group:
795
16
    case Intrinsic::is_constant:
796
16
    case Intrinsic::lifetime_start:
797
16
    case Intrinsic::lifetime_end:
798
16
    case Intrinsic::objectsize:
799
16
    case Intrinsic::ptr_annotation:
800
16
    case Intrinsic::var_annotation:
801
16
    case Intrinsic::experimental_gc_result:
802
16
    case Intrinsic::experimental_gc_relocate:
803
16
    case Intrinsic::coro_alloc:
804
16
    case Intrinsic::coro_begin:
805
16
    case Intrinsic::coro_free:
806
16
    case Intrinsic::coro_end:
807
16
    case Intrinsic::coro_frame:
808
16
    case Intrinsic::coro_size:
809
16
    case Intrinsic::coro_suspend:
810
16
    case Intrinsic::coro_param:
811
16
    case Intrinsic::coro_subfn_addr:
812
16
      // These intrinsics don't actually represent code after lowering.
813
16
      return TTI::TCC_Free;
814
16
    }
815
16
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
57
                            ArrayRef<Type *> ParamTys, const User *U) {
775
57
    switch (IID) {
776
57
    default:
777
56
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
56
      // Model them as having a basic instruction cost.
779
56
      return TTI::TCC_Basic;
780
57
781
57
    // TODO: other libc intrinsics.
782
57
    case Intrinsic::memcpy:
783
1
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
57
785
57
    case Intrinsic::annotation:
786
0
    case Intrinsic::assume:
787
0
    case Intrinsic::sideeffect:
788
0
    case Intrinsic::dbg_declare:
789
0
    case Intrinsic::dbg_value:
790
0
    case Intrinsic::dbg_label:
791
0
    case Intrinsic::invariant_start:
792
0
    case Intrinsic::invariant_end:
793
0
    case Intrinsic::launder_invariant_group:
794
0
    case Intrinsic::strip_invariant_group:
795
0
    case Intrinsic::is_constant:
796
0
    case Intrinsic::lifetime_start:
797
0
    case Intrinsic::lifetime_end:
798
0
    case Intrinsic::objectsize:
799
0
    case Intrinsic::ptr_annotation:
800
0
    case Intrinsic::var_annotation:
801
0
    case Intrinsic::experimental_gc_result:
802
0
    case Intrinsic::experimental_gc_relocate:
803
0
    case Intrinsic::coro_alloc:
804
0
    case Intrinsic::coro_begin:
805
0
    case Intrinsic::coro_free:
806
0
    case Intrinsic::coro_end:
807
0
    case Intrinsic::coro_frame:
808
0
    case Intrinsic::coro_size:
809
0
    case Intrinsic::coro_suspend:
810
0
    case Intrinsic::coro_param:
811
0
    case Intrinsic::coro_subfn_addr:
812
0
      // These intrinsics don't actually represent code after lowering.
813
0
      return TTI::TCC_Free;
814
57
    }
815
57
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
20
                            ArrayRef<Type *> ParamTys, const User *U) {
775
20
    switch (IID) {
776
20
    default:
777
1
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
1
      // Model them as having a basic instruction cost.
779
1
      return TTI::TCC_Basic;
780
20
781
20
    // TODO: other libc intrinsics.
782
20
    case Intrinsic::memcpy:
783
9
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
20
785
20
    case Intrinsic::annotation:
786
10
    case Intrinsic::assume:
787
10
    case Intrinsic::sideeffect:
788
10
    case Intrinsic::dbg_declare:
789
10
    case Intrinsic::dbg_value:
790
10
    case Intrinsic::dbg_label:
791
10
    case Intrinsic::invariant_start:
792
10
    case Intrinsic::invariant_end:
793
10
    case Intrinsic::launder_invariant_group:
794
10
    case Intrinsic::strip_invariant_group:
795
10
    case Intrinsic::is_constant:
796
10
    case Intrinsic::lifetime_start:
797
10
    case Intrinsic::lifetime_end:
798
10
    case Intrinsic::objectsize:
799
10
    case Intrinsic::ptr_annotation:
800
10
    case Intrinsic::var_annotation:
801
10
    case Intrinsic::experimental_gc_result:
802
10
    case Intrinsic::experimental_gc_relocate:
803
10
    case Intrinsic::coro_alloc:
804
10
    case Intrinsic::coro_begin:
805
10
    case Intrinsic::coro_free:
806
10
    case Intrinsic::coro_end:
807
10
    case Intrinsic::coro_frame:
808
10
    case Intrinsic::coro_size:
809
10
    case Intrinsic::coro_suspend:
810
10
    case Intrinsic::coro_param:
811
10
    case Intrinsic::coro_subfn_addr:
812
10
      // These intrinsics don't actually represent code after lowering.
813
10
      return TTI::TCC_Free;
814
20
    }
815
20
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
146k
                            ArrayRef<Type *> ParamTys, const User *U) {
775
146k
    switch (IID) {
776
146k
    default:
777
27.9k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
27.9k
      // Model them as having a basic instruction cost.
779
27.9k
      return TTI::TCC_Basic;
780
146k
781
146k
    // TODO: other libc intrinsics.
782
146k
    case Intrinsic::memcpy:
783
7.43k
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
146k
785
146k
    case Intrinsic::annotation:
786
111k
    case Intrinsic::assume:
787
111k
    case Intrinsic::sideeffect:
788
111k
    case Intrinsic::dbg_declare:
789
111k
    case Intrinsic::dbg_value:
790
111k
    case Intrinsic::dbg_label:
791
111k
    case Intrinsic::invariant_start:
792
111k
    case Intrinsic::invariant_end:
793
111k
    case Intrinsic::launder_invariant_group:
794
111k
    case Intrinsic::strip_invariant_group:
795
111k
    case Intrinsic::is_constant:
796
111k
    case Intrinsic::lifetime_start:
797
111k
    case Intrinsic::lifetime_end:
798
111k
    case Intrinsic::objectsize:
799
111k
    case Intrinsic::ptr_annotation:
800
111k
    case Intrinsic::var_annotation:
801
111k
    case Intrinsic::experimental_gc_result:
802
111k
    case Intrinsic::experimental_gc_relocate:
803
111k
    case Intrinsic::coro_alloc:
804
111k
    case Intrinsic::coro_begin:
805
111k
    case Intrinsic::coro_free:
806
111k
    case Intrinsic::coro_end:
807
111k
    case Intrinsic::coro_frame:
808
111k
    case Intrinsic::coro_size:
809
111k
    case Intrinsic::coro_suspend:
810
111k
    case Intrinsic::coro_param:
811
111k
    case Intrinsic::coro_subfn_addr:
812
111k
      // These intrinsics don't actually represent code after lowering.
813
111k
      return TTI::TCC_Free;
814
146k
    }
815
146k
  }
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::User const*)
Line
Count
Source
774
489
                            ArrayRef<Type *> ParamTys, const User *U) {
775
489
    switch (IID) {
776
489
    default:
777
144
      // Intrinsics rarely (if ever) have normal argument setup constraints.
778
144
      // Model them as having a basic instruction cost.
779
144
      return TTI::TCC_Basic;
780
489
781
489
    // TODO: other libc intrinsics.
782
489
    case Intrinsic::memcpy:
783
10
      return static_cast<T *>(this)->getMemcpyCost(dyn_cast<Instruction>(U));
784
489
785
489
    case Intrinsic::annotation:
786
335
    case Intrinsic::assume:
787
335
    case Intrinsic::sideeffect:
788
335
    case Intrinsic::dbg_declare:
789
335
    case Intrinsic::dbg_value:
790
335
    case Intrinsic::dbg_label:
791
335
    case Intrinsic::invariant_start:
792
335
    case Intrinsic::invariant_end:
793
335
    case Intrinsic::launder_invariant_group:
794
335
    case Intrinsic::strip_invariant_group:
795
335
    case Intrinsic::is_constant:
796
335
    case Intrinsic::lifetime_start:
797
335
    case Intrinsic::lifetime_end:
798
335
    case Intrinsic::objectsize:
799
335
    case Intrinsic::ptr_annotation:
800
335
    case Intrinsic::var_annotation:
801
335
    case Intrinsic::experimental_gc_result:
802
335
    case Intrinsic::experimental_gc_relocate:
803
335
    case Intrinsic::coro_alloc:
804
335
    case Intrinsic::coro_begin:
805
335
    case Intrinsic::coro_free:
806
335
    case Intrinsic::coro_end:
807
335
    case Intrinsic::coro_frame:
808
335
    case Intrinsic::coro_size:
809
335
    case Intrinsic::coro_suspend:
810
335
    case Intrinsic::coro_param:
811
335
    case Intrinsic::coro_subfn_addr:
812
335
      // These intrinsics don't actually represent code after lowering.
813
335
      return TTI::TCC_Free;
814
489
    }
815
489
  }
816
817
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
818
4
                            ArrayRef<const Value *> Arguments, const User *U) {
819
4
    // Delegate to the generic intrinsic handling code. This mostly provides an
820
4
    // opportunity for targets to (for example) special case the cost of
821
4
    // certain intrinsics based on constants used as arguments.
822
4
    SmallVector<Type *, 8> ParamTys;
823
4
    ParamTys.reserve(Arguments.size());
824
12
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx8
)
825
8
      ParamTys.push_back(Arguments[Idx]->getType());
826
4
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys, U);
827
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
818
2
                            ArrayRef<const Value *> Arguments, const User *U) {
819
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
820
2
    // opportunity for targets to (for example) special case the cost of
821
2
    // certain intrinsics based on constants used as arguments.
822
2
    SmallVector<Type *, 8> ParamTys;
823
2
    ParamTys.reserve(Arguments.size());
824
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
825
4
      ParamTys.push_back(Arguments[Idx]->getType());
826
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys, U);
827
2
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Line
Count
Source
818
2
                            ArrayRef<const Value *> Arguments, const User *U) {
819
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
820
2
    // opportunity for targets to (for example) special case the cost of
821
2
    // certain intrinsics based on constants used as arguments.
822
2
    SmallVector<Type *, 8> ParamTys;
823
2
    ParamTys.reserve(Arguments.size());
824
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
825
4
      ParamTys.push_back(Arguments[Idx]->getType());
826
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys, U);
827
2
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
Unexecuted instantiation: TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>, llvm::User const*)
828
829
42.5M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
42.5M
    if (isa<PHINode>(U))
831
3.53M
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
39.0M
833
39.0M
    // Static alloca doesn't generate target instructions.
834
39.0M
    if (auto *A = dyn_cast<AllocaInst>(U))
835
124
      if (A->isStaticAlloca())
836
2
        return TTI::TCC_Free;
837
39.0M
838
39.0M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
6.03M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
6.03M
                                                GEP->getPointerOperand(),
841
6.03M
                                                Operands.drop_front());
842
6.03M
    }
843
33.0M
844
33.0M
    if (auto CS = ImmutableCallSite(U)) {
845
5.33M
      const Function *F = CS.getCalledFunction();
846
5.33M
      if (!F) {
847
245k
        // Just use the called value type.
848
245k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
245k
        return static_cast<T *>(this)
850
245k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
245k
      }
852
5.09M
853
5.09M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
5.09M
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
5.09M
    }
856
27.6M
857
27.6M
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)26.8M
||
isa<FPExtInst>(U)26.1M
)
858
1.56M
      // The old behaviour of generally treating extensions of icmp to be free
859
1.56M
      // has been removed. A target that needs it should override getUserCost().
860
1.56M
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
1.56M
                                                Operands.back());
862
26.1M
863
26.1M
    return static_cast<T *>(this)->getOperationCost(
864
26.1M
        Operator::getOpcode(U), U->getType(),
865
26.1M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()10.8M
:
nullptr15.2M
);
866
26.1M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
38.2M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
38.2M
    if (isa<PHINode>(U))
831
3.24M
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
34.9M
833
34.9M
    // Static alloca doesn't generate target instructions.
834
34.9M
    if (auto *A = dyn_cast<AllocaInst>(U))
835
82
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
34.9M
838
34.9M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
5.47M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
5.47M
                                                GEP->getPointerOperand(),
841
5.47M
                                                Operands.drop_front());
842
5.47M
    }
843
29.5M
844
29.5M
    if (auto CS = ImmutableCallSite(U)) {
845
4.25M
      const Function *F = CS.getCalledFunction();
846
4.25M
      if (!F) {
847
170k
        // Just use the called value type.
848
170k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
170k
        return static_cast<T *>(this)
850
170k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
170k
      }
852
4.08M
853
4.08M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
4.08M
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
4.08M
    }
856
25.2M
857
25.2M
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)24.5M
||
isa<FPExtInst>(U)23.9M
)
858
1.37M
      // The old behaviour of generally treating extensions of icmp to be free
859
1.37M
      // has been removed. A target that needs it should override getUserCost().
860
1.37M
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
1.37M
                                                Operands.back());
862
23.8M
863
23.8M
    return static_cast<T *>(this)->getOperationCost(
864
23.8M
        Operator::getOpcode(U), U->getType(),
865
23.8M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()9.80M
:
nullptr14.0M
);
866
23.8M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
460
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
460
    if (isa<PHINode>(U))
831
50
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
410
833
410
    // Static alloca doesn't generate target instructions.
834
410
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
410
838
410
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
15
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
15
                                                GEP->getPointerOperand(),
841
15
                                                Operands.drop_front());
842
15
    }
843
395
844
395
    if (auto CS = ImmutableCallSite(U)) {
845
2
      const Function *F = CS.getCalledFunction();
846
2
      if (!F) {
847
0
        // Just use the called value type.
848
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
0
        return static_cast<T *>(this)
850
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
0
      }
852
2
853
2
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
2
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
2
    }
856
393
857
393
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)386
||
isa<FPExtInst>(U)386
)
858
7
      // The old behaviour of generally treating extensions of icmp to be free
859
7
      // has been removed. A target that needs it should override getUserCost().
860
7
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
7
                                                Operands.back());
862
386
863
386
    return static_cast<T *>(this)->getOperationCost(
864
386
        Operator::getOpcode(U), U->getType(),
865
386
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()66
:
nullptr320
);
866
386
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
9.70k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
9.70k
    if (isa<PHINode>(U))
831
1.59k
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
8.11k
833
8.11k
    // Static alloca doesn't generate target instructions.
834
8.11k
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
8.11k
838
8.11k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
635
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
635
                                                GEP->getPointerOperand(),
841
635
                                                Operands.drop_front());
842
635
    }
843
7.48k
844
7.48k
    if (auto CS = ImmutableCallSite(U)) {
845
728
      const Function *F = CS.getCalledFunction();
846
728
      if (!F) {
847
120
        // Just use the called value type.
848
120
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
120
        return static_cast<T *>(this)
850
120
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
120
      }
852
608
853
608
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
608
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
608
    }
856
6.75k
857
6.75k
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)6.64k
||
isa<FPExtInst>(U)6.53k
)
858
221
      // The old behaviour of generally treating extensions of icmp to be free
859
221
      // has been removed. A target that needs it should override getUserCost().
860
221
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
221
                                                Operands.back());
862
6.53k
863
6.53k
    return static_cast<T *>(this)->getOperationCost(
864
6.53k
        Operator::getOpcode(U), U->getType(),
865
6.53k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()1.28k
:
nullptr5.24k
);
866
6.53k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
1.00M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
1.00M
    if (isa<PHINode>(U))
831
52.8k
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
953k
833
953k
    // Static alloca doesn't generate target instructions.
834
953k
    if (auto *A = dyn_cast<AllocaInst>(U))
835
18
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
953k
838
953k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
92.2k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
92.2k
                                                GEP->getPointerOperand(),
841
92.2k
                                                Operands.drop_front());
842
92.2k
    }
843
861k
844
861k
    if (auto CS = ImmutableCallSite(U)) {
845
283k
      const Function *F = CS.getCalledFunction();
846
283k
      if (!F) {
847
9.22k
        // Just use the called value type.
848
9.22k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
9.22k
        return static_cast<T *>(this)
850
9.22k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
9.22k
      }
852
274k
853
274k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
274k
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
274k
    }
856
577k
857
577k
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)538k
||
isa<FPExtInst>(U)508k
)
858
69.0k
      // The old behaviour of generally treating extensions of icmp to be free
859
69.0k
      // has been removed. A target that needs it should override getUserCost().
860
69.0k
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
69.0k
                                                Operands.back());
862
508k
863
508k
    return static_cast<T *>(this)->getOperationCost(
864
508k
        Operator::getOpcode(U), U->getType(),
865
508k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()214k
:
nullptr293k
);
866
508k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
290
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
290
    if (isa<PHINode>(U))
831
24
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
266
833
266
    // Static alloca doesn't generate target instructions.
834
266
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
266
838
266
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
29
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
29
                                                GEP->getPointerOperand(),
841
29
                                                Operands.drop_front());
842
29
    }
843
237
844
237
    if (auto CS = ImmutableCallSite(U)) {
845
28
      const Function *F = CS.getCalledFunction();
846
28
      if (!F) {
847
0
        // Just use the called value type.
848
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
0
        return static_cast<T *>(this)
850
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
0
      }
852
28
853
28
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
28
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
28
    }
856
209
857
209
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)207
||
isa<FPExtInst>(U)197
)
858
12
      // The old behaviour of generally treating extensions of icmp to be free
859
12
      // has been removed. A target that needs it should override getUserCost().
860
12
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
12
                                                Operands.back());
862
197
863
197
    return static_cast<T *>(this)->getOperationCost(
864
197
        Operator::getOpcode(U), U->getType(),
865
197
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()60
:
nullptr137
);
866
197
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
5
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
5
    if (isa<PHINode>(U))
831
0
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
5
833
5
    // Static alloca doesn't generate target instructions.
834
5
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
5
838
5
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
0
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
0
                                                GEP->getPointerOperand(),
841
0
                                                Operands.drop_front());
842
0
    }
843
5
844
5
    if (auto CS = ImmutableCallSite(U)) {
845
5
      const Function *F = CS.getCalledFunction();
846
5
      if (!F) {
847
0
        // Just use the called value type.
848
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
0
        return static_cast<T *>(this)
850
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
0
      }
852
5
853
5
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
5
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
5
    }
856
0
857
0
    if (isa<SExtInst>(U) || isa<ZExtInst>(U) || isa<FPExtInst>(U))
858
0
      // The old behaviour of generally treating extensions of icmp to be free
859
0
      // has been removed. A target that needs it should override getUserCost().
860
0
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
0
                                                Operands.back());
862
0
863
0
    return static_cast<T *>(this)->getOperationCost(
864
0
        Operator::getOpcode(U), U->getType(),
865
0
        U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr);
866
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
134
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
134
    if (isa<PHINode>(U))
831
9
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
125
833
125
    // Static alloca doesn't generate target instructions.
834
125
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
125
838
125
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
2
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
2
                                                GEP->getPointerOperand(),
841
2
                                                Operands.drop_front());
842
2
    }
843
123
844
123
    if (auto CS = ImmutableCallSite(U)) {
845
20
      const Function *F = CS.getCalledFunction();
846
20
      if (!F) {
847
0
        // Just use the called value type.
848
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
0
        return static_cast<T *>(this)
850
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
0
      }
852
20
853
20
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
20
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
20
    }
856
103
857
103
    if (isa<SExtInst>(U) || isa<ZExtInst>(U) || 
isa<FPExtInst>(U)102
)
858
1
      // The old behaviour of generally treating extensions of icmp to be free
859
1
      // has been removed. A target that needs it should override getUserCost().
860
1
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
1
                                                Operands.back());
862
102
863
102
    return static_cast<T *>(this)->getOperationCost(
864
102
        Operator::getOpcode(U), U->getType(),
865
102
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()16
:
nullptr86
);
866
102
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
9.02k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
9.02k
    if (isa<PHINode>(U))
831
911
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
8.11k
833
8.11k
    // Static alloca doesn't generate target instructions.
834
8.11k
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
8.11k
838
8.11k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
1.08k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
1.08k
                                                GEP->getPointerOperand(),
841
1.08k
                                                Operands.drop_front());
842
1.08k
    }
843
7.02k
844
7.02k
    if (auto CS = ImmutableCallSite(U)) {
845
324
      const Function *F = CS.getCalledFunction();
846
324
      if (!F) {
847
101
        // Just use the called value type.
848
101
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
101
        return static_cast<T *>(this)
850
101
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
101
      }
852
223
853
223
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
223
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
223
    }
856
6.70k
857
6.70k
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)6.60k
||
isa<FPExtInst>(U)6.46k
)
858
245
      // The old behaviour of generally treating extensions of icmp to be free
859
245
      // has been removed. A target that needs it should override getUserCost().
860
245
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
245
                                                Operands.back());
862
6.46k
863
6.46k
    return static_cast<T *>(this)->getOperationCost(
864
6.46k
        Operator::getOpcode(U), U->getType(),
865
6.46k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()2.23k
:
nullptr4.22k
);
866
6.46k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
136
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
136
    if (isa<PHINode>(U))
831
0
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
136
833
136
    // Static alloca doesn't generate target instructions.
834
136
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
136
838
136
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
132
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
132
                                                GEP->getPointerOperand(),
841
132
                                                Operands.drop_front());
842
132
    }
843
4
844
4
    if (auto CS = ImmutableCallSite(U)) {
845
0
      const Function *F = CS.getCalledFunction();
846
0
      if (!F) {
847
0
        // Just use the called value type.
848
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
0
        return static_cast<T *>(this)
850
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
0
      }
852
0
853
0
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
0
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
0
    }
856
4
857
4
    if (isa<SExtInst>(U) || isa<ZExtInst>(U) || isa<FPExtInst>(U))
858
0
      // The old behaviour of generally treating extensions of icmp to be free
859
0
      // has been removed. A target that needs it should override getUserCost().
860
0
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
0
                                                Operands.back());
862
4
863
4
    return static_cast<T *>(this)->getOperationCost(
864
4
        Operator::getOpcode(U), U->getType(),
865
4
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()1
:
nullptr3
);
866
4
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
1.30k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
1.30k
    if (isa<PHINode>(U))
831
67
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
1.23k
833
1.23k
    // Static alloca doesn't generate target instructions.
834
1.23k
    if (auto *A = dyn_cast<AllocaInst>(U))
835
0
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
1.23k
838
1.23k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
75
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
75
                                                GEP->getPointerOperand(),
841
75
                                                Operands.drop_front());
842
75
    }
843
1.15k
844
1.15k
    if (auto CS = ImmutableCallSite(U)) {
845
53
      const Function *F = CS.getCalledFunction();
846
53
      if (!F) {
847
1
        // Just use the called value type.
848
1
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
1
        return static_cast<T *>(this)
850
1
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
1
      }
852
52
853
52
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
52
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
52
    }
856
1.10k
857
1.10k
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)1.09k
||
isa<FPExtInst>(U)1.08k
)
858
23
      // The old behaviour of generally treating extensions of icmp to be free
859
23
      // has been removed. A target that needs it should override getUserCost().
860
23
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
23
                                                Operands.back());
862
1.08k
863
1.08k
    return static_cast<T *>(this)->getOperationCost(
864
1.08k
        Operator::getOpcode(U), U->getType(),
865
1.08k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()243
:
nullptr839
);
866
1.08k
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
3.22M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
3.22M
    if (isa<PHINode>(U))
831
212k
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
3.00M
833
3.00M
    // Static alloca doesn't generate target instructions.
834
3.00M
    if (auto *A = dyn_cast<AllocaInst>(U))
835
22
      if (A->isStaticAlloca())
836
2
        return TTI::TCC_Free;
837
3.00M
838
3.00M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
461k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
461k
                                                GEP->getPointerOperand(),
841
461k
                                                Operands.drop_front());
842
461k
    }
843
2.54M
844
2.54M
    if (auto CS = ImmutableCallSite(U)) {
845
792k
      const Function *F = CS.getCalledFunction();
846
792k
      if (!F) {
847
65.5k
        // Just use the called value type.
848
65.5k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
65.5k
        return static_cast<T *>(this)
850
65.5k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
65.5k
      }
852
727k
853
727k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
727k
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
727k
    }
856
1.75M
857
1.75M
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)1.69M
||
isa<FPExtInst>(U)1.63M
)
858
118k
      // The old behaviour of generally treating extensions of icmp to be free
859
118k
      // has been removed. A target that needs it should override getUserCost().
860
118k
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
118k
                                                Operands.back());
862
1.63M
863
1.63M
    return static_cast<T *>(this)->getOperationCost(
864
1.63M
        Operator::getOpcode(U), U->getType(),
865
1.63M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()758k
:
nullptr876k
);
866
1.63M
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
829
115k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
830
115k
    if (isa<PHINode>(U))
831
13.6k
      return TTI::TCC_Free; // Model all PHI nodes as free.
832
101k
833
101k
    // Static alloca doesn't generate target instructions.
834
101k
    if (auto *A = dyn_cast<AllocaInst>(U))
835
2
      if (A->isStaticAlloca())
836
0
        return TTI::TCC_Free;
837
101k
838
101k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
839
9.85k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
840
9.85k
                                                GEP->getPointerOperand(),
841
9.85k
                                                Operands.drop_front());
842
9.85k
    }
843
92.0k
844
92.0k
    if (auto CS = ImmutableCallSite(U)) {
845
7.16k
      const Function *F = CS.getCalledFunction();
846
7.16k
      if (!F) {
847
36
        // Just use the called value type.
848
36
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
849
36
        return static_cast<T *>(this)
850
36
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
851
36
      }
852
7.12k
853
7.12k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
854
7.12k
      return static_cast<T *>(this)->getCallCost(F, Arguments, U);
855
7.12k
    }
856
84.8k
857
84.8k
    if (isa<SExtInst>(U) || 
isa<ZExtInst>(U)84.7k
||
isa<FPExtInst>(U)82.5k
)
858
2.30k
      // The old behaviour of generally treating extensions of icmp to be free
859
2.30k
      // has been removed. A target that needs it should override getUserCost().
860
2.30k
      return static_cast<T *>(this)->getExtCost(cast<Instruction>(U),
861
2.30k
                                                Operands.back());
862
82.5k
863
82.5k
    return static_cast<T *>(this)->getOperationCost(
864
82.5k
        Operator::getOpcode(U), U->getType(),
865
82.5k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()34.9k
:
nullptr47.6k
);
866
82.5k
  }
867
868
78
  int getInstructionLatency(const Instruction *I) {
869
78
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
870
78
                                           I->value_op_end());
871
78
    if (getUserCost(I, Operands) == TTI::TCC_Free)
872
5
      return 0;
873
73
874
73
    if (isa<LoadInst>(I))
875
0
      return 4;
876
73
877
73
    Type *DstTy = I->getType();
878
73
879
73
    // Usually an intrinsic is a simple instruction.
880
73
    // A real function call is much slower.
881
73
    if (auto *CI = dyn_cast<CallInst>(I)) {
882
2
      const Function *F = CI->getCalledFunction();
883
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
884
1
        return 40;
885
1
      // Some intrinsics return a value and a flag, we use the value type
886
1
      // to decide its latency.
887
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
888
1
        DstTy = StructTy->getElementType(0);
889
1
      // Fall through to simple instructions.
890
1
    }
891
73
892
73
    
if (VectorType *72
VectorTy72
= dyn_cast<VectorType>(DstTy))
893
68
      DstTy = VectorTy->getElementType();
894
72
    if (DstTy->isFloatingPointTy())
895
68
      return 3;
896
4
897
4
    return 1;
898
4
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getInstructionLatency(llvm::Instruction const*)
Line
Count
Source
868
68
  int getInstructionLatency(const Instruction *I) {
869
68
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
870
68
                                           I->value_op_end());
871
68
    if (getUserCost(I, Operands) == TTI::TCC_Free)
872
0
      return 0;
873
68
874
68
    if (isa<LoadInst>(I))
875
0
      return 4;
876
68
877
68
    Type *DstTy = I->getType();
878
68
879
68
    // Usually an intrinsic is a simple instruction.
880
68
    // A real function call is much slower.
881
68
    if (auto *CI = dyn_cast<CallInst>(I)) {
882
0
      const Function *F = CI->getCalledFunction();
883
0
      if (!F || static_cast<T *>(this)->isLoweredToCall(F))
884
0
        return 40;
885
0
      // Some intrinsics return a value and a flag, we use the value type
886
0
      // to decide its latency.
887
0
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
888
0
        DstTy = StructTy->getElementType(0);
889
0
      // Fall through to simple instructions.
890
0
    }
891
68
892
68
    if (VectorType *VectorTy = dyn_cast<VectorType>(DstTy))
893
68
      DstTy = VectorTy->getElementType();
894
68
    if (DstTy->isFloatingPointTy())
895
68
      return 3;
896
0
897
0
    return 1;
898
0
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::RISCVTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getInstructionLatency(llvm::Instruction const*)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getInstructionLatency(llvm::Instruction const*)
Line
Count
Source
868
10
  int getInstructionLatency(const Instruction *I) {
869
10
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
870
10
                                           I->value_op_end());
871
10
    if (getUserCost(I, Operands) == TTI::TCC_Free)
872
5
      return 0;
873
5
874
5
    if (isa<LoadInst>(I))
875
0
      return 4;
876
5
877
5
    Type *DstTy = I->getType();
878
5
879
5
    // Usually an intrinsic is a simple instruction.
880
5
    // A real function call is much slower.
881
5
    if (auto *CI = dyn_cast<CallInst>(I)) {
882
2
      const Function *F = CI->getCalledFunction();
883
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
884
1
        return 40;
885
1
      // Some intrinsics return a value and a flag, we use the value type
886
1
      // to decide its latency.
887
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
888
1
        DstTy = StructTy->getElementType(0);
889
1
      // Fall through to simple instructions.
890
1
    }
891
5
892
5
    
if (VectorType *4
VectorTy4
= dyn_cast<VectorType>(DstTy))
893
0
      DstTy = VectorTy->getElementType();
894
4
    if (DstTy->isFloatingPointTy())
895
0
      return 3;
896
4
897
4
    return 1;
898
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getInstructionLatency(llvm::Instruction const*)
899
};
900
}
901
902
#endif