diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -709,7 +709,7 @@ bool isTypeLegal(Type *Ty) const; /// Returns the estimated number of registers required to represent \p Ty. - unsigned getRegUsageForType(Type *Ty) const; + InstructionCost getRegUsageForType(Type *Ty) const; /// Return true if switches should be turned into lookup tables for the /// target. @@ -1528,7 +1528,7 @@ virtual bool isProfitableToHoist(Instruction *I) = 0; virtual bool useAA() = 0; virtual bool isTypeLegal(Type *Ty) = 0; - virtual unsigned getRegUsageForType(Type *Ty) = 0; + virtual InstructionCost getRegUsageForType(Type *Ty) = 0; virtual bool shouldBuildLookupTables() = 0; virtual bool shouldBuildLookupTablesForConstant(Constant *C) = 0; virtual bool shouldBuildRelLookupTables() = 0; @@ -1921,7 +1921,7 @@ } bool useAA() override { return Impl.useAA(); } bool isTypeLegal(Type *Ty) override { return Impl.isTypeLegal(Ty); } - unsigned getRegUsageForType(Type *Ty) override { + InstructionCost getRegUsageForType(Type *Ty) override { return Impl.getRegUsageForType(Ty); } bool shouldBuildLookupTables() override { diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -291,7 +291,7 @@ bool isTypeLegal(Type *Ty) const { return false; } - unsigned getRegUsageForType(Type *Ty) const { return 1; } + InstructionCost getRegUsageForType(Type *Ty) const { return 1; } bool shouldBuildLookupTables() const { return true; } 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 @@ -356,9 +356,8 @@ return getTLI()->isTypeLegal(VT); } - unsigned getRegUsageForType(Type *Ty) { - InstructionCost::CostType Val = - *getTLI()->getTypeLegalizationCost(DL, Ty).first.getValue(); + InstructionCost getRegUsageForType(Type *Ty) { + InstructionCost Val = getTLI()->getTypeLegalizationCost(DL, Ty).first; assert(Val >= 0 && "Negative cost!"); return Val; } diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -449,7 +449,7 @@ return TTIImpl->isTypeLegal(Ty); } -unsigned TargetTransformInfo::getRegUsageForType(Type *Ty) const { +InstructionCost TargetTransformInfo::getRegUsageForType(Type *Ty) const { return TTIImpl->getRegUsageForType(Ty); } diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -6568,8 +6568,8 @@ const auto &TTICapture = TTI; auto GetRegUsage = [&TTICapture](Type *Ty, ElementCount VF) { if (Ty->isTokenTy() || !VectorType::isValidElementType(Ty)) - return 0U; - return TTICapture.getRegUsageForType(VectorType::get(Ty, VF)); + return 0; + return *TTICapture.getRegUsageForType(VectorType::get(Ty, VF)).getValue(); }; for (unsigned int i = 0, s = IdxToInstr.size(); i < s; ++i) {