[llvm] r299811 - [IR] Inline Type::getScalarType() by using isVectorTy() and getVectorElementType() that were already available inline.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 7 22:47:09 PDT 2017
Author: ctopper
Date: Sat Apr 8 00:47:09 2017
New Revision: 299811
URL: http://llvm.org/viewvc/llvm-project?rev=299811&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/IR/Type.h
llvm/trunk/lib/IR/Type.cpp
Modified: llvm/trunk/include/llvm/IR/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Type.h?rev=299811&r1=299810&r2=299811&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Type.h (original)
+++ llvm/trunk/include/llvm/IR/Type.h Sat Apr 8 00:47:09 2017
@@ -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.
Modified: llvm/trunk/lib/IR/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=299811&r1=299810&r2=299811&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Type.cpp (original)
+++ llvm/trunk/lib/IR/Type.cpp Sat Apr 8 00:47:09 2017
@@ -41,12 +41,6 @@ Type *Type::getPrimitiveType(LLVMContext
}
}
-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;
}
More information about the llvm-commits
mailing list