Coverage Report

Created: 2018-11-16 02:38

/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
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
/// \file
10
/// This file provides helpers for the implementation of
11
/// a TargetTransformInfo-conforming class.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
16
#define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
17
18
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
19
#include "llvm/Analysis/TargetTransformInfo.h"
20
#include "llvm/Analysis/VectorUtils.h"
21
#include "llvm/IR/CallSite.h"
22
#include "llvm/IR/DataLayout.h"
23
#include "llvm/IR/Function.h"
24
#include "llvm/IR/GetElementPtrTypeIterator.h"
25
#include "llvm/IR/Operator.h"
26
#include "llvm/IR/Type.h"
27
28
namespace llvm {
29
30
/// Base class for use as a mix-in that aids implementing
31
/// a TargetTransformInfo-compatible class.
32
class TargetTransformInfoImplBase {
33
protected:
34
  typedef TargetTransformInfo TTI;
35
36
  const DataLayout &DL;
37
38
15.7M
  explicit TargetTransformInfoImplBase(const DataLayout &DL) : DL(DL) {}
39
40
public:
41
  // Provide value semantics. MSVC requires that we spell all of these out.
42
  TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)
43
15.7M
      : DL(Arg.DL) {}
44
15.7M
  TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) : DL(Arg.DL) {}
45
46
52.9k
  const DataLayout &getDataLayout() const { return DL; }
47
48
25.8M
  unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) {
49
25.8M
    switch (Opcode) {
50
25.8M
    default:
51
22.4M
      // By default, just classify everything as 'basic'.
52
22.4M
      return TTI::TCC_Basic;
53
25.8M
54
25.8M
    case Instruction::GetElementPtr:
55
0
      llvm_unreachable("Use getGEPCost for GEP operations!");
56
25.8M
57
25.8M
    case Instruction::BitCast:
58
1.89M
      assert(OpTy && "Cast instructions must provide the operand type");
59
1.89M
      if (Ty == OpTy || 
(1.89M
Ty->isPointerTy()1.89M
&&
OpTy->isPointerTy()1.89M
))
60
1.89M
        // Identity and pointer-to-pointer casts are free.
61
1.89M
        return TTI::TCC_Free;
62
3.40k
63
3.40k
      // Otherwise, the default basic cost is used.
64
3.40k
      return TTI::TCC_Basic;
65
3.40k
66
278k
    case Instruction::FDiv:
67
278k
    case Instruction::FRem:
68
278k
    case Instruction::SDiv:
69
278k
    case Instruction::SRem:
70
278k
    case Instruction::UDiv:
71
278k
    case Instruction::URem:
72
278k
      return TTI::TCC_Expensive;
73
278k
74
469k
    case Instruction::IntToPtr: {
75
469k
      // An inttoptr cast is free so long as the input is a legal integer type
76
469k
      // which doesn't contain values outside the range of a pointer.
77
469k
      unsigned OpSize = OpTy->getScalarSizeInBits();
78
469k
      if (DL.isLegalInteger(OpSize) &&
79
469k
          
OpSize <= DL.getPointerTypeSizeInBits(Ty)469k
)
80
469k
        return TTI::TCC_Free;
81
5
82
5
      // Otherwise it's not a no-op.
83
5
      return TTI::TCC_Basic;
84
5
    }
85
726k
    case Instruction::PtrToInt: {
86
726k
      // A ptrtoint cast is free so long as the result is large enough to store
87
726k
      // the pointer, and a legal integer type.
88
726k
      unsigned DestSize = Ty->getScalarSizeInBits();
89
726k
      if (DL.isLegalInteger(DestSize) &&
90
726k
          
DestSize >= DL.getPointerTypeSizeInBits(OpTy)726k
)
91
726k
        return TTI::TCC_Free;
92
31
93
31
      // Otherwise it's not a no-op.
94
31
      return TTI::TCC_Basic;
95
31
    }
96
58
    case Instruction::Trunc:
97
58
      // trunc to a native type is free (assuming the target has compare and
98
58
      // shift-right of the same width).
99
58
      if (DL.isLegalInteger(DL.getTypeSizeInBits(Ty)))
100
25
        return TTI::TCC_Free;
101
33
102
33
      return TTI::TCC_Basic;
103
25.8M
    }
104
25.8M
  }
105
106
  int getGEPCost(Type *PointeeType, const Value *Ptr,
107
0
                 ArrayRef<const Value *> Operands) {
108
0
    // In the basic model, we just assume that all-constant GEPs will be folded
109
0
    // into their uses via addressing modes.
110
0
    for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
111
0
      if (!isa<Constant>(Operands[Idx]))
112
0
        return TTI::TCC_Basic;
113
0
114
0
    return TTI::TCC_Free;
115
0
  }
116
117
  unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
118
2
                                            unsigned &JTSize) {
119
2
    JTSize = 0;
120
2
    return SI.getNumCases();
121
2
  }
122
123
2.29k
  int getExtCost(const Instruction *I, const Value *Src) {
124
2.29k
    return TTI::TCC_Basic;
125
2.29k
  }
126
127
6.32M
  unsigned getCallCost(FunctionType *FTy, int NumArgs) {
128
6.32M
    assert(FTy && "FunctionType must be provided to this routine.");
129
6.32M
130
6.32M
    // The target-independent implementation just measures the size of the
131
6.32M
    // function by approximating that each argument will take on average one
132
6.32M
    // instruction to prepare.
133
6.32M
134
6.32M
    if (NumArgs < 0)
135
0
      // Set the argument number to the number of explicit arguments in the
136
0
      // function.
137
0
      NumArgs = FTy->getNumParams();
138
6.32M
139
6.32M
    return TTI::TCC_Basic * (NumArgs + 1);
140
6.32M
  }
141
142
839
  unsigned getInliningThresholdMultiplier() { return 1; }
143
144
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
145
1.56M
                            ArrayRef<Type *> ParamTys) {
146
1.56M
    switch (IID) {
147
1.56M
    default:
148
227k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
149
227k
      // Model them as having a basic instruction cost.
150
227k
      // FIXME: This is wrong for libc intrinsics.
151
227k
      return TTI::TCC_Basic;
152
1.56M
153
1.56M
    case Intrinsic::annotation:
154
1.33M
    case Intrinsic::assume:
155
1.33M
    case Intrinsic::sideeffect:
156
1.33M
    case Intrinsic::dbg_declare:
157
1.33M
    case Intrinsic::dbg_value:
158
1.33M
    case Intrinsic::dbg_label:
159
1.33M
    case Intrinsic::invariant_start:
160
1.33M
    case Intrinsic::invariant_end:
161
1.33M
    case Intrinsic::launder_invariant_group:
162
1.33M
    case Intrinsic::strip_invariant_group:
163
1.33M
    case Intrinsic::is_constant:
164
1.33M
    case Intrinsic::lifetime_start:
165
1.33M
    case Intrinsic::lifetime_end:
166
1.33M
    case Intrinsic::objectsize:
167
1.33M
    case Intrinsic::ptr_annotation:
168
1.33M
    case Intrinsic::var_annotation:
169
1.33M
    case Intrinsic::experimental_gc_result:
170
1.33M
    case Intrinsic::experimental_gc_relocate:
171
1.33M
    case Intrinsic::coro_alloc:
172
1.33M
    case Intrinsic::coro_begin:
173
1.33M
    case Intrinsic::coro_free:
174
1.33M
    case Intrinsic::coro_end:
175
1.33M
    case Intrinsic::coro_frame:
176
1.33M
    case Intrinsic::coro_size:
177
1.33M
    case Intrinsic::coro_suspend:
178
1.33M
    case Intrinsic::coro_param:
179
1.33M
    case Intrinsic::coro_subfn_addr:
180
1.33M
      // These intrinsics don't actually represent code after lowering.
181
1.33M
      return TTI::TCC_Free;
182
1.56M
    }
183
1.56M
  }
184
185
1.42k
  bool hasBranchDivergence() { return false; }
186
187
0
  bool isSourceOfDivergence(const Value *V) { return false; }
188
189
0
  bool isAlwaysUniform(const Value *V) { return false; }
190
191
0
  unsigned getFlatAddressSpace () {
192
0
    return -1;
193
0
  }
194
195
11.4M
  bool isLoweredToCall(const Function *F) {
196
11.4M
    assert(F && "A concrete function must be provided to this routine.");
197
11.4M
198
11.4M
    // FIXME: These should almost certainly not be handled here, and instead
199
11.4M
    // handled with the help of TLI or the target itself. This was largely
200
11.4M
    // ported from existing analysis heuristics here so that such refactorings
201
11.4M
    // can take place in the future.
202
11.4M
203
11.4M
    if (F->isIntrinsic())
204
236k
      return false;
205
11.2M
206
11.2M
    if (F->hasLocalLinkage() || 
!F->hasName()9.96M
)
207
1.25M
      return true;
208
9.96M
209
9.96M
    StringRef Name = F->getName();
210
9.96M
211
9.96M
    // These will all likely lower to a single selection DAG node.
212
9.96M
    if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
213
9.96M
        
Name == "fabs"9.96M
||
Name == "fabsf"9.96M
||
Name == "fabsl"9.96M
||
Name == "sin"9.96M
||
214
9.96M
        
Name == "fmin"9.96M
||
Name == "fminf"9.96M
||
Name == "fminl"9.96M
||
215
9.96M
        
Name == "fmax"9.96M
||
Name == "fmaxf"9.96M
||
Name == "fmaxl"9.96M
||
216
9.96M
        
Name == "sinf"9.96M
||
Name == "sinl"9.96M
||
Name == "cos"9.96M
||
Name == "cosf"9.96M
||
217
9.96M
        
Name == "cosl"9.96M
||
Name == "sqrt"9.96M
||
Name == "sqrtf"9.96M
||
Name == "sqrtl"9.96M
)
218
41
      return false;
219
9.96M
220
9.96M
    // These are all likely to be optimized into something smaller.
221
9.96M
    if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
222
9.96M
        Name == "exp2l" || Name == "exp2f" || Name == "floor" ||
223
9.96M
        Name == "floorf" || Name == "ceil" || Name == "round" ||
224
9.96M
        Name == "ffs" || Name == "ffsl" || Name == "abs" || 
Name == "labs"9.96M
||
225
9.96M
        
