[llvm] [LV] Fix crash when vectorizing function calls with linear args. (PR #76274)

Maciej Gabka via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 27 06:02:15 PST 2023


================
@@ -504,7 +504,8 @@ void VPWidenCallRecipe::execute(VPTransformState &State) {
   for (unsigned Part = 0; Part < State.UF; ++Part) {
     SmallVector<Type *, 2> TysForDecl;
     // Add return type if intrinsic is overloaded on it.
-    if (isVectorIntrinsicWithOverloadTypeAtArg(VectorIntrinsicID, -1)) {
+    if (isVectorIntrinsicWithOverloadTypeAtArg(VectorIntrinsicID, -1) &&
----------------
mgabka wrote:

from what I can see the problem started being visible when we allowed to vectorise calls which do not return a value.
>From what I can see the VPWidenCallRecipe contains both:

- VectorIntrinsicID (if the vector variant of intrinsics should be used)
- Variant (if the vector function call should be used)

When the Variant should be used the the VectorIntrinsicId  is set to not_intrinsic https://github.com/llvm/llvm-project/blob/38c9390b59c4d2b9181614d6a909887497d3692f/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L8387

so I think you fix is  correct, however I think it would be good o add an extra assert inside "isVectorIntrinsicWithOverloadTypeAtArg" as it blindly returns true for non intrnisics when the passed Idx is -1


If that assert will be triggered then I think it means that uses of this function aren't correct.

https://github.com/llvm/llvm-project/pull/76274


More information about the llvm-commits mailing list