Skip to content

Commit 6f9d0b8

Browse files
committed
[SLP][REVEC] NFC. Provide an universal interface for getNumElements.
1 parent 15138b0 commit 6f9d0b8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,19 @@ 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+
assert(!isa<ScalableVectorType>(Ty) &&
244+
"ScalableVectorType is not supported.");
245+
if (auto *VecTy = dyn_cast<FixedVectorType>(Ty))
246+
return VecTy->getNumElements();
247+
return 1;
248+
}
249+
241250
/// \returns the vector type of ScalarTy based on vectorization factor.
242251
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);
252+
return FixedVectorType::get(ScalarTy->getScalarType(),
253+
VF * getNumElements(ScalarTy));
247254
}
248255

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

0 commit comments

Comments
 (0)