[PATCH] D78127: [SVE] Move VectorType::getNumElements() into FixedVectorType

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 16:16:44 PDT 2020


ctetreau updated this revision to Diff 259119.
ctetreau added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78127/new/

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,25 +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 {
-    ElementCount EC = getElementCount();
-#ifdef STRICT_FIXED_SIZE_VECTORS
-    assert(!EC.Scalable &&
-           "Request for fixed number of elements from scalable vector");
-    return EC.Min;
-#else
-    if (EC.Scalable)
-      WithColor::warning()
-          << "The code that requested the fixed number of elements has made "
-             "the assumption that this vector is not scalable. This assumption "
-             "was not correct, and this may lead to broken code\n";
-    return EC.Min;
-#endif
-  }
-
   Type *getElementType() const { return ContainedType; }
 
   /// This static method is the primary way to construct an VectorType.
@@ -513,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);
   }
 
@@ -543,6 +522,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.259119.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/b4b371b3/attachment-0001.bin>


More information about the llvm-commits mailing list