[all-commits] [llvm/llvm-project] e2b46e: [DAGCombiner][VP] Fold zero-length or false-masked...
Fraser Cormack via All-commits
all-commits at lists.llvm.org
Mon Sep 27 03:40:32 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e2b46e336badce1fef2232ae11c2249f869188c9
https://github.com/llvm/llvm-project/commit/e2b46e336badce1fef2232ae11c2249f869188c9
Author: Fraser Cormack <fraser at codeplay.com>
Date: 2021-09-27 (Mon, 27 Sep 2021)
Changed paths:
M llvm/include/llvm/CodeGen/ISDOpcodes.h
M llvm/include/llvm/IR/VPIntrinsics.def
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
M llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vadd-vp.ll
A llvm/test/CodeGen/RISCV/rvv/undef-vp-ops.ll
M llvm/test/CodeGen/RISCV/rvv/vadd-vp.ll
Log Message:
-----------
[DAGCombiner][VP] Fold zero-length or false-masked VP ops
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.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D109148
More information about the All-commits
mailing list