Coverage Report

Created: 2018-07-19 03:59

/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
16.5M
  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
16.5M
      : DL(Arg.DL) {}
44
16.5M
  TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg) : DL(Arg.DL) {}
45
46
47.4k
  const DataLayout &getDataLayout() const { return DL; }
47
48
25.5M
  unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) {
49
25.5M
    switch (Opcode) {
50
25.5M
    default:
51
22.3M
      // By default, just classify everything as 'basic'.
52
22.3M
      return TTI::TCC_Basic;
53
25.5M
54
25.5M
    case Instruction::GetElementPtr:
55
0
      llvm_unreachable("Use getGEPCost for GEP operations!");
56
25.5M
57
25.5M
    case Instruction::BitCast:
58
1.98M
      assert(OpTy && "Cast instructions must provide the operand type");
59
1.98M
      if (Ty == OpTy || 
(1.98M
Ty->isPointerTy()1.98M
&&
OpTy->isPointerTy()1.98M
))
60
1.98M
        // Identity and pointer-to-pointer casts are free.
61
1.98M
        return TTI::TCC_Free;
62
3.29k
63
3.29k
      // Otherwise, the default basic cost is used.
64
3.29k
      return TTI::TCC_Basic;
65
3.29k
66
268k
    case Instruction::FDiv:
67
268k
    case Instruction::FRem:
68
268k
    case Instruction::SDiv:
69
268k
    case Instruction::SRem:
70
268k
    case Instruction::UDiv:
71
268k
    case Instruction::URem:
72
268k
      return TTI::TCC_Expensive;
73
268k
74
374k
    case Instruction::IntToPtr: {
75
374k
      // An inttoptr cast is free so long as the input is a legal integer type
76
374k
      // which doesn't contain values outside the range of a pointer.
77
374k
      unsigned OpSize = OpTy->getScalarSizeInBits();
78
374k
      if (DL.isLegalInteger(OpSize) &&
79
374k
          
OpSize <= DL.getPointerTypeSizeInBits(Ty)374k
)
80
374k
        return TTI::TCC_Free;
81
5
82
5
      // Otherwise it's not a no-op.
83
5
      return TTI::TCC_Basic;
84
5
    }
85
564k
    case Instruction::PtrToInt: {
86
564k
      // A ptrtoint cast is free so long as the result is large enough to store
87
564k
      // the pointer, and a legal integer type.
88
564k
      unsigned DestSize = Ty->getScalarSizeInBits();
89
564k
      if (DL.isLegalInteger(DestSize) &&
90
564k
          
DestSize >= DL.getPointerTypeSizeInBits(OpTy)564k
)
91
564k
        return TTI::TCC_Free;
92
219
93
219
      // Otherwise it's not a no-op.
94
219
      return TTI::TCC_Basic;
95
219
    }
96
219
    case Instruction::Trunc:
97
41
      // trunc to a native type is free (assuming the target has compare and
98
41
      // shift-right of the same width).
99
41
      if (DL.isLegalInteger(DL.getTypeSizeInBits(Ty)))
100
9
        return TTI::TCC_Free;
101
32
102
32
      return TTI::TCC_Basic;
103
25.5M
    }
104
25.5M
  }
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.28k
  int getExtCost(const Instruction *I, const Value *Src) {
124
2.28k
    return TTI::TCC_Basic;
125
2.28k
  }
126
127
5.87M
  unsigned getCallCost(FunctionType *FTy, int NumArgs) {
128
5.87M
    assert(FTy && "FunctionType must be provided to this routine.");
129
5.87M
130
5.87M
    // The target-independent implementation just measures the size of the
131
5.87M
    // function by approximating that each argument will take on average one
132
5.87M
    // instruction to prepare.
133
5.87M
134
5.87M
    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
5.87M
139
5.87M
    return TTI::TCC_Basic * (NumArgs + 1);
140
5.87M
  }
141
142
884
  unsigned getInliningThresholdMultiplier() { return 1; }
143
144
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
145
1.12M
                            ArrayRef<Type *> ParamTys) {
146
1.12M
    switch (IID) {
147
1.12M
    default:
148
229k
      // Intrinsics rarely (if ever) have normal argument setup constraints.
149
229k
      // Model them as having a basic instruction cost.
150
229k
      // FIXME: This is wrong for libc intrinsics.
151
229k
      return TTI::TCC_Basic;
152
1.12M
153
1.12M
    case Intrinsic::annotation:
154
896k
    case Intrinsic::assume:
155
896k
    case Intrinsic::sideeffect:
156
896k
    case Intrinsic::dbg_declare:
157
896k
    case Intrinsic::dbg_value:
158
896k
    case Intrinsic::dbg_label:
159
896k
    case Intrinsic::invariant_start:
160
896k
    case Intrinsic::invariant_end:
161
896k
    case Intrinsic::lifetime_start:
162
896k
    case Intrinsic::lifetime_end:
163
896k
    case Intrinsic::objectsize:
164
896k
    case Intrinsic::ptr_annotation:
165
896k
    case Intrinsic::var_annotation:
166
896k
    case Intrinsic::experimental_gc_result:
167
896k
    case Intrinsic::experimental_gc_relocate:
168
896k
    case Intrinsic::coro_alloc:
169
896k
    case Intrinsic::coro_begin:
170
896k
    case Intrinsic::coro_free:
171
896k
    case Intrinsic::coro_end:
172
896k
    case Intrinsic::coro_frame:
173
896k
    case Intrinsic::coro_size:
174
896k
    case Intrinsic::coro_suspend:
175
896k
    case Intrinsic::coro_param:
176
896k
    case Intrinsic::coro_subfn_addr:
177
896k
      // These intrinsics don't actually represent code after lowering.
178
896k
      return TTI::TCC_Free;
179
1.12M
    }
180
1.12M
  }
181
182
5.16k
  bool hasBranchDivergence() { return false; }
183
184
0
  bool isSourceOfDivergence(const Value *V) { return false; }
185
186
0
  bool isAlwaysUniform(const Value *V) { return false; }
187
188
0
  unsigned getFlatAddressSpace () {
189
0
    return -1;
190
0
  }
191
192
9.81M
  bool isLoweredToCall(const Function *F) {
193
9.81M
    assert(F && "A concrete function must be provided to this routine.");
194
9.81M
195
9.81M
    // FIXME: These should almost certainly not be handled here, and instead
196
9.81M
    // handled with the help of TLI or the target itself. This was largely
197
9.81M
    // ported from existing analysis heuristics here so that such refactorings
198
9.81M
    // can take place in the future.
199
9.81M
200
9.81M
    if (F->isIntrinsic())
201
219k
      return false;
202
9.59M
203
9.59M
    if (F->hasLocalLinkage() || 
!F->hasName()8.28M
)
204
1.30M
      return true;
205
8.28M
206
8.28M
    StringRef Name = F->getName();
207
8.28M
208
8.28M
    // These will all likely lower to a single selection DAG node.
209
8.28M
    if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
210
8.28M
        
Name == "fabs"8.28M
||
Name == "fabsf"8.28M
||
Name == "fabsl"8.28M
||
Name == "sin"8.28M
||
211
8.28M
        
Name == "fmin"8.28M
||
Name == "fminf"8.28M
||
Name == "fminl"8.28M
||
212
8.28M
        
Name == "fmax"8.28M
||
Name == "fmaxf"8.28M
||
Name == "fmaxl"8.28M
||
213
8.28M
        
Name == "sinf"8.28M
||
Name == "sinl"8.28M
||
Name == "cos"8.28M
||
Name == "cosf"8.28M
||
214
8.28M
        
Name == "cosl"8.28M
||
Name == "sqrt"8.28M
||
Name == "sqrtf"8.28M
||
Name == "sqrtl"8.28M
)
215
70
      return false;
216
8.28M
217
8.28M
    // These are all likely to be optimized into something smaller.
218
8.28M
    if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
219
8.28M
        Name == "exp2l" || Name == "exp2f" || Name == "floor" ||
220
8.28M
        Name == "floorf" || Name == "ceil" || Name == "round" ||
221
8.28M
        Name == "ffs" || Name == "ffsl" || Name == "abs" || 
Name == "labs"8.28M
||
222
8.28M
        
Name == "llabs"8.28M
)
223
8
      return false;
224
8.28M
225
8.28M
    return true;
226
8.28M
  }
227
228
  void getUnrollingPreferences(Loop *, ScalarEvolution &,
229
557
                               TTI::UnrollingPreferences &) {}
230
231
6.57k
  bool isLegalAddImmediate(int64_t Imm) { return false; }
232
233
646
  bool isLegalICmpImmediate(int64_t Imm) { return false; }
234
235
  bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
236
                             bool HasBaseReg, int64_t Scale,
237
61.3k
                             unsigned AddrSpace, Instruction *I = nullptr) {
238
61.3k
    // Guess that only reg and reg+reg addressing is allowed. This heuristic is
239
61.3k
    // taken from the implementation of LSR.
240
61.3k
    return !BaseGV && 
BaseOffset == 056.7k
&&
(51.5k
Scale == 051.5k
||
Scale == 151.2k
);
241
61.3k
  }
242
243
3.57M
  bool isLSRCostLess(TTI::LSRCost &C1, TTI::LSRCost &C2) {
244
3.57M
    return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
245
3.57M
                    C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
246
3.57M
           std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
247
3.57M
                    C2.ScaleCost, C2.ImmCost, C2.SetupCost);
248
3.57M
  }
249
250
662k
  bool canMacroFuseCmp() { return false; }
251
252
11.7M
  bool shouldFavorPostInc() const { return false; }
253
254
3.28k
  bool isLegalMaskedStore(Type *DataType) { return false; }
255
256
2.33k
  bool isLegalMaskedLoad(Type *DataType) { return false; }
257
258
9.30k
  bool isLegalMaskedScatter(Type *DataType) { return false; }
259
260
13.8k
  bool isLegalMaskedGather(Type *DataType) { return false; }
261
262
444
  bool hasDivRemOp(Type *DataType, bool IsSigned) { return false; }
263
264
262
  bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) { return false; }
265
266
30.4k
  bool prefersVectorizedAddressing() { return true; }
267
268
  int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
269
13.9k
                           bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
270
13.9k
    // Guess that all legal addressing mode are free.
271
13.9k
    if (isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
272
13.9k
                              Scale, AddrSpace))
273
13.9k
      return 0;
274
0
    return -1;
275
0
  }
