1664e354dSChandler Carruth //===- BasicTargetTransformInfo.cpp - Basic target-independent TTI impl ---===// 2664e354dSChandler Carruth // 3664e354dSChandler Carruth // The LLVM Compiler Infrastructure 4664e354dSChandler Carruth // 5664e354dSChandler Carruth // This file is distributed under the University of Illinois Open Source 6664e354dSChandler Carruth // License. See LICENSE.TXT for details. 7664e354dSChandler Carruth // 8664e354dSChandler Carruth //===----------------------------------------------------------------------===// 9664e354dSChandler Carruth /// \file 10664e354dSChandler Carruth /// This file provides the implementation of a basic TargetTransformInfo pass 11664e354dSChandler Carruth /// predicated on the target abstractions present in the target independent 12664e354dSChandler Carruth /// code generator. It uses these (primarily TargetLowering) to model as much 13664e354dSChandler Carruth /// of the TTI query interface as possible. It is included by most targets so 14664e354dSChandler Carruth /// that they can specialize only a small subset of the query space. 15664e354dSChandler Carruth /// 16664e354dSChandler Carruth //===----------------------------------------------------------------------===// 17664e354dSChandler Carruth 18664e354dSChandler Carruth #define DEBUG_TYPE "basictti" 19664e354dSChandler Carruth #include "llvm/CodeGen/Passes.h" 20d3e73556SChandler Carruth #include "llvm/Analysis/TargetTransformInfo.h" 21664e354dSChandler Carruth #include "llvm/Target/TargetLowering.h" 22664e354dSChandler Carruth #include <utility> 23664e354dSChandler Carruth 24664e354dSChandler Carruth using namespace llvm; 25664e354dSChandler Carruth 26664e354dSChandler Carruth namespace { 27664e354dSChandler Carruth 28664e354dSChandler Carruth class BasicTTI : public ImmutablePass, public TargetTransformInfo { 29664e354dSChandler Carruth const TargetLowering *TLI; 30664e354dSChandler Carruth 31664e354dSChandler Carruth /// Estimate the overhead of scalarizing an instruction. Insert and Extract 32664e354dSChandler Carruth /// are set if the result needs to be inserted and/or extracted from vectors. 33664e354dSChandler Carruth unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const; 34664e354dSChandler Carruth 35664e354dSChandler Carruth public: 36664e354dSChandler Carruth BasicTTI() : ImmutablePass(ID), TLI(0) { 37664e354dSChandler Carruth llvm_unreachable("This pass cannot be directly constructed"); 38664e354dSChandler Carruth } 39664e354dSChandler Carruth 40664e354dSChandler Carruth BasicTTI(const TargetLowering *TLI) : ImmutablePass(ID), TLI(TLI) { 41664e354dSChandler Carruth initializeBasicTTIPass(*PassRegistry::getPassRegistry()); 42664e354dSChandler Carruth } 43664e354dSChandler Carruth 44664e354dSChandler Carruth virtual void initializePass() { 45664e354dSChandler Carruth pushTTIStack(this); 46664e354dSChandler Carruth } 47664e354dSChandler Carruth 48664e354dSChandler Carruth virtual void finalizePass() { 49664e354dSChandler Carruth popTTIStack(); 50664e354dSChandler Carruth } 51664e354dSChandler Carruth 52664e354dSChandler Carruth virtual void getAnalysisUsage(AnalysisUsage &AU) const { 53664e354dSChandler Carruth TargetTransformInfo::getAnalysisUsage(AU); 54664e354dSChandler Carruth } 55664e354dSChandler Carruth 56664e354dSChandler Carruth /// Pass identification. 57664e354dSChandler Carruth static char ID; 58664e354dSChandler Carruth 59664e354dSChandler Carruth /// Provide necessary pointer adjustments for the two base classes. 60664e354dSChandler Carruth virtual void *getAdjustedAnalysisPointer(const void *ID) { 61664e354dSChandler Carruth if (ID == &TargetTransformInfo::ID) 62664e354dSChandler Carruth return (TargetTransformInfo*)this; 63664e354dSChandler Carruth return this; 64664e354dSChandler Carruth } 65664e354dSChandler Carruth 66664e354dSChandler Carruth /// \name Scalar TTI Implementations 67664e354dSChandler Carruth /// @{ 68664e354dSChandler Carruth 69664e354dSChandler Carruth virtual bool isLegalAddImmediate(int64_t imm) const; 70664e354dSChandler Carruth virtual bool isLegalICmpImmediate(int64_t imm) const; 71664e354dSChandler Carruth virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, 72664e354dSChandler Carruth int64_t BaseOffset, bool HasBaseReg, 73664e354dSChandler Carruth int64_t Scale) const; 74664e354dSChandler Carruth virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const; 75664e354dSChandler Carruth virtual bool isTypeLegal(Type *Ty) const; 76664e354dSChandler Carruth virtual unsigned getJumpBufAlignment() const; 77664e354dSChandler Carruth virtual unsigned getJumpBufSize() const; 78664e354dSChandler Carruth virtual bool shouldBuildLookupTables() const; 79664e354dSChandler Carruth 80664e354dSChandler Carruth /// @} 81664e354dSChandler Carruth 82664e354dSChandler Carruth /// \name Vector TTI Implementations 83664e354dSChandler Carruth /// @{ 84664e354dSChandler Carruth 85664e354dSChandler Carruth virtual unsigned getNumberOfRegisters(bool Vector) const; 86*b696c36fSNadav Rotem virtual unsigned getMaximumUnrollFactor() const; 87664e354dSChandler Carruth virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const; 88664e354dSChandler Carruth virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp, 89664e354dSChandler Carruth int Index, Type *SubTp) const; 90664e354dSChandler Carruth virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst, 91664e354dSChandler Carruth Type *Src) const; 92664e354dSChandler Carruth virtual unsigned getCFInstrCost(unsigned Opcode) const; 93664e354dSChandler Carruth virtual unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, 94664e354dSChandler Carruth Type *CondTy) const; 95664e354dSChandler Carruth virtual unsigned getVectorInstrCost(unsigned Opcode, Type *Val, 96664e354dSChandler Carruth unsigned Index) const; 97664e354dSChandler Carruth virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src, 98664e354dSChandler Carruth unsigned Alignment, 99664e354dSChandler Carruth unsigned AddressSpace) const; 100664e354dSChandler Carruth virtual unsigned getIntrinsicInstrCost(Intrinsic::ID, Type *RetTy, 101664e354dSChandler Carruth ArrayRef<Type*> Tys) const; 102664e354dSChandler Carruth virtual unsigned getNumberOfParts(Type *Tp) const; 103664e354dSChandler Carruth 104664e354dSChandler Carruth /// @} 105664e354dSChandler Carruth }; 106664e354dSChandler Carruth 107664e354dSChandler Carruth } 108664e354dSChandler Carruth 109664e354dSChandler Carruth INITIALIZE_AG_PASS(BasicTTI, TargetTransformInfo, "basictti", 110664e354dSChandler Carruth "Target independent code generator's TTI", true, true, false) 111664e354dSChandler Carruth char BasicTTI::ID = 0; 112664e354dSChandler Carruth 113664e354dSChandler Carruth ImmutablePass * 114664e354dSChandler Carruth llvm::createBasicTargetTransformInfoPass(const TargetLowering *TLI) { 115664e354dSChandler Carruth return new BasicTTI(TLI); 116664e354dSChandler Carruth } 117664e354dSChandler Carruth 118664e354dSChandler Carruth 119664e354dSChandler Carruth bool BasicTTI::isLegalAddImmediate(int64_t imm) const { 120664e354dSChandler Carruth return TLI->isLegalAddImmediate(imm); 121664e354dSChandler Carruth } 122664e354dSChandler Carruth 123664e354dSChandler Carruth bool BasicTTI::isLegalICmpImmediate(int64_t imm) const { 124664e354dSChandler Carruth return TLI->isLegalICmpImmediate(imm); 125664e354dSChandler Carruth } 126664e354dSChandler Carruth 127664e354dSChandler Carruth bool BasicTTI::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, 128664e354dSChandler Carruth int64_t BaseOffset, bool HasBaseReg, 129664e354dSChandler Carruth int64_t Scale) const { 13095f83e01SChandler Carruth TargetLowering::AddrMode AM; 131664e354dSChandler Carruth AM.BaseGV = BaseGV; 132664e354dSChandler Carruth AM.BaseOffs = BaseOffset; 133664e354dSChandler Carruth AM.HasBaseReg = HasBaseReg; 134664e354dSChandler Carruth AM.Scale = Scale; 135664e354dSChandler Carruth return TLI->isLegalAddressingMode(AM, Ty); 136664e354dSChandler Carruth } 137664e354dSChandler Carruth 138664e354dSChandler Carruth bool BasicTTI::isTruncateFree(Type *Ty1, Type *Ty2) const { 139664e354dSChandler Carruth return TLI->isTruncateFree(Ty1, Ty2); 140664e354dSChandler Carruth } 141664e354dSChandler Carruth 142664e354dSChandler Carruth bool BasicTTI::isTypeLegal(Type *Ty) const { 143664e354dSChandler Carruth EVT T = TLI->getValueType(Ty); 144664e354dSChandler Carruth return TLI->isTypeLegal(T); 145664e354dSChandler Carruth } 146664e354dSChandler Carruth 147664e354dSChandler Carruth unsigned BasicTTI::getJumpBufAlignment() const { 148664e354dSChandler Carruth return TLI->getJumpBufAlignment(); 149664e354dSChandler Carruth } 150664e354dSChandler Carruth 151664e354dSChandler Carruth unsigned BasicTTI::getJumpBufSize() const { 152664e354dSChandler Carruth return TLI->getJumpBufSize(); 153664e354dSChandler Carruth } 154664e354dSChandler Carruth 155664e354dSChandler Carruth bool BasicTTI::shouldBuildLookupTables() const { 156664e354dSChandler Carruth return TLI->supportJumpTables() && 157664e354dSChandler Carruth (TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) || 158664e354dSChandler Carruth TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other)); 159664e354dSChandler Carruth } 160664e354dSChandler Carruth 161664e354dSChandler Carruth //===----------------------------------------------------------------------===// 162664e354dSChandler Carruth // 163664e354dSChandler Carruth // Calls used by the vectorizers. 164664e354dSChandler Carruth // 165664e354dSChandler Carruth //===----------------------------------------------------------------------===// 166664e354dSChandler Carruth 167664e354dSChandler Carruth unsigned BasicTTI::getScalarizationOverhead(Type *Ty, bool Insert, 168664e354dSChandler Carruth bool Extract) const { 169664e354dSChandler Carruth assert (Ty->isVectorTy() && "Can only scalarize vectors"); 170664e354dSChandler Carruth unsigned Cost = 0; 171664e354dSChandler Carruth 172664e354dSChandler Carruth for (int i = 0, e = Ty->getVectorNumElements(); i < e; ++i) { 173664e354dSChandler Carruth if (Insert) 174664e354dSChandler Carruth Cost += TopTTI->getVectorInstrCost(Instruction::InsertElement, Ty, i); 175664e354dSChandler Carruth if (Extract) 176664e354dSChandler Carruth Cost += TopTTI->getVectorInstrCost(Instruction::ExtractElement, Ty, i); 177664e354dSChandler Carruth } 178664e354dSChandler Carruth 179664e354dSChandler Carruth return Cost; 180664e354dSChandler Carruth } 181664e354dSChandler Carruth 182664e354dSChandler Carruth unsigned BasicTTI::getNumberOfRegisters(bool Vector) const { 183664e354dSChandler Carruth return 1; 184664e354dSChandler Carruth } 185664e354dSChandler Carruth 186*b696c36fSNadav Rotem unsigned BasicTTI::getMaximumUnrollFactor() const { 187*b696c36fSNadav Rotem return 1; 188*b696c36fSNadav Rotem } 189*b696c36fSNadav Rotem 190664e354dSChandler Carruth unsigned BasicTTI::getArithmeticInstrCost(unsigned Opcode, Type *Ty) const { 191664e354dSChandler Carruth // Check if any of the operands are vector operands. 192664e354dSChandler Carruth int ISD = TLI->InstructionOpcodeToISD(Opcode); 193664e354dSChandler Carruth assert(ISD && "Invalid opcode"); 194664e354dSChandler Carruth 195664e354dSChandler Carruth std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty); 196664e354dSChandler Carruth 197664e354dSChandler Carruth if (TLI->isOperationLegalOrPromote(ISD, LT.second)) { 198664e354dSChandler Carruth // The operation is legal. Assume it costs 1. 199664e354dSChandler Carruth // If the type is split to multiple registers, assume that thre is some 200664e354dSChandler Carruth // overhead to this. 201664e354dSChandler Carruth // TODO: Once we have extract/insert subvector cost we need to use them. 202664e354dSChandler Carruth if (LT.first > 1) 203664e354dSChandler Carruth return LT.first * 2; 204664e354dSChandler Carruth return LT.first * 1; 205664e354dSChandler Carruth } 206664e354dSChandler Carruth 207664e354dSChandler Carruth if (!TLI->isOperationExpand(ISD, LT.second)) { 208664e354dSChandler Carruth // If the operation is custom lowered then assume 209664e354dSChandler Carruth // thare the code is twice as expensive. 210664e354dSChandler Carruth return LT.first * 2; 211664e354dSChandler Carruth } 212664e354dSChandler Carruth 213664e354dSChandler Carruth // Else, assume that we need to scalarize this op. 214664e354dSChandler Carruth if (Ty->isVectorTy()) { 215664e354dSChandler Carruth unsigned Num = Ty->getVectorNumElements(); 216664e354dSChandler Carruth unsigned Cost = TopTTI->getArithmeticInstrCost(Opcode, Ty->getScalarType()); 217664e354dSChandler Carruth // return the cost of multiple scalar invocation plus the cost of inserting 218664e354dSChandler Carruth // and extracting the values. 219664e354dSChandler Carruth return getScalarizationOverhead(Ty, true, true) + Num * Cost; 220664e354dSChandler Carruth } 221664e354dSChandler Carruth 222664e354dSChandler Carruth // We don't know anything about this scalar instruction. 223664e354dSChandler Carruth return 1; 224664e354dSChandler Carruth } 225664e354dSChandler Carruth 226664e354dSChandler Carruth unsigned BasicTTI::getShuffleCost(ShuffleKind Kind, Type *Tp, int Index, 227664e354dSChandler Carruth Type *SubTp) const { 228664e354dSChandler Carruth return 1; 229664e354dSChandler Carruth } 230664e354dSChandler Carruth 231664e354dSChandler Carruth unsigned BasicTTI::getCastInstrCost(unsigned Opcode, Type *Dst, 232664e354dSChandler Carruth Type *Src) const { 233664e354dSChandler Carruth int ISD = TLI->InstructionOpcodeToISD(Opcode); 234664e354dSChandler Carruth assert(ISD && "Invalid opcode"); 235664e354dSChandler Carruth 236664e354dSChandler Carruth std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(Src); 237664e354dSChandler Carruth std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(Dst); 238664e354dSChandler Carruth 239664e354dSChandler Carruth // Handle scalar conversions. 240664e354dSChandler Carruth if (!Src->isVectorTy() && !Dst->isVectorTy()) { 241664e354dSChandler Carruth 242664e354dSChandler Carruth // Scalar bitcasts are usually free. 243664e354dSChandler Carruth if (Opcode == Instruction::BitCast) 244664e354dSChandler Carruth return 0; 245664e354dSChandler Carruth 246664e354dSChandler Carruth if (Opcode == Instruction::Trunc && 247664e354dSChandler Carruth TLI->isTruncateFree(SrcLT.second, DstLT.second)) 248664e354dSChandler Carruth return 0; 249664e354dSChandler Carruth 250664e354dSChandler Carruth if (Opcode == Instruction::ZExt && 251664e354dSChandler Carruth TLI->isZExtFree(SrcLT.second, DstLT.second)) 252664e354dSChandler Carruth return 0; 253664e354dSChandler Carruth 254664e354dSChandler Carruth // Just check the op cost. If the operation is legal then assume it costs 1. 255664e354dSChandler Carruth if (!TLI->isOperationExpand(ISD, DstLT.second)) 256664e354dSChandler Carruth return 1; 257664e354dSChandler Carruth 258664e354dSChandler Carruth // Assume that illegal scalar instruction are expensive. 259664e354dSChandler Carruth return 4; 260664e354dSChandler Carruth } 261664e354dSChandler Carruth 262664e354dSChandler Carruth // Check vector-to-vector casts. 263664e354dSChandler Carruth if (Dst->isVectorTy() && Src->isVectorTy()) { 264664e354dSChandler Carruth 265664e354dSChandler Carruth // If the cast is between same-sized registers, then the check is simple. 266664e354dSChandler Carruth if (SrcLT.first == DstLT.first && 267664e354dSChandler Carruth SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) { 268664e354dSChandler Carruth 269664e354dSChandler Carruth // Bitcast between types that are legalized to the same type are free. 270664e354dSChandler Carruth if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc) 271664e354dSChandler Carruth return 0; 272664e354dSChandler Carruth 273664e354dSChandler Carruth // Assume that Zext is done using AND. 274664e354dSChandler Carruth if (Opcode == Instruction::ZExt) 275664e354dSChandler Carruth return 1; 276664e354dSChandler Carruth 277664e354dSChandler Carruth // Assume that sext is done using SHL and SRA. 278664e354dSChandler Carruth if (Opcode == Instruction::SExt) 279664e354dSChandler Carruth return 2; 280664e354dSChandler Carruth 281664e354dSChandler Carruth // Just check the op cost. If the operation is legal then assume it costs 282664e354dSChandler Carruth // 1 and multiply by the type-legalization overhead. 283664e354dSChandler Carruth if (!TLI->isOperationExpand(ISD, DstLT.second)) 284664e354dSChandler Carruth return SrcLT.first * 1; 285664e354dSChandler Carruth } 286664e354dSChandler Carruth 287664e354dSChandler Carruth // If we are converting vectors and the operation is illegal, or 288664e354dSChandler Carruth // if the vectors are legalized to different types, estimate the 289664e354dSChandler Carruth // scalarization costs. 290664e354dSChandler Carruth unsigned Num = Dst->getVectorNumElements(); 291664e354dSChandler Carruth unsigned Cost = TopTTI->getCastInstrCost(Opcode, Dst->getScalarType(), 292664e354dSChandler Carruth Src->getScalarType()); 293664e354dSChandler Carruth 294664e354dSChandler Carruth // Return the cost of multiple scalar invocation plus the cost of 295664e354dSChandler Carruth // inserting and extracting the values. 296664e354dSChandler Carruth return getScalarizationOverhead(Dst, true, true) + Num * Cost; 297664e354dSChandler Carruth } 298664e354dSChandler Carruth 299664e354dSChandler Carruth // We already handled vector-to-vector and scalar-to-scalar conversions. This 300664e354dSChandler Carruth // is where we handle bitcast between vectors and scalars. We need to assume 301664e354dSChandler Carruth // that the conversion is scalarized in one way or another. 302664e354dSChandler Carruth if (Opcode == Instruction::BitCast) 303664e354dSChandler Carruth // Illegal bitcasts are done by storing and loading from a stack slot. 304664e354dSChandler Carruth return (Src->isVectorTy()? getScalarizationOverhead(Src, false, true):0) + 305664e354dSChandler Carruth (Dst->isVectorTy()? getScalarizationOverhead(Dst, true, false):0); 306664e354dSChandler Carruth 307664e354dSChandler Carruth llvm_unreachable("Unhandled cast"); 308664e354dSChandler Carruth } 309664e354dSChandler Carruth 310664e354dSChandler Carruth unsigned BasicTTI::getCFInstrCost(unsigned Opcode) const { 311664e354dSChandler Carruth // Branches are assumed to be predicted. 312664e354dSChandler Carruth return 0; 313664e354dSChandler Carruth } 314664e354dSChandler Carruth 315664e354dSChandler Carruth unsigned BasicTTI::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, 316664e354dSChandler Carruth Type *CondTy) const { 317664e354dSChandler Carruth int ISD = TLI->InstructionOpcodeToISD(Opcode); 318664e354dSChandler Carruth assert(ISD && "Invalid opcode"); 319664e354dSChandler Carruth 320664e354dSChandler Carruth // Selects on vectors are actually vector selects. 321664e354dSChandler Carruth if (ISD == ISD::SELECT) { 322664e354dSChandler Carruth assert(CondTy && "CondTy must exist"); 323664e354dSChandler Carruth if (CondTy->isVectorTy()) 324664e354dSChandler Carruth ISD = ISD::VSELECT; 325664e354dSChandler Carruth } 326664e354dSChandler Carruth 327664e354dSChandler Carruth std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy); 328664e354dSChandler Carruth 329664e354dSChandler Carruth if (!TLI->isOperationExpand(ISD, LT.second)) { 330664e354dSChandler Carruth // The operation is legal. Assume it costs 1. Multiply 331664e354dSChandler Carruth // by the type-legalization overhead. 332664e354dSChandler Carruth return LT.first * 1; 333664e354dSChandler Carruth } 334664e354dSChandler Carruth 335664e354dSChandler Carruth // Otherwise, assume that the cast is scalarized. 336664e354dSChandler Carruth if (ValTy->isVectorTy()) { 337664e354dSChandler Carruth unsigned Num = ValTy->getVectorNumElements(); 338664e354dSChandler Carruth if (CondTy) 339664e354dSChandler Carruth CondTy = CondTy->getScalarType(); 340664e354dSChandler Carruth unsigned Cost = TopTTI->getCmpSelInstrCost(Opcode, ValTy->getScalarType(), 341664e354dSChandler Carruth CondTy); 342664e354dSChandler Carruth 343664e354dSChandler Carruth // Return the cost of multiple scalar invocation plus the cost of inserting 344664e354dSChandler Carruth // and extracting the values. 345664e354dSChandler Carruth return getScalarizationOverhead(ValTy, true, false) + Num * Cost; 346664e354dSChandler Carruth } 347664e354dSChandler Carruth 348664e354dSChandler Carruth // Unknown scalar opcode. 349664e354dSChandler Carruth return 1; 350664e354dSChandler Carruth } 351664e354dSChandler Carruth 352664e354dSChandler Carruth unsigned BasicTTI::getVectorInstrCost(unsigned Opcode, Type *Val, 353664e354dSChandler Carruth unsigned Index) const { 354664e354dSChandler Carruth return 1; 355664e354dSChandler Carruth } 356664e354dSChandler Carruth 357664e354dSChandler Carruth unsigned BasicTTI::getMemoryOpCost(unsigned Opcode, Type *Src, 358664e354dSChandler Carruth unsigned Alignment, 359664e354dSChandler Carruth unsigned AddressSpace) const { 360664e354dSChandler Carruth assert(!Src->isVoidTy() && "Invalid type"); 361664e354dSChandler Carruth std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Src); 362664e354dSChandler Carruth 363664e354dSChandler Carruth // Assume that all loads of legal types cost 1. 364664e354dSChandler Carruth return LT.first; 365664e354dSChandler Carruth } 366664e354dSChandler Carruth 367664e354dSChandler Carruth unsigned BasicTTI::getIntrinsicInstrCost(Intrinsic::ID, Type *RetTy, 368664e354dSChandler Carruth ArrayRef<Type *> Tys) const { 369664e354dSChandler Carruth // assume that we need to scalarize this intrinsic. 370664e354dSChandler Carruth unsigned ScalarizationCost = 0; 371664e354dSChandler Carruth unsigned ScalarCalls = 1; 372664e354dSChandler Carruth if (RetTy->isVectorTy()) { 373664e354dSChandler Carruth ScalarizationCost = getScalarizationOverhead(RetTy, true, false); 374664e354dSChandler Carruth ScalarCalls = std::max(ScalarCalls, RetTy->getVectorNumElements()); 375664e354dSChandler Carruth } 376664e354dSChandler Carruth for (unsigned i = 0, ie = Tys.size(); i != ie; ++i) { 377664e354dSChandler Carruth if (Tys[i]->isVectorTy()) { 378664e354dSChandler Carruth ScalarizationCost += getScalarizationOverhead(Tys[i], false, true); 379664e354dSChandler Carruth ScalarCalls = std::max(ScalarCalls, RetTy->getVectorNumElements()); 380664e354dSChandler Carruth } 381664e354dSChandler Carruth } 382664e354dSChandler Carruth return ScalarCalls + ScalarizationCost; 383664e354dSChandler Carruth } 384664e354dSChandler Carruth 385664e354dSChandler Carruth unsigned BasicTTI::getNumberOfParts(Type *Tp) const { 386664e354dSChandler Carruth std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp); 387664e354dSChandler Carruth return LT.first; 388664e354dSChandler Carruth } 389