]> granicus.if.org Git - llvm/commit
[SLP] Fix for PR32038: extra add of PHI node when it is not required.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 1 Mar 2017 10:50:44 +0000 (10:50 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 1 Mar 2017 10:50:44 +0000 (10:50 +0000)
commit145ace26f579aec16cb58068732c7664695664ee
tree66fbad7b8ad0533d262110405f397ed82440eb36
parent5abd133c8d6f336bab40c8c25545398167680c6c
[SLP] Fix for PR32038: extra add of PHI node when it is not required.

Summary:
If horizontal reduction tree starts from the binary operation that is
used in PHI node, but this PHI is not used in horizontal reduction, we
may end up with extra addition of this PHI node after vectorization.
Here is an example:
```
%phi = phi i32 [ %tmp, %end], ...
...
%tmp = add i32 %tmp1, %tmp2
end:
```
after vectorization we always have something like:

```
%phi = phi i32 [ %tmp, %end], ...
...
%red = extractelement <8 x 32> %vec.red, 0
%tmp = add i32 %red, %phi
end:
```
even if `%phi` is not used in reduction tree. Patch considers these PHI
nodes as extra arguments and considers them in the final result iff they
really used in reduction.

Reviewers: mkuper, hfinkel, mzolotukhin

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296606 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/AArch64/gather-root.ll
test/Transforms/SLPVectorizer/X86/reduction_loads.ll
test/Transforms/SLPVectorizer/X86/scheduling.ll