[PATCH] D72324: [LV] Still vectorise when tail-folding can't find a primary inducation variable

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 05:14:03 PST 2020


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: hsaito, fhahn, samparker, dmgreen, dorit.
Herald added subscribers: rkruppe, hiraditya.
Herald added a project: LLVM.

This addresses a vectorisation regression for tail-folded loops that are counting down, e.g. loops as simple as this:

  void foo(char *A, char *B, char *C, uint32_t N) {
    while (N > 0) {
      *C++ = *A++ + *B++;
       N--;
    }
  }
    

These are loops that can be vectorised, but when tail-folding is requested, it can't find a primary induction variable which we do need for predicating the loop. As a result, the loop isn't vectorised at all, which it is able to do when tail-folding is not attempted. So, this adds a check for the primary induction variable where we decide how to lower the scalar epilogue.  I.e., when there isn't a primary induction variable, a scalar epilogue loop is allowed (i.e. don't request tail-folding) so that vectorisation could still be triggered.

      

Having this check for the primary induction variable make sense anyway, and in addition, in a follow-up of this I will look into discovering earlier the primary induction variable for counting down loops, so that this can also be tail-folded.


https://reviews.llvm.org/D72324

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/ARM/tail-folding-counting-down.ll
  llvm/test/Transforms/LoopVectorize/tail-folding-counting-down.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72324.236555.patch
Type: text/x-patch
Size: 7788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200107/c529deff/attachment.bin>


More information about the llvm-commits mailing list