[llvm] ae22e84 - [CodeGen] Fix warnings in isPow2VectorType and getPow2VectorType

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 01:17:33 PDT 2020


Author: David Sherwood
Date: 2020-06-18T09:17:06+01:00
New Revision: ae22e8416347757e91c8bcf9e431a5893dd8d000

URL: https://github.com/llvm/llvm-project/commit/ae22e8416347757e91c8bcf9e431a5893dd8d000
DIFF: https://github.com/llvm/llvm-project/commit/ae22e8416347757e91c8bcf9e431a5893dd8d000.diff

LOG: [CodeGen] Fix warnings in isPow2VectorType and getPow2VectorType

We should either call getVectorMinNumElements() or
getVectorElementCount().

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

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/ValueTypes.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.h b/llvm/include/llvm/CodeGen/ValueTypes.h
index d48a327bd238..db8161caf7d2 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -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;


        


More information about the llvm-commits mailing list