276
277
4.08M
  bool LSRWithInstrQueries() { return false; }
278
279
9.21k
  bool isTruncateFree(Type *Ty1, Type *Ty2) { return false; }
280
281
70
  bool isProfitableToHoist(Instruction *I) { return true; }
282
283
0
  bool useAA() { return false; }
284
285
412
  bool isTypeLegal(Type *Ty) { return false; }
286
287
0
  unsigned getJumpBufAlignment() { return 0; }
288
289
0
  unsigned getJumpBufSize() { return 0; }
290
291
19
  bool shouldBuildLookupTables() { return true; }
292
69.1k
  bool shouldBuildLookupTablesForConstant(Constant *C) { return true; }
293
294
6
  bool useColdCCForColdCall(Function &F) { return false; }
295
296
347
  unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) {
297
347
    return 0;
298
347
  }
299
300
  unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
301
315
                                            unsigned VF) { return 0; }
302
303
14.7k
  bool supportsEfficientVectorElementLoadStore() { return false; }
304
305
934
  bool enableAggressiveInterleaving(bool LoopHasReductions) { return false; }
306
307
  const TTI::MemCmpExpansionOptions *enableMemCmpExpansion(
308
318k
      bool IsZeroCmp) const {
309
318k
    return nullptr;
310
318k
  }
311
312
526
  bool enableInterleavedAccessVectorization() { return false; }
313
314
10.6k
  bool isFPVectorizationPotentiallyUnsafe() { return false; }
315
316
  bool allowsMisalignedMemoryAccesses(LLVMContext &Context,
317
                                      unsigned BitWidth,
318
                                      unsigned AddressSpace,
319
                                      unsigned Alignment,
320
0
                                      bool *Fast) { return false; }
321
322
3.77k
  TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) {
323
3.77k
    return TTI::PSK_Software;
324
3.77k
  }
325
326
4
  bool haveFastSqrt(Type *Ty) { return false; }
327
328
0
  bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) { return true; }
329
  
330
1
  unsigned getFPOpCost(Type *Ty) { return TargetTransformInfo::TCC_Basic; }
331
332
  int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
333
692
                            Type *Ty) {
334
692
    return 0;
335
692
  }
336
337
31
  unsigned getIntImmCost(const APInt &Imm, Type *Ty) { return TTI::TCC_Basic; }
338
339
  unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
340
37.9k
                         Type *Ty) {
341
37.9k
    return TTI::TCC_Free;
342
37.9k
  }
343
344
  unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
345
38.7k
                         Type *Ty) {
346
38.7k
    return TTI::TCC_Free;
347
38.7k
  }
348
349
33.5k
  unsigned getNumberOfRegisters(bool Vector) { return 8; }
350
351
1.21k
  unsigned getRegisterBitWidth(bool Vector) const { return 32; }
352
353
35.0k
  unsigned getMinVectorRegisterBitWidth() { return 128; }
354
355
18.8k
  bool shouldMaximizeVectorBandwidth(bool OptSize) const { return false; }
356
357
0
  unsigned getMinimumVF(unsigned ElemWidth) const { return 0; }
358
359
  bool
360
  shouldConsiderAddressTypePromotion(const Instruction &I,
361
63.2k
                                     bool &AllowPromotionWithoutCommonHeader) {
362
63.2k
    AllowPromotionWithoutCommonHeader = false;
363
63.2k
    return false;
364
63.2k
  }
365
366
0
  unsigned getCacheLineSize() { return 0; }
367
368
2
  llvm::Optional<unsigned> getCacheSize(TargetTransformInfo::CacheLevel Level) {
369
2
    switch (Level) {
370
2
    case TargetTransformInfo::CacheLevel::L1D:
371
1
      LLVM_FALLTHROUGH;
372
2
    case TargetTransformInfo::CacheLevel::L2D:
373
2
      return llvm::Optional<unsigned>();
374
0
    }
375
0
376
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
377
0
  }
378
379
  llvm::Optional<unsigned> getCacheAssociativity(
380
1
    TargetTransformInfo::CacheLevel Level) {
381
1
    switch (Level) {
382
1
    case TargetTransformInfo::CacheLevel::L1D:
383
0
      LLVM_FALLTHROUGH;
384
1
    case TargetTransformInfo::CacheLevel::L2D:
385
1
      return llvm::Optional<unsigned>();
386
0
    }
387
0
388
0
    llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
389
0
  }
390
391
0
  unsigned getPrefetchDistance() { return 0; }
392
393
29
  unsigned getMinPrefetchStride() { return 1; }
394
395
175
  unsigned getMaxPrefetchIterationsAhead() { return UINT_MAX; }
396
397
464
  unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
398
399
  unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
400
                                  TTI::OperandValueKind Opd1Info,
401
                                  TTI::OperandValueKind Opd2Info,
402
                                  TTI::OperandValueProperties Opd1PropInfo,
403
                                  TTI::OperandValueProperties Opd2PropInfo,
404
1.34k
                                  ArrayRef<const Value *> Args) {
405
1.34k
    return 1;
406
1.34k
  }
407
408
  unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Ty, int Index,
409
99
                          Type *SubTp) {
410
99
    return 1;
411
99
  }
412
413
  unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
414
411
                            const Instruction *I) { return 1; }
415
416
  unsigned getExtractWithExtendCost(unsigned Opcode, Type *Dst,
417
0
                                    VectorType *VecTy, unsigned Index) {
418
0
    return 1;
419
0
  }
420
421
1.38k
  unsigned getCFInstrCost(unsigned Opcode) { return 1; }
422
423
  unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
424
672
                              const Instruction *I) {
425
672
    return 1;
426
672
  }
427
428
248
  unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
429
248
    return 1;
430
248
  }
431
432
  unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
433
926
                           unsigned AddressSpace, const Instruction *I) {
434
926
    return 1;
435
926
  }
436
437
  unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
438
0
                                 unsigned AddressSpace) {
439
0
    return 1;
440
0
  }
441
442
  unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
443
                                  bool VariableMask,
444
0
                                  unsigned Alignment) {
445
0
    return 1;
446
0
  }
447
448
  unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
449
                                      unsigned Factor,
450
                                      ArrayRef<unsigned> Indices,
451
                                      unsigned Alignment,
452
33
                                      unsigned AddressSpace) {
453
33
    return 1;
454
33
  }
455
456
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
457
                                 ArrayRef<Type *> Tys, FastMathFlags FMF,
458
0
                                 unsigned ScalarizationCostPassed) {
459
0
    return 1;
460
0
  }
461
  unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
462
142
            ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) {
463
142
    return 1;
464
142
  }
465
466
142
  unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys) {
467
142
    return 1;
468
142
  }
469
470
1.93k
  unsigned getNumberOfParts(Type *Tp) { return 0; }
471
472
  unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *,
473
274
                                     const SCEV *) {
474
274
    return 0;
475
274
  }
476
477
2
  unsigned getArithmeticReductionCost(unsigned, Type *, bool) { return 1; }
478
479
0
  unsigned getMinMaxReductionCost(Type *, Type *, bool, bool) { return 1; }
480
481
35.6k
  unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) { return 0; }
482
483
127k
  bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) {
484
127k
    return false;
485
127k
  }
486
487
1
  unsigned getAtomicMemIntrinsicMaxElementSize() const {
488
1
    // Note for overrides: You must ensure for all element unordered-atomic
489
1
    // memory intrinsics that all power-of-2 element sizes up to, and
490
1
    // including, the return value of this method have a corresponding
491
1
    // runtime lib call. These runtime lib call definitions can be found
492
1
    // in RuntimeLibcalls.h
493
1
    return 0;
494
1
  }
495
496
  Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
497
9
                                           Type *ExpectedType) {
498
9
    return nullptr;
499
9
  }
500
501
  Type *getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length,
502
15
                                  unsigned SrcAlign, unsigned DestAlign) const {
503
15
    return Type::getInt8Ty(Context);
504
15
  }
505
506
  void getMemcpyLoopResidualLoweringType(SmallVectorImpl<Type *> &OpsOut,
507
                                         LLVMContext &Context,
508
                                         unsigned RemainingBytes,
509
                                         unsigned SrcAlign,
510
0
                                         unsigned DestAlign) const {
511
0
    for (unsigned i = 0; i != RemainingBytes; ++i)
512
0
      OpsOut.push_back(Type::getInt8Ty(Context));
513
0
  }
514
515
  bool areInlineCompatible(const Function *Caller,
516
1.03k
                           const Function *Callee) const {
517
1.03k
    return (Caller->getFnAttribute("target-cpu") ==
518
1.03k
            Callee->getFnAttribute("target-cpu")) &&
519
1.03k
           (Caller->getFnAttribute("target-features") ==
520
1.02k
            Callee->getFnAttribute("target-features"));
521
1.03k
  }
522
523
  bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty,
524
0
                          const DataLayout &DL) const {
525
0
    return false;
526
0
  }
527
528
  bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty,
529
0
                           const DataLayout &DL) const {
530
0
    return false;
531
0
  }
532
533
618
  unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const { return 128; }
534
535
40.8k
  bool isLegalToVectorizeLoad(LoadInst *LI) const { return true; }
536
537
16.5k
  bool isLegalToVectorizeStore(StoreInst *SI) const { return true; }
538
539
  bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes,
540
                                   unsigned Alignment,
541
31
                                   unsigned AddrSpace) const {
542
31
    return true;
543
31
  }
544
545
  bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
546
                                    unsigned Alignment,
547
11
                                    unsigned AddrSpace) const {
548
11
    return true;
549
11
  }
550
551
  unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize,
552
                               unsigned ChainSizeInBytes,
553
497
                               VectorType *VecTy) const {
554
497
    return VF;
555
497
  }
556
557
  unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize,
558
                                unsigned ChainSizeInBytes,
559
364
                                VectorType *VecTy) const {
560
364
    return VF;
561
364
  }
562
563
  bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
564
397
                             TTI::ReductionFlags Flags) const {
565
397
    return false;
566
397
  }
567
568
1.68k
  bool shouldExpandReduction(const IntrinsicInst *II) const {
569
1.68k
    return true;
570
1.68k
  }
571
572
protected:
573
  // Obtain the minimum required size to hold the value (without the sign)
574
  // In case of a vector it returns the min required size for one element.
