@@ -1011,7 +1011,6 @@ class LoopVectorizationCostModel {
1011
1011
// / \return true if the UserVF is a feasible VF to be chosen.
1012
1012
bool selectUserVectorizationFactor (ElementCount UserVF) {
1013
1013
collectUniformsAndScalars (UserVF);
1014
- collectInstsToScalarize (UserVF);
1015
1014
return expectedCost (UserVF).isValid ();
1016
1015
}
1017
1016
@@ -1281,6 +1280,7 @@ class LoopVectorizationCostModel {
1281
1280
collectLoopUniforms (VF);
1282
1281
setVectorizedCallDecision (VF);
1283
1282
collectLoopScalars (VF);
1283
+ collectInstsToScalarize (VF);
1284
1284
}
1285
1285
1286
1286
// / Returns true if the target machine supports masked store operation
@@ -5393,20 +5393,21 @@ bool LoopVectorizationCostModel::useEmulatedMaskMemRefHack(Instruction *I,
5393
5393
}
5394
5394
5395
5395
void LoopVectorizationCostModel::collectInstsToScalarize (ElementCount VF) {
5396
- // If we aren't vectorizing the loop, or if we've already collected the
5397
- // instructions to scalarize, there's nothing to do. Collection may already
5398
- // have occurred if we have a user-selected VF and are now computing the
5399
- // expected cost for interleaving.
5400
- if (VF.isScalar () || VF.isZero () || InstsToScalarize.contains (VF))
5396
+ assert (VF.isVector () && " Expected VF >= 2" );
5397
+
5398
+ // If we've already collected the instructions to scalarize or the predicated
5399
+ // BBs after vectorization, there's nothing to do. Collection may already have
5400
+ // occurred if we have a user-selected VF and are now computing the expected
5401
+ // cost for interleaving.
5402
+ if (InstsToScalarize.contains (VF) ||
5403
+ PredicatedBBsAfterVectorization.contains (VF))
5401
5404
return ;
5402
5405
5403
5406
// Initialize a mapping for VF in InstsToScalalarize. If we find that it's
5404
5407
// not profitable to scalarize any instructions, the presence of VF in the
5405
5408
// map will indicate that we've analyzed it already.
5406
5409
ScalarCostsTy &ScalarCostsVF = InstsToScalarize[VF];
5407
5410
5408
- PredicatedBBsAfterVectorization[VF].clear ();
5409
-
5410
5411
// Find all the instructions that are scalar with predication in the loop and
5411
5412
// determine if it would be better to not if-convert the blocks they are in.
5412
5413
// If so, we also record the instructions to scalarize.
@@ -7193,16 +7194,10 @@ void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
7193
7194
VFCandidates.push_back (VF);
7194
7195
7195
7196
CM.collectInLoopReductions ();
7196
- for (const auto &VF : VFCandidates) {
7197
+ for (const auto &VF : VFCandidates)
7197
7198
// Collect Uniform and Scalar instructions after vectorization with VF.
7198
7199
CM.collectUniformsAndScalars (VF);
7199
7200
7200
- // Collect the instructions (and their associated costs) that will be more
7201
- // profitable to scalarize.
7202
- if (VF.isVector ())
7203
- CM.collectInstsToScalarize (VF);
7204
- }
7205
-
7206
7201
buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF );
7207
7202
buildVPlansWithVPRecipes (ElementCount::getScalable (1 ), MaxFactors.ScalableVF );
7208
7203
0 commit comments