From 3d941bc69675e1cc22289e5ede0f0450d245f2a1 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. llvm-svn: 299811 --- llvm/include/llvm/IR/Type.h | 6 +++++- llvm/lib/IR/Type.cpp | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h index feb6918..e6a0df9 100644 --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/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/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index ca86673..b67b0a30 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/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.7.4