575
48
  unsigned minRequiredElementSize(const Value* Val, bool &isSigned) {
576
48
    if (isa<ConstantDataVector>(Val) || 
isa<ConstantVector>(Val)36
) {
577
12
      const auto* VectorValue = cast<Constant>(Val);
578
12
579
12
      // In case of a vector need to pick the max between the min
580
12
      // required size for each element
581
12
      auto *VT = cast<VectorType>(Val->getType());
582
12
583
12
      // Assume unsigned elements
584
12
      isSigned = false;
585
12
586
12
      // The max required size is the total vector width divided by num
587
12
      // of elements in the vector
588
12
      unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
589
12
590
12
      unsigned MinRequiredSize = 0;
591
60
      for(unsigned i = 0, e = VT->getNumElements(); i < e; 
++i48
) {
592
48
        if (auto* IntElement =
593
48
              dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
594
48
          bool signedElement = IntElement->getValue().isNegative();
595
48
          // Get the element min required size.
596
48
          unsigned ElementMinRequiredSize =
597
48
            IntElement->getValue().getMinSignedBits() - 1;
598
48
          // In case one element is signed then all the vector is signed.
599
48
          isSigned |= signedElement;
600
48
          // Save the max required bit size between all the elements.
601
48
          MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
602
48
        }
603
0
        else {
604
0
          // not an int constant element
605
0
          return MaxRequiredSize;
606
0
        }
607
48
      }
608
12
      return MinRequiredSize;
609
36
    }
610
36
611
36
    if (const auto* CI = dyn_cast<ConstantInt>(Val)) {
612
0
      isSigned = CI->getValue().isNegative();
613
0
      return CI->getValue().getMinSignedBits() - 1;
614
0
    }
615
36
616
36
    if (const auto* Cast = dyn_cast<SExtInst>(Val)) {
617
6
      isSigned = true;
618
6
      return Cast->getSrcTy()->getScalarSizeInBits() - 1;
619
6
    }
620
30
621
30
    if (const auto* Cast = dyn_cast<ZExtInst>(Val)) {
622
6
      isSigned = false;
623
6
      return Cast->getSrcTy()->getScalarSizeInBits();
624
6
    }
625
24
626
24
    isSigned = false;
627
24
    return Val->getType()->getScalarSizeInBits();
628
24
  }
629
630
15.3k
  bool isStridedAccess(const SCEV *Ptr) {
631
15.3k
    return Ptr && 
isa<SCEVAddRecExpr>(Ptr)8.23k
;
632
15.3k
  }
633
634
  const SCEVConstant *getConstantStrideStep(ScalarEvolution *SE,
635
14.3k
                                            const SCEV *Ptr) {
636
14.3k
    if (!isStridedAccess(Ptr))
637
7.81k
      return nullptr;
638
6.56k
    const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
639
6.56k
    return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
640
6.56k
  }
641
642
  bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
643
13.6k
                                       int64_t MergeDistance) {
644
13.6k
    const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
645
13.6k
    if (!Step)
646
7.84k
      return false;
647
5.82k
    APInt StrideVal = Step->getAPInt();
648
5.82k
    if (StrideVal.getBitWidth() > 64)
649
0
      return false;
650
5.82k
    // FIXME: Need to take absolute value for negative stride case.
651
5.82k
    return StrideVal.getSExtValue() < MergeDistance;
652
5.82k
  }
653
};
654
655
/// CRTP base class for use as a mix-in that aids implementing
656
/// a TargetTransformInfo-compatible class.
657
template <typename T>
658
class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
659
private:
660
  typedef TargetTransformInfoImplBase BaseT;
661
662
protected:
663
16.5M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
12.0M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
39.5k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::AMDGPUTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
423k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
384k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
698k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
33.7k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
742
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
20.3k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
92.9k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
85.4k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
2.64M
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
2.24k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
16.7k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::TargetTransformInfoImplCRTPBase(llvm::DataLayout const&)
Line
Count
Source
663
106k
  explicit TargetTransformInfoImplCRTPBase(const DataLayout &DL) : BaseT(DL) {}
664
665
public:
666
  using BaseT::getCallCost;
667
668
6.77M
  unsigned getCallCost(const Function *F, int NumArgs) {
669
6.77M
    assert(F && "A concrete function must be provided to this routine.");
670
6.77M
671
6.77M
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
6.77M
676
6.77M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
1.15M
      FunctionType *FTy = F->getFunctionType();
678
1.15M
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
1.15M
      return static_cast<T *>(this)
680
1.15M
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
1.15M
    }
682
5.62M
683
5.62M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
61
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
5.62M
                             // directly.
686
5.62M
687
5.62M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
5.62M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
5.17M
  unsigned getCallCost(const Function *F, int NumArgs) {
669
5.17M
    assert(F && "A concrete function must be provided to this routine.");
670
5.17M
671
5.17M
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
5.17M
676
5.17M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
828k
      FunctionType *FTy = F->getFunctionType();
678
828k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
828k
      return static_cast<T *>(this)
680
828k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
828k
    }
682
4.34M
683
4.34M
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
28
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
4.34M
                             // directly.
686
4.34M
687
4.34M
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
4.34M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
2
  unsigned getCallCost(const Function *F, int NumArgs) {
669
2
    assert(F && "A concrete function must be provided to this routine.");
670
2
671
2
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
2
676
2
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
2
      FunctionType *FTy = F->getFunctionType();
678
2
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
2
      return static_cast<T *>(this)
680
2
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
2
    }
682
0
683
0
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
0
                             // directly.
686
0
687
0
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
0
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
1.17k
  unsigned getCallCost(const Function *F, int NumArgs) {
669
1.17k
    assert(F && "A concrete function must be provided to this routine.");
670
1.17k
671
1.17k
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
1.17k
676
1.17k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
814
      FunctionType *FTy = F->getFunctionType();
678
814
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
814
      return static_cast<T *>(this)
680
814
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
814
    }
682
365
683
365
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
12
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
353
                             // directly.
686
353
687
353
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
353
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
430k
  unsigned getCallCost(const Function *F, int NumArgs) {
669
430k
    assert(F && "A concrete function must be provided to this routine.");
670
430k
671
430k
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
430k
676
430k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
87.5k
      FunctionType *FTy = F->getFunctionType();
678
87.5k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
87.5k
      return static_cast<T *>(this)
680
87.5k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
87.5k
    }
682
342k
683
342k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
342k
                             // directly.
686
342k
687
342k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
342k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
28
  unsigned getCallCost(const Function *F, int NumArgs) {
669
28
    assert(F && "A concrete function must be provided to this routine.");
670
28
671
28
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
28
676
28
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
14
      FunctionType *FTy = F->getFunctionType();
678
14
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
14
      return static_cast<T *>(this)
680
14
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
14
    }
682
14
683
14
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
14
                             // directly.
686
14
687
14
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
14
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::LanaiTTIImpl>::getCallCost(llvm::Function const*, int)
llvm::TargetTransformInfoImplCRTPBase<llvm::BasicTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
6
  unsigned getCallCost(const Function *F, int NumArgs) {
669
6
    assert(F && "A concrete function must be provided to this routine.");
670
6
671
6
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
6
676
6
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
5
      FunctionType *FTy = F->getFunctionType();
678
5
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
5
      return static_cast<T *>(this)
680
5
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
5
    }
682
1
683
1
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
1
                             // directly.
686
1
687
1
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
1
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
20
  unsigned getCallCost(const Function *F, int NumArgs) {
669
20
    assert(F && "A concrete function must be provided to this routine.");
670
20
671
20
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
20
676
20
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
16
      FunctionType *FTy = F->getFunctionType();
678
16
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
16
      return static_cast<T *>(this)
680
16
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
16
    }
682
4
683
4
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
4
                             // directly.
686
4
687
4
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
4
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
212
  unsigned getCallCost(const Function *F, int NumArgs) {
669
212
    assert(F && "A concrete function must be provided to this routine.");
670
212
671
212
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
212
676
212
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
59
      FunctionType *FTy = F->getFunctionType();
678
59
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
59
      return static_cast<T *>(this)
680
59
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
59
    }
682
153
683
153
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
17
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
136
                             // directly.
686
136
687
136
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
136
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
52
  unsigned getCallCost(const Function *F, int NumArgs) {
669
52
    assert(F && "A concrete function must be provided to this routine.");
670
52
671
52
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
52
676
52
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
20
      FunctionType *FTy = F->getFunctionType();
678
20
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
20
      return static_cast<T *>(this)
680
20
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
20
    }
682
32
683
32
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
0
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
32
                             // directly.
686
32
687
32
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
32
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, int)
Line
Count
Source
668
1.15M
  unsigned getCallCost(const Function *F, int NumArgs) {
669
1.15M
    assert(F && "A concrete function must be provided to this routine.");
670
1.15M
671
1.15M
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
1.15M
676
1.15M
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
234k
      FunctionType *FTy = F->getFunctionType();
678
234k
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
234k
      return static_cast<T *>(this)
680
234k
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
234k
    }
682
920k
683
920k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
2
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
920k
                             // directly.
686
920k
687
920k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
920k
  }
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
668
7.07k
  unsigned getCallCost(const Function *F, int NumArgs) {
669
7.07k
    assert(F && "A concrete function must be provided to this routine.");
670
7.07k
671
7.07k
    if (NumArgs < 0)
672
0
      // Set the argument number to the number of explicit arguments in the
673
0
      // function.
674
0
      NumArgs = F->arg_size();
675
7.07k
676
7.07k
    if (Intrinsic::ID IID = F->getIntrinsicID()) {
677
294
      FunctionType *FTy = F->getFunctionType();
678
294
      SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
679
294
      return static_cast<T *>(this)
680
294
          ->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
681
294
    }
682
6.77k
683
6.77k
    if (!static_cast<T *>(this)->isLoweredToCall(F))
684
2
      return TTI::TCC_Basic; // Give a basic cost if it will be lowered
685
6.77k
                             // directly.
686
6.77k
687
6.77k
    return static_cast<T *>(this)->getCallCost(F->getFunctionType(), NumArgs);
688
6.77k
  }
689
690
6.77M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
6.77M
    // Simply delegate to generic handling of the call.
692
6.77M
    // FIXME: We should use instsimplify or something else to catch calls which
693
6.77M
    // will constant fold with these arguments.
694
6.77M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
6.77M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
5.17M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
5.17M
    // Simply delegate to generic handling of the call.
692
5.17M
    // FIXME: We should use instsimplify or something else to catch calls which
693
5.17M
    // will constant fold with these arguments.
694
5.17M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
5.17M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
2
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
2
    // Simply delegate to generic handling of the call.
