Skip to content

Commit 31fd6b8

Browse files
committed
[SLP] Protect against scalable vector users.
We started seeing a crash after 8a0bfe4 that the user could be scalable, meaning the typesize is scalable and an implicit convertion to uint64_t could be performed. Protect against that by making sure the users type is not scalable.
1 parent 58187fa commit 31fd6b8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14146,6 +14146,7 @@ bool BoUpSLP::collectValuesToDemote(
1414614146
return getTreeEntry(U) ||
1414714147
(UserIgnoreList && UserIgnoreList->contains(U)) ||
1414814148
(U->getType()->isSized() &&
14149+
!U->getType()->isScalableTy() &&
1414914150
DL->getTypeSizeInBits(U->getType()) <= BitWidth);
1415014151
}) &&
1415114152
!IsPotentiallyTruncated(I, BitWidth))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -passes=slp-vectorizer -S | FileCheck %s
3+
4+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5+
target triple = "aarch64-unknown-linux-gnu"
6+
7+
; Protect against a crash with scalable vector users
8+
9+
define i1 @crash(i32 %a, i32 %b) {
10+
; CHECK-LABEL: @crash(
11+
; CHECK-NEXT: entry:
12+
; CHECK-NEXT: [[CONV_I446:%.*]] = sext i32 [[A:%.*]] to i64
13+
; CHECK-NEXT: [[CMP_I618870_NOT_NOT:%.*]] = icmp ult i64 0, [[CONV_I446]]
14+
; CHECK-NEXT: [[CONV_I401:%.*]] = sext i32 [[B:%.*]] to i64
15+
; CHECK-NEXT: [[CMP_I407876_NOT_NOT:%.*]] = icmp ult i64 0, [[CONV_I401]]
16+
; CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 2 x i1> @llvm.aarch64.sve.whilelo.nxv2i1.i64(i64 0, i64 [[CONV_I401]])
17+
; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP_I618870_NOT_NOT]], i1 [[CMP_I407876_NOT_NOT]], i1 false
18+
; CHECK-NEXT: ret i1 [[R]]
19+
;
20+
entry:
21+
%conv.i446 = sext i32 %a to i64
22+
%cmp.i618870.not.not = icmp ult i64 0, %conv.i446
23+
%conv.i401 = sext i32 %b to i64
24+
%cmp.i407876.not.not = icmp ult i64 0, %conv.i401
25+
%0 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.whilelo.nxv2i1.i64(i64 0, i64 %conv.i401)
26+
%r = select i1 %cmp.i618870.not.not, i1 %cmp.i407876.not.not, i1 0
27+
ret i1 %r
28+
}

0 commit comments

Comments
 (0)