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

Diego Caballero via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 15:36:13 PDT 2018


dcaballe 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
----------------
Ayal wrote:
> 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.
Thanks, Ayal.

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

Not only for debug. Look at line 5059. Not sure if it would be executed when vectorization is forced, though, but I'd prefer not to change the behavior w.r.t the scalar cost in this patch.

I'll proceed then.


Repository:
  rL LLVM

https://reviews.llvm.org/D48048





More information about the llvm-commits mailing list