692
2
    // FIXME: We should use instsimplify or something else to catch calls which
693
2
    // will constant fold with these arguments.
694
2
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
2
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
1.17k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
1.17k
    // Simply delegate to generic handling of the call.
692
1.17k
    // FIXME: We should use instsimplify or something else to catch calls which
693
1.17k
    // will constant fold with these arguments.
694
1.17k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
1.17k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
430k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
430k
    // Simply delegate to generic handling of the call.
692
430k
    // FIXME: We should use instsimplify or something else to catch calls which
693
430k
    // will constant fold with these arguments.
694
430k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
430k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
28
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
28
    // Simply delegate to generic handling of the call.
692
28
    // FIXME: We should use instsimplify or something else to catch calls which
693
28
    // will constant fold with these arguments.
694
28
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
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
690
6
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
6
    // Simply delegate to generic handling of the call.
692
6
    // FIXME: We should use instsimplify or something else to catch calls which
693
6
    // will constant fold with these arguments.
694
6
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
6
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
20
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
20
    // Simply delegate to generic handling of the call.
692
20
    // FIXME: We should use instsimplify or something else to catch calls which
693
20
    // will constant fold with these arguments.
694
20
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
20
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
212
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
212
    // Simply delegate to generic handling of the call.
692
212
    // FIXME: We should use instsimplify or something else to catch calls which
693
212
    // will constant fold with these arguments.
694
212
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
212
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
52
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
52
    // Simply delegate to generic handling of the call.
692
52
    // FIXME: We should use instsimplify or something else to catch calls which
693
52
    // will constant fold with these arguments.
694
52
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
52
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getCallCost(llvm::Function const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
690
1.15M
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
1.15M
    // Simply delegate to generic handling of the call.
692
1.15M
    // FIXME: We should use instsimplify or something else to catch calls which
693
1.15M
    // will constant fold with these arguments.
694
1.15M
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
1.15M
  }
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
690
7.07k
  unsigned getCallCost(const Function *F, ArrayRef<const Value *> Arguments) {
691
7.07k
    // Simply delegate to generic handling of the call.
692
7.07k
    // FIXME: We should use instsimplify or something else to catch calls which
693
7.07k
    // will constant fold with these arguments.
694
7.07k
    return static_cast<T *>(this)->getCallCost(F, Arguments.size());
695
7.07k
  }
696
697
  using BaseT::getGEPCost;
698
699
  int getGEPCost(Type *PointeeType, const Value *Ptr,
700
6.48M
                 ArrayRef<const Value *> Operands) {
701
6.48M
    const GlobalValue *BaseGV = nullptr;
702
6.48M
    if (Ptr != nullptr) {
703
6.48M
      // TODO: will remove this when pointers have an opaque type.
704
6.48M
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
6.48M
                 PointeeType &&
706
6.48M
             "explicit pointee type doesn't match operand's pointee type");
707
6.48M
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
6.48M
    }
709
6.48M
    bool HasBaseReg = (BaseGV == nullptr);
710
6.48M
711
6.48M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
6.48M
    APInt BaseOffset(PtrSizeBits, 0);
713
6.48M
    int64_t Scale = 0;
714
6.48M
715
6.48M
    auto GTI = gep_type_begin(PointeeType, Operands);
716
6.48M
    Type *TargetType = nullptr;
717
6.48M
718
6.48M
    // Handle the case where the GEP instruction has a single operand,
719
6.48M
    // the basis, therefore TargetType is a nullptr.
720
6.48M
    if (Operands.empty())
721
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
722
6.48M
723
18.5M
    
for (auto I = Operands.begin(); 6.48M
I != Operands.end();
++I, ++GTI12.0M
) {
724
12.1M
      TargetType = GTI.getIndexedType();
725
12.1M
      // We assume that the cost of Scalar GEP with constant index and the
726
12.1M
      // cost of Vector GEP with splat constant index are the same.
727
12.1M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
12.1M
      if (!ConstIdx)
729
3.15M
        if (auto Splat = getSplatValue(*I))
730
2.02k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
12.1M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
4.18M
        // For structures the index is always splat or scalar constant
733
4.18M
        assert(ConstIdx && "Unexpected GEP index");
734
4.18M
        uint64_t Field = ConstIdx->getZExtValue();
735
4.18M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
7.97M
      } else {
737
7.97M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
7.97M
        if (ConstIdx) {
739
4.82M
          BaseOffset +=
740
4.82M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
4.82M
        } else {
742
3.15M
          // Needs scale register.
743
3.15M
          if (Scale != 0)
744
125k
            // No addressing mode takes two scale registers.
745
125k
            return TTI::TCC_Basic;
746
3.03M
          Scale = ElementSize;
747
3.03M
        }
748
7.97M
      }
749
12.1M
    }
750
6.48M
751
6.48M
    // Assumes the address space is 0 when Ptr is nullptr.
752
6.48M
    unsigned AS =
753
6.35M
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
6.35M
755
6.35M
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
6.35M
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
6.35M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
5.04M
      return TTI::TCC_Free;
759
1.31M
    return TTI::TCC_Basic;
760
1.31M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
5.83M
                 ArrayRef<const Value *> Operands) {
701
5.83M
    const GlobalValue *BaseGV = nullptr;
702
5.83M
    if (Ptr != nullptr) {
703
5.83M
      // TODO: will remove this when pointers have an opaque type.
704
5.83M
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
5.83M
                 PointeeType &&
706
5.83M
             "explicit pointee type doesn't match operand's pointee type");
707
5.83M
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
5.83M
    }
709
5.83M
    bool HasBaseReg = (BaseGV == nullptr);
710
5.83M
711
5.83M
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
5.83M
    APInt BaseOffset(PtrSizeBits, 0);
713
5.83M
    int64_t Scale = 0;
714
5.83M
715
5.83M
    auto GTI = gep_type_begin(PointeeType, Operands);
716
5.83M
    Type *TargetType = nullptr;
717
5.83M
718
5.83M
    // Handle the case where the GEP instruction has a single operand,
719
5.83M
    // the basis, therefore TargetType is a nullptr.
720
5.83M
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
5.83M
723
16.3M
    
for (auto I = Operands.begin(); 5.83M
I != Operands.end();
++I, ++GTI10.5M
) {
724
10.6M
      TargetType = GTI.getIndexedType();
725
10.6M
      // We assume that the cost of Scalar GEP with constant index and the
726
10.6M
      // cost of Vector GEP with splat constant index are the same.
727
10.6M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
10.6M
      if (!ConstIdx)
729
2.80M
        if (auto Splat = getSplatValue(*I))
730
18
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
10.6M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
3.53M
        // For structures the index is always splat or scalar constant
733
3.53M
        assert(ConstIdx && "Unexpected GEP index");
734
3.53M
        uint64_t Field = ConstIdx->getZExtValue();
735
3.53M
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
7.13M
      } else {
737
7.13M
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
7.13M
        if (ConstIdx) {
739
4.32M
          BaseOffset +=
740
4.32M
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
4.32M
        } else {
742
2.80M
          // Needs scale register.
743
2.80M
          if (Scale != 0)
744
106k
            // No addressing mode takes two scale registers.
745
106k
            return TTI::TCC_Basic;
746
2.69M
          Scale = ElementSize;
747
2.69M
        }
748
7.13M
      }
749
10.6M
    }
750
5.83M
751
5.83M
    // Assumes the address space is 0 when Ptr is nullptr.
752
5.83M
    unsigned AS =
753
5.73M
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
5.73M
755
5.73M
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
5.73M
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
5.73M
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
4.59M
      return TTI::TCC_Free;
759
1.13M
    return TTI::TCC_Basic;
760
1.13M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
1.79k
                 ArrayRef<const Value *> Operands) {
701
1.79k
    const GlobalValue *BaseGV = nullptr;
702
1.79k
    if (Ptr != nullptr) {
703
1.79k
      // TODO: will remove this when pointers have an opaque type.
704
1.79k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
1.79k
                 PointeeType &&
706
1.79k
             "explicit pointee type doesn't match operand's pointee type");
707
1.79k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
1.79k
    }
709
1.79k
    bool HasBaseReg = (BaseGV == nullptr);
710
1.79k
711
1.79k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
1.79k
    APInt BaseOffset(PtrSizeBits, 0);
713
1.79k
    int64_t Scale = 0;
714
1.79k
715
1.79k
    auto GTI = gep_type_begin(PointeeType, Operands);
716
1.79k
    Type *TargetType = nullptr;
717
1.79k
718
1.79k
    // Handle the case where the GEP instruction has a single operand,
719
1.79k
    // the basis, therefore TargetType is a nullptr.
720
1.79k
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
1.79k
723
4.52k
    
for (auto I = Operands.begin(); 1.79k
I != Operands.end();
++I, ++GTI2.73k
) {
724
2.73k
      TargetType = GTI.getIndexedType();
725
2.73k
      // We assume that the cost of Scalar GEP with constant index and the
726
2.73k
      // cost of Vector GEP with splat constant index are the same.
727
2.73k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
2.73k
      if (!ConstIdx)
729
996
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
2.73k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
112
        // For structures the index is always splat or scalar constant
733
112
        assert(ConstIdx && "Unexpected GEP index");
734
112
        uint64_t Field = ConstIdx->getZExtValue();
735
112
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
2.62k
      } else {
737
2.62k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
2.62k
        if (ConstIdx) {
739
1.62k
          BaseOffset +=
740
1.62k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
1.62k
        } else {
742
996
          // Needs scale register.
743
996
          if (Scale != 0)
744
0
            // No addressing mode takes two scale registers.
745
0
            return TTI::TCC_Basic;
746
996
          Scale = ElementSize;
747
996
        }
748
2.62k
      }
749
2.73k
    }
750
1.79k
751
1.79k
    // Assumes the address space is 0 when Ptr is nullptr.
752
1.79k
    unsigned AS =
753
1.79k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
1.79k
755
1.79k
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
1.79k
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
1.79k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
848
      return TTI::TCC_Free;
759
946
    return TTI::TCC_Basic;
760
946
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
33.1k
                 ArrayRef<const Value *> Operands) {
701
33.1k
    const GlobalValue *BaseGV = nullptr;
702
33.1k
    if (Ptr != nullptr) {
703
33.1k
      // TODO: will remove this when pointers have an opaque type.
704
33.1k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
33.1k
                 PointeeType &&
706
33.1k
             "explicit pointee type doesn't match operand's pointee type");
707
33.1k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
33.1k
    }
