[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
Wed Jun 13 13:50:29 PDT 2018


dcaballe added a comment.

Thanks for the comments, Ayal! Please, let me know if you have any other concerns.



================
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:
> 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



Repository:
  rL LLVM

https://reviews.llvm.org/D48048





More information about the llvm-commits mailing list