[PATCH] D48048: [LV] Prevent LV to run cost model twice for VF=2

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 15:16:08 PDT 2018


Ayal added inline comments.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5033
 
   for (unsigned i = 2; i <= MaxVF; i *= 2) {
     // Notice that the vector loop needs to be executed less times, so
----------------
dcaballe wrote:
> Ayal wrote:
> > Could have alternatively started from `unsigned i = 2 * Width`, as the condition above is essentially peeling the first iteration.
> > 
> > Ideally computing `expectedCost(1)` would also be saved in this case.
> Good points!
> 
> > Could have alternatively started from unsigned i = 2 * Width, as the condition above is essentially peeling the first iteration.
> 
> I initially did that but then I had to replicate the LLVM_DEBUG line also in the peeled iteration to be consistent. For that reason I opted for this approach which doesn't need that replication.
> 
> > Ideally computing expectedCost(1) would also be saved in this case.
> 
> Agreed. Unfortunately ScalarCost is necessary below. I also thought that it'd be interesting to have the debug information about the scalar cost for these cases
> 
Having a designated LLVM_DEBUG line explaining that the first VF considered is 2 instead of 1, might be helpful.

If cost is to be computed just for supplying it as debug information, it should appear under LLVM_DEBUG.

Anyway, mtcw, feel free to proceed.


Repository:
  rL LLVM

https://reviews.llvm.org/D48048





More information about the llvm-commits mailing list