Name == "llabs"9.96M
)
226
2
      return false;
227
9.96M
228
9.96M
    return true;
229
9.96M
  }
230
231
  void getUnrollingPreferences(Loop *, ScalarEvolution &,
232
590
                               TTI::UnrollingPreferences &) {}
233
234
6.57k
  bool isLegalAddImmediate(int64_t Imm) { return false; }
235
236
646
  bool isLegalICmpImmediate(int64_t Imm) { return false; }
237
238
  bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
239
                             bool HasBaseReg, int64_t Scale,
240
61.7k
                             unsigned AddrSpace, Instruction *I = nullptr) {
241
61.7k
    // Guess that only reg and reg+reg addressing is allowed. This heuristic is
242
61.7k
    // taken from the implementation of LSR.
243
61.7k
    return !BaseGV && 
BaseOffset == 057.1k
&&
(51.9k
Scale == 051.9k
||
Scale == 151.6k
);
244
61.7k
  }
245
246
4.06M
  bool isLSRCostLess(TTI::LSRCost &C1, TTI::LSRCost &C2) {
247
4.06M
    return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
248
4.06M
                    C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
249
4.06M
           std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
250
4.06M
                    C2.ScaleCost, C2.ImmCost, C2.SetupCost);
251
4.06M
  }
252
253
698k
  bool canMacroFuseCmp() { return false; }
254
255
12.4M
  bool shouldFavorPostInc() const { return false; }
256
257
2.56k
  bool isLegalMaskedStore(Type *DataType) { return false; }
258
259
1.56k
  bool isLegalMaskedLoad(Type *DataType) { return false; }
260
261
9.31k
  bool isLegalMaskedScatter(Type *DataType) { return false; }
262
263
12.9k
  bool isLegalMaskedGather(Type *DataType) { return false; }
264
265
1.21k
  bool hasDivRemOp(Type *DataType, bool IsSigned) { return false; }
266
267
269
  bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) { return false; }
268
269
42.0k
  bool prefersVectorizedAddressing() { return true; }
270
271
  int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
272
13.9k
                           bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
273
13.9k
    // Guess that all legal addressing mode are free.
274
13.9k
    if (isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
275
13.9k
                              Scale, AddrSpace))
276
13.9k
      return 0;
277
0
    return -1;
278
0
  }
279
280
4.53M
  bool LSRWithInstrQueries() { return false; }
281
282
9.22k
  bool isTruncateFree(Type *Ty1, Type *Ty2) { return false; }
283
284
70
  bool isProfitableToHoist(Instruction *I) { return true; }
285
286
0
  bool useAA() { return false; }
287
288
418
  bool isTypeLegal(Type *Ty) { return false; }
289
290
0
  unsigned getJumpBufAlignment() { return 0; }
291
292
0
  unsigned getJumpBufSize() { return 0; }
293
294
19
  bool shouldBuildLookupTables() { return true; }
295
71.9k
  bool shouldBuildLookupTablesForConstant(Constant *C) { return true; }
296
297
14
  bool useColdCCForColdCall(Function &F) { return false; }
298
299
379
  unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) {
300
379
    return 0;
301
379
  }
302
303
  unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
304
344
                                            unsigned VF) { return 0; }
305
306
16.1k
  bool supportsEfficientVectorElementLoadStore() { return false; }
307
308
1.21k
  bool enableAggressiveInterleaving(bool LoopHasReductions) { return false; }
309
310
  const TTI::MemCmpExpansionOptions *enableMemCmpExpansion(
311
328k
      bool IsZeroCmp) const {
312
328k
    return nullptr;
313
328k
  }
314
315
550
  bool enableInterleavedAccessVectorization() { return false; }
316
317
19.3k
  bool enableMaskedInterleavedAccessVectorization() { return false; }
318
319
10.7k
  bool isFPVectorizationPotentiallyUnsafe() { return false; }
320
321
  bool allowsMisalignedMemoryAccesses(LLVMContext &Context,
322
                                      unsigned BitWidth,
323
                                      unsigned AddressSpace,
324
                                      unsigned Alignment,
325
0
                                      bool *Fast) { return false; }
326
327
3.77k
  TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) {
328
3.77k
    return TTI::PSK_Software;
329
3.77k
  }
330
331
4
  bool haveFastSqrt(Type *Ty) { return false; }
332
333
0
  bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) { return true; }
334
335
1
  unsigned getFPOpCost(Type *Ty) { return TargetTransformInfo::TCC_Basic; }
336
337
  int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
338
769
                            Type *Ty) {
339
769
    return 0;
340
769
  }
341
342
32
  unsigned getIntImmCost(const APInt &Imm, Type *Ty) { return TTI::TCC_Basic; }
343
344
  unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
345
42.3k
                         Type *Ty) {
346
42.3k
    return TTI::TCC_Free;
347
42.3k
  }
348
349
  unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
350
42.3k
                         Type *Ty) {
351
42.3k
    return TTI::TCC_Free;
352
42.3k
  }
353
354
33.6k
  unsigned getNumberOfRegisters(bool Vector) { return 8; }
355
356
1.27k
  unsigned getRegisterBitWidth(bool Vector) const { return 32; }
357
358
35.1k
  unsigned getMinVectorRegisterBitWidth() { return 128; }
359
360
19.5k
  bool shouldMaximizeVectorBandwidth(bool OptSize) const { return false; }
361
362
0
  unsigned getMinimumVF(unsigned ElemWidth) const { return 0; }
363
364
  bool
365
  shouldConsiderAddressTypePromotion(const Instruction &I,
366
68.5k
                                     bool &AllowPromotionWithoutCommonHeader) {
367
68.5k
    AllowPromotionWithoutCommonHeader = false;
368
68.5k
    return false;
369
68.5k
  }
370
371
0
  unsigned getCacheLineSize() { return 0; }
372
373
2
  llvm::Optional<unsigned> getCacheSize(TargetTransformInfo::CacheLevel Level) {
374
2
    switch (Level) {
375
2
    case TargetTransformInfo::CacheLevel::L1D:
376
1
      LLVM_FALLTHROUGH;
377
2
    case TargetTransformInfo::CacheLevel::L2D:
378
2
      return llvm::Optional<unsigned>();
379
0
    }
380
0
381
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
382
0
  }
383
384
  llvm::Optional<unsigned> getCacheAssociativity(
385
1
    TargetTransformInfo::CacheLevel Level) {
386
1
    switch (Level) {
387
1
    case TargetTransformInfo::CacheLevel::L1D:
388
0
      LLVM_FALLTHROUGH;
389
1
    case TargetTransformInfo::CacheLevel::L2D:
390
1
      return llvm::Optional<unsigned>();
391
0
    }
392
0
393
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
394
0
  }
395
396
0
  unsigned getPrefetchDistance() { return 0; }
397
398
29
  unsigned getMinPrefetchStride() { return 1; }
399
400
178
  unsigned getMaxPrefetchIterationsAhead() { return UINT_MAX; }
401
402
487
  unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
403
404
  unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
405
                                  TTI::OperandValueKind Opd1Info,
406
                                  TTI::OperandValueKind Opd2Info,
407
                                  TTI::OperandValueProperties Opd1PropInfo,
408
                                  TTI::OperandValueProperties Opd2PropInfo,
409
1.40k
                                  ArrayRef<const Value *> Args) {
410
1.40k
    return 1;
411
1.40k
  }
412
413
  unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Ty, int Index,
414
98
                          Type *SubTp) {
415
98
    return 1;
416
98
  }
417
418
  unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
419
416
                            const Instruction *I) { return 1; }
420
421
  unsigned getExtractWithExtendCost(unsigned Opcode, Type *Dst,
422
0
                                    VectorType *VecTy, unsigned Index) {
423
0
    return 1;
424
0
  }
425
426
1.43k
  unsigned getCFInstrCost(unsigned Opcode) { return 1; }
427
428
  unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
429
716
                              const Instruction *I) {
430
716
    return 1;
431
716
  }
432
433
305
  unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
434
305
    return 1;
435
305
  }
436
437
  unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
438
980
                           unsigned AddressSpace, const Instruction *I) {
439
980
    return 1;
440
980
  }
441
442
  unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
443
0
                                 unsigned AddressSpace) {
444
0
    return 1;
445
0
  }
446
447
  unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
448
                                  bool VariableMask,
449
0
                                  unsigned Alignment) {
450
0
    return 1;
451
0
  }
452
453
  unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
454
                                      unsigned Factor,
455
                                      ArrayRef<unsigned> Indices,
456
                                      unsigned Alignment, unsigned AddressSpace,
457
                                      bool UseMaskForCond = false,
458
37
                                      bool UseMaskForGaps = false) {
459
37
    return 1;
460
37
  }
461
462
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
463
                                 ArrayRef<Type *> Tys, FastMathFlags FMF,
464
0
                                 unsigned ScalarizationCostPassed) {
465
0
    return 1;
466
0
  }
467
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
468
154
            ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) {
469
154
    return 1;
470
154
  }
471
472
154
  unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys) {
473
154
    return 1;
474
154
  }
475
476
2.02k
  unsigned getNumberOfParts(Type *Tp) { return 0; }
477
478
  unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *,
479
302
                                     const SCEV *) {
480
302
    return 0;
481
302
  }
482
483
2
  unsigned getArithmeticReductionCost(unsigned, Type *, bool) { return 1; }
484
485
0
  unsigned getMinMaxReductionCost(Type *, Type *, bool, bool) { return 1; }
486
487
36.9k
  unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) { return 0; }
488
489
130k
  bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) {
490
130k
    return false;
491
130k
  }
492
493
1
  unsigned getAtomicMemIntrinsicMaxElementSize() const {
494
1
    // Note for overrides: You must ensure for all element unordered-atomic
495
1
    // memory intrinsics that all power-of-2 element sizes up to, and
496
1
    // including, the return value of this method have a corresponding
497
1
    // runtime lib call. These runtime lib call definitions can be found
498
1
    // in RuntimeLibcalls.h
499
1
    return 0;
500
1
  }
501
502
  Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
503
9
                                           Type *ExpectedType) {
504
9
    return nullptr;
505
9
  }
506
507
  Type *getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length,
508
15
                                  unsigned SrcAlign, unsigned DestAlign) const {
509
15
    return Type::getInt8Ty(Context);
510
15
  }
