[PATCH] D30409: [SLP] Fix for PR32038: extra add of PHI node when it is not required.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 08:33:39 PST 2017


ABataev created this revision.

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.


https://reviews.llvm.org/D30409

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30409.89889.patch
Type: text/x-patch
Size: 9352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170227/8dac7663/attachment.bin>


More information about the llvm-commits mailing list