709
33.1k
    bool HasBaseReg = (BaseGV == nullptr);
710
33.1k
711
33.1k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
33.1k
    APInt BaseOffset(PtrSizeBits, 0);
713
33.1k
    int64_t Scale = 0;
714
33.1k
715
33.1k
    auto GTI = gep_type_begin(PointeeType, Operands);
716
33.1k
    Type *TargetType = nullptr;
717
33.1k
718
33.1k
    // Handle the case where the GEP instruction has a single operand,
719
33.1k
    // the basis, therefore TargetType is a nullptr.
720
33.1k
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
33.1k
723
71.0k
    
for (auto I = Operands.begin(); 33.1k
I != Operands.end();
++I, ++GTI37.8k
) {
724
37.9k
      TargetType = GTI.getIndexedType();
725
37.9k
      // We assume that the cost of Scalar GEP with constant index and the
726
37.9k
      // cost of Vector GEP with splat constant index are the same.
727
37.9k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
37.9k
      if (!ConstIdx)
729
19.6k
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
37.9k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
365
        // For structures the index is always splat or scalar constant
733
365
        assert(ConstIdx && "Unexpected GEP index");
734
365
        uint64_t Field = ConstIdx->getZExtValue();
735
365
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
37.6k
      } else {
737
37.6k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
37.6k
        if (ConstIdx) {
739
18.0k
          BaseOffset +=
740
18.0k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
19.6k
        } else {
742
19.6k
          // Needs scale register.
743
19.6k
          if (Scale != 0)
744
119
            // No addressing mode takes two scale registers.
745
119
            return TTI::TCC_Basic;
746
19.4k
          Scale = ElementSize;
747
19.4k
        }
748
37.6k
      }
749
37.9k
    }
750
33.1k
751
33.1k
    // Assumes the address space is 0 when Ptr is nullptr.
752
33.1k
    unsigned AS =
753
33.0k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
33.0k
755
33.0k
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
33.0k
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
33.0k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
9.92k
      return TTI::TCC_Free;
759
23.1k
    return TTI::TCC_Basic;
760
23.1k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
108k
                 ArrayRef<const Value *> Operands) {
701
108k
    const GlobalValue *BaseGV = nullptr;
702
108k
    if (Ptr != nullptr) {
703
108k
      // TODO: will remove this when pointers have an opaque type.
704
108k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
108k
                 PointeeType &&
706
108k
             "explicit pointee type doesn't match operand's pointee type");
707
108k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
108k
    }
709
108k
    bool HasBaseReg = (BaseGV == nullptr);
710
108k
711
108k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
108k
    APInt BaseOffset(PtrSizeBits, 0);
713
108k
    int64_t Scale = 0;
714
108k
715
108k
    auto GTI = gep_type_begin(PointeeType, Operands);
716
108k
    Type *TargetType = nullptr;
717
108k
718
108k
    // Handle the case where the GEP instruction has a single operand,
719
108k
    // the basis, therefore TargetType is a nullptr.
720
108k
    if (Operands.empty())
721
1
      return !BaseGV ? 
TTI::TCC_Free0
: TTI::TCC_Basic;
722
108k
723
356k
    
for (auto I = Operands.begin(); 108k
I != Operands.end();
++I, ++GTI247k
) {
724
254k
      TargetType = GTI.getIndexedType();
725
254k
      // We assume that the cost of Scalar GEP with constant index and the
726
254k
      // cost of Vector GEP with splat constant index are the same.
727
254k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
254k
      if (!ConstIdx)
729
73.3k
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
254k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
98.3k
        // For structures the index is always splat or scalar constant
733
98.3k
        assert(ConstIdx && "Unexpected GEP index");
734
98.3k
        uint64_t Field = ConstIdx->getZExtValue();
735
98.3k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
155k
      } else {
737
155k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
155k
        if (ConstIdx) {
739
82.5k
          BaseOffset +=
740
82.5k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
82.5k
        } else {
742
73.3k
          // Needs scale register.
743
73.3k
          if (Scale != 0)
744
6.23k
            // No addressing mode takes two scale registers.
745
6.23k
            return TTI::TCC_Basic;
746
67.0k
          Scale = ElementSize;
747
67.0k
        }
748
155k
      }
749
254k
    }
750
108k
751
108k
    // Assumes the address space is 0 when Ptr is nullptr.
752
108k
    unsigned AS =
753
102k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
102k
755
102k
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
102k
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
102k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
62.5k
      return TTI::TCC_Free;
759
39.8k
    return TTI::TCC_Basic;
760
39.8k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
3
                 ArrayRef<const Value *> Operands) {
701
3
    const GlobalValue *BaseGV = nullptr;
702
3
    if (Ptr != nullptr) {
703
3
      // TODO: will remove this when pointers have an opaque type.
704
3
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
3
                 PointeeType &&
706
3
             "explicit pointee type doesn't match operand's pointee type");
707
3
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
3
    }
709
3
    bool HasBaseReg = (BaseGV == nullptr);
710
3
711
3
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
3
    APInt BaseOffset(PtrSizeBits, 0);
713
3
    int64_t Scale = 0;
714
3
715
3
    auto GTI = gep_type_begin(PointeeType, Operands);
716
3
    Type *TargetType = nullptr;
717
3
718
3
    // Handle the case where the GEP instruction has a single operand,
719
3
    // the basis, therefore TargetType is a nullptr.
720
3
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
3
723
6
    
for (auto I = Operands.begin(); 3
I != Operands.end();
++I, ++GTI3
) {
724
3
      TargetType = GTI.getIndexedType();
725
3
      // We assume that the cost of Scalar GEP with constant index and the
726
3
      // cost of Vector GEP with splat constant index are the same.
727
3
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
3
      if (!ConstIdx)
729
0
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
3
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
0
        // For structures the index is always splat or scalar constant
733
0
        assert(ConstIdx && "Unexpected GEP index");
734
0
        uint64_t Field = ConstIdx->getZExtValue();
735
0
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
3
      } else {
737
3
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
3
        if (ConstIdx) {
739
3
          BaseOffset +=
740
3
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
3
        } else {
742
0
          // Needs scale register.
743
0
          if (Scale != 0)
744
0
            // No addressing mode takes two scale registers.
745
0
            return TTI::TCC_Basic;
746
0
          Scale = ElementSize;
747
0
        }
748
3
      }
749
3
    }
750
3
751
3
    // Assumes the address space is 0 when Ptr is nullptr.
752
3
    unsigned AS =
753
3
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
3
755
3
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
3
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
3
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
3
      return TTI::TCC_Free;
759
0
    return TTI::TCC_Basic;
760
0
  }
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
700
331
                 ArrayRef<const Value *> Operands) {
701
331
    const GlobalValue *BaseGV = nullptr;
702
331
    if (Ptr != nullptr) {
703
331
      // TODO: will remove this when pointers have an opaque type.
704
331
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
331
                 PointeeType &&
706
331
             "explicit pointee type doesn't match operand's pointee type");
707
331
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
331
    }
709
331
    bool HasBaseReg = (BaseGV == nullptr);
710
331
711
331
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
331
    APInt BaseOffset(PtrSizeBits, 0);
713
331
    int64_t Scale = 0;
714
331
715
331
    auto GTI = gep_type_begin(PointeeType, Operands);
716
331
    Type *TargetType = nullptr;
717
331
718
331
    // Handle the case where the GEP instruction has a single operand,
719
331
    // the basis, therefore TargetType is a nullptr.
720
331
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
331
723
760
    
for (auto I = Operands.begin(); 331
I != Operands.end();
++I, ++GTI429
) {
724
501
      TargetType = GTI.getIndexedType();
725
501
      // We assume that the cost of Scalar GEP with constant index and the
726
501
      // cost of Vector GEP with splat constant index are the same.
727
501
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
501
      if (!ConstIdx)
729
270
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
501
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
10
        // For structures the index is always splat or scalar constant
733
10
        assert(ConstIdx && "Unexpected GEP index");
734
10
        uint64_t Field = ConstIdx->getZExtValue();
735
10
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
491
      } else {
737
491
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
491
        if (ConstIdx) {
739
221
          BaseOffset +=
740
221
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
270
        } else {
742
270
          // Needs scale register.
743
270
          if (Scale != 0)
744
72
            // No addressing mode takes two scale registers.
745
72
            return TTI::TCC_Basic;
746
198
          Scale = ElementSize;
747
198
        }
748
491
      }
749
501
    }
750
331
751
331
    // Assumes the address space is 0 when Ptr is nullptr.
752
331
    unsigned AS =
753
259
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
259
755
259
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
259
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
259
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
128
      return TTI::TCC_Free;
759
131
    return TTI::TCC_Basic;
760
131
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
746
                 ArrayRef<const Value *> Operands) {
701
746
    const GlobalValue *BaseGV = nullptr;
702
746
    if (Ptr != nullptr) {
703
746
      // TODO: will remove this when pointers have an opaque type.
704
746
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
746
                 PointeeType &&
706
746
             "explicit pointee type doesn't match operand's pointee type");
707
746
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
746
    }
709
746
    bool HasBaseReg = (BaseGV == nullptr);
710
746
711
746
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
746
    APInt BaseOffset(PtrSizeBits, 0);
713
746
    int64_t Scale = 0;
714
746
715
746
    auto GTI = gep_type_begin(PointeeType, Operands);
716
746
    Type *TargetType = nullptr;
717
746
718
746
    // Handle the case where the GEP instruction has a single operand,
719
746
    // the basis, therefore TargetType is a nullptr.
720
746
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
746
723
1.66k
    
for (auto I = Operands.begin(); 746
I != Operands.end();
++I, ++GTI918
) {
724
924
      TargetType = GTI.getIndexedType();
725
924
      // We assume that the cost of Scalar GEP with constant index and the
726
924
      // cost of Vector GEP with splat constant index are the same.
727
924
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
924
      if (!ConstIdx)
729
458
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
924
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
75
        // For structures the index is always splat or scalar constant
733
75
        assert(ConstIdx && "Unexpected GEP index");
734
75
        uint64_t Field = ConstIdx->getZExtValue();
735
75
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
849
      } else {
737
849
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
849
        if (ConstIdx) {
739
391
          BaseOffset +=
740
391
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
458
        } else {
742
458
          // Needs scale register.
743
458
          if (Scale != 0)
744
6
            // No addressing mode takes two scale registers.
745
6
            return TTI::TCC_Basic;
746
452
          Scale = ElementSize;
747
452
        }
748
849
      }
