[PATCH] D93317: [LV] Vectorize (some) early and multiple exit loops

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 10:38:10 PST 2020


reames created this revision.
reames added reviewers: Ayal, fhahn.
Herald added subscribers: dantrushin, javed.absar, bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This patch is a major step towards supporting multiple exit loops in the vectorizer.  This patch on it's own extends the loop forms allowed in two ways:

1. single exit loops which are not bottom tested
2. multiple exit loops w/ a single exit block reached from all exits and no values defined in the loop used outside of it.

The restrictions on multiple exit loop structures will be removed in follow up patches; disallowing cases for now makes the code changes smaller and more obvious.  As before, we can only handle loops with entirely analyzable exits.  Removing that restriction is much harder, and is not part of currently planned efforts.

The basic idea here is that we can force the last iteration to run in the scalar epilogue loop (if we have one).  From the definition of SCEV's backedge taken count, we know that no earlier iteration can exit the vector body.  As such, we can leave the decision on which exit to be taken to the scalar code and generate a bottom tested vector loop which runs all but the last iteration.

The existing code already had the notion of  requiring one iteration in the scalar epilogue, this patch is mainly about generalizing that support slightly, making sure we don't try to use this mechanism when tail folding, and updating the code to reflect the difference between a single exit block and a unique exit block (very mechanical).

Testing wise, I completely rewrote the loop-form.ll test case and will land the tests and then rebase to make the changes more obvious.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93317

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/control-flow.ll
  llvm/test/Transforms/LoopVectorize/loop-form.ll
  llvm/test/Transforms/LoopVectorize/loop-legality-checks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93317.311960.patch
Type: text/x-patch
Size: 24157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/d0d418f4/attachment.bin>


More information about the llvm-commits mailing list