[PATCH] Optimize unrolled reductions in LoopStrengthReduce

hfinkel at anl.gov hfinkel at anl.gov
Tue Feb 3 16:13:29 PST 2015


In http://reviews.llvm.org/D7128#118028, @ohsallen wrote:

> As explained in my last email, the regular loop unroller (LoopUnroll.cpp) does not break dependencies in reduction chains. Only the loop vectorizer/unroller (LoopVectorize.cpp) does. Problem with the latter is that, the code which breaks dependencies and the one which performs unrolling is tightly coupled. So, if the loop was already unrolled by the first unrolling pass, then reductions aren't optimized by the loop vectorizer/unroller.


I don't understand the problem you're trying to highlight. The loop unroller is run in two places within the standard optimization pipeline. The first place is 'early', within the inliner-driven CGSCC pass manager. When run early, it does *full* unrolling only. It is also run 'late', after the loop vectorizer, when it might also do target-directed partial unrolling. But this is after the loop vectorizer runs, so there should be no conflict.

> To reuse the existing code in LoopVectorize.cpp (instead of my patch), we could choose in LoopUnroll.cpp to not unroll loops which contain reductions. Then the vectorizer would see the opportunity to unroll and perform the optimization. There would be a few cosmetic changes to do in the loop vectorizer, which I can detail if you think this is reasonable.


Yes, I think that enhancing the loop vectorizer to do this is reasonable.

> Olivier





http://reviews.llvm.org/D7128

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list