511
512
  void getMemcpyLoopResidualLoweringType(SmallVectorImpl<Type *> &OpsOut,
513
                                         LLVMContext &Context,
514
                                         unsigned RemainingBytes,
515
                                         unsigned SrcAlign,
516
0
                                         unsigned DestAlign) const {
517
0
    for (unsigned i = 0; i != RemainingBytes; ++i)
518
0
      OpsOut.push_back(Type::getInt8Ty(Context));
519
0
  }
520
521
  bool areInlineCompatible(const Function *Caller,
522
1.00k
                           const Function *Callee) const {
523
1.00k
    return (Caller->getFnAttribute("target-cpu") ==
524
1.00k
            Callee->getFnAttribute("target-cpu")) &&
525
1.00k
           (Caller->getFnAttribute("target-features") ==
526
1.00k
            Callee->getFnAttribute("target-features"));
527
1.00k
  }
528
529
  bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty,
530
0
                          const DataLayout &DL) const {
531
0
    return false;
532
0
  }
533
534
  bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty,
535
0
                           const DataLayout &DL) const {
536
0
    return false;
537
0
  }
538
539
679
  unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const { return 128; }
540
541
43.8k
  bool isLegalToVectorizeLoad(LoadInst *LI) const { return true; }
542
543
17.5k
  bool isLegalToVectorizeStore(StoreInst *SI) const { return true; }
544
545
  bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes,
546
                                   unsigned Alignment,
547
21
                                   unsigned AddrSpace) const {
548
21
    return true;
549
21
  }
550
551
  bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
552
                                    unsigned Alignment,
553
8
                                    unsigned AddrSpace) const {
554
8
    return true;
555
8
  }
556
557
  unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize,
558
                               unsigned ChainSizeInBytes,
559
515
                               VectorType *VecTy) const {
560
515
    return VF;
561
515
  }
562
563
  unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize,
564
                                unsigned ChainSizeInBytes,
565
375
                                VectorType *VecTy) const {
566
375
    return VF;
567
375
  }
568
569
  bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
570
408
                             TTI::ReductionFlags Flags) const {
571
408
    return false;
572
408
  }
573
574
1.68k
  bool shouldExpandReduction(const IntrinsicInst *II) const {
575
1.68k
    return true;
576
1.68k
  }
577
578
protected:
579
  // Obtain the minimum required size to hold the value (without the sign)
580
  // In case of a vector it returns the min required size for one element.
581
48
  unsigned minRequiredElementSize(const Value* Val, bool &isSigned) {
582
48
    if (isa<ConstantDataVector>(Val) || 
isa<ConstantVector>(Val)36
) {
583
12
      const auto* VectorValue = cast<Constant>(Val);
584
12
585
12
      // In case of a vector need to pick the max between the min
586
12
      // required size for each element
587
12
      auto *VT = cast<VectorType>(Val->getType());
588
12
589
12
      // Assume unsigned elements
590
12
      isSigned = false;
591
12
592
12
      // The max required size is the total vector width divided by num
593
12
      // of elements in the vector
594
12
      unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
595
12
596
12
      unsigned MinRequiredSize = 0;
597
60
      for(unsigned i = 0, e = VT->getNumElements(); i < e; 
++i48
) {
598
48
        if (auto* IntElement =
599
48
              dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
600
48
          bool signedElement = IntElement->getValue().isNegative();
601
48
          // Get the element min required size.
602
48
          unsigned ElementMinRequiredSize =
603
48
            IntElement->getValue().getMinSignedBits() - 1;
604
48
          // In case one element is signed then all the vector is signed.
605
48
          isSigned |= signedElement;
606
48
          // Save the max required bit size between all the elements.
607
48
          MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
608
48
        }
609
0
        else {
610
0
          // not an int constant element
611
0
          return MaxRequiredSize;
612
0
        }
613
48
      }
614
12
      return MinRequiredSize;
615
36
    }
616
36
617
36
    if (const auto* CI = dyn_cast<ConstantInt>(Val)) {
618
0
      isSigned = CI->getValue().isNegative();
619
0
      return CI->getValue().getMinSignedBits() - 1;
620
0
    }
621
36
622
36
    if (const auto* Cast = dyn_cast<SExtInst>(Val)) {
623
6
      isSigned = true;
624
6
      return Cast->getSrcTy()->getScalarSizeInBits() - 1;
625
6
    }
626
30
627
30
    if (const auto* Cast = dyn_cast<ZExtInst>(Val)) {
628
6
      isSigned = false;
629
6
      return Cast->getSrcTy()->getScalarSizeInBits();
630
6
    }
631
24
632
24
    isSigned = false;
633
24
    return Val->getType()->getScalarSizeInBits();
634
24
  }
635
636
16.7k
  bool isStridedAccess(const SCEV *Ptr) {
637
16.7k
    return Ptr && 
isa<SCEVAddRecExpr>(Ptr)9.24k
;
638
16.7k
  }
639
640
  const SCEVConstant *getConstantStrideStep(ScalarEvolution *SE,
641
15.6k
                                            const SCEV *Ptr) {
642
15.6k
    if (!isStridedAccess(Ptr))
643
8.25k
      return nullptr;
644
7.39k
    const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
645
7.39k
    return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
646
7.39k
  }
647
648
  bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
649
14.8k
                                       int64_t MergeDistance) {
650
14.8k
    const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
651
14.8k
    if (!Step)
652
8.29k
      return false;
653
6.58k
    APInt StrideVal = Step->getAPInt();
654
6.58k
    if (StrideVal.getBitWidth() > 64)
655
0
      return false;
656
6.58k
    // FIXME: Need to take absolute value for negative stride case.
657
6.58k
    return StrideVal.getSExtValue() < MergeDistance;
658
6.58k
  }
659
};
660
661
/// CRTP base class for use as a mix-in that aids implementing
662
/// a TargetTransformInfo-compatible class.
663
template <typename T>
664
class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
665
private:
666
  typedef TargetTransformInfoImplBase BaseT;
667
668
protected:
669
15.7M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
11.5M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
38.0k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AMDGPUTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
440k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
402k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
598k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
30.2k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
627
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
18.9k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
83.1k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
78.2k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
28.6k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
2.40M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
1.87k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
16.8k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
669
92.7k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
670
671
public:
672
  using BaseT::getCallCost;
673
674
7.62M
  unsigned getCallCost(const Function *F, int NumArgs) {
675
7.62M
    assert(F && "A concrete function must be provided to this routine.");
676
7.62M
677
7.62M
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
7.62M
682
7.62M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
1.58M
      FunctionType *FTy = F->getFunctionType();
684
1.58M
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
1.58M
      return static_cast<T *>(this)
686
1.58M
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
1.58M
    }
688
6.04M
689
6.04M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
47
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
6.04M
                             // directly.
692
6.04M
693
6.04M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
6.04M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
5.94M
  unsigned getCallCost(const Function *F, int NumArgs) {
675
5.94M
    assert(F && "A concrete function must be provided to this routine.");
676
5.94M
677
5.94M
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
5.94M
682
5.94M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
1.25M
      FunctionType *FTy = F->getFunctionType();
684
1.25M
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
1.25M
      return static_cast<T *>(this)
686
1.25M
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
1.25M
    }
688
4.69M
689
4.69M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
6
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
4.69M
                             // directly.
692
4.69M
693
4.69M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
4.69M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
2
  unsigned getCallCost(const Function *F, int NumArgs) {
675
2
    assert(F && "A concrete function must be provided to this routine.");
676
2
677
2
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
2
682
2
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
2
      FunctionType *FTy = F->getFunctionType();
684
2
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
2
      return static_cast<T *>(this)
686
2
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
2
    }
688
0
689
0
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
0
                             // directly.
692
0
693
0
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
1.17k
  unsigned getCallCost(const Function *F, int NumArgs) {
675
1.17k
    assert(F && "A concrete function must be provided to this routine.");
676
1.17k
677
1.17k
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
1.17k
682
1.17k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
806
      FunctionType *FTy = F->getFunctionType();
684
806
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
806
      return static_cast<T *>(this)
686
806
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
806
    }
688
373
689
373
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
20
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
353
                             // directly.
692
353
693
353
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
353
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
402k
  unsigned getCallCost(const Function *F, int NumArgs) {
675
402k
    assert(F && "A concrete function must be provided to this routine.");
676
402k
677
402k
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
402k
682
402k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
79.1k
      FunctionType *FTy = F->getFunctionType();
684
79.1k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
79.1k
      return static_cast<T *>(this)
686
79.1k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
79.1k
    }
688
323k
689
323k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
323k
                             // directly.
692
323k
693
323k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
323k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
28
  unsigned getCallCost(const Function *F, int NumArgs) {
675
28
    assert(F && "A concrete function must be provided to this routine.");
676
28
677
28
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
28
682
28
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
14
      FunctionType *FTy = F->getFunctionType();
684
14
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
14
      return static_cast<T *>(this)
686
14
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
14
    }
688
14
689
14
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
14
                             // directly.
692
14
693
14
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
14
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getCallCost(llvm::Function const*, int)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
6
  unsigned getCallCost(const Function *F, int NumArgs) {
675
6
    assert(F && "A concrete function must be provided to this routine.");
676
6
677
6
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
6
682
6
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
5
      FunctionType *FTy = F->getFunctionType();
684
5
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
5
      return static_cast<T *>(this)
686
5
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
5
    }
688
1
689
1
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
1
                             // directly.
692
1
693
1
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
1
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
20
  unsigned getCallCost(const Function *F, int NumArgs) {
675
20
    assert(F && "A concrete function must be provided to this routine.");
676
20
677
20
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
20
682
20
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
16
      FunctionType *FTy = F->getFunctionType();
684
16
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
16
      return static_cast<T *>(this)
686
16
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
16
    }
688
4
689
4
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
4
                             // directly.
692
4
693
4
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
4
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
196
  unsigned getCallCost(const Function *F, int NumArgs) {
675
196
    assert(F && "A concrete function must be provided to this routine.");
676
196
677
196
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
196
682
196
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
59
      FunctionType *FTy = F->getFunctionType();
684
59
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
59
      return static_cast<T *>(this)
686
59
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
59
    }
688
137
689
137
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
17
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
120
                             // directly.
