[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).
Francesco Petrogalli via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 07:17:01 PDT 2020
fpetrogalli added inline comments.
================
Comment at: llvm/include/llvm/Analysis/TargetLibraryInfo.h:91
Accelerate, // Use Accelerate framework.
+ LIBMVEC, // GLIBC Vector Math library.
MASSV, // IBM MASS vector library.
----------------
nemanjai wrote:
> fpetrogalli wrote:
> > Can we call this LIBMVEC-X86? Libmvec itself is supposed to support other architectures, I can see list of mappings for each of the supported targets.
> >
> > Then, the logic of selecting the correct one in the frontent clang would depend on the value of `-fvec-lib=libmvec` plus the value of `-target`.
> So if I follow correctly, we can choose the various vendor-specific libraries as well as `libmvec` which itself has target-specific ports.
>
> Would it make sense to just add an overload of `addVectorizableFunctions()` that would consider the `Triple` and remove any entries from `VectorDescs` that the target doesn't support? Or even more specifically, simply add the `Triple` argument to `addVectorizableFunctionsFromVecLib()` and call something like `removeLIBMVECEntriesForTarget(const Triple &T)` that would do the job.
>
> And of course, if the triple isn't provided and the user is targeting an architecture that doesn't provide some entry, that is just user error.
The overload of the `addVectorizableFunctions()` might be feasible, but for the sake of simplicity I think that having `LIBMVEC_<TARGET>` in `enum VectorLibrary` for each of the <TARGET> to support would avoid having to deal with overload of methods. Given that these lists are static, I'd rather see them explicitly instead of having them filled up by add/remove methods.
All in all, I think it is easier to add the logic for the target triple in clang as it is just a matter of modifying the changes in `BackendUtils.cpp` (warning, pseudocode ahead):
```
case CodeGenOptions::LIBMVEC:
switch(Triple) {
case X:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::LIBMVEC_X);
break
case Y:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::LIBMVEC_Y);
break;
case ...
}
break;
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88154/new/
https://reviews.llvm.org/D88154
More information about the cfe-commits
mailing list