@@ -979,8 +979,7 @@ class LoopVectorizationCostModel {
979
979
// / Setup cost-based decisions for user vectorization factor.
980
980
// / \return true if the UserVF is a feasible VF to be chosen.
981
981
bool selectUserVectorizationFactor (ElementCount UserVF) {
982
- collectUniformsAndScalars (UserVF);
983
- collectInstsToScalarize (UserVF);
982
+ collectNonVectorizedAndSetWideningDecisions (UserVF);
984
983
return expectedCost (UserVF).isValid ();
985
984
}
986
985
@@ -1236,20 +1235,22 @@ class LoopVectorizationCostModel {
1236
1235
// / the loop.
1237
1236
void collectInstsToScalarize (ElementCount VF);
1238
1237
1239
- // / Collect Uniform and Scalar values for the given \p VF.
1238
+ // / Collect values that will not be widened, including Uniforms, Scalars, and
1239
+ // / Instructions to Scalarize for the given \p VF.
1240
1240
// / The sets depend on CM decision for Load/Store instructions
1241
1241
// / that may be vectorized as interleave, gather-scatter or scalarized.
1242
1242
// / Also make a decision on what to do about call instructions in the loop
1243
1243
// / at that VF -- scalarize, call a known vector routine, or call a
1244
1244
// / vector intrinsic.
1245
- void collectUniformsAndScalars (ElementCount VF) {
1245
+ void collectNonVectorizedAndSetWideningDecisions (ElementCount VF) {
1246
1246
// Do the analysis once.
1247
1247
if (VF.isScalar () || Uniforms.contains (VF))
1248
1248
return ;
1249
1249
setCostBasedWideningDecision (VF);
1250
1250
collectLoopUniforms (VF);
1251
1251
setVectorizedCallDecision (VF);
1252
1252
collectLoopScalars (VF);
1253
+ collectInstsToScalarize (VF);
1253
1254
}
1254
1255
1255
1256
// / Returns true if the target machine supports masked store operation
@@ -5285,7 +5286,7 @@ LoopVectorizationCostModel::calculateRegisterUsage(ArrayRef<ElementCount> VFs) {
5285
5286
RegUsage[ClassID] += 1 ;
5286
5287
}
5287
5288
} else {
5288
- collectUniformsAndScalars (VFs[J]);
5289
+ collectNonVectorizedAndSetWideningDecisions (VFs[J]);
5289
5290
for (auto *Inst : OpenIntervals) {
5290
5291
// Skip ignored values for VF > 1.
5291
5292
if (VecValuesToIgnore.count (Inst))
@@ -5382,20 +5383,21 @@ bool LoopVectorizationCostModel::useEmulatedMaskMemRefHack(Instruction *I,
5382
5383
}
5383
5384
5384
5385
void LoopVectorizationCostModel::collectInstsToScalarize (ElementCount VF) {
5385
- // If we aren't vectorizing the loop, or if we've already collected the
5386
- // instructions to scalarize, there's nothing to do. Collection may already
5387
- // have occurred if we have a user-selected VF and are now computing the
5388
- // expected cost for interleaving.
5389
- if (VF.isScalar () || VF.isZero () || InstsToScalarize.contains (VF))
5386
+ assert (VF.isVector () && " Expected VF >= 2" );
5387
+
5388
+ // If we've already collected the instructions to scalarize or the predicated
5389
+ // BBs after vectorization, there's nothing to do. Collection may already have
5390
+ // occurred if we have a user-selected VF and are now computing the expected
5391
+ // cost for interleaving.
5392
+ if (InstsToScalarize.contains (VF) ||
5393
+ PredicatedBBsAfterVectorization.contains (VF))
5390
5394
return ;
5391
5395
5392
5396
// Initialize a mapping for VF in InstsToScalalarize. If we find that it's
5393
5397
// not profitable to scalarize any instructions, the presence of VF in the
5394
5398
// map will indicate that we've analyzed it already.
5395
5399
ScalarCostsTy &ScalarCostsVF = InstsToScalarize[VF];
5396
5400
5397
- PredicatedBBsAfterVectorization[VF].clear ();
5398
-
5399
5401
// Find all the instructions that are scalar with predication in the loop and
5400
5402
// determine if it would be better to not if-convert the blocks they are in.
5401
5403
// If so, we also record the instructions to scalarize.
@@ -7187,12 +7189,7 @@ void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
7187
7189
CM.collectInLoopReductions ();
7188
7190
for (const auto &VF : VFCandidates) {
7189
7191
// Collect Uniform and Scalar instructions after vectorization with VF.
7190
- CM.collectUniformsAndScalars (VF);
7191
-
7192
- // Collect the instructions (and their associated costs) that will be more
7193
- // profitable to scalarize.
7194
- if (VF.isVector ())
7195
- CM.collectInstsToScalarize (VF);
7192
+ CM.collectNonVectorizedAndSetWideningDecisions (VF);
7196
7193
}
7197
7194
7198
7195
buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF );
0 commit comments