692
120
693
120
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
120
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
52
  unsigned getCallCost(const Function *F, int NumArgs) {
675
52
    assert(F && "A concrete function must be provided to this routine.");
676
52
677
52
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
52
682
52
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
20
      FunctionType *FTy = F->getFunctionType();
684
20
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
20
      return static_cast<T *>(this)
686
20
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
20
    }
688
32
689
32
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
32
                             // directly.
692
32
693
32
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
32
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getCallCost(llvm::Function const*, int)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
1.26M
  unsigned getCallCost(const Function *F, int NumArgs) {
675
1.26M
    assert(F && "A concrete function must be provided to this routine.");
676
1.26M
677
1.26M
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
1.26M
682
1.26M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
249k
      FunctionType *FTy = F->getFunctionType();
684
249k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
249k
      return static_cast<T *>(this)
686
249k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
249k
    }
688
1.01M
689
1.01M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
2
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
1.01M
                             // directly.
692
1.01M
693
1.01M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
1.01M
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getCallCost(llvm::Function const*, int)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
674
6.90k
  unsigned getCallCost(const Function *F, int NumArgs) {
675
6.90k
    assert(F && "A concrete function must be provided to this routine.");
676
6.90k
677
6.90k
    if (NumArgs < 0)
678
0
      // Set the argument number to the number of explicit arguments in the
679
0
      // function.
680
0
      NumArgs = F->arg_size();
681
6.90k
682
6.90k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
683
433
      FunctionType *FTy = F->getFunctionType();
684
433
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
685
433
      return static_cast<T *>(this)
686
433
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
687
433
    }
688
6.46k
689
6.46k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
690
2
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
691
6.46k
                             // directly.
692
6.46k
693
6.46k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
694
6.46k
  }
695
696
7.62M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
7.62M
    // Simply delegate to generic handling of the call.
698
7.62M
    // FIXME: We should use instsimplify or something else to catch calls which
699
7.62M
    // will constant fold with these arguments.
700
7.62M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
7.62M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
5.94M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
5.94M
    // Simply delegate to generic handling of the call.
698
5.94M
    // FIXME: We should use instsimplify or something else to catch calls which
699
5.94M
    // will constant fold with these arguments.
700
5.94M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
5.94M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
2
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
2
    // Simply delegate to generic handling of the call.
698
2
    // FIXME: We should use instsimplify or something else to catch calls which
699
2
    // will constant fold with these arguments.
700
2
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
2
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
1.17k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
1.17k
    // Simply delegate to generic handling of the call.
698
1.17k
    // FIXME: We should use instsimplify or something else to catch calls which
699
1.17k
    // will constant fold with these arguments.
700
1.17k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
1.17k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
402k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
402k
    // Simply delegate to generic handling of the call.
698
402k
    // FIXME: We should use instsimplify or something else to catch calls which
699
402k
    // will constant fold with these arguments.
700
402k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
402k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
28
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
28
    // Simply delegate to generic handling of the call.
698
28
    // FIXME: We should use instsimplify or something else to catch calls which
699
28
    // will constant fold with these arguments.
700
28
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
28
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
6
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
6
    // Simply delegate to generic handling of the call.
698
6
    // FIXME: We should use instsimplify or something else to catch calls which
699
6
    // will constant fold with these arguments.
700
6
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
6
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
20
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
20
    // Simply delegate to generic handling of the call.
698
20
    // FIXME: We should use instsimplify or something else to catch calls which
699
20
    // will constant fold with these arguments.
700
20
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
20
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
196
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
196
    // Simply delegate to generic handling of the call.
698
196
    // FIXME: We should use instsimplify or something else to catch calls which
699
196
    // will constant fold with these arguments.
700
196
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
196
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
52
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
52
    // Simply delegate to generic handling of the call.
698
52
    // FIXME: We should use instsimplify or something else to catch calls which
699
52
    // will constant fold with these arguments.
700
52
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
52
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
1.26M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
1.26M
    // Simply delegate to generic handling of the call.
698
1.26M
    // FIXME: We should use instsimplify or something else to catch calls which
699
1.26M
    // will constant fold with these arguments.
700
1.26M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
1.26M
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
696
6.90k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
697
6.90k
    // Simply delegate to generic handling of the call.
698
6.90k
    // FIXME: We should use instsimplify or something else to catch calls which
699
6.90k
    // will constant fold with these arguments.
700
6.90k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
701
6.90k
  }
702
703
  using BaseT::getGEPCost;
704
705
  int getGEPCost(Type *PointeeType, const Value *Ptr,
706
6.27M
                 ArrayRef<const Value *> Operands) {
707
6.27M
    const GlobalValue *BaseGV = nullptr;
708
6.27M
    if (Ptr != nullptr) {
709
6.27M
      // TODO: will remove this when pointers have an opaque type.
710
6.27M
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
6.27M
                 PointeeType &&
712
6.27M
             "explicit pointee type doesn't match operand's pointee type");
713
6.27M
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
6.27M
    }
715
6.27M
    bool HasBaseReg = (BaseGV == nullptr);
716
6.27M
717
6.27M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
6.27M
    APInt BaseOffset(PtrSizeBits, 0);
719
6.27M
    int64_t Scale = 0;
720
6.27M
721
6.27M
    auto GTI = gep_type_begin(PointeeType, Operands);
722
6.27M
    Type *TargetType = nullptr;
723
6.27M
724
6.27M
    // Handle the case where the GEP instruction has a single operand,
725
6.27M
    // the basis, therefore TargetType is a nullptr.
726
6.27M
    if (Operands.empty())
727
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
728
6.27M
729
18.3M
    
for (auto I = Operands.begin(); 6.27M
I != Operands.end();
++I, ++GTI12.0M
) {
730
12.2M
      TargetType = GTI.getIndexedType();
731
12.2M
      // We assume that the cost of Scalar GEP with constant index and the
732
12.2M
      // cost of Vector GEP with splat constant index are the same.
733
12.2M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
12.2M
      if (!ConstIdx)
735
3.38M
        if (auto Splat = getSplatValue(*I))
736
2.02k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
12.2M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
4.43M
        // For structures the index is always splat or scalar constant
739
4.43M
        assert(ConstIdx && "Unexpected GEP index");
740
4.43M
        uint64_t Field = ConstIdx->getZExtValue();
741
4.43M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
7.78M
      } else {
743
7.78M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
7.78M
        if (ConstIdx) {
745
4.40M
          BaseOffset +=
746
4.40M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
4.40M
        } else {
748
3.38M
          // Needs scale register.
749
3.38M
          if (Scale != 0)
750
128k
            // No addressing mode takes two scale registers.
751
128k
            return TTI::TCC_Basic;
752
3.25M
          Scale = ElementSize;
753
3.25M
        }
754
7.78M
      }
755
12.2M
    }
756
6.27M
757
6.27M
    // Assumes the address space is 0 when Ptr is nullptr.
758
6.27M
    unsigned AS =
759
6.14M
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
6.14M
761
6.14M
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
6.14M
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
6.14M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
4.75M
      return TTI::TCC_Free;
765
1.39M
    return TTI::TCC_Basic;
766
1.39M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
5.65M
                 ArrayRef<const Value *> Operands) {
707
5.65M
    const GlobalValue *BaseGV = nullptr;
708
5.65M
    if (Ptr != nullptr) {
709
5.65M
      // TODO: will remove this when pointers have an opaque type.
710
5.65M
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
5.65M
                 PointeeType &&
712
5.65M
             "explicit pointee type doesn't match operand's pointee type");
713
5.65M
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
5.65M
    }
715
5.65M
    bool HasBaseReg = (BaseGV == nullptr);
716
5.65M
717
5.65M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
5.65M
    APInt BaseOffset(PtrSizeBits, 0);
719
5.65M
    int64_t Scale = 0;
720
5.65M
721
5.65M
    auto GTI = gep_type_begin(PointeeType, Operands);
722
5.65M
    Type *TargetType = nullptr;
723
5.65M
724
5.65M
    // Handle the case where the GEP instruction has a single operand,
725
5.65M
    // the basis, therefore TargetType is a nullptr.
726
5.65M
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
5.65M
729
16.3M
    
for (auto I = Operands.begin(); 5.65M
I != Operands.end();
++I, ++GTI10.6M
) {
730
10.7M
      TargetType = GTI.getIndexedType();
731
10.7M
      // We assume that the cost of Scalar GEP with constant index and the
732
10.7M
      // cost of Vector GEP with splat constant index are the same.
733
10.7M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
10.7M
      if (!ConstIdx)
735
3.01M
        if (auto Splat = getSplatValue(*I))
736
24
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
10.7M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
3.81M
        // For structures the index is always splat or scalar constant
739
3.81M
        assert(ConstIdx && "Unexpected GEP index");
740
3.81M
        uint64_t Field = ConstIdx->getZExtValue();
741
3.81M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
6.96M
      } else {
743
6.96M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
6.96M
        if (ConstIdx) {
745
3.94M
          BaseOffset +=
746
3.94M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
3.94M
        } else {
748
3.01M
          // Needs scale register.
749
3.01M
          if (Scale != 0)
750
108k
            // No addressing mode takes two scale registers.
751
108k
            return TTI::TCC_Basic;
752
2.90M
          Scale = ElementSize;
753
2.90M
        }
754
6.96M
      }
755
10.7M
    }
756
5.65M
757
5.65M
    // Assumes the address space is 0 when Ptr is nullptr.
758
5.65M
    unsigned AS =
759
5.54M
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
5.54M
761
5.54M
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
5.54M
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
5.54M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
4.32M
      return TTI::TCC_Free;
765
1.21M
    return TTI::TCC_Basic;
766
1.21M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
1.83k
                 ArrayRef<const Value *> Operands) {
707
1.83k
    const GlobalValue *BaseGV = nullptr;
708
1.83k
    if (Ptr != nullptr) {
709
1.83k
      // TODO: will remove this when pointers have an opaque type.
710
1.83k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
1.83k
                 PointeeType &&
712
1.83k
             "explicit pointee type doesn't match operand's pointee type");
713
1.83k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
1.83k
    }
715
1.83k
    bool HasBaseReg = (BaseGV == nullptr);
716
1.83k
717
1.83k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
1.83k
    APInt BaseOffset(PtrSizeBits, 0);
