Skip to content

Commit 6016d56

Browse files
committed
[SLP][REVEC] NFC. Provide an universal interface for getNumElements.
1 parent 0b53076 commit 6016d56

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,17 @@ static bool isValidElementType(Type *Ty) {
238238
!Ty->isPPC_FP128Ty();
239239
}
240240

241+
/// \returns the number of elements for Ty.
242+
static unsigned getNumElements(Type *Ty) {
243+
if (auto *VecTy = dyn_cast<FixedVectorType>(Ty))
244+
return VecTy->getNumElements();
245+
return 1;
246+
}
247+
241248
/// \returns the vector type of ScalarTy based on vectorization factor.
242249
static FixedVectorType *getWidenedType(Type *ScalarTy, unsigned VF) {
243-
if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy))
244-
return FixedVectorType::get(VecTy->getElementType(),
245-
VF * VecTy->getNumElements());
246-
return FixedVectorType::get(ScalarTy, VF);
250+
return FixedVectorType::get(ScalarTy->getScalarType(),
251+
VF * getNumElements(ScalarTy));
247252
}
248253

249254
/// \returns True if the value is a constant (but not globals/constant

0 commit comments

Comments
 (0)