@@ -231,12 +231,17 @@ static const unsigned MaxPHINumOperands = 128;
231
231
/// avoids spending time checking the cost model and realizing that they will
232
232
/// be inevitably scalarized.
233
233
static bool isValidElementType(Type *Ty) {
234
+ if (RunSLPReVectorization && isa<FixedVectorType>(Ty))
235
+ Ty = Ty->getScalarType();
234
236
return VectorType::isValidElementType(Ty) && !Ty->isX86_FP80Ty() &&
235
237
!Ty->isPPC_FP128Ty();
236
238
}
237
239
238
240
/// \returns the vector type of ScalarTy based on vectorization factor.
239
241
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());
240
245
return FixedVectorType::get(ScalarTy, VF);
241
246
}
242
247
@@ -6783,21 +6788,23 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6783
6788
return;
6784
6789
}
6785
6790
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");
6797
6796
newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx);
6798
6797
return;
6799
6798
}
6800
6799
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
+
6801
6808
// If all of the operands are identical or constant we have a simple solution.
6802
6809
// If we deal with insert/extract instructions, they all must have constant
6803
6810
// indices, otherwise we should gather them, not try to vectorize.
0 commit comments