Skip to content

Commit 3d941bc

Browse files
committed
[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
1 parent b4419f9 commit 3d941bc

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

llvm/include/llvm/IR/Type.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ class Type {
290290

291291
/// If this is a vector type, return the element type, otherwise return
292292
/// 'this'.
293-
Type *getScalarType() const LLVM_READONLY;
293+
Type *getScalarType() const {
294+
if (isVectorTy())
295+
return getVectorElementType();
296+
return const_cast<Type*>(this);
297+
}
294298

295299
//===--------------------------------------------------------------------===//
296300
// Type Iteration support.

llvm/lib/IR/Type.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
4141
}
4242
}
4343

44-
Type *Type::getScalarType() const {
45-
if (auto *VTy = dyn_cast<VectorType>(this))
46-
return VTy->getElementType();
47-
return const_cast<Type*>(this);
48-
}
49-
5044
bool Type::isIntegerTy(unsigned Bitwidth) const {
5145
return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
5246
}

0 commit comments

Comments
 (0)