Skip to content

Commit f3164a7

Browse files
committed
[SLP][REVEC] Apply RunSLPReVectorization to the existing code.
1 parent 48ca8bf commit f3164a7

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,17 @@ 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+
if (RunSLPReVectorization && isa<FixedVectorType>(Ty))
235+
Ty = Ty->getScalarType();
234236
return VectorType::isValidElementType(Ty) && !Ty->isX86_FP80Ty() &&
235237
!Ty->isPPC_FP128Ty();
236238
}
237239

238240
/// \returns the vector type of ScalarTy based on vectorization factor.
239241
static FixedVectorType *getWidenedType(Type *ScalarTy, unsigned VF) {
242+
if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy))
243+
return FixedVectorType::get(VecTy->getElementType(),
244+
VF * VecTy->getNumElements());
240245
return FixedVectorType::get(ScalarTy, VF);
241246
}
242247

@@ -6783,21 +6788,23 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
67836788
return;
67846789
}
67856790

6786-
// Don't handle vectors.
6787-
if (S.OpValue->getType()->isVectorTy() &&
6788-
!isa<InsertElementInst>(S.OpValue)) {
6789-
LLVM_DEBUG(dbgs() << "SLP: Gathering due to vector type.\n");
6790-
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
6791-
return;
6792-
}
6793-
6794-
if (StoreInst *SI = dyn_cast<StoreInst>(S.OpValue))
6795-
if (SI->getValueOperand()->getType()->isVectorTy()) {
6796-
LLVM_DEBUG(dbgs() << "SLP: Gathering due to store vector type.\n");
6791+
if (!RunSLPReVectorization) {
6792+
// Don't handle vectors.
6793+
if (S.OpValue->getType()->isVectorTy() &&
6794+
!isa<InsertElementInst>(S.OpValue)) {
6795+
LLVM_DEBUG(dbgs() << "SLP: Gathering due to vector type.\n");
67976796
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
67986797
return;
67996798
}
68006799

6800+
if (StoreInst *SI = dyn_cast<StoreInst>(S.OpValue))
6801+
if (SI->getValueOperand()->getType()->isVectorTy()) {
6802+
LLVM_DEBUG(dbgs() << "SLP: Gathering due to store vector type.\n");
6803+
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
6804+
return;
6805+
}
6806+
}
6807+
68016808
// If all of the operands are identical or constant we have a simple solution.
68026809
// If we deal with insert/extract instructions, they all must have constant
68036810
// indices, otherwise we should gather them, not try to vectorize.

0 commit comments

Comments
 (0)