Skip to content

Commit

Permalink
[SLP]Fix PR107198: add a check for empty complex type
Browse files Browse the repository at this point in the history
Need to check if the complex type is empty before trying to dig in,
trying to find vectorizable type

Fixes llvm#107198
  • Loading branch information
alexey-bataev committed Sep 4, 2024
1 parent c2b92a4 commit d65ff3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Transforms/SLPVectorizer/empty-struct.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit d65ff3e

Please sign in to comment.