diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -1207,7 +1207,7 @@ return TargetTransformInfo::TCC_Basic; if (ICA.isTypeBasedOnly()) - return getTypeBasedIntrinsicInstrCost(ICA, CostKind); + return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue(); Type *RetTy = ICA.getReturnType(); @@ -1294,13 +1294,13 @@ case Intrinsic::vector_reduce_umax: case Intrinsic::vector_reduce_umin: { IntrinsicCostAttributes Attrs(IID, RetTy, Args[0]->getType(), FMF, I, 1); - return getTypeBasedIntrinsicInstrCost(Attrs, CostKind); + return *getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue(); } case Intrinsic::vector_reduce_fadd: case Intrinsic::vector_reduce_fmul: { IntrinsicCostAttributes Attrs( IID, RetTy, {Args[0]->getType(), Args[1]->getType()}, FMF, I, 1); - return getTypeBasedIntrinsicInstrCost(Attrs, CostKind); + return *getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue(); } case Intrinsic::fshl: case Intrinsic::fshr: { @@ -1365,15 +1365,16 @@ IntrinsicCostAttributes Attrs(IID, RetTy, ICA.getArgTypes(), FMF, I, ScalarizationCost); - return thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind); + return *thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue(); } /// Get intrinsic cost based on argument types. /// If ScalarizationCostPassed is std::numeric_limits::max(), the /// cost of scalarizing the arguments and the return value will be computed /// based on types. - unsigned getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, - TTI::TargetCostKind CostKind) { + InstructionCost + getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, + TTI::TargetCostKind CostKind) { Intrinsic::ID IID = ICA.getID(); Type *RetTy = ICA.getReturnType(); const SmallVectorImpl &Tys = ICA.getArgTypes(); @@ -1399,7 +1400,7 @@ switch (IID) { default: { // Assume that we need to scalarize this intrinsic. - unsigned ScalarizationCost = ScalarizationCostPassed; + InstructionCost ScalarizationCost = ScalarizationCostPassed; unsigned ScalarCalls = 1; Type *ScalarRetTy = RetTy; if (auto *RetVTy = dyn_cast(RetTy)) { @@ -1425,7 +1426,7 @@ return 1; // Return cost of a scalar intrinsic. Assume it to be cheap. IntrinsicCostAttributes ScalarAttrs(IID, ScalarRetTy, ScalarTys, FMF); - unsigned ScalarCost = + InstructionCost ScalarCost = thisT()->getIntrinsicInstrCost(ScalarAttrs, CostKind); return ScalarCalls * ScalarCost + ScalarizationCost; @@ -1605,7 +1606,7 @@ // SatMax -> Overflow && SumDiff < 0 // SatMin -> Overflow && SumDiff >= 0 - unsigned Cost = 0; + InstructionCost Cost = 0; IntrinsicCostAttributes Attrs(OverflowOp, OpTy, {RetTy, RetTy}, FMF, nullptr, ScalarizationCostPassed); Cost += thisT()->getIntrinsicInstrCost(Attrs, CostKind); @@ -1626,7 +1627,7 @@ ? Intrinsic::uadd_with_overflow : Intrinsic::usub_with_overflow; - unsigned Cost = 0; + InstructionCost Cost = 0; IntrinsicCostAttributes Attrs(OverflowOp, OpTy, {RetTy, RetTy}, FMF, nullptr, ScalarizationCostPassed); Cost += thisT()->getIntrinsicInstrCost(Attrs, CostKind); @@ -1644,7 +1645,7 @@ IID == Intrinsic::smul_fix ? Instruction::SExt : Instruction::ZExt; TTI::CastContextHint CCH = TTI::CastContextHint::None; - unsigned Cost = 0; + InstructionCost Cost = 0; Cost += 2 * thisT()->getCastInstrCost(ExtOp, ExtTy, RetTy, CCH, CostKind); Cost += thisT()->getArithmeticInstrCost(Instruction::Mul, ExtTy, CostKind); @@ -1713,7 +1714,7 @@ IID == Intrinsic::smul_fix ? Instruction::SExt : Instruction::ZExt; TTI::CastContextHint CCH = TTI::CastContextHint::None; - unsigned Cost = 0; + InstructionCost Cost = 0; Cost += 2 * thisT()->getCastInstrCost(ExtOp, ExtTy, MulTy, CCH, CostKind); Cost += thisT()->getArithmeticInstrCost(Instruction::Mul, ExtTy, CostKind); @@ -1821,7 +1822,8 @@ ScalarTys.push_back(Ty); } IntrinsicCostAttributes Attrs(IID, RetTy->getScalarType(), ScalarTys, FMF); - unsigned ScalarCost = thisT()->getIntrinsicInstrCost(Attrs, CostKind); + InstructionCost ScalarCost = + thisT()->getIntrinsicInstrCost(Attrs, CostKind); for (unsigned i = 0, ie = Tys.size(); i != ie; ++i) { if (auto *VTy = dyn_cast(Tys[i])) { if (!ICA.skipScalarizationCost()) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp @@ -743,7 +743,7 @@ // TODO: Combine these two logic paths. if (ICA.isTypeBasedOnly()) - return getTypeBasedIntrinsicInstrCost(ICA, CostKind); + return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue(); unsigned RetVF = (RetTy->isVectorTy() ? cast(RetTy)->getNumElements() diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h --- a/llvm/lib/Target/X86/X86TargetTransformInfo.h +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h @@ -167,8 +167,9 @@ unsigned getAtomicMemIntrinsicMaxElementSize() const; - int getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, - TTI::TargetCostKind CostKind); + InstructionCost + getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, + TTI::TargetCostKind CostKind); int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind); diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -2284,8 +2284,9 @@ unsigned X86TTIImpl::getAtomicMemIntrinsicMaxElementSize() const { return 16; } -int X86TTIImpl::getTypeBasedIntrinsicInstrCost( - const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) { +InstructionCost +X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, + TTI::TargetCostKind CostKind) { // Costs should match the codegen from: // BITREVERSE: llvm\test\CodeGen\X86\vector-bitreverse.ll @@ -2914,7 +2915,7 @@ int X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) { if (ICA.isTypeBasedOnly()) - return getTypeBasedIntrinsicInstrCost(ICA, CostKind); + return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue(); static const CostTblEntry AVX512CostTbl[] = { { ISD::ROTL, MVT::v8i64, 1 },