LLVM  3.7.0
AMDGPUTargetTransformInfo.cpp
Go to the documentation of this file.
1 //===-- AMDGPUTargetTransformInfo.cpp - AMDGPU specific TTI pass ---------===//
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 //
10 // \file
11 // This file implements a TargetTransformInfo analysis pass specific to the
12 // AMDGPU target machine. It uses the target's detailed information to provide
13 // more precise answers to certain TTI queries, while letting the target
14 // independent and default TTI implementations handle the rest.
15 //
16 //===----------------------------------------------------------------------===//
17 
19 #include "llvm/Analysis/LoopInfo.h"
23 #include "llvm/IR/Module.h"
24 #include "llvm/Support/Debug.h"
25 #include "llvm/Target/CostTable.h"
27 using namespace llvm;
28 
29 #define DEBUG_TYPE "AMDGPUtti"
30 
33  UP.Threshold = 300; // Twice the default.
34  UP.MaxCount = UINT_MAX;
35  UP.Partial = true;
36 
37  // TODO: Do we want runtime unrolling?
38 
39  for (const BasicBlock *BB : L->getBlocks()) {
40  const DataLayout &DL = BB->getModule()->getDataLayout();
41  for (const Instruction &I : *BB) {
43  if (!GEP || GEP->getAddressSpace() != AMDGPUAS::PRIVATE_ADDRESS)
44  continue;
45 
46  const Value *Ptr = GEP->getPointerOperand();
47  const AllocaInst *Alloca =
49  if (Alloca) {
50  // We want to do whatever we can to limit the number of alloca
51  // instructions that make it through to the code generator. allocas
52  // require us to use indirect addressing, which is slow and prone to
53  // compiler bugs. If this loop does an address calculation on an
54  // alloca ptr, then we want to use a higher than normal loop unroll
55  // threshold. This will give SROA a better chance to eliminate these
56  // allocas.
57  //
58  // Don't use the maximum allowed value here as it will make some
59  // programs way too big.
60  UP.Threshold = 800;
61  }
62  }
63  }
64 }
65 
67  if (Vec)
68  return 0;
69 
70  // Number of VGPRs on SI.
72  return 256;
73 
74  return 4 * 128; // XXX - 4 channels. Should these count as vector instead?
75 }
76 
77 unsigned AMDGPUTTIImpl::getRegisterBitWidth(bool) { return 32; }
78 
80  // Semi-arbitrary large amount.
81  return 64;
82 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:104
bool Partial
Allow partial unrolling (unrolling of loops to expand the size of the loop body, not only to eliminat...
This file a TargetTransformInfo::Concept conforming object specific to the AMDGPU target machine...
unsigned getNumberOfRegisters(bool Vector)
void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP)
Cost tables and simple lookup functions.
Hexagon Common GEP
const std::vector< BlockT * > & getBlocks() const
getBlocks - Get a list of the basic blocks which make up this loop.
Definition: LoopInfo.h:139
unsigned getRegisterBitWidth(bool Vector)
unsigned getMaxInterleaveFactor(unsigned VF)
Generation getGeneration() const
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
Definition: Instructions.h:830
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
Address space for private memory.
Definition: AMDGPU.h:109
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
GetUnderlyingObject - This method strips off any GEP address adjustments and pointer casts from the s...
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
Definition: Instructions.h:938
Module.h This file contains the declarations for the Module class.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:285
unsigned Threshold
The cost threshold for the unrolled loop.
Parameters that control the generic loop unrolling transformation.
#define I(x, y, z)
Definition: MD5.cpp:54
LLVM Value Representation.
Definition: Value.h:69
This pass exposes codegen information to IR-level passes.
This file describes how to lower LLVM code to machine code.
AllocaInst - an instruction to allocate memory on the stack.
Definition: Instructions.h:76