1 //===-- NVPTXTargetTransformInfo.cpp - NVPTX specific TTI -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "NVPTXTargetTransformInfo.h"
11 #include "llvm/Analysis/LoopInfo.h"
12 #include "llvm/Analysis/TargetTransformInfo.h"
13 #include "llvm/Analysis/ValueTracking.h"
14 #include "llvm/CodeGen/BasicTTIImpl.h"
15 #include "llvm/Support/Debug.h"
16 #include "llvm/Target/CostTable.h"
17 #include "llvm/Target/TargetLowering.h"
20 #define DEBUG_TYPE "NVPTXtti"
22 unsigned NVPTXTTIImpl::getArithmeticInstrCost(
23 unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info,
24 TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
25 TTI::OperandValueProperties Opd2PropInfo) {
27 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
29 int ISD = TLI->InstructionOpcodeToISD(Opcode);
33 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
34 Opd1PropInfo, Opd2PropInfo);
40 // The machine code (SASS) simulates an i64 with two i32. Therefore, we
41 // estimate that arithmetic operations on i64 are twice as expensive as
42 // those on types that can fit into one machine register.
43 if (LT.second.SimpleTy == MVT::i64)
45 // Delegate other cases to the basic TTI.
46 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
47 Opd1PropInfo, Opd2PropInfo);