Skip to content

Commit 875b551

Browse files
authored
[SLP][REVEC] Make computeMinimumValueSizes and collectValuesToDemote support vector instructions. (#103005)
1 parent 778a1f2 commit 875b551

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15564,7 +15564,8 @@ bool BoUpSLP::collectValuesToDemote(
1556415564
if (all_of(E.Scalars, IsaPred<Constant>))
1556515565
return true;
1556615566

15567-
unsigned OrigBitWidth = DL->getTypeSizeInBits(E.Scalars.front()->getType());
15567+
unsigned OrigBitWidth =
15568+
DL->getTypeSizeInBits(E.Scalars.front()->getType()->getScalarType());
1556815569
if (OrigBitWidth == BitWidth) {
1556915570
MaxDepthLevel = 1;
1557015571
return true;
@@ -15995,7 +15996,8 @@ void BoUpSLP::computeMinimumValueSizes() {
1599515996
}
1599615997

1599715998
unsigned VF = E.getVectorFactor();
15998-
auto *TreeRootIT = dyn_cast<IntegerType>(E.Scalars.front()->getType());
15999+
auto *TreeRootIT =
16000+
dyn_cast<IntegerType>(E.Scalars.front()->getType()->getScalarType());
1599916001
if (!TreeRootIT || !Opcode)
1600016002
return 0u;
1600116003

@@ -16145,7 +16147,8 @@ void BoUpSLP::computeMinimumValueSizes() {
1614516147

1614616148
for (unsigned Idx : RootDemotes) {
1614716149
if (all_of(VectorizableTree[Idx]->Scalars, [&](Value *V) {
16148-
uint32_t OrigBitWidth = DL->getTypeSizeInBits(V->getType());
16150+
uint32_t OrigBitWidth =
16151+
DL->getTypeSizeInBits(V->getType()->getScalarType());
1614916152
if (OrigBitWidth > MaxBitWidth) {
1615016153
APInt Mask = APInt::getBitsSetFrom(OrigBitWidth, MaxBitWidth);
1615116154
return MaskedValueIsZero(V, Mask, SimplifyQuery(*DL));

llvm/test/Transforms/SLPVectorizer/revec.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,19 @@ entry:
222222
%cmp = icmp ugt <4 x i32> %vbsl, <i32 2, i32 3, i32 4, i32 5>
223223
ret <4 x i1> %cmp
224224
}
225+
226+
define void @test7() {
227+
; CHECK-LABEL: @test7(
228+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i64> @llvm.vector.insert.v16i64.v8i64(<16 x i64> poison, <8 x i64> zeroinitializer, i64 0)
229+
; CHECK-NEXT: [[TMP2:%.*]] = call <16 x i64> @llvm.vector.insert.v16i64.v8i64(<16 x i64> [[TMP1]], <8 x i64> zeroinitializer, i64 8)
230+
; CHECK-NEXT: [[TMP3:%.*]] = trunc <16 x i64> [[TMP2]] to <16 x i16>
231+
; CHECK-NEXT: store <16 x i16> [[TMP3]], ptr null, align 2
232+
; CHECK-NEXT: ret void
233+
;
234+
%1 = getelementptr i8, ptr null, i64 16
235+
%2 = trunc <8 x i64> zeroinitializer to <8 x i16>
236+
store <8 x i16> %2, ptr %1, align 2
237+
%3 = trunc <8 x i64> zeroinitializer to <8 x i16>
238+
store <8 x i16> %3, ptr null, align 2
239+
ret void
240+
}

0 commit comments

Comments
 (0)