[PATCH] D47477: [VPlan] Avoid building VPlans for each VF in the ILV (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 29 12:45:54 PDT 2018


fhahn added a comment.

Thanks Diego!



================
Comment at: lib/Transforms/Vectorize/LoopVectorizationPlanner.h:352
+  /// Legal. This method is only used for the legacy inner loop vectorizer.
+  VPlanPtr buildVPRecipes(VFRange &Range);
 };
----------------
dcaballe wrote:
> I really like this change! This is decoupling the VPlan construction with VPInstructions from the legacy VPlan construction using recipes. I understand that you will refactor even more the code in `buildVPRecipes` to implement the temporary VPInstruction-to-VPRecipe step in the native path.
> 
> Maybe we should name this buildVPlanWithRecipes or something like that to clearly state that it's creating a new VPlan?
Yep there is some more refactoring I plan on doing. Ideally I think we should try to move as much of the VPlan related implementation out of LoopVectorize.cpp


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:6342
 
-  buildVPlans(1, MaxVF);
+  VFRange R = {BestVF.Width, BestVF.Width + 1};
+  VPlans.push_back(buildVPRecipes(R));
----------------
dcaballe wrote:
> Why `BestVF.Width + 1`? Shouldn't be `BestVF.Width`?
yep, buildVPRecipes does not really need a range , so this could be simplified.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:6347
   // Select the optimal vectorization factor.
-  return CM.selectVectorizationFactor(MaxVF);
+  return BestVF;
 }
----------------
dcaballe wrote:
> The rationale of building VPlans for all the VFs and then invoke CM to choose the best VF (without using those VPlans) was to eventually port CM to work on these VPlans. This hasn't happened yet but @hsaito is working on this VPlan based version of the CM. We think that this step is very important in the converge of both vectorization paths since it will allow us to move the VPlan construction in the inner loop path to earlier stages of the path.
> 
> Since this is a small change, my suggestion would be: 1) if this change is needed by your subsequent patches, let's go with it. Hideki could move the VPlan construction again after CM when his code is ready; 2) otherwise, let's keep the original version. Please, note that we are mostly sharing a single VPlan for all the VFs so we shouldn't be using unnecessary memory most of the times.
> 
> WDYT?
> 
I understand, but do you think we will be able to replace the legacy cost model anytime soon? I expect implementing VPlan based inner loop vectorization that does not introduce regressions over the legacy cost model will be a big task. I thought the plan was to develop this cost model in the VPlan native path (with support for inner loops). That will allow us to get an initial cost model in and iterate on that, until we match the performance of the legacy one. At that point, we can retire the legacy inner loop vectorizer.  What do you think?


https://reviews.llvm.org/D47477





More information about the llvm-commits mailing list