[SLP]Fix PR79193: skip analysis of gather nodes for minbitwidth.
authorAlexey Bataev <a.bataev@outlook.com>
Tue, 23 Jan 2024 19:34:11 +0000 (11:34 -0800)
committerAlexey Bataev <a.bataev@outlook.com>
Tue, 23 Jan 2024 20:44:49 +0000 (12:44 -0800)
No need in trying to analyze small graphs with gather node only to avoid
crash.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/SystemZ/minbitwidth-non-vector-root.ll [new file with mode: 0644]

index 809d740aae3e0979080729917a04a0685e795b0b..601d2454c1e1635ac652ca404d3163fcb1e1ff70 100644 (file)
@@ -13183,7 +13183,7 @@ void BoUpSLP::computeMinimumValueSizes() {
   // We only attempt to truncate integer expressions.
   auto &TreeRoot = VectorizableTree[0]->Scalars;
   auto *TreeRootIT = dyn_cast<IntegerType>(TreeRoot[0]->getType());
-  if (!TreeRootIT)
+  if (!TreeRootIT || VectorizableTree.front()->State == TreeEntry::NeedToGather)
     return;
 
   // Ensure the roots of the vectorizable tree don't form a cycle.
diff --git a/llvm/test/Transforms/SLPVectorizer/SystemZ/minbitwidth-non-vector-root.ll b/llvm/test/Transforms/SLPVectorizer/SystemZ/minbitwidth-non-vector-root.ll
new file mode 100644 (file)
index 0000000..6524b37
--- /dev/null
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt -passes=slp-vectorizer -S -slp-optimize-identity-hor-reduction-ops=false < %s -mtriple=s390x-ibm-linux -mcpu=arch13 | FileCheck %s
+
+define void @foo() {
+; CHECK-LABEL: define void @foo(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> zeroinitializer)
+; CHECK-NEXT:    store i32 [[TMP1]], ptr null, align 4
+; CHECK-NEXT:    ret void
+;
+  %1 = add i32 0, 0
+  %2 = add i32 %1, 0
+  %3 = add i32 %2, 0
+  store i32 %3, ptr null, align 4
+  ret void
+}