719
1.83k
    int64_t Scale = 0;
720
1.83k
721
1.83k
    auto GTI = gep_type_begin(PointeeType, Operands);
722
1.83k
    Type *TargetType = nullptr;
723
1.83k
724
1.83k
    // Handle the case where the GEP instruction has a single operand,
725
1.83k
    // the basis, therefore TargetType is a nullptr.
726
1.83k
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
1.83k
729
4.61k
    
for (auto I = Operands.begin(); 1.83k
I != Operands.end();
++I, ++GTI2.77k
) {
730
2.77k
      TargetType = GTI.getIndexedType();
731
2.77k
      // We assume that the cost of Scalar GEP with constant index and the
732
2.77k
      // cost of Vector GEP with splat constant index are the same.
733
2.77k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
2.77k
      if (!ConstIdx)
735
1.03k
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
2.77k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
112
        // For structures the index is always splat or scalar constant
739
112
        assert(ConstIdx && "Unexpected GEP index");
740
112
        uint64_t Field = ConstIdx->getZExtValue();
741
112
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
2.66k
      } else {
743
2.66k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
2.66k
        if (ConstIdx) {
745
1.62k
          BaseOffset +=
746
1.62k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
1.62k
        } else {
748
1.03k
          // Needs scale register.
749
1.03k
          if (Scale != 0)
750
0
            // No addressing mode takes two scale registers.
751
0
            return TTI::TCC_Basic;
752
1.03k
          Scale = ElementSize;
753
1.03k
        }
754
2.66k
      }
755
2.77k
    }
756
1.83k
757
1.83k
    // Assumes the address space is 0 when Ptr is nullptr.
758
1.83k
    unsigned AS =
759
1.83k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
1.83k
761
1.83k
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
1.83k
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
1.83k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
890
      return TTI::TCC_Free;
765
948
    return TTI::TCC_Basic;
766
948
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
32.9k
                 ArrayRef<const Value *> Operands) {
707
32.9k
    const GlobalValue *BaseGV = nullptr;
708
32.9k
    if (Ptr != nullptr) {
709
32.9k
      // TODO: will remove this when pointers have an opaque type.
710
32.9k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
32.9k
                 PointeeType &&
712
32.9k
             "explicit pointee type doesn't match operand's pointee type");
713
32.9k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
32.9k
    }
715
32.9k
    bool HasBaseReg = (BaseGV == nullptr);
716
32.9k
717
32.9k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
32.9k
    APInt BaseOffset(PtrSizeBits, 0);
719
32.9k
    int64_t Scale = 0;
720
32.9k
721
32.9k
    auto GTI = gep_type_begin(PointeeType, Operands);
722
32.9k
    Type *TargetType = nullptr;
723
32.9k
724
32.9k
    // Handle the case where the GEP instruction has a single operand,
725
32.9k
    // the basis, therefore TargetType is a nullptr.
726
32.9k
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
32.9k
729
70.6k
    
for (auto I = Operands.begin(); 32.9k
I != Operands.end();
++I, ++GTI37.7k
) {
730
37.8k
      TargetType = GTI.getIndexedType();
731
37.8k
      // We assume that the cost of Scalar GEP with constant index and the
732
37.8k
      // cost of Vector GEP with splat constant index are the same.
733
37.8k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
37.8k
      if (!ConstIdx)
735
18.9k
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
37.8k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
413
        // For structures the index is always splat or scalar constant
739
413
        assert(ConstIdx && "Unexpected GEP index");
740
413
        uint64_t Field = ConstIdx->getZExtValue();
741
413
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
37.4k
      } else {
743
37.4k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
37.4k
        if (ConstIdx) {
745
18.4k
          BaseOffset +=
746
18.4k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
18.9k
        } else {
748
18.9k
          // Needs scale register.
749
18.9k
          if (Scale != 0)
750
137
            // No addressing mode takes two scale registers.
751
137
            return TTI::TCC_Basic;
752
18.8k
          Scale = ElementSize;
753
18.8k
        }
754
37.4k
      }
755
37.8k
    }
756
32.9k
757
32.9k
    // Assumes the address space is 0 when Ptr is nullptr.
758
32.9k
    unsigned AS =
759
32.7k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
32.7k
761
32.7k
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
32.7k
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
32.7k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
10.2k
      return TTI::TCC_Free;
765
22.5k
    return TTI::TCC_Basic;
766
22.5k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
98.7k
                 ArrayRef<const Value *> Operands) {
707
98.7k
    const GlobalValue *BaseGV = nullptr;
708
98.7k
    if (Ptr != nullptr) {
709
98.7k
      // TODO: will remove this when pointers have an opaque type.
710
98.7k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
98.7k
                 PointeeType &&
712
98.7k
             "explicit pointee type doesn't match operand's pointee type");
713
98.7k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
98.7k
    }
715
98.7k
    bool HasBaseReg = (BaseGV == nullptr);
716
98.7k
717
98.7k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
98.7k
    APInt BaseOffset(PtrSizeBits, 0);
719
98.7k
    int64_t Scale = 0;
720
98.7k
721
98.7k
    auto GTI = gep_type_begin(PointeeType, Operands);
722
98.7k
    Type *TargetType = nullptr;
723
98.7k
724
98.7k
    // Handle the case where the GEP instruction has a single operand,
725
98.7k
    // the basis, therefore TargetType is a nullptr.
726
98.7k
    if (Operands.empty())
727
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
728
98.7k
729
324k
    
for (auto I = Operands.begin(); 98.7k
I != Operands.end();
++I, ++GTI226k
) {
730
232k
      TargetType = GTI.getIndexedType();
731
232k
      // We assume that the cost of Scalar GEP with constant index and the
732
232k
      // cost of Vector GEP with splat constant index are the same.
733
232k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
232k
      if (!ConstIdx)
735
71.4k
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
232k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
87.8k
        // For structures the index is always splat or scalar constant
739
87.8k
        assert(ConstIdx && "Unexpected GEP index");
740
87.8k
        uint64_t Field = ConstIdx->getZExtValue();
741
87.8k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
144k
      } else {
743
144k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
144k
        if (ConstIdx) {
745
73.0k
          BaseOffset +=
746
73.0k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
73.0k
        } else {
748
71.4k
          // Needs scale register.
749
71.4k
          if (Scale != 0)
750
6.22k
            // No addressing mode takes two scale registers.
751
6.22k
            return TTI::TCC_Basic;
752
65.2k
          Scale = ElementSize;
753
65.2k
        }
754
144k
      }
755
232k
    }
756
98.7k
757
98.7k
    // Assumes the address space is 0 when Ptr is nullptr.
758
98.7k
    unsigned AS =
759
92.5k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
92.5k
761
92.5k
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
92.5k
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
92.5k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
56.1k
      return TTI::TCC_Free;
765
36.3k
    return TTI::TCC_Basic;
766
36.3k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
27
                 ArrayRef<const Value *> Operands) {
707
27
    const GlobalValue *BaseGV = nullptr;
708
27
    if (Ptr != nullptr) {
709
27
      // TODO: will remove this when pointers have an opaque type.
710
27
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
27
                 PointeeType &&
712
27
             "explicit pointee type doesn't match operand's pointee type");
713
27
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
27
    }
715
27
    bool HasBaseReg = (BaseGV == nullptr);
716
27
717
27
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
27
    APInt BaseOffset(PtrSizeBits, 0);
719
27
    int64_t Scale = 0;
720
27
721
27
    auto GTI = gep_type_begin(PointeeType, Operands);
722
27
    Type *TargetType = nullptr;
723
27
724
27
    // Handle the case where the GEP instruction has a single operand,
725
27
    // the basis, therefore TargetType is a nullptr.
726
27
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
27
729
82
    
for (auto I = Operands.begin(); 27
I != Operands.end();
++I, ++GTI55
) {
730
55
      TargetType = GTI.getIndexedType();
731
55
      // We assume that the cost of Scalar GEP with constant index and the
732
55
      // cost of Vector GEP with splat constant index are the same.
733
55
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
55
      if (!ConstIdx)
735
3
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
55
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
14
        // For structures the index is always splat or scalar constant
739
14
        assert(ConstIdx && "Unexpected GEP index");
740
14
        uint64_t Field = ConstIdx->getZExtValue();
741
14
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
41
      } else {
743
41
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
41
        if (ConstIdx) {
745
38
          BaseOffset +=
746
38
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
38
        } else {
748
3
          // Needs scale register.
749
3
          if (Scale != 0)
750
0
            // No addressing mode takes two scale registers.
751
0
            return TTI::TCC_Basic;
752
3
          Scale = ElementSize;
753
3
        }
754
41
      }
755
55
    }
756
27
757
27
    // Assumes the address space is 0 when Ptr is nullptr.
758
27
    unsigned AS =
759
27
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
27
761
27
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
27
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
27
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
24
      return TTI::TCC_Free;
765
3
    return TTI::TCC_Basic;
766
3
  }
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
706
329
                 ArrayRef<const Value *> Operands) {
707
329
    const GlobalValue *BaseGV = nullptr;
708
329
    if (Ptr != nullptr) {
709
329
      // TODO: will remove this when pointers have an opaque type.
710
329
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
329
                 PointeeType &&
712
329
             "explicit pointee type doesn't match operand's pointee type");
713
329
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
329
    }
715
329
    bool HasBaseReg = (BaseGV == nullptr);
716
329
717
329
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
329
    APInt BaseOffset(PtrSizeBits, 0);
719
329
    int64_t Scale = 0;
720
329
721
329
    auto GTI = gep_type_begin(PointeeType, Operands);
722
329
    Type *TargetType = nullptr;
723
329
724
329
    // Handle the case where the GEP instruction has a single operand,
725
329
    // the basis, therefore TargetType is a nullptr.
726
329
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
329
729
756
    
for (auto I = Operands.begin(); 329
I != Operands.end();
++I, ++GTI427
) {
730
499
      TargetType = GTI.getIndexedType();
731
499
      // We assume that the cost of Scalar GEP with constant index and the
732
499
      // cost of Vector GEP with splat constant index are the same.
733
499
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
499
      if (!ConstIdx)
735
270
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
499
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
10
        // For structures the index is always splat or scalar constant
739
10
        assert(ConstIdx && "Unexpected GEP index");
740
10
        uint64_t Field = ConstIdx->getZExtValue();
741
10
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
489
      } else {
743
489
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
489
        if (ConstIdx) {
745
219
          BaseOffset +=
746
219
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
270
        } else {
748
270
          // Needs scale register.
749
270
          if (Scale != 0)
750
72
            // No addressing mode takes two scale registers.
751
72
            return TTI::TCC_Basic;
752
198
          Scale = ElementSize;
753
198
        }
754
489
      }