749
924
    }
750
746
751
746
    // Assumes the address space is 0 when Ptr is nullptr.
752
746
    unsigned AS =
753
740
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
740
755
740
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
740
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
740
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
442
      return TTI::TCC_Free;
759
298
    return TTI::TCC_Basic;
760
298
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
74
                 ArrayRef<const Value *> Operands) {
701
74
    const GlobalValue *BaseGV = nullptr;
702
74
    if (Ptr != nullptr) {
703
74
      // TODO: will remove this when pointers have an opaque type.
704
74
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
74
                 PointeeType &&
706
74
             "explicit pointee type doesn't match operand's pointee type");
707
74
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
74
    }
709
74
    bool HasBaseReg = (BaseGV == nullptr);
710
74
711
74
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
74
    APInt BaseOffset(PtrSizeBits, 0);
713
74
    int64_t Scale = 0;
714
74
715
74
    auto GTI = gep_type_begin(PointeeType, Operands);
716
74
    Type *TargetType = nullptr;
717
74
718
74
    // Handle the case where the GEP instruction has a single operand,
719
74
    // the basis, therefore TargetType is a nullptr.
720
74
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
74
723
209
    
for (auto I = Operands.begin(); 74
I != Operands.end();
++I, ++GTI135
) {
724
135
      TargetType = GTI.getIndexedType();
725
135
      // We assume that the cost of Scalar GEP with constant index and the
726
135
      // cost of Vector GEP with splat constant index are the same.
727
135
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
135
      if (!ConstIdx)
729
53
        if (auto Splat = getSplatValue(*I))
730
0
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
135
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
39
        // For structures the index is always splat or scalar constant
733
39
        assert(ConstIdx && "Unexpected GEP index");
734
39
        uint64_t Field = ConstIdx->getZExtValue();
735
39
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
96
      } else {
737
96
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
96
        if (ConstIdx) {
739
43
          BaseOffset +=
740
43
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
53
        } else {
742
53
          // Needs scale register.
743
53
          if (Scale != 0)
744
0
            // No addressing mode takes two scale registers.
745
0
            return TTI::TCC_Basic;
746
53
          Scale = ElementSize;
747
53
        }
748
96
      }
749
135
    }
750
74
751
74
    // Assumes the address space is 0 when Ptr is nullptr.
752
74
    unsigned AS =
753
74
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
74
755
74
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
74
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
74
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
20
      return TTI::TCC_Free;
759
54
    return TTI::TCC_Basic;
760
54
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getGEPCost(llvm::Type*, llvm::Value const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
700
487k
                 ArrayRef<const Value *> Operands) {
701
487k
    const GlobalValue *BaseGV = nullptr;
702
487k
    if (Ptr != nullptr) {
703
487k
      // TODO: will remove this when pointers have an opaque type.
704
487k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
487k
                 PointeeType &&
706
487k
             "explicit pointee type doesn't match operand's pointee type");
707
487k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
487k
    }
709
487k
    bool HasBaseReg = (BaseGV == nullptr);
710
487k
711
487k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
487k
    APInt BaseOffset(PtrSizeBits, 0);
713
487k
    int64_t Scale = 0;
714
487k
715
487k
    auto GTI = gep_type_begin(PointeeType, Operands);
716
487k
    Type *TargetType = nullptr;
717
487k
718
487k
    // Handle the case where the GEP instruction has a single operand,
719
487k
    // the basis, therefore TargetType is a nullptr.
720
487k
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
487k
723
1.66M
    
for (auto I = Operands.begin(); 487k
I != Operands.end();
++I, ++GTI1.17M
) {
724
1.18M
      TargetType = GTI.getIndexedType();
725
1.18M
      // We assume that the cost of Scalar GEP with constant index and the
726
1.18M
      // cost of Vector GEP with splat constant index are the same.
727
1.18M
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
1.18M
      if (!ConstIdx)
729
253k
        if (auto Splat = getSplatValue(*I))
730
4
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
1.18M
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
550k
        // For structures the index is always splat or scalar constant
733
550k
        assert(ConstIdx && "Unexpected GEP index");
734
550k
        uint64_t Field = ConstIdx->getZExtValue();
735
550k
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
636k
      } else {
737
636k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
636k
        if (ConstIdx) {
739
383k
          BaseOffset +=
740
383k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
383k
        } else {
742
253k
          // Needs scale register.
743
253k
          if (Scale != 0)
744
12.7k
            // No addressing mode takes two scale registers.
745
12.7k
            return TTI::TCC_Basic;
746
240k
          Scale = ElementSize;
747
240k
        }
748
636k
      }
749
1.18M
    }
750
487k
751
487k
    // Assumes the address space is 0 when Ptr is nullptr.
752
487k
    unsigned AS =
753
474k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
474k
755
474k
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
474k
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
474k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
370k
      return TTI::TCC_Free;
759
103k
    return TTI::TCC_Basic;
760
103k
  }
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
700
9.63k
                 ArrayRef<const Value *> Operands) {
701
9.63k
    const GlobalValue *BaseGV = nullptr;
702
9.63k
    if (Ptr != nullptr) {
703
9.63k
      // TODO: will remove this when pointers have an opaque type.
704
9.63k
      assert(Ptr->getType()->getScalarType()->getPointerElementType() ==
705
9.63k
                 PointeeType &&
706
9.63k
             "explicit pointee type doesn't match operand's pointee type");
707
9.63k
      BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
708
9.63k
    }
709
9.63k
    bool HasBaseReg = (BaseGV == nullptr);
710
9.63k
711
9.63k
    auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
712
9.63k
    APInt BaseOffset(PtrSizeBits, 0);
713
9.63k
    int64_t Scale = 0;
714
9.63k
715
9.63k
    auto GTI = gep_type_begin(PointeeType, Operands);
716
9.63k
    Type *TargetType = nullptr;
717
9.63k
718
9.63k
    // Handle the case where the GEP instruction has a single operand,
719
9.63k
    // the basis, therefore TargetType is a nullptr.
720
9.63k
    if (Operands.empty())
721
0
      return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
722
9.63k
723
24.1k
    
for (auto I = Operands.begin(); 9.63k
I != Operands.end();
++I, ++GTI14.5k
) {
724
14.5k
      TargetType = GTI.getIndexedType();
725
14.5k
      // We assume that the cost of Scalar GEP with constant index and the
726
14.5k
      // cost of Vector GEP with splat constant index are the same.
727
14.5k
      const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
728
14.5k
      if (!ConstIdx)
729
9.49k
        if (auto Splat = getSplatValue(*I))
730
2.00k
          ConstIdx = dyn_cast<ConstantInt>(Splat);
731
14.5k
      if (StructType *STy = GTI.getStructTypeOrNull()) {
732
232
        // For structures the index is always splat or scalar constant
733
232
        assert(ConstIdx && "Unexpected GEP index");
734
232
        uint64_t Field = ConstIdx->getZExtValue();
735
232
        BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
736
14.2k
      } else {
737
14.2k
        int64_t ElementSize = DL.getTypeAllocSize(GTI.getIndexedType());
738
14.2k
        if (ConstIdx) {
739
6.79k
          BaseOffset +=
740
6.79k
              ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
741
7.49k
        } else {
742
7.49k
          // Needs scale register.
743
7.49k
          if (Scale != 0)
744
22
            // No addressing mode takes two scale registers.
745
22
            return TTI::TCC_Basic;
746
7.47k
          Scale = ElementSize;
747
7.47k
        }
748
14.2k
      }
749
14.5k
    }
750
9.63k
751
9.63k
    // Assumes the address space is 0 when Ptr is nullptr.
752
9.63k
    unsigned AS =
753
9.60k
        (Ptr == nullptr ? 
00
: Ptr->getType()->getPointerAddressSpace());
754
9.60k
755
9.60k
    if (static_cast<T *>(this)->isLegalAddressingMode(
756
9.60k
            TargetType, const_cast<GlobalValue *>(BaseGV),
757
9.60k
            BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale, AS))
758
36
      return TTI::TCC_Free;
759
9.57k
    return TTI::TCC_Basic;
760
9.57k
  }
761
762
  using BaseT::getIntrinsicCost;
763
764
  unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
765
4
                            ArrayRef<const Value *> Arguments) {
766
4
    // Delegate to the generic intrinsic handling code. This mostly provides an
767
4
    // opportunity for targets to (for example) special case the cost of
768
4
    // certain intrinsics based on constants used as arguments.
769
4
    SmallVector<Type *, 8> ParamTys;
770
4
    ParamTys.reserve(Arguments.size());
771
12
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx8
)
772
8
      ParamTys.push_back(Arguments[Idx]->getType());
773
4
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
774
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
765
2
                            ArrayRef<const Value *> Arguments) {
766
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
767
2
    // opportunity for targets to (for example) special case the cost of
768
2
    // certain intrinsics based on constants used as arguments.
769
2
    SmallVector<Type *, 8> ParamTys;
770
2
    ParamTys.reserve(Arguments.size());
771
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
772
4
      ParamTys.push_back(Arguments[Idx]->getType());
773
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
774
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*>)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getIntrinsicCost(llvm::Intrinsic::ID, llvm::Type*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
765
2
                            ArrayRef<const Value *> Arguments) {
766
2
    // Delegate to the generic intrinsic handling code. This mostly provides an
767
2
    // opportunity for targets to (for example) special case the cost of
768
2
    // certain intrinsics based on constants used as arguments.
769
2
    SmallVector<Type *, 8> ParamTys;
770
2
    ParamTys.reserve(Arguments.size());
771
6
    for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; 
++Idx4
)
772
4
      ParamTys.push_back(Arguments[Idx]->getType());
773
2
    return static_cast<T *>(this)->getIntrinsicCost(IID, RetTy, ParamTys);
774
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*>)
775
776
45.2M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
45.2M
    if (isa<PHINode>(U))
778
3.50M
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
41.7M
780
41.7M
    // Static alloca doesn't generate target instructions.
781
41.7M
    if (auto *A = dyn_cast<AllocaInst>(U))
782
158k
      if (A->isStaticAlloca())
783
158k
        return TTI::TCC_Free;
784
41.5M
785
41.5M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
6.44M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
6.44M
                                                GEP->getPointerOperand(),
788
6.44M
                                                Operands.drop_front());
789
6.44M
    }
