Skip to content

Commit 3cb82f4

Browse files
committed
[SLP]Fix PR99899: Use canonical type instead of original vector of ptr.
Use adjusted canonical integer type instead of the original ptr type to fix the crash in the TTI. Fixes #99899
1 parent 9a8b040 commit 3cb82f4

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9699,7 +9699,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
96999699
CanonicalType = CanonicalType->getWithNewType(IntegerType::get(
97009700
CanonicalType->getContext(),
97019701
DL->getTypeSizeInBits(CanonicalType->getScalarType())));
9702-
IntrinsicCostAttributes CostAttrs(MinMaxID, VecTy, {VecTy, VecTy});
9702+
IntrinsicCostAttributes CostAttrs(MinMaxID, CanonicalType,
9703+
{CanonicalType, CanonicalType});
97039704
InstructionCost IntrinsicCost =
97049705
TTI->getIntrinsicInstrCost(CostAttrs, CostKind);
97059706
// If the selects are the only uses of the compares, they will be
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S --passes=slp-vectorizer -mtriple=s390x-unknown-linux-gnu -mcpu=z16 -slp-threshold=-10 < %s | FileCheck %s
3+
4+
define i1 @test(i64 %0, i64 %1, ptr %2) {
5+
; CHECK-LABEL: define i1 @test(
6+
; CHECK-SAME: i64 [[TMP0:%.*]], i64 [[TMP1:%.*]], ptr [[TMP2:%.*]]) #[[ATTR0:[0-9]+]] {
7+
; CHECK-NEXT: [[ENTRY:.*:]]
8+
; CHECK-NEXT: [[GEP44:%.*]] = getelementptr i8, ptr null, i64 [[TMP0]]
9+
; CHECK-NEXT: [[GEP45:%.*]] = getelementptr i8, ptr null, i64 [[TMP1]]
10+
; CHECK-NEXT: [[GEP48:%.*]] = getelementptr i8, ptr null, i64 [[TMP0]]
11+
; CHECK-NEXT: [[GEP49:%.*]] = getelementptr i8, ptr null, i64 [[TMP1]]
12+
; CHECK-NEXT: [[TMP3:%.*]] = insertelement <2 x ptr> poison, ptr [[GEP44]], i32 0
13+
; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x ptr> [[TMP3]], ptr [[GEP48]], i32 1
14+
; CHECK-NEXT: [[TMP5:%.*]] = insertelement <2 x ptr> poison, ptr [[GEP45]], i32 0
15+
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <2 x ptr> [[TMP5]], ptr [[GEP49]], i32 1
16+
; CHECK-NEXT: [[TMP7:%.*]] = icmp ult <2 x ptr> [[TMP4]], [[TMP6]]
17+
; CHECK-NEXT: [[TMP8:%.*]] = select <2 x i1> [[TMP7]], <2 x ptr> [[TMP4]], <2 x ptr> [[TMP6]]
18+
; CHECK-NEXT: [[TMP9:%.*]] = insertelement <2 x ptr> poison, ptr [[TMP2]], i32 0
19+
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <2 x ptr> [[TMP9]], <2 x ptr> poison, <2 x i32> zeroinitializer
20+
; CHECK-NEXT: [[TMP11:%.*]] = icmp ult <2 x ptr> [[TMP8]], [[TMP10]]
21+
; CHECK-NEXT: [[TMP12:%.*]] = extractelement <2 x i1> [[TMP11]], i32 0
22+
; CHECK-NEXT: [[TMP13:%.*]] = extractelement <2 x i1> [[TMP11]], i32 1
23+
; CHECK-NEXT: [[RES:%.*]] = and i1 [[TMP12]], [[TMP13]]
24+
; CHECK-NEXT: ret i1 [[RES]]
25+
;
26+
entry:
27+
%gep44 = getelementptr i8, ptr null, i64 %0
28+
%gep45 = getelementptr i8, ptr null, i64 %1
29+
%4 = icmp ult ptr %gep44, %gep45
30+
%umin = select i1 %4, ptr %gep44, ptr %gep45
31+
%gep48 = getelementptr i8, ptr null, i64 %0
32+
%gep49 = getelementptr i8, ptr null, i64 %1
33+
%5 = icmp ult ptr %gep48, %gep49
34+
%umin50 = select i1 %5, ptr %gep48, ptr %gep49
35+
%b095 = icmp ult ptr %umin, %2
36+
%b196 = icmp ult ptr %umin50, %2
37+
%res = and i1 %b095, %b196
38+
ret i1 %res
39+
}

0 commit comments

Comments
 (0)