@@ -2304,6 +2304,34 @@ static VectorType *isVectorPromotionViable(Partition &P, const DataLayout &DL) {
2304
2304
}
2305
2305
}
2306
2306
};
2307
+ auto createAndCheckVectorTypesForPromotion =
2308
+ [&](SetVector<Type *> OtherTys,
2309
+ SmallVector<VectorType *, 4 > CandidateTysCopy) {
2310
+ // Consider additional vector types where the element type size is a
2311
+ // multiple of load/store element size.
2312
+ for (Type *Ty : OtherTys) {
2313
+ if (!VectorType::isValidElementType (Ty))
2314
+ continue ;
2315
+ unsigned TypeSize = DL.getTypeSizeInBits (Ty).getFixedValue ();
2316
+ // Make a copy of CandidateTys and iterate through it, because we
2317
+ // might append to CandidateTys in the loop.
2318
+ for (VectorType *&VTy : CandidateTysCopy) {
2319
+ unsigned VectorSize = DL.getTypeSizeInBits (VTy).getFixedValue ();
2320
+ unsigned ElementSize =
2321
+ DL.getTypeSizeInBits (VTy->getElementType ()).getFixedValue ();
2322
+ if (TypeSize != VectorSize && TypeSize != ElementSize &&
2323
+ VectorSize % TypeSize == 0 ) {
2324
+ VectorType *NewVTy =
2325
+ VectorType::get (Ty, VectorSize / TypeSize, false );
2326
+ CheckCandidateType (NewVTy);
2327
+ }
2328
+ }
2329
+ }
2330
+
2331
+ return checkVectorTypesForPromotion (
2332
+ P, DL, CandidateTys, HaveCommonEltTy, CommonEltTy, HaveVecPtrTy,
2333
+ HaveCommonVecPtrTy, CommonVecPtrTy);
2334
+ };
2307
2335
2308
2336
// Put load and store types into a set for de-duplication.
2309
2337
for (const Slice &S : P) {
@@ -2325,31 +2353,9 @@ static VectorType *isVectorPromotionViable(Partition &P, const DataLayout &DL) {
2325
2353
HaveCommonVecPtrTy, CommonVecPtrTy))
2326
2354
return VTy;
2327
2355
2328
- // Consider additional vector types where the element type size is a
2329
- // multiple of load/store element size.
2330
- for (Type *Ty : LoadStoreTys) {
2331
- if (!VectorType::isValidElementType (Ty))
2332
- continue ;
2333
- unsigned TypeSize = DL.getTypeSizeInBits (Ty).getFixedValue ();
2334
- // Make a copy of CandidateTys and iterate through it, because we might
2335
- // append to CandidateTys in the loop.
2336
- SmallVector<VectorType *, 4 > CandidateTysCopy = CandidateTys;
2337
- CandidateTys.clear ();
2338
- for (VectorType *&VTy : CandidateTysCopy) {
2339
- unsigned VectorSize = DL.getTypeSizeInBits (VTy).getFixedValue ();
2340
- unsigned ElementSize =
2341
- DL.getTypeSizeInBits (VTy->getElementType ()).getFixedValue ();
2342
- if (TypeSize != VectorSize && TypeSize != ElementSize &&
2343
- VectorSize % TypeSize == 0 ) {
2344
- VectorType *NewVTy = VectorType::get (Ty, VectorSize / TypeSize, false );
2345
- CheckCandidateType (NewVTy);
2346
- }
2347
- }
2348
- }
2349
-
2350
- return checkVectorTypesForPromotion (P, DL, CandidateTys, HaveCommonEltTy,
2351
- CommonEltTy, HaveVecPtrTy,
2352
- HaveCommonVecPtrTy, CommonVecPtrTy);
2356
+ SmallVector<VectorType *, 4 > CandidateTysCopy = CandidateTys;
2357
+ CandidateTys.clear ();
2358
+ return createAndCheckVectorTypesForPromotion (LoadStoreTys, CandidateTysCopy);
2353
2359
}
2354
2360
2355
2361
// / Test whether a slice of an alloca is valid for integer widening.
0 commit comments