[PATCH] D15250: Detecte vector reduction operations just before instruction selection.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 15:43:14 PST 2015


congh created this revision.
congh added reviewers: hfinkel, spatel, RKSimon, davidxl.
congh added a subscriber: llvm-commits.

This patch detects vector reductions before instruction selection. Vector reductions are vectorized reduction operations, and for such operations we have freedom to reorganize the elements of the result as long as the reduction of them stay unchanged. This will enable some reduction pattern recognition during instruction combine such as SAD/dot-product on X86. A flag is added to SDNodeFlags to mark those vector reduction nodes to be checked during instruction combine.

To detect those vector reductions, we search def-use chains starting from the given instruction, and check if all uses fall into two categories:

1. Reduction with another vector.
2. Reduction on all elements.

in which 2 is detected by recognizing the pattern that the loop vectorizer generates to reduce all elements in the vector outside of the loop, which includes several ShuffleVector and one ExtractElement instructions.

Please checkout http://lists.llvm.org/pipermail/llvm-dev/2015-November/092379.html for discussions on this topic.

http://reviews.llvm.org/D15250

Files:
  include/llvm/CodeGen/SelectionDAGNodes.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/Generic/vector-redux.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15250.41954.patch
Type: text/x-patch
Size: 14638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/f48442e9/attachment.bin>


More information about the llvm-commits mailing list