@@ -7014,27 +7014,32 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
70147014
70157015 ElementCount MaxUserVF =
70167016 UserVF.isScalable () ? MaxFactors.ScalableVF : MaxFactors.FixedVF ;
7017- bool UserVFIsLegal = ElementCount::isKnownLE (UserVF, MaxUserVF);
7018- if (!UserVF.isZero () && UserVFIsLegal) {
7019- assert (isPowerOf2_32 (UserVF.getKnownMinValue ()) &&
7020- " VF needs to be a power of two" );
7021- // Collect the instructions (and their associated costs) that will be more
7022- // profitable to scalarize.
7023- CM.collectInLoopReductions ();
7024- if (CM.selectUserVectorizationFactor (UserVF)) {
7025- LLVM_DEBUG (dbgs () << " LV: Using user VF " << UserVF << " .\n " );
7026- buildVPlansWithVPRecipes (UserVF, UserVF);
7027- if (!hasPlanWithVF (UserVF)) {
7028- LLVM_DEBUG (dbgs () << " LV: No VPlan could be built for " << UserVF
7029- << " .\n " );
7030- return std::nullopt ;
7031- }
7017+ if (!UserVF.isZero ()) {
7018+ if (!ElementCount::isKnownLE (UserVF, MaxUserVF)) {
7019+ reportVectorizationInfo (
7020+ " UserVF ignored because it may be larger than the maximal safe VF" ,
7021+ " InvalidUserVF" , ORE, OrigLoop);
7022+ } else {
7023+ assert (isPowerOf2_32 (UserVF.getKnownMinValue ()) &&
7024+ " VF needs to be a power of two" );
7025+ // Collect the instructions (and their associated costs) that will be more
7026+ // profitable to scalarize.
7027+ CM.collectInLoopReductions ();
7028+ if (CM.selectUserVectorizationFactor (UserVF)) {
7029+ LLVM_DEBUG (dbgs () << " LV: Using user VF " << UserVF << " .\n " );
7030+ buildVPlansWithVPRecipes (UserVF, UserVF);
7031+ if (!hasPlanWithVF (UserVF)) {
7032+ LLVM_DEBUG (dbgs ()
7033+ << " LV: No VPlan could be built for " << UserVF << " .\n " );
7034+ return std::nullopt ;
7035+ }
70327036
7033- LLVM_DEBUG (printPlans (dbgs ()));
7034- return {{UserVF, 0 , 0 }};
7035- } else
7036- reportVectorizationInfo (" UserVF ignored because of invalid costs." ,
7037- " InvalidCost" , ORE, OrigLoop);
7037+ LLVM_DEBUG (printPlans (dbgs ()));
7038+ return {{UserVF, 0 , 0 }};
7039+ } else
7040+ reportVectorizationInfo (" UserVF ignored because of invalid costs." ,
7041+ " InvalidCost" , ORE, OrigLoop);
7042+ }
70387043 }
70397044
70407045 // Collect the Vectorization Factor Candidates.
0 commit comments