[PATCH] D109148: [DAGCombiner][VP] Fold zero-length or false-masked VP ops
Fraser Cormack via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 2 05:06:47 PDT 2021
frasercrmck created this revision.
frasercrmck added reviewers: craig.topper, RKSimon, spatel, simoll.
Herald added subscribers: ecnelises, rogfer01, luismarques, apazos, sameer.abuasal, steven.zhang, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
frasercrmck requested review of this revision.
Herald added subscribers: llvm-commits, vkmr, MaskRay.
Herald added a project: LLVM.
This patch adds a generic DAGCombine for vector-predicated (VP) nodes.
Those for which we can determine that no vector element is active can be
replaced by either undef or, for reductions, the start value.
This is tested rather trivially at the IR level, where it's possible
that we want to teach instcombine to perform this optimization.
However, we can also see the zero-evl case arise during SelectionDAG
legalization, when wide VP operations can be split into two and the
upper operation emerges as trivially false.
It's possible that we could perform this optimization "proactively"
(both on legal vectors and before splitting) and reduce the width of an
operation and insert it into a larger undef vector:
v8i32 vp_add x, y, mask, 4
->
v8i32 insert_subvector (v8i32 undef), (v4i32 vp_add xsub, ysub, mask, 4), i32 0
This is somewhat analogous to similar vector narrow/widening
optimizations, but it's unclear at this point whether that's beneficial
to do this for VP ops for any/all targets.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109148
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vadd-vp.ll
llvm/test/CodeGen/RISCV/rvv/undef-vp-ops.ll
llvm/test/CodeGen/RISCV/rvv/vadd-vp.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109148.370233.patch
Type: text/x-patch
Size: 32311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/156bfdb4/attachment.bin>
More information about the llvm-commits
mailing list