[IR] Implement DataLayout::getPointerTypeSizeInBits using getPointerSizeInBits directly

Currently we use getTypeSizeInBits which contains a switch statement to dispatch based on what the Type is. We know we always have a pointer type here, but the compiler isn't able to figure out that out to remove the switch.

This patch changes it to just call handle the pointer type directly by calling getPointerSizeInBits without going through a switch.

getPointerTypeSizeInBits is called pretty often, particularly by getOrEnforceKnownAlignment which is used by InstCombine. This should speed that up a little bit.

Differential Revision: https://reviews.llvm.org/D31841

llvm-svn: 300475
This commit is contained in:
Craig Topper 2017-04-17 18:22:36 +00:00
parent 46e36f0953
commit 5b4f5b0887
1 changed files with 2 additions and 5 deletions

View File

@ -608,11 +608,8 @@ unsigned DataLayout::getPointerSize(unsigned AS) const {
unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
assert(Ty->isPtrOrPtrVectorTy() &&
"This should only be called with a pointer or pointer vector type");
if (Ty->isPointerTy())
return getTypeSizeInBits(Ty);
return getTypeSizeInBits(Ty->getScalarType());
Ty = Ty->getScalarType();
return getPointerSizeInBits(cast<PointerType>(Ty)->getAddressSpace());
}
/*!