[llvm] [Vectorize] Update comment of getSubdividedVectorType (PR #107632)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 12:25:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: None (Sterling-Augustine)
<details>
<summary>Changes</summary>
The original comment here is wrong, as demonstrated by the included test.
Update the comment to reflect what getSubdividedVectorType actually does.
---
Full diff: https://github.com/llvm/llvm-project/pull/107632.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/DerivedTypes.h (+3-3)
- (modified) llvm/unittests/IR/VectorTypesTest.cpp (+4)
``````````diff
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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/107632
More information about the llvm-commits
mailing list