[PATCH] D78127: [SVE] Move VectorType::getNumElements() into FixedVectorType
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 10:11:05 PDT 2020
ctetreau created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
ctetreau added a parent revision: D77587: [SVE] Add new VectorType subclasses.
Move getNumElements() into FixedVectorType in order to eliminate the
class of bugs where a scalable vector is accidentally treated like a
fixed length vector.
See: http://lists.llvm.org/pipermail/llvm-dev/2020-March/139811.html
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78127
Files:
llvm/include/llvm/IR/DerivedTypes.h
Index: llvm/include/llvm/IR/DerivedTypes.h
===================================================================
--- llvm/include/llvm/IR/DerivedTypes.h
+++ llvm/include/llvm/IR/DerivedTypes.h
@@ -414,11 +414,6 @@
VectorType(const VectorType &) = delete;
VectorType &operator=(const VectorType &) = delete;
- /// Get the number of elements in this vector. It does not make sense to call
- /// this function on a scalable vector, and this will be moved into
- /// FixedVectorType in a future commit
- unsigned getNumElements() const { return EC.Min; }
-
Type *getElementType() const { return ContainedType; }
/// This static method is the primary way to construct an VectorType.
@@ -499,8 +494,6 @@
/// input type and the same element type.
static VectorType *getDoubleElementsVectorType(VectorType *VTy) {
auto EltCnt = VTy->getElementCount();
- assert((VTy->getNumElements() * 2ull) <= UINT_MAX &&
- "Too many elements in vector");
return VectorType::get(VTy->getElementType(), EltCnt*2);
}
@@ -510,8 +503,6 @@
/// Return an ElementCount instance to represent the (possibly scalable)
/// number of elements in the vector.
ElementCount getElementCount() const {
- uint64_t MinimumEltCnt = getNumElements();
- assert(MinimumEltCnt <= UINT_MAX && "Too many elements in vector");
return EC;
}
@@ -533,6 +524,9 @@
public:
static FixedVectorType *get(Type *ElementType, unsigned NumElts);
+ /// Get the number of elements in this vector.
+ unsigned getNumElements() const { return getElementCount().Min; }
+
static bool classof(const Type *T) {
return T->getTypeID() == FixedVectorTyID;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78127.257393.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/8805e248/attachment.bin>
More information about the llvm-commits
mailing list