Skip to content

Commit 403bd58

Browse files
committed
[SLP]Fix a crash on scalarized vectors.
Need to register in-vector for scalarized types to avoid crash in further analysis.
1 parent 0a0181d commit 403bd58

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6934,8 +6934,10 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
69346934
auto *VecTy = FixedVectorType::get(VL.front()->getType(), VL.size());
69356935
// If the resulting type is scalarized, do not adjust the cost.
69366936
unsigned VecNumParts = TTI.getNumberOfParts(VecTy);
6937-
if (VecNumParts == VecTy->getNumElements())
6937+
if (VecNumParts == VecTy->getNumElements()) {
6938+
InVectors.assign(1, Constant::getNullValue(VecTy));
69386939
return nullptr;
6940+
}
69396941
DenseMap<Value *, int> ExtractVectorsTys;
69406942
SmallPtrSet<Value *, 4> CheckedExtracts;
69416943
for (auto [I, V] : enumerate(VL)) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2+
; RUN: opt -S -passes=slp-vectorizer -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
3+
4+
define i1 @test() {
5+
; CHECK-LABEL: define i1 @test() {
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: [[TMP0:%.*]] = freeze <4 x i1> zeroinitializer
8+
; CHECK-NEXT: [[TMP1:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP0]])
9+
; CHECK-NEXT: ret i1 [[TMP1]]
10+
;
11+
entry:
12+
%0 = extractelement <4 x fp128> zeroinitializer, i32 0
13+
%cmp = fcmp ogt fp128 %0, 0xL00000000000000000000000000000000
14+
%cmp3 = fcmp olt fp128 %0, 0xL00000000000000000000000000000000
15+
%or.cond = and i1 %cmp, %cmp3
16+
%1 = extractelement <4 x fp128> zeroinitializer, i32 0
17+
%cmp6 = fcmp ogt fp128 %1, 0xL00000000000000000000000000000000
18+
%or.cond29 = select i1 %or.cond, i1 %cmp6, i1 false
19+
%cmp10 = fcmp olt fp128 %1, 0xL00000000000000000000000000000000
20+
%or.cond30 = select i1 %or.cond29, i1 %cmp10, i1 false
21+
ret i1 %or.cond30
22+
}

0 commit comments

Comments
 (0)