[llvm] [Vectorize] Update comment of getSubdividedVectorType (PR #107632)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 13:14:33 PDT 2024
https://github.com/Sterling-Augustine updated https://github.com/llvm/llvm-project/pull/107632
>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 1/2] [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) {
>From 99963fecb6caf083d07fa10334773413ed0fc260 Mon Sep 17 00:00:00 2001
From: Sterling Augustine <saugustine at google.com>
Date: Fri, 6 Sep 2024 13:13:41 -0700
Subject: [PATCH 2/2] Update test and example with more common sizes.
---
llvm/include/llvm/IR/DerivedTypes.h | 4 ++--
llvm/unittests/IR/VectorTypesTest.cpp | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 7bc42ca0192e74..d31654ac131d24 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -493,8 +493,8 @@ class VectorType : public Type {
}
// 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>
+ // 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 9749a039fd203e..0b0787a11c418d 100644
--- a/llvm/unittests/IR/VectorTypesTest.cpp
+++ b/llvm/unittests/IR/VectorTypesTest.cpp
@@ -126,9 +126,9 @@ TEST(VectorTypesTest, FixedLength) {
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));
+ 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