Skip to content

Commit a52fcc0

Browse files
committed
[SLP][REVEC] Fix getStoreMinimumVF only accept scalar types.
Fix "Element type of a VectorType must " "be an integer, floating point, or " "pointer type.".
1 parent a9094e1 commit a52fcc0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19697,10 +19697,18 @@ bool SLPVectorizerPass::vectorizeStores(
1969719697
Type *ValueTy = StoreTy;
1969819698
if (auto *Trunc = dyn_cast<TruncInst>(Store->getValueOperand()))
1969919699
ValueTy = Trunc->getSrcTy();
19700-
unsigned MinVF = std::max<unsigned>(
19701-
2, PowerOf2Ceil(TTI->getStoreMinimumVF(
19702-
R.getMinVF(DL->getTypeStoreSizeInBits(StoreTy)), StoreTy,
19703-
ValueTy)));
19700+
// When REVEC is enabled, StoreTy and ValueTy may be FixedVectorType. But
19701+
// getStoreMinimumVF only support scalar type as arguments. As a result,
19702+
// we need to use the element type of StoreTy and ValueTy to retrieve the
19703+
// VF and then transform it back.
19704+
// Remember: VF is defined as the number we want to vectorize, not the
19705+
// number of elements in the final vector.
19706+
Type *StoreScalarTy = StoreTy->getScalarType();
19707+
unsigned MinVF = PowerOf2Ceil(TTI->getStoreMinimumVF(
19708+
R.getMinVF(DL->getTypeStoreSizeInBits(StoreScalarTy)), StoreScalarTy,
19709+
ValueTy->getScalarType()));
19710+
MinVF /= getNumElements(StoreTy);
19711+
MinVF = std::max<unsigned>(2, MinVF);
1970419712

1970519713
if (MaxVF < MinVF) {
1970619714
LLVM_DEBUG(dbgs() << "SLP: Vectorization infeasible as MaxVF (" << MaxVF

llvm/test/Transforms/SLPVectorizer/X86/revec-getStoreMinimumVF.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
; RUN: opt -mtriple=x86_64-unknown-linux-gnu -passes=slp-vectorizer -S -slp-revec %s | FileCheck %s
33

44
define void @test() {
5+
; CHECK-LABEL: @test(
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: [[TMP0:%.*]] = call <8 x i8> @llvm.vector.insert.v8i8.v4i8(<8 x i8> poison, <4 x i8> zeroinitializer, i64 0)
8+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i8> @llvm.vector.insert.v8i8.v4i8(<8 x i8> [[TMP0]], <4 x i8> zeroinitializer, i64 4)
9+
; CHECK-NEXT: store <8 x i8> [[TMP1]], ptr null, align 1
10+
; CHECK-NEXT: ret void
11+
;
512
entry:
613
%0 = getelementptr i8, ptr null, i64 4
714
store <4 x i8> zeroinitializer, ptr null, align 1

0 commit comments

Comments
 (0)