[llvm] [Vectorize] Update comment of getSubdividedVectorType (PR #107632)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 12:24:51 PDT 2024


https://github.com/Sterling-Augustine created https://github.com/llvm/llvm-project/pull/107632

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

Update the comment to reflect what getSubdividedVectorType actually does.

>From 57162c92913edc36310ba889664196ae8f483488 Mon Sep 17 00:00:00 2001
From: Sterling Augustine <saugustine at google.com>
Date: Fri, 6 Sep 2024 12:18:56 -0700
Subject: [PATCH] [Vectorize] Update

---
 llvm/include/llvm/IR/DerivedTypes.h   | 6 +++---
 llvm/unittests/IR/VectorTypesTest.cpp | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 0c8cbe1921ac9b..7bc42ca0192e74 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 <16 x i8>
+  // subdivided twice would return <64 x i2>
   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..9749a039fd203e 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(V16Int8Ty, 2);
+  EXPECT_EQ(SubTy->getElementCount(), ElementCount::getFixed(64));
+  EXPECT_TRUE(SubTy->getElementType()->isIntegerTy(2));
 }
 
 TEST(VectorTypesTest, Scalable) {



More information about the llvm-commits mailing list