790
35.1M
791
35.1M
    if (auto CS = ImmutableCallSite(U)) {
792
7.02M
      const Function *F = CS.getCalledFunction();
793
7.02M
      if (!F) {
794
254k
        // Just use the called value type.
795
254k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
254k
        return static_cast<T *>(this)
797
254k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
254k
      }
799
6.77M
800
6.77M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
6.77M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
6.77M
    }
803
28.0M
804
28.0M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
5.82M
      // Result of a cmp instruction is often extended (to be used by other
806
5.82M
      // cmp instructions, logical or return instructions). These are usually
807
5.82M
      // nop on most sane targets.
808
5.82M
      if (isa<CmpInst>(CI->getOperand(0)))
809
113k
        return TTI::TCC_Free;
810
5.71M
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)4.82M
||
isa<FPExtInst>(CI)4.09M
)
811
1.69M
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
26.2M
    }
813
26.2M
814
26.2M
    return static_cast<T *>(this)->getOperationCost(
815
26.2M
        Operator::getOpcode(U), U->getType(),
816
26.2M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()10.7M
:
nullptr15.5M
);
817
26.2M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::AArch64TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
40.0M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
40.0M
    if (isa<PHINode>(U))
778
3.24M
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
36.7M
780
36.7M
    // Static alloca doesn't generate target instructions.
781
36.7M
    if (auto *A = dyn_cast<AllocaInst>(U))
782
124k
      if (A->isStaticAlloca())
783
124k
        return TTI::TCC_Free;
784
36.6M
785
36.6M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
5.83M
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
5.83M
                                                GEP->getPointerOperand(),
788
5.83M
                                                Operands.drop_front());
789
5.83M
    }
790
30.8M
791
30.8M
    if (auto CS = ImmutableCallSite(U)) {
792
5.34M
      const Function *F = CS.getCalledFunction();
793
5.34M
      if (!F) {
794
168k
        // Just use the called value type.
795
168k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
168k
        return static_cast<T *>(this)
797
168k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
168k
      }
799
5.17M
800
5.17M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
5.17M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
5.17M
    }
803
25.4M
804
25.4M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
4.99M
      // Result of a cmp instruction is often extended (to be used by other
806
4.99M
      // cmp instructions, logical or return instructions). These are usually
807
4.99M
      // nop on most sane targets.
808
4.99M
      if (isa<CmpInst>(CI->getOperand(0)))
809
96.8k
        return TTI::TCC_Free;
810
4.89M
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)4.14M
||
isa<FPExtInst>(CI)3.54M
)
811
1.42M
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
23.9M
    }
813
23.9M
814
23.9M
    return static_cast<T *>(this)->getOperationCost(
815
23.9M
        Operator::getOpcode(U), U->getType(),
816
23.9M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()9.67M
:
nullptr14.2M
);
817
23.9M
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::R600TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
382
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
382
    if (isa<PHINode>(U))
778
44
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
338
780
338
    // Static alloca doesn't generate target instructions.
781
338
    if (auto *A = dyn_cast<AllocaInst>(U))
782
0
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
338
785
338
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
15
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
15
                                                GEP->getPointerOperand(),
788
15
                                                Operands.drop_front());
789
15
    }
790
323
791
323
    if (auto CS = ImmutableCallSite(U)) {
792
2
      const Function *F = CS.getCalledFunction();
793
2
      if (!F) {
794
0
        // Just use the called value type.
795
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
0
        return static_cast<T *>(this)
797
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
0
      }
799
2
800
2
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
2
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
2
    }
803
321
804
321
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
47
      // Result of a cmp instruction is often extended (to be used by other
806
47
      // cmp instructions, logical or return instructions). These are usually
807
47
      // nop on most sane targets.
808
47
      if (isa<CmpInst>(CI->getOperand(0)))
809
6
        return TTI::TCC_Free;
810
41
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)40
||
isa<FPExtInst>(CI)40
)
811
1
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
314
    }
813
314
814
314
    return static_cast<T *>(this)->getOperationCost(
815
314
        Operator::getOpcode(U), U->getType(),
816
314
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()66
:
nullptr248
);
817
314
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::GCNTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
8.55k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
8.55k
    if (isa<PHINode>(U))
778
1.35k
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
7.20k
780
7.20k
    // Static alloca doesn't generate target instructions.
781
7.20k
    if (auto *A = dyn_cast<AllocaInst>(U))
782
23
      if (A->isStaticAlloca())
783
23
        return TTI::TCC_Free;
784
7.17k
785
7.17k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
388
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
388
                                                GEP->getPointerOperand(),
788
388
                                                Operands.drop_front());
789
388
    }
790
6.79k
791
6.79k
    if (auto CS = ImmutableCallSite(U)) {
792
1.29k
      const Function *F = CS.getCalledFunction();
793
1.29k
      if (!F) {
794
112
        // Just use the called value type.
795
112
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
112
        return static_cast<T *>(this)
797
112
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
112
      }
799
1.17k
800
1.17k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
1.17k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
1.17k
    }
803
5.49k
804
5.49k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
784
      // Result of a cmp instruction is often extended (to be used by other
806
784
      // cmp instructions, logical or return instructions). These are usually
807
784
      // nop on most sane targets.
808
784
      if (isa<CmpInst>(CI->getOperand(0)))
809
116
        return TTI::TCC_Free;
810
668
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)591
||
isa<FPExtInst>(CI)499
)
811
169
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
5.21k
    }
813
5.21k
814
5.21k
    return static_cast<T *>(this)->getOperationCost(
815
5.21k
        Operator::getOpcode(U), U->getType(),
816
5.21k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()855
:
nullptr4.35k
);
817
5.21k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::ARMTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
1.24M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
1.24M
    if (isa<PHINode>(U))
778
52.8k
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
1.19M
780
1.19M
    // Static alloca doesn't generate target instructions.
781
1.19M
    if (auto *A = dyn_cast<AllocaInst>(U))
782
6.13k
      if (A->isStaticAlloca())
783
6.10k
        return TTI::TCC_Free;
784
1.19M
785
1.19M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
108k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
108k
                                                GEP->getPointerOperand(),
788
108k
                                                Operands.drop_front());
789
108k
    }
790
1.08M
791
1.08M
    if (auto CS = ImmutableCallSite(U)) {
792
441k
      const Function *F = CS.getCalledFunction();
793
441k
      if (!F) {
794
10.5k
        // Just use the called value type.
795
10.5k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
10.5k
        return static_cast<T *>(this)
797
10.5k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
10.5k
      }
799
430k
800
430k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
430k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
430k
    }
803
640k
804
640k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
216k
      // Result of a cmp instruction is often extended (to be used by other
806
216k
      // cmp instructions, logical or return instructions). These are usually
807
216k
      // nop on most sane targets.
808
216k
      if (isa<CmpInst>(CI->getOperand(0)))
809
5.68k
        return TTI::TCC_Free;
810
210k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)167k
||
isa<FPExtInst>(CI)123k
)
811
87.1k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
547k
    }
813
547k
814
547k
    return static_cast<T *>(this)->getOperationCost(
815
547k
        Operator::getOpcode(U), U->getType(),
816
547k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()239k
:
nullptr308k
);
817
547k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::HexagonTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
147
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
147
    if (isa<PHINode>(U))
778
24
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
123
780
123
    // Static alloca doesn't generate target instructions.
781
123
    if (auto *A = dyn_cast<AllocaInst>(U))
782
0
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
123
785
123
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
3
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
3
                                                GEP->getPointerOperand(),
788
3
                                                Operands.drop_front());
789
3
    }
790
120
791
120
    if (auto CS = ImmutableCallSite(U)) {
792
28
      const Function *F = CS.getCalledFunction();
793
28
      if (!F) {
794
0
        // Just use the called value type.
795
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
0
        return static_cast<T *>(this)
797
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
0
      }
799
28
800
28
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
28
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
28
    }
803
92
804
92
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
15
      // Result of a cmp instruction is often extended (to be used by other
806
15
      // cmp instructions, logical or return instructions). These are usually
807
15
      // nop on most sane targets.
808
15
      if (isa<CmpInst>(CI->getOperand(0)))
809
0
        return TTI::TCC_Free;
810
15
      if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || 
isa<FPExtInst>(CI)9
)
811
6
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
86
    }
813
86
814
86
    return static_cast<T *>(this)->getOperationCost(
815
86
        Operator::getOpcode(U), U->getType(),
816
86
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()24
:
nullptr62
);
817
86
  }
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
776
8
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
8
    if (isa<PHINode>(U))
778
0
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
8
780
8
    // Static alloca doesn't generate target instructions.
781
8
    if (auto *A = dyn_cast<AllocaInst>(U))
782
0
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
8
785
8
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
0
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
0
                                                GEP->getPointerOperand(),
788
0
                                                Operands.drop_front());
789
0
    }
790
8
791
8
    if (auto CS = ImmutableCallSite(U)) {
792
6
      const Function *F = CS.getCalledFunction();
793
6
      if (!F) {
794
0
        // Just use the called value type.
795
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
0
        return static_cast<T *>(this)
797
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
0
      }
799
6
800
6
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
6
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
6
    }
803
2
804
2
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
2
      // Result of a cmp instruction is often extended (to be used by other
806
2
      // cmp instructions, logical or return instructions). These are usually
807
2
      // nop on most sane targets.
808
2
      if (isa<CmpInst>(CI->getOperand(0)))
809
0
        return TTI::TCC_Free;
810
2
      if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
811
0
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
2
    }
813
2
814
2
    return static_cast<T *>(this)->getOperationCost(
815
2
        Operator::getOpcode(U), U->getType(),
816
2
        U->getNumOperands() == 1 ? U->getOperand(0)->getType() : 
nullptr0
);
817
2
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::NVPTXTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
134
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
134
    if (isa<PHINode>(U))
778
9
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
125
780
125
    // Static alloca doesn't generate target instructions.
781
125
    if (auto *A = dyn_cast<AllocaInst>(U))
782
0
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
125
785
125
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
2
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
2
                                                GEP->getPointerOperand(),
788
2
                                                Operands.drop_front());
789
2
    }
790
123
791
123
    if (auto CS = ImmutableCallSite(U)) {
792
20
      const Function *F = CS.getCalledFunction();
793
20
      if (!F) {
794
0
        // Just use the called value type.
795
0
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
0
        return static_cast<T *>(this)
797
0
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
0
      }
799
20
800
20
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
20
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
20
    }
803
103
804
103
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
17
      // Result of a cmp instruction is often extended (to be used by other
