From 0a13ad663759daca3a16a556a8e7e61d9ea31710 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 8 Apr 2017 05:47:09 +0000 Subject: [PATCH] [IR] Inline Type::getScalarType() by using isVectorTy() and getVectorElementType() that were already available inline. Seems to have very little compiled code size impact. But might give a tiny performance boost. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299811 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Type.h | 6 +++++- lib/IR/Type.cpp | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index feb69187158..e6a0df937e9 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -290,7 +290,11 @@ public: /// If this is a vector type, return the element type, otherwise return /// 'this'. - Type *getScalarType() const LLVM_READONLY; + Type *getScalarType() const { + if (isVectorTy()) + return getVectorElementType(); + return const_cast(this); + } //===--------------------------------------------------------------------===// // Type Iteration support. diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index ca866738f88..b67b0a30786 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -41,12 +41,6 @@ Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) { } } -Type *Type::getScalarType() const { - if (auto *VTy = dyn_cast(this)) - return VTy->getElementType(); - return const_cast(this); -} - bool Type::isIntegerTy(unsigned Bitwidth) const { return isIntegerTy() && cast(this)->getBitWidth() == Bitwidth; } -- 2.40.0