[CodeGen] Fix warnings in isPow2VectorType and getPow2VectorType
authorDavid Sherwood <david.sherwood@arm.com>
Tue, 16 Jun 2020 16:00:12 +0000 (17:00 +0100)
committerDavid Sherwood <david.sherwood@arm.com>
Thu, 18 Jun 2020 08:17:06 +0000 (09:17 +0100)
We should either call getVectorMinNumElements() or
getVectorElementCount().

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

llvm/include/llvm/CodeGen/ValueTypes.h

index d48a327..db8161c 100644 (file)
@@ -389,7 +389,7 @@ namespace llvm {
 
     /// Returns true if the given vector is a power of 2.
     bool isPow2VectorType() const {
-      unsigned NElts = getVectorNumElements();
+      unsigned NElts = getVectorMinNumElements();
       return !(NElts & (NElts - 1));
     }
 
@@ -397,10 +397,9 @@ namespace llvm {
     /// and returns that type.
     EVT getPow2VectorType(LLVMContext &Context) const {
       if (!isPow2VectorType()) {
-        unsigned NElts = getVectorNumElements();
-        unsigned Pow2NElts = 1 <<  Log2_32_Ceil(NElts);
-        return EVT::getVectorVT(Context, getVectorElementType(), Pow2NElts,
-                                isScalableVector());
+        ElementCount NElts = getVectorElementCount();
+        NElts.Min = 1 << Log2_32_Ceil(NElts.Min);
+        return EVT::getVectorVT(Context, getVectorElementType(), NElts);
       }
       else {
         return *this;