From eab73dfed9bc32e9a3c8508c03ae5dfc622534c8 Mon Sep 17 00:00:00 2001 From: Christopher Tetreault Date: Mon, 13 Apr 2020 16:00:10 -0700 Subject: [PATCH] [SVE] Change return type of getNumElements to unsigned Reviewers: efriedma, sdesmalen, craig.topper, dexonsmith Reviewed By: efriedma, sdesmalen Subscribers: tschuett, hiraditya, rkruppe, psnobl, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77763 --- llvm/include/llvm/CodeGen/BasicTTIImpl.h | 11 +++++------ llvm/include/llvm/IR/DerivedTypes.h | 2 +- llvm/lib/IR/Function.cpp | 3 +-- mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h index df4f642..4822abc 100644 --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -1214,8 +1214,8 @@ public: if (RetTy->isVectorTy()) { if (ScalarizationCostPassed == std::numeric_limits::max()) ScalarizationCost = getScalarizationOverhead(RetTy, true, false); - ScalarCalls = std::max( - ScalarCalls, (unsigned)cast(RetTy)->getNumElements()); + ScalarCalls = + std::max(ScalarCalls, cast(RetTy)->getNumElements()); ScalarRetTy = RetTy->getScalarType(); } SmallVector ScalarTys; @@ -1224,8 +1224,8 @@ public: if (Ty->isVectorTy()) { if (ScalarizationCostPassed == std::numeric_limits::max()) ScalarizationCost += getScalarizationOverhead(Ty, false, true); - ScalarCalls = std::max( - ScalarCalls, (unsigned)cast(Ty)->getNumElements()); + ScalarCalls = + std::max(ScalarCalls, cast(Ty)->getNumElements()); Ty = Ty->getScalarType(); } ScalarTys.push_back(Ty); @@ -1572,8 +1572,7 @@ public: if (ScalarizationCostPassed == std::numeric_limits::max()) ScalarizationCost += getScalarizationOverhead(Tys[i], false, true); ScalarCalls = - std::max(ScalarCalls, - (unsigned)cast(Tys[i])->getNumElements()); + std::max(ScalarCalls, cast(Tys[i])->getNumElements()); } } diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h index 1ce5ced..9201744 100644 --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -420,7 +420,7 @@ public: /// For scalable vectors, this will return the minimum number of elements /// in the vector. - uint64_t getNumElements() const { return NumElements; } + unsigned getNumElements() const { return NumElements; } Type *getElementType() const { return ContainedType; } /// This static method is the primary way to construct an VectorType. diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 7791d26..ec390b3 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1075,8 +1075,7 @@ static Type *DecodeFixedType(ArrayRef &Infos, return Tys[D.getOverloadArgNumber()]; case IITDescriptor::ScalableVecArgument: { auto *Ty = cast(DecodeFixedType(Infos, Tys, Context)); - return VectorType::get(Ty->getElementType(), - {(unsigned)Ty->getNumElements(), true}); + return VectorType::get(Ty->getElementType(), {Ty->getNumElements(), true}); } } llvm_unreachable("unhandled"); diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp index acc84f9..abb3fd7 100644 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -1802,10 +1802,10 @@ struct RsqrtOpLowering : public ConvertOpToLLVMPattern { op, operands, typeConverter, [&](LLVM::LLVMType llvmVectorTy, ValueRange operands) { auto splatAttr = SplatElementsAttr::get( - mlir::VectorType::get({(unsigned)cast( - llvmVectorTy.getUnderlyingType()) - ->getNumElements()}, - floatType), + mlir::VectorType::get( + {cast(llvmVectorTy.getUnderlyingType()) + ->getNumElements()}, + floatType), floatOne); auto one = rewriter.create(loc, llvmVectorTy, splatAttr); -- 2.7.4