[PATCH] D89566: [LV] Epilogue Vectorization with Optimal Control Flow

Bardia Mahjour via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 10:30:10 PDT 2020


bmahjour created this revision.
bmahjour added reviewers: Ayal, fhahn, dmgreen, SjoerdMeijer, gilr, ashutosh.nema, mivnay, etiotto.
bmahjour added a project: LLVM.
Herald added subscribers: llvm-commits, rogfer01, javed.absar, bollu, hiraditya.
Herald added a reviewer: rengolin.
bmahjour requested review of this revision.
Herald added a subscriber: vkmr.

This is yet another attempt at providing support for epilogue vectorization following discussions raised in RFC http://llvm.1065342.n5.nabble.com/llvm-dev-Proposal-RFC-Epilog-loop-vectorization-tt106322.html#none and reviews https://reviews.llvm.org/D30247 and https://reviews.llvm.org/D88819.

Similar to https://reviews.llvm.org/D88819, this patch achieve epilogue vectorization by executing a single vplan twice: once on the main loop and a second time on the epilogue loop (using a different VF). This implementation differs from D88819 <https://reviews.llvm.org/D88819> at least in the following ways:

1. It's able to generate the most optimal control flow discussed in the above mentioned RFC by shortening the path-length in the case of small trip counts (those that result in all or most of the vector code getting skipped). It also avoids the redundant generation of runtime memory and SCEV checks needed to check for pointer aliasing. Please refer to the attached image illustrating the generated CFG.
2. It uses a more modular approach by using the strategy design pattern <https://en.wikipedia.org/wiki/Strategy_pattern> and extending the `InnerLoopVectorizer` class.
3. It can handle loops with multiple induction variables.
4. It adds more debug traces.

The heuristic for determining when to perform the transform is overly simplistic and needs to be improved in the future. That work is not in the scope of this patch.F13323900: Screen Shot 2020-10-06 at 10.16.04 AM.png <https://reviews.llvm.org/F13323900>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89566

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89566.298651.patch
Type: text/x-patch
Size: 56505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/632322bb/attachment-0001.bin>


More information about the llvm-commits mailing list