-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[LV] Fix crash when vectorizing function calls with linear args. #76274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-transforms Author: Alexandros Lamprineas (labrinea) Changesllvm/lib/IR/Type.cpp:694: Happens with function calls of void return type. Full diff: https://github.com/llvm/llvm-project/pull/76274.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 02e400d590bed4..1ca9556adad6ac 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -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) &&
+ VectorIntrinsicID != Intrinsic::not_intrinsic) {
TysForDecl.push_back(
VectorType::get(CI.getType()->getScalarType(), State.VF));
}
diff --git a/llvm/test/Transforms/LoopVectorize/vector-call-linear-args.ll b/llvm/test/Transforms/LoopVectorize/vector-call-linear-args.ll
new file mode 100644
index 00000000000000..e84326d5d402aa
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/vector-call-linear-args.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "call.*foo" --version 4
+; RUN: opt -passes=loop-vectorize,simplifycfg -force-vector-interleave=1 -force-vector-width=2 -S < %s | FileCheck %s
+
+; Make sure the vectorizer does not crash.
+
+define void @test_foo(ptr noalias %in, ptr noalias %out) {
+; CHECK-LABEL: define void @test_foo(
+; CHECK-SAME: ptr noalias [[IN:%.*]], ptr noalias [[OUT:%.*]]) {
+; CHECK: call void @vec_foo(<2 x i64> [[WIDE_LOAD:%.*]], ptr [[TMP4:%.*]])
+;
+entry:
+ br label %for.body
+
+for.body:
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %gep.in = getelementptr i64, ptr %in, i64 %indvars.iv
+ %num = load i64, ptr %gep.in, align 8
+ %gep.out = getelementptr i64, ptr %out, i64 %indvars.iv
+ call void @foo(i64 %num, ptr %gep.out) #0
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond = icmp eq i64 %indvars.iv.next, 1000
+ br i1 %exitcond, label %for.cond.cleanup, label %for.body
+
+for.cond.cleanup:
+ ret void
+}
+
+declare void @foo(i64, ptr)
+declare void @vec_foo(<2 x i64>, ptr)
+
+attributes #0 = { "vector-function-abi-variant"="_ZGV_LLVM_N2vl8_foo(vec_foo)" }
|
d919a65 to
6866bae
Compare
6866bae to
bb95433
Compare
mgabka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the changes, LGTM.
llvm/lib/IR/Type.cpp:694:
Assertion `isValidElementType(ElementType) && "Element type of a
VectorType must be an integer, floating point, or pointer type."'
failed.
Stack dump:
llvm::FixedVectorType::get(llvm::Type*, unsigned int)
llvm::VPWidenCallRecipe::execute(llvm::VPTransformState&)
llvm::VPBasicBlock::execute(llvm::VPTransformState*)
llvm::VPRegionBlock::execute(llvm::VPTransformState*)
llvm::VPlan::execute(llvm::VPTransformState*)
...
Happens with function calls of void return type.
bb95433 to
0625674
Compare
llvm/lib/IR/Type.cpp:694:
Assertion `isValidElementType(ElementType) && "Element type of a
VectorType must be an integer, floating point, or pointer type."'
failed.
Stack dump:
llvm::FixedVectorType::get(llvm::Type*, unsigned int)
llvm::VPWidenCallRecipe::execute(llvm::VPTransformState&)
llvm::VPBasicBlock::execute(llvm::VPTransformState*)
llvm::VPRegionBlock::execute(llvm::VPTransformState*)
llvm::VPlan::execute(llvm::VPTransformState*)
...
Happens with function calls of void return type.