[PATCH] D99682: [SelectionDAG] Teach SelectionDAG::FoldConstantArithmetic to handle SPLAT_VECTOR

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 31 13:43:50 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, frasercrmck, sdesmalen.
Herald added subscribers: ecnelises, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
craig.topper requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

This allows FoldConstantArithmetic to handle SPLAT_VECTOR in
addition to BUILD_VECTOR. This allows it to support scalable
vectors. I'm also allowing fixed length SPLAT_VECTOR which is
used by some targets, but I'm not familiar enough to write tests
for those targets.

I had to block this function from running on CONCAT_VECTORS to
avoid calling getNode for a CONCAT_VECTORS of 2 scalars.
This can happen because the 2 operand getNode calls this
function for any opcode. Previously we were protected because
CONCAT_VECTORs of BUILD_VECTOR is folded to a larger BUILD_VECTOR
before that call. But it's not always possible to fold a CONCAT_VECTORS
of SPLAT_VECTORs, and we don't even try.

This fixes PR49781 where DAG combine thought constant folding
should be possible, but FoldConstantArithmetic couldn't do it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99682

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/test/CodeGen/AArch64/pr49781.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-sdnode-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-sdnode-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vsub-sdnode-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsub-sdnode-rv64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99682.334524.patch
Type: text/x-patch
Size: 9581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210331/56c48f70/attachment.bin>


More information about the llvm-commits mailing list