[llvm] 941841b - [Vectorize] Update comment of getSubdividedVectorType (#107632)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 13:18:12 PDT 2024


Author: Sterling-Augustine
Date: 2024-09-06T13:18:09-07:00
New Revision: 941841b19d4f8832012f0c6ccd57954917369a3b

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

LOG: [Vectorize] Update comment of getSubdividedVectorType (#107632)

The original comment here is wrong, as demonstrated by the included
test.

Update the comment to reflect what getSubdividedVectorType actually
does.

Added: 
    

Modified: 
    llvm/include/llvm/IR/DerivedTypes.h
    llvm/unittests/IR/VectorTypesTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 0c8cbe1921ac9b..d31654ac131d24 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -492,9 +492,9 @@ class VectorType : public Type {
     return VectorType::get(EltTy, VTy->getElementCount());
   }
 
-  // This static method returns a VectorType with a smaller number of elements
-  // of a larger type than the input element type. For example, a <16 x i8>
-  // subdivided twice would return <4 x i32>
+  // This static method returns a VectorType with a larger number of elements
+  // of a smaller type than the input element type. For example, a <4 x i64>
+  // subdivided twice would return <16 x i16>
   static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs) {
     for (int i = 0; i < NumSubdivs; ++i) {
       VTy = VectorType::getDoubleElementsVectorType(VTy);

diff  --git a/llvm/unittests/IR/VectorTypesTest.cpp b/llvm/unittests/IR/VectorTypesTest.cpp
index c592f809f7bf3e..0b0787a11c418d 100644
--- a/llvm/unittests/IR/VectorTypesTest.cpp
+++ b/llvm/unittests/IR/VectorTypesTest.cpp
@@ -125,6 +125,10 @@ TEST(VectorTypesTest, FixedLength) {
   EltCnt = V8Int64Ty->getElementCount();
   EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
   ASSERT_FALSE(EltCnt.isScalable());
+
+  auto *SubTy = VectorType::getSubdividedVectorType(V4Int64Ty, 2);
+  EXPECT_EQ(SubTy->getElementCount(), ElementCount::getFixed(16));
+  EXPECT_TRUE(SubTy->getElementType()->isIntegerTy(16));
 }
 
 TEST(VectorTypesTest, Scalable) {


        


More information about the llvm-commits mailing list