]> granicus.if.org Git - llvm/commit
[SDAG][AArch64] Legalize VECREDUCE
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 11 Mar 2019 20:22:13 +0000 (20:22 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 11 Mar 2019 20:22:13 +0000 (20:22 +0000)
commit802a6632d562c7a45cfd89e0f625ccf77496a25a
tree864835c8b8312cab674f820db2318db93bf1e771
parentb3804eeeac66cfda3de465c7d4612bd51e6f072a
[SDAG][AArch64] Legalize VECREDUCE

Fixes https://bugs.llvm.org/show_bug.cgi?id=36796.

Implement basic legalizations (PromoteIntRes, PromoteIntOp,
ExpandIntRes, ScalarizeVecOp, WidenVecOp) for VECREDUCE opcodes.
There are more legalizations missing (esp float legalizations),
but there's no way to test them right now, so I'm not adding them.

This also includes a few more changes to make this work somewhat
reasonably:

 * Add support for expanding VECREDUCE in SDAG. Usually
   experimental.vector.reduce is expanded prior to codegen, but if the
   target does have native vector reduce, it may of course still be
   necessary to expand due to legalization issues. This uses a shuffle
   reduction if possible, followed by a naive scalar reduction.
 * Allow the result type of integer VECREDUCE to be larger than the
   vector element type. For example we need to be able to reduce a v8i8
   into an (nominally) i32 result type on AArch64.
 * Use the vector operand type rather than the scalar result type to
   determine the action, so we can control exactly which vector types are
   supported. Also change the legalize vector op code to handle
   operations that only have vector operands, but no vector results, as
   is the case for VECREDUCE.
 * Default VECREDUCE to Expand. On AArch64 (only target using VECREDUCE),
   explicitly specify for which vector types the reductions are supported.

This does not handle anything related to VECREDUCE_STRICT_*.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355860 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
include/llvm/CodeGen/ISDOpcodes.h
include/llvm/CodeGen/TargetLowering.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h
lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/CodeGen/TargetLoweringBase.cpp
lib/Target/AArch64/AArch64ISelLowering.cpp
test/CodeGen/AArch64/vecreduce-add-legalization.ll [new file with mode: 0644]
test/CodeGen/AArch64/vecreduce-and-legalization.ll [new file with mode: 0644]
test/CodeGen/AArch64/vecreduce-fadd-legalization.ll [new file with mode: 0644]
test/CodeGen/AArch64/vecreduce-fmax-legalization.ll [new file with mode: 0644]
test/CodeGen/AArch64/vecreduce-umax-legalization.ll [new file with mode: 0644]