755
499
    }
756
329
757
329
    // Assumes the address space is 0 when Ptr is nullptr.
758
329
    unsigned AS =
759
257
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
257
761
257
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
257
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
257
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
126
      return TTI::TCC_Free;
765
131
    return TTI::TCC_Basic;
766
131
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
855
                 ArrayRef<const Value *> Operands) {
707
855
    const GlobalValue *BaseGV = nullptr;
708
855
    if (Ptr != nullptr) {
709
855
      // TODO: will remove this when pointers have an opaque type.
710
855
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
855
                 PointeeType &&
712
855
             "explicit pointee type doesn't match operand's pointee type");
713
855
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
855
    }
715
855
    bool HasBaseReg = (BaseGV == nullptr);
716
855
717
855
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
855
    APInt BaseOffset(PtrSizeBits, 0);
719
855
    int64_t Scale = 0;
720
855
721
855
    auto GTI = gep_type_begin(PointeeType, Operands);
722
855
    Type *TargetType = nullptr;
723
855
724
855
    // Handle the case where the GEP instruction has a single operand,
725
855
    // the basis, therefore TargetType is a nullptr.
726
855
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
855
729
1.88k
    
for (auto I = Operands.begin(); 855
I != Operands.end();
++I, ++GTI1.02k
) {
730
1.03k
      TargetType = GTI.getIndexedType();
731
1.03k
      // We assume that the cost of Scalar GEP with constant index and the
732
1.03k
      // cost of Vector GEP with splat constant index are the same.
733
1.03k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
1.03k
      if (!ConstIdx)
735
488
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
1.03k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
75
        // For structures the index is always splat or scalar constant
739
75
        assert(ConstIdx && "Unexpected GEP index");
740
75
        uint64_t Field = ConstIdx->getZExtValue();
741
75
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
958
      } else {
743
958
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
958
        if (ConstIdx) {
745
470
          BaseOffset +=
746
470
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
488
        } else {
748
488
          // Needs scale register.
749
488
          if (Scale != 0)
750
6
            // No addressing mode takes two scale registers.
751
6
            return TTI::TCC_Basic;
752
482
          Scale = ElementSize;
753
482
        }
754
958
      }
755
1.03k
    }
756
855
757
855
    // Assumes the address space is 0 when Ptr is nullptr.
758
855
    unsigned AS =
759
849
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
849
761
849
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
849
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
849
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
544
      return TTI::TCC_Free;
765
305
    return TTI::TCC_Basic;
766
305
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
706
75
                 ArrayRef<const Value *> Operands) {
707
75
    const GlobalValue *BaseGV = nullptr;
708
75
    if (Ptr != nullptr) {
709
75
      // TODO: will remove this when pointers have an opaque type.
710
75
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
75
                 PointeeType &&
712
75
             "explicit pointee type doesn't match operand's pointee type");
713
75
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
75
    }
715
75
    bool HasBaseReg = (BaseGV == nullptr);
716
75
717
75
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
75
    APInt BaseOffset(PtrSizeBits, 0);
719
75
    int64_t Scale = 0;
720
75
721
75
    auto GTI = gep_type_begin(PointeeType, Operands);
722
75
    Type *TargetType = nullptr;
723
75
724
75
    // Handle the case where the GEP instruction has a single operand,
725
75
    // the basis, therefore TargetType is a nullptr.
726
75
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
75
729
211
    
for (auto I = Operands.begin(); 75
I != Operands.end();
++I, ++GTI136
) {
730
136
      TargetType = GTI.getIndexedType();
731
136
      // We assume that the cost of Scalar GEP with constant index and the
732
136
      // cost of Vector GEP with splat constant index are the same.
733
136
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
136
      if (!ConstIdx)
735
54
        if (auto Splat = getSplatValue(*I))
736
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
136
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
39
        // For structures the index is always splat or scalar constant
739
39
        assert(ConstIdx && "Unexpected GEP index");
740
39
        uint64_t Field = ConstIdx->getZExtValue();
741
39
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
97
      } else {
743
97
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
97
        if (ConstIdx) {
745
43
          BaseOffset +=
746
43
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
54
        } else {
748
54
          // Needs scale register.
749
54
          if (Scale != 0)
750
0
            // No addressing mode takes two scale registers.
751
0
            return TTI::TCC_Basic;
752
54
          Scale = ElementSize;
753
54
        }
754
97
      }
755
136
    }
756
75
757
75
    // Assumes the address space is 0 when Ptr is nullptr.
758
75
    unsigned AS =
759
75
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
75
761
75
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
75
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
75
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
21
      return TTI::TCC_Free;
765
54
    return TTI::TCC_Basic;
766
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
706
477k
                 ArrayRef<const Value *> Operands) {
707
477k
    const GlobalValue *BaseGV = nullptr;
708
477k
    if (Ptr != nullptr) {
709
477k
      // TODO: will remove this when pointers have an opaque type.
710
477k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
477k
                 PointeeType &&
712
477k
             "explicit pointee type doesn't match operand's pointee type");
713
477k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
477k
    }
715
477k
    bool HasBaseReg = (BaseGV == nullptr);
716
477k
717
477k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
477k
    APInt BaseOffset(PtrSizeBits, 0);
719
477k
    int64_t Scale = 0;
720
477k
721
477k
    auto GTI = gep_type_begin(PointeeType, Operands);
722
477k
    Type *TargetType = nullptr;
723
477k
724
477k
    // Handle the case where the GEP instruction has a single operand,
725
477k
    // the basis, therefore TargetType is a nullptr.
726
477k
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
477k
729
1.62M
    
for (auto I = Operands.begin(); 477k
I != Operands.end();
++I, ++GTI1.14M
) {
730
1.15M
      TargetType = GTI.getIndexedType();
731
1.15M
      // We assume that the cost of Scalar GEP with constant index and the
732
1.15M
      // cost of Vector GEP with splat constant index are the same.
733
1.15M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
1.15M
      if (!ConstIdx)
735
272k
        if (auto Splat = getSplatValue(*I))
736
4
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
1.15M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
531k
        // For structures the index is always splat or scalar constant
739
531k
        assert(ConstIdx && "Unexpected GEP index");
740
531k
        uint64_t Field = ConstIdx->getZExtValue();
741
531k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
625k
      } else {
743
625k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
625k
        if (ConstIdx) {
745
353k
          BaseOffset +=
746
353k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
353k
        } else {
748
272k
          // Needs scale register.
749
272k
          if (Scale != 0)
750
12.8k
            // No addressing mode takes two scale registers.
751
12.8k
            return TTI::TCC_Basic;
752
259k
          Scale = ElementSize;
753
259k
        }
754
625k
      }
755
1.15M
    }
756
477k
757
477k
    // Assumes the address space is 0 when Ptr is nullptr.
758
477k
    unsigned AS =
759
464k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
464k
761
464k
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
464k
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
464k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
356k
      return TTI::TCC_Free;
765
107k
    return TTI::TCC_Basic;
766
107k
  }
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
706
9.70k
                 ArrayRef<const Value *> Operands) {
707
9.70k
    const GlobalValue *BaseGV = nullptr;
708
9.70k
    if (Ptr != nullptr) {
709
9.70k
      // TODO: will remove this when pointers have an opaque type.
710
9.70k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
711
9.70k
                 PointeeType &&
712
9.70k
             "explicit pointee type doesn't match operand's pointee type");
713
9.70k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
714
9.70k
    }
715
9.70k
    bool HasBaseReg = (BaseGV == nullptr);
716
9.70k
717
9.70k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
718
9.70k
    APInt BaseOffset(PtrSizeBits, 0);
719
9.70k
    int64_t Scale = 0;
720
9.70k
721
9.70k
    auto GTI = gep_type_begin(PointeeType, Operands);
722
9.70k
    Type *TargetType = nullptr;
723
9.70k
724
9.70k
    // Handle the case where the GEP instruction has a single operand,
725
9.70k
    // the basis, therefore TargetType is a nullptr.
726
9.70k
    if (Operands.empty())
727
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
728
9.70k
729
24.2k
    
for (auto I = Operands.begin(); 9.70k
I != Operands.end();
++I, ++GTI14.5k
) {
730
14.5k
      TargetType = GTI.getIndexedType();
731
14.5k
      // We assume that the cost of Scalar GEP with constant index and the
732
14.5k
      // cost of Vector GEP with splat constant index are the same.
733
14.5k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
734
14.5k
      if (!ConstIdx)
735
9.54k
        if (auto Splat = getSplatValue(*I))
736
2.00k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
737
14.5k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
738
232
        // For structures the index is always splat or scalar constant
739
232
        assert(ConstIdx && "Unexpected GEP index");
740
232
        uint64_t Field = ConstIdx->getZExtValue();
741
232
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
742
14.3k
      } else {
743
14.3k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
744
14.3k
        if (ConstIdx) {
745
6.82k
          BaseOffset +=
746
6.82k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
747
7.54k
        } else {
748
7.54k
          // Needs scale register.
749
7.54k
          if (Scale != 0)
750
22
            // No addressing mode takes two scale registers.
751
22
            return TTI::TCC_Basic;
752
7.51k
          Scale = ElementSize;
753
7.51k
        }
754
14.3k
      }
755
14.5k
    }
756
9.70k
757
9.70k
    // Assumes the address space is 0 when Ptr is nullptr.
758
9.70k
    unsigned AS =
759
9.67k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
760
9.67k
761
9.67k
    if (static_cast<T *>(this)->isLegalAddressingMode(
762
9.67k
            TargetType, const_cast<GlobalValue *>(BaseGV),
763
9.67k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
764
36
      return TTI::TCC_Free;
765
9.64k
    return TTI::TCC_Basic;
766
9.64k
  }
767
768
  using BaseT::getIntrinsicCost;
769
770
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
771
4
                            ArrayRef<const Value *> Arguments) {
772
4
    // Delegate to the generic intrinsic handling code. This mostly provides an
773
4
    // opportunity for targets to (for example) special case the cost of
774
4
    // certain intrinsics based on constants used as arguments.
775
4
    SmallVector<Type *, 8> ParamTys;
776
4
    ParamTys.reserve(Arguments.size());
777
12
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx8
)
778
8
      ParamTys.push_back(Arguments[Idx]->getType());
