[LegalizeTypes][VP] Add splitting support for binary VP ops
authorFraser Cormack <fraser@codeplay.com>
Wed, 11 Aug 2021 15:47:12 +0000 (16:47 +0100)
committerFraser Cormack <fraser@codeplay.com>
Thu, 2 Sep 2021 09:15:53 +0000 (10:15 +0100)
commitef78f2106cd7d5bf9afeaaf030dc4e0d241f7ea3
tree7f9e517f118016ff12ddcaf195b232bd03850f0c
parentea2cdbf5e655ce157c2224f7d427229be55551cc
[LegalizeTypes][VP] Add splitting support for binary VP ops

This patch extends D107904's introduction of vector-predicated (VP)
operation legalization to include vector splitting.

When the result of a binary VP operation needs splitting, all of its
operands are split in kind. The two operands and the mask are split as
usual, and the vector-length parameter EVL is "split" such that the low
and high halves each execute the correct number of elements.

Tests have been added to the RISC-V target to show splitting several
scenarios for fixed- and scalable-vector types. Without support for
`umax` (e.g. in the `B` extension) the generated code starts to branch.
Ideally a cost model would prevent their insertion in the first place.

Through these tests many opportunities for better codegen can be seen:
combining known-undef VP operations and for constant-folding operations
on `ISD::VSCALE`, to name but a few.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D107957
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vadd-vp.ll
llvm/test/CodeGen/RISCV/rvv/vadd-vp.ll