A recent commit (https://reviews.llvm.org/rG66c120f02560ef528a60924104ead66f330190f1) changed the cost for calls to functions that have a vector version for some vectorization factor. However, no check is performed for whether the vectorization factor matches the current one being cost modeled. This leads to attempts to widen call instructions to a vectorization factor for which such a function does not exist, which in turn leads to an assertion failure.
This patch adds the check for vectorization factor (i.e. not just that the called function has a vector version for some VF, but that it has a vector version for this VF).
I think that what you have implemented here is doing something very similar to what is already implemented the API provided by the VFShape class and the VFDatabase.
You could first build the VFShape you expect to have for VF and CI by invoking the get method at https://github.com/llvm/llvm-project/blob/f37e899fd73d1a8958246d761eeb306a8846e81a/llvm/include/llvm/Analysis/VectorUtils.h#L103:
This will create the "shape" that the vector version of the vector call associated with CI will have when trying to vectorize with a vectorization factor of VF.
Then, you can check whether that specific shape for VF is available by querying the VFDatabase with it (see https://github.com/llvm/llvm-project/blob/f37e899fd73d1a8958246d761eeb306a8846e81a/llvm/include/llvm/Analysis/VectorUtils.h#L242):
This call will return a nullptr if there is no vector function that realizes vectorization with VF lanes.