[llvm] d65ff3e - [SLP]Fix PR107198: add a check for empty complex type
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 05:29:46 PDT 2024
Author: Alexey Bataev
Date: 2024-09-04T05:13:43-07:00
New Revision: d65ff3e9364536f9e0bd5f1c1bace626c256a2ad
URL: https://github.com/llvm/llvm-project/commit/d65ff3e9364536f9e0bd5f1c1bace626c256a2ad
DIFF: https://github.com/llvm/llvm-project/commit/d65ff3e9364536f9e0bd5f1c1bace626c256a2ad.diff
LOG: [SLP]Fix PR107198: add a check for empty complex type
Need to check if the complex type is empty before trying to dig in,
trying to find vectorizable type
Fixes https://github.com/llvm/llvm-project/issues/107198
Added:
llvm/test/Transforms/SLPVectorizer/empty-struct.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 19b95cf473e914..a2af7f4e1b01c3 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7780,6 +7780,8 @@ unsigned BoUpSLP::canMapToVector(Type *T) const {
Type *EltTy = T;
while (isa<StructType, ArrayType, FixedVectorType>(EltTy)) {
+ if (EltTy->isEmptyTy())
+ return 0;
if (auto *ST = dyn_cast<StructType>(EltTy)) {
// Check that struct is homogeneous.
for (const auto *Ty : ST->elements())
diff --git a/llvm/test/Transforms/SLPVectorizer/empty-struct.ll b/llvm/test/Transforms/SLPVectorizer/empty-struct.ll
new file mode 100644
index 00000000000000..422d6b2eb3276b
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/empty-struct.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S --passes=slp-vectorizer < %s | FileCheck %s
+
+define { { {}, {}, {}, {}, {}, {}, {} } } @test({ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0) {
+; CHECK-LABEL: define { { {}, {}, {}, {}, {}, {}, {} } } @test(
+; CHECK-SAME: { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } [[TMP0:%.*]]) {
+; CHECK-NEXT: [[TMP2:%.*]] = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } [[TMP0]], 18
+; CHECK-NEXT: [[TMP3:%.*]] = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } [[TMP2]], 0
+; CHECK-NEXT: ret { { {}, {}, {}, {}, {}, {}, {} } } [[TMP3]]
+;
+ %2 = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0, 18
+ %3 = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } %2, 0
+ ret { { {}, {}, {}, {}, {}, {}, {} } } %3
+}
More information about the llvm-commits
mailing list