Index: llvm/include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- llvm/include/llvm/Analysis/TargetTransformInfo.h +++ llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -1381,7 +1381,6 @@ virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0; virtual unsigned getGISelRematGlobalCost() const = 0; virtual bool hasActiveVectorLength() const = 0; - virtual int getInstructionLatency(const Instruction *I) = 0; }; template @@ -1859,10 +1858,6 @@ bool hasActiveVectorLength() const override { return Impl.hasActiveVectorLength(); } - - int getInstructionLatency(const Instruction *I) override { - return Impl.getInstructionLatency(I); - } }; template Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -863,38 +863,6 @@ // By default, just classify everything as 'basic'. return TTI::TCC_Basic; } - - int getInstructionLatency(const Instruction *I) { - SmallVector Operands(I->value_op_begin(), - I->value_op_end()); - if (getUserCost(I, Operands) == TTI::TCC_Free) - return 0; - - if (isa(I)) - return 4; - - Type *DstTy = I->getType(); - - // Usually an intrinsic is a simple instruction. - // A real function call is much slower. - if (auto *CI = dyn_cast(I)) { - const Function *F = CI->getCalledFunction(); - if (!F || static_cast(this)->isLoweredToCall(F)) - return 40; - // Some intrinsics return a value and a flag, we use the value type - // to decide its latency. - if (StructType *StructTy = dyn_cast(DstTy)) - DstTy = StructTy->getElementType(0); - // Fall through to simple instructions. - } - - if (VectorType *VectorTy = dyn_cast(DstTy)) - DstTy = VectorTy->getElementType(); - if (DstTy->isFloatingPointTy()) - return 3; - - return 1; - } }; } // namespace llvm Index: llvm/include/llvm/CodeGen/BasicTTIImpl.h =================================================================== --- llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -492,13 +492,6 @@ return BaseT::preferPredicateOverEpilogue(L, LI, SE, AC, TLI, DT, LAI); } - int getInstructionLatency(const Instruction *I) { - if (isa(I)) - return getST()->getSchedModel().DefaultLoadLatency; - - return BaseT::getInstructionLatency(I); - } - virtual Optional getCacheSize(TargetTransformInfo::CacheLevel Level) const { return Optional( Index: llvm/lib/Analysis/TargetTransformInfo.cpp =================================================================== --- llvm/lib/Analysis/TargetTransformInfo.cpp +++ llvm/lib/Analysis/TargetTransformInfo.cpp @@ -849,10 +849,6 @@ return TTIImpl->getGISelRematGlobalCost(); } -int TargetTransformInfo::getInstructionLatency(const Instruction *I) const { - return TTIImpl->getInstructionLatency(I); -} - static bool matchPairwiseShuffleMask(ShuffleVectorInst *SI, bool IsLeft, unsigned Level) { // We don't need a shuffle if we just want to have element 0 in position 0 of @@ -1149,6 +1145,38 @@ return RD->Kind; } +int TargetTransformInfo::getInstructionLatency(const Instruction *I) const { + SmallVector Operands(I->value_op_begin(), + I->value_op_end()); + if (getUserCost(I, Operands) == TargetTransformInfo::TCC_Free) + return 0; + + if (isa(I)) + return 4; + + Type *DstTy = I->getType(); + + // Usually an intrinsic is a simple instruction. + // A real function call is much slower. + if (auto *CI = dyn_cast(I)) { + const Function *F = CI->getCalledFunction(); + if (!F || TTIImpl->isLoweredToCall(F)) + return 40; + // Some intrinsics return a value and a flag, we use the value type + // to decide its latency. + if (StructType *StructTy = dyn_cast(DstTy)) + DstTy = StructTy->getElementType(0); + // Fall through to simple instructions. + } + + if (VectorType *VectorTy = dyn_cast(DstTy)) + DstTy = VectorTy->getElementType(); + if (DstTy->isFloatingPointTy()) + return 3; + + return 1; +} + int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const { switch (I->getOpcode()) { case Instruction::GetElementPtr: