Skip to content

Commit 9361e8b

Browse files
committed
[SLP][REVEC] Apply RunSLPReVectorization to the existing code.
1 parent 42de8a8 commit 9361e8b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,18 @@ static const unsigned MaxPHINumOperands = 128;
231231
/// avoids spending time checking the cost model and realizing that they will
232232
/// be inevitably scalarized.
233233
static bool isValidElementType(Type *Ty) {
234+
// TODO: Support ScalableVectorType.
235+
if (isa<FixedVectorType>(Ty))
236+
Ty = Ty->getScalarType();
234237
return VectorType::isValidElementType(Ty) && !Ty->isX86_FP80Ty() &&
235238
!Ty->isPPC_FP128Ty();
236239
}
237240

238241
/// \returns the vector type of ScalarTy based on vectorization factor.
239242
static FixedVectorType *getWidenedType(Type *ScalarTy, unsigned VF) {
243+
if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy))
244+
return FixedVectorType::get(VecTy->getElementType(),
245+
VF * VecTy->getNumElements());
240246
return FixedVectorType::get(ScalarTy, VF);
241247
}
242248

@@ -6784,15 +6790,15 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
67846790
}
67856791

67866792
// Don't handle vectors.
6787-
if (S.OpValue->getType()->isVectorTy() &&
6793+
if (!SLPReVec && S.OpValue->getType()->isVectorTy() &&
67886794
!isa<InsertElementInst>(S.OpValue)) {
67896795
LLVM_DEBUG(dbgs() << "SLP: Gathering due to vector type.\n");
67906796
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
67916797
return;
67926798
}
67936799

67946800
if (StoreInst *SI = dyn_cast<StoreInst>(S.OpValue))
6795-
if (SI->getValueOperand()->getType()->isVectorTy()) {
6801+
if (!SLPReVec && SI->getValueOperand()->getType()->isVectorTy()) {
67966802
LLVM_DEBUG(dbgs() << "SLP: Gathering due to store vector type.\n");
67976803
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
67986804
return;

0 commit comments

Comments
 (0)