[SVE][LoopVectorize] Add support for scalable vectorization of first-order recurrences
authorKerry McLaughlin <kerry.mclaughlin@arm.com>
Thu, 6 May 2021 09:50:51 +0000 (10:50 +0100)
committerKerry McLaughlin <kerry.mclaughlin@arm.com>
Thu, 6 May 2021 10:35:39 +0000 (11:35 +0100)
commit8c9742bd239af602ee2743baa3c4281f24d45df1
tree47cf09ab387dae235e4bf3b124b273b5f8a1586f
parentcdf33962d9768fbd8d6b193aff463a21eaa984f3
[SVE][LoopVectorize] Add support for scalable vectorization of first-order recurrences

Adds support for scalable vectorization of loops containing first-order recurrences, e.g:
```
for(int i = 0; i < n; i++)
  b[i] =  a[i] + a[i - 1]
```
This patch changes fixFirstOrderRecurrence for scalable vectors to take vscale into
account when inserting into and extracting from the last lane of a vector.
CreateVectorSplice has been added to construct a vector for the recurrence, which
returns a splice intrinsic for scalable types. For fixed-width the behaviour
remains unchanged as CreateVectorSplice will return a shufflevector instead.

The tests included here are the same as test/Transform/LoopVectorize/first-order-recurrence.ll

Reviewed By: david-arm, fhahn

Differential Revision: https://reviews.llvm.org/D101076
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/IRBuilder.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll [new file with mode: 0644]