779
4
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
780
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
771
2
                            ArrayRef<const Value *> Arguments) {
772
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
773
2
    // opportunity for targets to (for example) special case the cost of
774
2
    // certain intrinsics based on constants used as arguments.
775
2
    SmallVector<Type *, 8> ParamTys;
776
2
    ParamTys.reserve(Arguments.size());
777
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
778
4
      ParamTys.push_back(Arguments[Idx]->getType());
779
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
780
2
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::WebAssemblyTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
771
2
                            ArrayRef<const Value *> Arguments) {
772
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
773
2
    // opportunity for targets to (for example) special case the cost of
774
2
    // certain intrinsics based on constants used as arguments.
775
2
    SmallVector<Type *, 8> ParamTys;
776
2
    ParamTys.reserve(Arguments.size());
777
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
778
4
      ParamTys.push_back(Arguments[Idx]->getType());
779
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
780
2
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Unexecuted instantiation: TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
781
782
46.2M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
46.2M
    if (isa<PHINode>(U))
784
3.64M
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
42.5M
786
42.5M
    // Static alloca doesn't generate target instructions.
787
42.5M
    if (auto *A = dyn_cast<AllocaInst>(U))
788
112
      if (A->isStaticAlloca())
789
2
        return TTI::TCC_Free;
790
42.5M
791
42.5M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
6.24M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
6.24M
                                                GEP->getPointerOperand(),
794
6.24M
                                                Operands.drop_front());
795
6.24M
    }
796
36.3M
797
36.3M
    if (auto CS = ImmutableCallSite(U)) {
798
7.91M
      const Function *F = CS.getCalledFunction();
799
7.91M
      if (!F) {
800
286k
        // Just use the called value type.
801
286k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
286k
        return static_cast<T *>(this)
803
286k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
286k
      }
805
7.62M
806
7.62M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
7.62M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
7.62M
    }
809
28.4M
810
28.4M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
6.10M
      // Result of a cmp instruction is often extended (to be used by other
812
6.10M
      // cmp instructions, logical or return instructions). These are usually
813
6.10M
      // nop on most sane targets.
814
6.10M
      if (isa<CmpInst>(CI->getOperand(0)))
815
119k
        return TTI::TCC_Free;
816
5.98M
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)5.06M
||
isa<FPExtInst>(CI)4.31M
)
817
1.73M
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
26.5M
    }
819
26.5M
820
26.5M
    return static_cast<T *>(this)->getOperationCost(
821
26.5M
        Operator::getOpcode(U), U->getType(),
822
26.5M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()11.0M
:
nullptr15.5M
);
823
26.5M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
41.0M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
41.0M
    if (isa<PHINode>(U))
784
3.38M
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
37.6M
786
37.6M
    // Static alloca doesn't generate target instructions.
787
37.6M
    if (auto *A = dyn_cast<AllocaInst>(U))
788
64
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
37.6M
791
37.6M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
5.65M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
5.65M
                                                GEP->getPointerOperand(),
794
5.65M
                                                Operands.drop_front());
795
5.65M
    }
796
31.9M
797
31.9M
    if (auto CS = ImmutableCallSite(U)) {
798
6.14M
      const Function *F = CS.getCalledFunction();
799
6.14M
      if (!F) {
800
194k
        // Just use the called value type.
801
194k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
194k
        return static_cast<T *>(this)
803
194k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
194k
      }
805
5.94M
806
5.94M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
5.94M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
5.94M
    }
809
25.8M
810
25.8M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
5.31M
      // Result of a cmp instruction is often extended (to be used by other
812
5.31M
      // cmp instructions, logical or return instructions). These are usually
813
5.31M
      // nop on most sane targets.
814
5.31M
      if (isa<CmpInst>(CI->getOperand(0)))
815
101k
        return TTI::TCC_Free;
816
5.20M
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)4.42M
||
isa<FPExtInst>(CI)3.80M
)
817
1.47M
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
24.2M
    }
819
24.2M
820
24.2M
    return static_cast<T *>(this)->getOperationCost(
821
24.2M
        Operator::getOpcode(U), U->getType(),
822
24.2M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()9.98M
:
nullptr14.2M
);
823
24.2M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
382
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
382
    if (isa<PHINode>(U))
784
44
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
338
786
338
    // Static alloca doesn't generate target instructions.
787
338
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
338
791
338
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
15
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
15
                                                GEP->getPointerOperand(),
794
15
                                                Operands.drop_front());
795
15
    }
796
323
797
323
    if (auto CS = ImmutableCallSite(U)) {
798
2
      const Function *F = CS.getCalledFunction();
799
2
      if (!F) {
800
0
        // Just use the called value type.
801
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
0
        return static_cast<T *>(this)
803
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
0
      }
805
2
806
2
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
2
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
2
    }
809
321
810
321
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
47
      // Result of a cmp instruction is often extended (to be used by other
812
47
      // cmp instructions, logical or return instructions). These are usually
813
47
      // nop on most sane targets.
814
47
      if (isa<CmpInst>(CI->getOperand(0)))
815
6
        return TTI::TCC_Free;
816
41
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)40
||
isa<FPExtInst>(CI)40
)
817
1
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
314
    }
819
314
820
314
    return static_cast<T *>(this)->getOperationCost(
821
314
        Operator::getOpcode(U), U->getType(),
822
314
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()66
:
nullptr248
);
823
314
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
8.59k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
8.59k
    if (isa<PHINode>(U))
784
1.36k
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
7.22k
786
7.22k
    // Static alloca doesn't generate target instructions.
787
7.22k
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
7.22k
791
7.22k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
369
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
369
                                                GEP->getPointerOperand(),
794
369
                                                Operands.drop_front());
795
369
    }
796
6.86k
797
6.86k
    if (auto CS = ImmutableCallSite(U)) {
798
1.29k
      const Function *F = CS.getCalledFunction();
799
1.29k
      if (!F) {
800
113
        // Just use the called value type.
801
113
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
113
        return static_cast<T *>(this)
803
113
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
113
      }
805
1.17k
806
1.17k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
1.17k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
1.17k
    }
809
5.56k
810
5.56k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
788
      // Result of a cmp instruction is often extended (to be used by other
812
788
      // cmp instructions, logical or return instructions). These are usually
813
788
      // nop on most sane targets.
814
788
      if (isa<CmpInst>(CI->getOperand(0)))
815
116
        return TTI::TCC_Free;
816
672
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)595
||
isa<FPExtInst>(CI)504
)
817
168
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
5.28k
    }
819
5.28k
820
5.28k
    return static_cast<T *>(this)->getOperationCost(
821
5.28k
        Operator::getOpcode(U), U->getType(),
822
5.28k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()866
:
nullptr4.41k
);
823
5.28k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
1.17M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
1.17M
    if (isa<PHINode>(U))
784
53.4k
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
1.12M
786
1.12M
    // Static alloca doesn't generate target instructions.
787
1.12M
    if (auto *A = dyn_cast<AllocaInst>(U))
788
18
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
1.12M
791
1.12M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
98.7k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
98.7k
                                                GEP->getPointerOperand(),
794
98.7k
                                                Operands.drop_front());
795
98.7k
    }
796
1.02M
797
1.02M
    if (auto CS = ImmutableCallSite(U)) {
798
413k
      const Function *F = CS.getCalledFunction();
799
413k
      if (!F) {
800
10.5k
        // Just use the called value type.
801
10.5k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
10.5k
        return static_cast<T *>(this)
803
10.5k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
10.5k
      }
805
402k
806
402k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
402k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
402k
    }
809
614k
810
614k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
200k
      // Result of a cmp instruction is often extended (to be used by other
812
200k
      // cmp instructions, logical or return instructions). These are usually
813
200k
      // nop on most sane targets.
814
200k
      if (isa<CmpInst>(CI->getOperand(0)))
815
5.67k
        return TTI::TCC_Free;
816
194k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)152k
||
isa<FPExtInst>(CI)109k
)
817
85.4k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
522k
    }
819
522k
820
522k
    return static_cast<T *>(this)->getOperationCost(
821
522k
        Operator::getOpcode(U), U->getType(),
822
522k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()220k
:
nullptr302k
);
823
522k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
288
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
288
    if (isa<PHINode>(U))
784
24
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
264
786
264
    // Static alloca doesn't generate target instructions.
787
264
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
264
791
264
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
27
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
27
                                                GEP->getPointerOperand(),
794
27
                                                Operands.drop_front());
795
27
    }
796
237
797
237
    if (auto CS = ImmutableCallSite(U)) {
798
28
      const Function *F = CS.getCalledFunction();
799
28
      if (!F) {
800
0
        // Just use the called value type.
801
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
0
        return static_cast<T *>(this)
803
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
0
      }
805
28
806
28
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
28
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
28
    }
809
209
810
209
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
30
      // Result of a cmp instruction is often extended (to be used by other
812
30
      // cmp instructions, logical or return instructions). These are usually
813
30
      // nop on most sane targets.
814
30
      if (isa<CmpInst>(CI->getOperand(0)))
815
0
        return TTI::TCC_Free;
816
30
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)28
||
isa<FPExtInst>(CI)18
)
817
12
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
197
    }
819
197
820
197
    return static_cast<T *>(this)->getOperationCost(
821
197
        Operator::getOpcode(U), U->getType(),
822
197
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()60
:
nullptr137
);
823
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
782
6
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
6
    if (isa<PHINode>(U))
784
0
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
6
786
6
    // Static alloca doesn't generate target instructions.
787
6
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
6
791
6
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
0
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
0
                                                GEP->getPointerOperand(),
794
0
                                                Operands.drop_front());
795
0
    }
796
6
797
6
    if (auto CS = ImmutableCallSite(U)) {
798
6
      const Function *F = CS.getCalledFunction();
799
6
      if (!F) {
800
0
        // Just use the called value type.
801
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
0
        return static_cast<T *>(this)
803
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
0
      }
805
6
806
6
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
6
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
6
    }
