[PATCH] D31841: [IR] Implement DataLayout::getPointerTypeSizeInBits using getPointerSizeInBits directly
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 11:06:58 PDT 2017
craig.topper created this revision.
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.
https://reviews.llvm.org/D31841
Files:
lib/IR/DataLayout.cpp
Index: lib/IR/DataLayout.cpp
===================================================================
--- lib/IR/DataLayout.cpp
+++ lib/IR/DataLayout.cpp
@@ -600,11 +600,8 @@
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());
}
/*!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31841.94588.patch
Type: text/x-patch
Size: 580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170410/8dda7c8a/attachment.bin>
More information about the llvm-commits
mailing list