806
17
      // cmp instructions, logical or return instructions). These are usually
807
17
      // nop on most sane targets.
808
17
      if (isa<CmpInst>(CI->getOperand(0)))
809
0
        return TTI::TCC_Free;
810
17
      if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || 
isa<FPExtInst>(CI)16
)
811
1
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
102
    }
813
102
814
102
    return static_cast<T *>(this)->getOperationCost(
815
102
        Operator::getOpcode(U), U->getType(),
816
102
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()16
:
nullptr86
);
817
102
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::PPCTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
7.10k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
7.10k
    if (isa<PHINode>(U))
778
674
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
6.43k
780
6.43k
    // Static alloca doesn't generate target instructions.
781
6.43k
    if (auto *A = dyn_cast<AllocaInst>(U))
782
70
      if (A->isStaticAlloca())
783
70
        return TTI::TCC_Free;
784
6.36k
785
6.36k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
746
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
746
                                                GEP->getPointerOperand(),
788
746
                                                Operands.drop_front());
789
746
    }
790
5.61k
791
5.61k
    if (auto CS = ImmutableCallSite(U)) {
792
276
      const Function *F = CS.getCalledFunction();
793
276
      if (!F) {
794
64
        // Just use the called value type.
795
64
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
64
        return static_cast<T *>(this)
797
64
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
64
      }
799
212
800
212
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
212
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
212
    }
803
5.33k
804
5.33k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
947
      // Result of a cmp instruction is often extended (to be used by other
806
947
      // cmp instructions, logical or return instructions). These are usually
807
947
      // nop on most sane targets.
808
947
      if (isa<CmpInst>(CI->getOperand(0)))
809
1
        return TTI::TCC_Free;
810
946
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)854
||
isa<FPExtInst>(CI)734
)
811
218
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
5.11k
    }
813
5.11k
814
5.11k
    return static_cast<T *>(this)->getOperationCost(
815
5.11k
        Operator::getOpcode(U), U->getType(),
816
5.11k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()1.79k
:
nullptr3.32k
);
817
5.11k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::SystemZTTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
1.23k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
1.23k
    if (isa<PHINode>(U))
778
64
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
1.17k
780
1.17k
    // Static alloca doesn't generate target instructions.
781
1.17k
    if (auto *A = dyn_cast<AllocaInst>(U))
782
0
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
1.17k
785
1.17k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
74
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
74
                                                GEP->getPointerOperand(),
788
74
                                                Operands.drop_front());
789
74
    }
790
1.09k
791
1.09k
    if (auto CS = ImmutableCallSite(U)) {
792
53
      const Function *F = CS.getCalledFunction();
793
53
      if (!F) {
794
1
        // Just use the called value type.
795
1
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
1
        return static_cast<T *>(this)
797
1
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
1
      }
799
52
800
52
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
52
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
52
    }
803
1.04k
804
1.04k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
72
      // Result of a cmp instruction is often extended (to be used by other
806
72
      // cmp instructions, logical or return instructions). These are usually
807
72
      // nop on most sane targets.
808
72
      if (isa<CmpInst>(CI->getOperand(0)))
809
5
        return TTI::TCC_Free;
810
67
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)63
||
isa<FPExtInst>(CI)51
)
811
16
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
1.02k
    }
813
1.02k
814
1.02k
    return static_cast<T *>(this)->getOperationCost(
815
1.02k
        Operator::getOpcode(U), U->getType(),
816
1.02k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()225
:
nullptr800
);
817
1.02k
  }
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getUserCost(llvm::User const*, llvm::ArrayRef<llvm::Value const*>)
Line
Count
Source
776
3.88M
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
3.88M
    if (isa<PHINode>(U))
778
196k
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
3.68M
780
3.68M
    // Static alloca doesn't generate target instructions.
781
3.68M
    if (auto *A = dyn_cast<AllocaInst>(U))
782
27.6k
      if (A->isStaticAlloca())
783
27.6k
        return TTI::TCC_Free;
784
3.65M
785
3.65M
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
487k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
487k
                                                GEP->getPointerOperand(),
788
487k
                                                Operands.drop_front());
789
487k
    }
790
3.17M
791
3.17M
    if (auto CS = ImmutableCallSite(U)) {
792
1.23M
      const Function *F = CS.getCalledFunction();
793
1.23M
      if (!F) {
794
74.9k
        // Just use the called value type.
795
74.9k
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
74.9k
        return static_cast<T *>(this)
797
74.9k
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
74.9k
      }
799
1.15M
800
1.15M
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
1.15M
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
1.15M
    }
803
1.94M
804
1.94M
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
610k
      // Result of a cmp instruction is often extended (to be used by other
806
610k
      // cmp instructions, logical or return instructions). These are usually
807
610k
      // nop on most sane targets.
808
610k
      if (isa<CmpInst>(CI->getOperand(0)))
809
11.3k
        return TTI::TCC_Free;
810
599k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)510k
||
isa<FPExtInst>(CI)424k
)
811
174k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
1.75M
    }
813
1.75M
814
1.75M
    return static_cast<T *>(this)->getOperationCost(
815
1.75M
        Operator::getOpcode(U), U->getType(),
816
1.75M
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()849k
:
nullptr905k
);
817
1.75M
  }
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
776
69.8k
  unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands) {
777
69.8k
    if (isa<PHINode>(U))
778
10.0k
      return TTI::TCC_Free; // Model all PHI nodes as free.
779
59.7k
780
59.7k
    // Static alloca doesn't generate target instructions.
781
59.7k
    if (auto *A = dyn_cast<AllocaInst>(U))
782
1
      if (A->isStaticAlloca())
783
0
        return TTI::TCC_Free;
784
59.7k
785
59.7k
    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
786
9.59k
      return static_cast<T *>(this)->getGEPCost(GEP->getSourceElementType(),
787
9.59k
                                                GEP->getPointerOperand(),
788
9.59k
                                                Operands.drop_front());
789
9.59k
    }
790
50.2k
791
50.2k
    if (auto CS = ImmutableCallSite(U)) {
792
7.09k
      const Function *F = CS.getCalledFunction();
793
7.09k
      if (!F) {
794
24
        // Just use the called value type.
795
24
        Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
796
24
        return static_cast<T *>(this)
797
24
            ->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
798
24
      }
799
7.07k
800
7.07k
      SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
801
7.07k
      return static_cast<T *>(this)->getCallCost(F, Arguments);
802
7.07k
    }
803
43.1k
804
43.1k
    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
805
6.47k
      // Result of a cmp instruction is often extended (to be used by other
806
6.47k
      // cmp instructions, logical or return instructions). These are usually
807
6.47k
      // nop on most sane targets.
808
6.47k
      if (isa<CmpInst>(CI->getOperand(0)))
809
6
        return TTI::TCC_Free;
810
6.47k
      if (isa<SExtInst>(CI) || 
isa<ZExtInst>(CI)6.32k
||
isa<FPExtInst>(CI)4.19k
)
811
2.28k
        return static_cast<T *>(this)->getExtCost(CI, Operands.back());
812
40.8k
    }
813
40.8k
814
40.8k
    return static_cast<T *>(this)->getOperationCost(
815
40.8k
        Operator::getOpcode(U), U->getType(),
816
40.8k
        U->getNumOperands() == 1 ? 
U->getOperand(0)->getType()10.8k
:
nullptr29.9k
);
817
40.8k
  }
818
819
10
  int getInstructionLatency(const Instruction *I) {
820
10
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
821
10
                                           I->value_op_end());
822
10
    if (getUserCost(I, Operands) == TTI::TCC_Free)
823
5
      return 0;
824
5
825
5
    if (isa<LoadInst>(I))
826
0
      return 4;
827
5
828
5
    Type *DstTy = I->getType();
829
5
830
5
    // Usually an intrinsic is a simple instruction.
831
5
    // A real function call is much slower.
832
5
    if (auto *CI = dyn_cast<CallInst>(I)) {
833
2
      const Function *F = CI->getCalledFunction();
834
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
835
1
        return 40;
836
1
      // Some intrinsics return a value and a flag, we use the value type
837
1
      // to decide its latency.
838
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
839
1
        DstTy = StructTy->getElementType(0);
840
1
      // Fall through to simple instructions.
841
1
    }
842
5
843
5
    
if (VectorType *4
VectorTy4
= dyn_cast<VectorType>(DstTy))
844
0
      DstTy = VectorTy->getElementType();
845
4
    if (DstTy->isFloatingPointTy())
846
0
      return 3;
847
4
848
4
    return 1;
849
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*)
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getInstructionLatency(llvm::Instruction const*)
Line
Count
Source
819
10
  int getInstructionLatency(const Instruction *I) {
820
10
    SmallVector<const Value *, 4> Operands(I->value_op_begin(),
821
10
                                           I->value_op_end());
822
10
    if (getUserCost(I, Operands) == TTI::TCC_Free)
823
5
      return 0;
824
5
825
5
    if (isa<LoadInst>(I))
826
0
      return 4;
827
5
828
5
    Type *DstTy = I->getType();
829
5
830
5
    // Usually an intrinsic is a simple instruction.
831
5
    // A real function call is much slower.
832
5
    if (auto *CI = dyn_cast<CallInst>(I)) {
833
2
      const Function *F = CI->getCalledFunction();
834
2
      if (!F || 
static_cast<T *>(this)->isLoweredToCall(F)1
)
835
1
        return 40;
836
1
      // Some intrinsics return a value and a flag, we use the value type
837
1
      // to decide its latency.
838
1
      if (StructType* StructTy = dyn_cast<StructType>(DstTy))
839
1
        DstTy = StructTy->getElementType(0);
840
1
      // Fall through to simple instructions.
841
1
    }
842
5
843
5
    
if (VectorType *4
VectorTy4
= dyn_cast<VectorType>(DstTy))
844
0
      DstTy = VectorTy->getElementType();
845
4
    if (DstTy->isFloatingPointTy())
846
0
      return 3;
847
4
848
4
    return 1;
849
4
  }
Unexecuted instantiation: llvm::TargetTransformInfoImplCRTPBase<llvm::XCoreTTIImpl>::getInstructionLatency(llvm::Instruction const*)
Unexecuted instantiation: TargetTransformInfo.cpp:llvm::TargetTransformInfoImplCRTPBase<(anonymous namespace)::NoTTIImpl>::getInstructionLatency(llvm::Instruction const*)
850
};
851
}
852
853
#endif