809
0
810
0
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
0
      // Result of a cmp instruction is often extended (to be used by other
812
0
      // cmp instructions, logical or return instructions). These are usually
813
0
      // nop on most sane targets.
814
0
      if (isa<CmpInst>(CI->getOperand(0)))
815
0
        return TTI::TCC_Free;
816
0
      if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
817
0
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
0
    }
819
0
820
0
    return static_cast<T *>(this)->getOperationCost(
821
0
        Operator::getOpcode(U), U->getType(),
822
0
        U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr);
823
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
134
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
134
    if (isa<PHINode>(U))
784
9
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
125
786
125
    // Static alloca doesn't generate target instructions.
787
125
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
125
791
125
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
2
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
2
                                                GEP->getPointerOperand(),
794
2
                                                Operands.drop_front());
795
2
    }
796
123
797
123
    if (auto CS = ImmutableCallSite(U)) {
798
20
      const Function *F = CS.getCalledFunction();
799
20
      if (!F) {
800
0
        // Just use the called value type.
801
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
0
        return static_cast<T *>(this)
803
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
0
      }
805
20
806
20
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
20
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
20
    }
809
103
810
103
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
17
      // Result of a cmp instruction is often extended (to be used by other
812
17
      // cmp instructions, logical or return instructions). These are usually
813
17
      // nop on most sane targets.
814
17
      if (isa<CmpInst>(CI->getOperand(0)))
815
0
        return TTI::TCC_Free;
816
17
      if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || 
isa<FPExtInst>(CI)16
)
817
1
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
102
    }
819
102
820
102
    return static_cast<T *>(this)->getOperationCost(
821
102
        Operator::getOpcode(U), U->getType(),
822
102
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()16
:
nullptr86
);
823
102
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
7.08k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
7.08k
    if (isa<PHINode>(U))
784
680
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
6.40k
786
6.40k
    // Static alloca doesn't generate target instructions.
787
6.40k
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
6.40k
791
6.40k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
855
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
855
                                                GEP->getPointerOperand(),
794
855
                                                Operands.drop_front());
795
855
    }
796
5.55k
797
5.55k
    if (auto CS = ImmutableCallSite(U)) {
798
262
      const Function *F = CS.getCalledFunction();
799
262
      if (!F) {
800
66
        // Just use the called value type.
801
66
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
66
        return static_cast<T *>(this)
803
66
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
66
      }
805
196
806
196
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
196
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
196
    }
809
5.29k
810
5.29k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
955
      // Result of a cmp instruction is often extended (to be used by other
812
955
      // cmp instructions, logical or return instructions). These are usually
813
955
      // nop on most sane targets.
814
955
      if (isa<CmpInst>(CI->getOperand(0)))
815
1
        return TTI::TCC_Free;
816
954
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)862
||
isa<FPExtInst>(CI)738
)
817
222
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
5.06k
    }
819
5.06k
820
5.06k
    return static_cast<T *>(this)->getOperationCost(
821
5.06k
        Operator::getOpcode(U), U->getType(),
822
5.06k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()1.80k
:
nullptr3.25k
);
823
5.06k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
782
1.27k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
1.27k
    if (isa<PHINode>(U))
784
67
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
1.20k
786
1.20k
    // Static alloca doesn't generate target instructions.
787
1.20k
    if (auto *A = dyn_cast<AllocaInst>(U))
788
0
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
1.20k
791
1.20k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
75
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
75
                                                GEP->getPointerOperand(),
794
75
                                                Operands.drop_front());
795
75
    }
796
1.13k
797
1.13k
    if (auto CS = ImmutableCallSite(U)) {
798
53
      const Function *F = CS.getCalledFunction();
799
53
      if (!F) {
800
1
        // Just use the called value type.
801
1
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
1
        return static_cast<T *>(this)
803
1
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
1
      }
805
52
806
52
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
52
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
52
    }
809
1.07k
810
1.07k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
76
      // Result of a cmp instruction is often extended (to be used by other
812
76
      // cmp instructions, logical or return instructions). These are usually
813
76
      // nop on most sane targets.
814
76
      if (isa<CmpInst>(CI->getOperand(0)))
815
5
        return TTI::TCC_Free;
816
71
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)67
||
isa<FPExtInst>(CI)54
)
817
17
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
1.05k
    }
819
1.05k
820
1.05k
    return static_cast<T *>(this)->getOperationCost(
821
1.05k
        Operator::getOpcode(U), U->getType(),
822
1.05k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()234
:
nullptr821
);
823
1.05k
  }
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
782
3.95M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
3.95M
    if (isa<PHINode>(U))
784
203k
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
3.74M
786
3.74M
    // Static alloca doesn't generate target instructions.
787
3.74M
    if (auto *A = dyn_cast<AllocaInst>(U))
788
28
      if (A->isStaticAlloca())
789
2
        return TTI::TCC_Free;
790
3.74M
791
3.74M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
477k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
477k
                                                GEP->getPointerOperand(),
794
477k
                                                Operands.drop_front());
795
477k
    }
796
3.27M
797
3.27M
    if (auto CS = ImmutableCallSite(U)) {
798
1.34M
      const Function *F = CS.getCalledFunction();
799
1.34M
      if (!F) {
800
81.1k
        // Just use the called value type.
801
81.1k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
81.1k
        return static_cast<T *>(this)
803
81.1k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
81.1k
      }
805
1.26M
806
1.26M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
1.26M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
1.26M
    }
809
1.92M
810
1.92M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
584k
      // Result of a cmp instruction is often extended (to be used by other
812
584k
      // cmp instructions, logical or return instructions). These are usually
813
584k
      // nop on most sane targets.
814
584k
      if (isa<CmpInst>(CI->getOperand(0)))
815
12.1k
        return TTI::TCC_Free;
816
572k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)483k
||
isa<FPExtInst>(CI)396k
)
817
176k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
1.73M
    }
819
1.73M
820
1.73M
    return static_cast<T *>(this)->getOperationCost(
821
1.73M
        Operator::getOpcode(U), U->getType(),
822
1.73M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()813k
:
nullptr920k
);
823
1.73M
  }
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
782
71.7k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
783
71.7k
    if (isa<PHINode>(U))
784
10.3k
      return TTI::TCC_Free; // Model all PHI nodes as free.
785
61.3k
786
61.3k
    // Static alloca doesn't generate target instructions.
787
61.3k
    if (auto *A = dyn_cast<AllocaInst>(U))
788
2
      if (A->isStaticAlloca())
789
0
        return TTI::TCC_Free;
790
61.3k
791
61.3k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
792
9.66k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
793
9.66k
                                                GEP->getPointerOperand(),
794
9.66k
                                                Operands.drop_front());
795
9.66k
    }
796
51.6k
797
51.6k
    if (auto CS = ImmutableCallSite(U)) {
798
6.92k
      const Function *F = CS.getCalledFunction();
799
6.92k
      if (!F) {
800
24
        // Just use the called value type.
801
24
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
802
24
        return static_cast<T *>(this)
803
24
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804
24
      }
805
6.90k
806
6.90k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
807
6.90k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
808
6.90k
    }
809
44.7k
810
44.7k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
811
6.53k
      // Result of a cmp instruction is often extended (to be used by other
812
6.53k
      // cmp instructions, logical or return instructions). These are usually
813
6.53k
      // nop on most sane targets.
814
6.53k
      if (isa<CmpInst>(CI->getOperand(0)))
815
7
        return TTI::TCC_Free;
816
6.52k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)6.37k
||
isa<FPExtInst>(CI)4.23k
)
817
2.29k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
818
42.4k
    }
819
42.4k
820
42.4k
    return static_cast<T *>(this)->getOperationCost(
821
42.4k
        Operator::getOpcode(U), U->getType(),
822
42.4k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()11.2k
:
nullptr31.1k
);
823
42.4k
  }
824
825
10
  int getInstructionLatency(const Instruction *I) {
826
10
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
827
10
                                           I->value_op_end());
828
10
    if (getUserCost(I, Operands) == TTI::TCC_Free)
829
5
      return 0;
830
5
831
5
    if (isa<LoadInst>(I))
832
0
      return 4;
833
5
834
5
    Type *DstTy = I->getType();
835
5
836
5
    // Usually an intrinsic is a simple instruction.
837
5
    // A real function call is much slower.
838
5
    if (auto *CI = dyn_cast<CallInst>(I)) {
839
2
      const Function *F = CI->getCalledFunction();
840
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
841
1
        return 40;
842
1
      // Some intrinsics return a value and a flag, we use the value type
843
1
      // to decide its latency.
844
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
845
1
        DstTy = StructTy->getElementType(0);
846
1
      // Fall through to simple instructions.
847
1
    }
848
5
849
5
    
if (VectorType *4
VectorTy4
= dyn_cast<VectorType>(DstTy))
850
0
      DstTy = VectorTy->getElementType();
851
4
    if (DstTy->isFloatingPointTy())
852
0
      return 3;
853
4
854
4
    return 1;
855
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getInstructionLatency(llvm::Instruction const*)
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::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
825
10
  int getInstructionLatency(const Instruction *I) {
826
10
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
827
10
                                           I->value_op_end());
828
10
    if (getUserCost(I, Operands) == TTI::TCC_Free)
829
5
      return 0;
830
5
831
5
    if (isa<LoadInst>(I))
832
0
      return 4;
833
5
834
5
    Type *DstTy = I->getType();
835
5
836
5
    // Usually an intrinsic is a simple instruction.
837
5
    // A real function call is much slower.
838
5
    if (auto *CI = dyn_cast<CallInst>(I)) {
839
2
      const Function *F = CI->getCalledFunction();
840
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
841
1
        return 40;
842
1
      // Some intrinsics return a value and a flag, we use the value type
843
1
      // to decide its latency.
844
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
845
1
        DstTy = StructTy->getElementType(0);
846
1
      // Fall through to simple instructions.
847
1
    }
848
5
849
5
    
if (VectorType *4
VectorTy4
= dyn_cast<VectorType>(DstTy))
850
0
      DstTy = VectorTy->getElementType();
851
4
    if (DstTy->isFloatingPointTy())
852
0
      return 3;
853
4
854
4
    return 1;
855
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getInstructionLatency(llvm::Instruction const*)
856
};
857
}
858
859
#endif