]> granicus.if.org Git - llvm/commit
[LV] Avoid vectorizing first order recurrence when phi uses are outside loop
authorAnna Thomas <anna@azul.com>
Tue, 11 Apr 2017 21:02:00 +0000 (21:02 +0000)
committerAnna Thomas <anna@azul.com>
Tue, 11 Apr 2017 21:02:00 +0000 (21:02 +0000)
commit3d57035bd97a794234c14fba744883a5867b25cc
tree7a39244442cf99b857fe8d2d68bd7aa71151b5dd
parent530eee5579305366d2db0299089e9efd4edf1955
[LV] Avoid vectorizing first order recurrence when phi uses are outside loop

In the vectorization of first order recurrence, we vectorize such
that the last element in the vector will be the one extracted to pass into the
scalar remainder loop. However, this is not true when there is a phi (other
than the primary induction variable) is used outside the loop.
In such a case, we need the value from the second last iteration (i.e.
the phi value), not the last iteration (which would be the phi update).
I've added a test case for this. Also see PR32396.

A follow up patch would generate the correct code gen for such cases,
and turn this vectorization on.

Differential Revision: https://reviews.llvm.org/D31910

Reviewers: mssimpso

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299985 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/LoopUtils.cpp
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/AArch64/loop-vectorization-factors.ll
test/Transforms/LoopVectorize/first-order-recurrence.ll