[IR] Inline Type::getScalarType() by using isVectorTy() and getVectorElementType...
authorCraig Topper <craig.topper@gmail.com>
Sat, 8 Apr 2017 05:47:09 +0000 (05:47 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 8 Apr 2017 05:47:09 +0000 (05:47 +0000)
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
llvm/lib/IR/Type.cpp

index feb6918..e6a0df9 100644 (file)
@@ -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<Type*>(this);
+  }
 
   //===--------------------------------------------------------------------===//
   // Type Iteration support.
index ca86673..b67b0a3 100644 (file)
@@ -41,12 +41,6 @@ Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
   }
 }
 
-Type *Type::getScalarType() const {
-  if (auto *VTy = dyn_cast<VectorType>(this))
-    return VTy->getElementType();
-  return const_cast<Type*>(this);
-}
-
 bool Type::isIntegerTy(unsigned Bitwidth) const {
   return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
 }