[llvm] a3508e0 - [SLP]Small buidlvector only graph should contains scalars from same block
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 10:50:04 PDT 2024
Author: Alexey Bataev
Date: 2024-10-23T10:46:38-07:00
New Revision: a3508e0246741851f06cb9ba86203be8d89febed
URL: https://github.com/llvm/llvm-project/commit/a3508e0246741851f06cb9ba86203be8d89febed
DIFF: https://github.com/llvm/llvm-project/commit/a3508e0246741851f06cb9ba86203be8d89febed.diff
LOG: [SLP]Small buidlvector only graph should contains scalars from same block
If the graph is small and has single buildvector node, all scalars
instructions must be from the same basic block to prevent compiler
crash.
Fixes #113451
Added:
llvm/test/Transforms/SLPVectorizer/X86/small-graph-diff-block-instructions.ll
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 756b25ac985612..d824c40c401df7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11588,7 +11588,8 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
if (VectorizableTree.back()->isGather() &&
VectorizableTree.back()->isAltShuffle() &&
- VectorizableTree.back()->getVectorFactor() > 2)
+ VectorizableTree.back()->getVectorFactor() > 2 &&
+ allSameBlock(VectorizableTree.back()->Scalars))
return false;
assert(VectorizableTree.empty()
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/small-graph-
diff -block-instructions.ll b/llvm/test/Transforms/SLPVectorizer/X86/small-graph-
diff -block-instructions.ll
new file mode 100644
index 00000000000000..82c8b1d707cf4f
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/small-graph-
diff -block-instructions.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512dq -slp-threshold=-99999 < %s | FileCheck %s
+
+define i32 @test(i32 %arg, i32 %arg1) {
+; CHECK-LABEL: define i32 @test(
+; CHECK-SAME: i32 [[ARG:%.*]], i32 [[ARG1:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: [[BB:.*:]]
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[ARG1]] to i64
+; CHECK-NEXT: [[ZEXT2:%.*]] = zext i32 [[ARG]] to i64
+; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[ARG]] to i64
+; CHECK-NEXT: br label %[[BB3:.*]]
+; CHECK: [[BB3]]:
+; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr i64, ptr addrspace(1) null, i64 [[ZEXT]]
+; CHECK-NEXT: [[GETELEMENTPTR4:%.*]] = getelementptr i64, ptr addrspace(1) null, i64 [[ZEXT2]]
+; CHECK-NEXT: [[GETELEMENTPTR5:%.*]] = getelementptr i64, ptr addrspace(1) null, i64 [[SEXT]]
+; CHECK-NEXT: [[ZEXT6:%.*]] = zext i32 0 to i64
+; CHECK-NEXT: [[GETELEMENTPTR7:%.*]] = getelementptr i64, ptr addrspace(1) null, i64 [[ZEXT6]]
+; CHECK-NEXT: ret i32 0
+;
+bb:
+ %zext = zext i32 %arg1 to i64
+ %zext2 = zext i32 %arg to i64
+ %sext = sext i32 %arg to i64
+ br label %bb3
+
+bb3:
+ %getelementptr = getelementptr i64, ptr addrspace(1) null, i64 %zext
+ %getelementptr4 = getelementptr i64, ptr addrspace(1) null, i64 %zext2
+ %getelementptr5 = getelementptr i64, ptr addrspace(1) null, i64 %sext
+ %zext6 = zext i32 0 to i64
+ %getelementptr7 = getelementptr i64, ptr addrspace(1) null, i64 %zext6
+ ret i32 0
+}
More information about the llvm-commits
mailing list