[llvm] [SVE] Don't require lookup when demangling vector function mappings (PR #72260)
Maciej Gabka via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 09:57:01 PST 2023
================
@@ -273,49 +275,88 @@ ParseRet tryParseAlign(StringRef &ParseString, Align &Alignment) {
return ParseRet::None;
}
-#ifndef NDEBUG
-// Verify the assumtion that all vectors in the signature of a vector
-// function have the same number of elements.
-bool verifyAllVectorsHaveSameWidth(FunctionType *Signature) {
- SmallVector<VectorType *, 2> VecTys;
- if (auto *RetTy = dyn_cast<VectorType>(Signature->getReturnType()))
- VecTys.push_back(RetTy);
- for (auto *Ty : Signature->params())
- if (auto *VTy = dyn_cast<VectorType>(Ty))
- VecTys.push_back(VTy);
-
- if (VecTys.size() <= 1)
- return true;
-
- assert(VecTys.size() > 1 && "Invalid number of elements.");
- const ElementCount EC = VecTys[0]->getElementCount();
- return llvm::all_of(llvm::drop_begin(VecTys), [&EC](VectorType *VTy) {
- return (EC == VTy->getElementCount());
- });
+// Given a type, return the size in bits if it is a supported element type
+// for vectorized function calls, or nullopt if not.
+std::optional<unsigned> getSizeFromScalarType(Type *Ty) {
+ // The scalar function should only take scalar arguments.
+ if (!Ty->isIntegerTy() && !Ty->isFloatingPointTy() && !Ty->isPointerTy())
----------------
mgabka wrote:
could be also worth to check here if Ty is not null, unless the idea is that for nullptr it returns std:nullopt (what I guess is what you are relying on when checking the return type later), then would be good to mention it directly in the comment above.
https://github.com/llvm/llvm-project/pull/72260
More information about the llvm-commits
mailing list