[PATCH] D98495: [CodeGen] Fix issues with scalable-vector INSERT_SUBVECTORs

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 05:16:22 PST 2021


frasercrmck created this revision.
frasercrmck added reviewers: craig.topper, RKSimon, spatel, david-arm.
Herald added subscribers: 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.
frasercrmck requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

This patch addresses a few issues when dealing with scalable-vector
INSERT_SUBVECTOR nodes.

When legalizing in DAGTypeLegalizer::SplitVecRes_INSERT_SUBVECTOR, we
store the low and high halves to the stack separately. The offset for
the high half was calculated incorrectly.

Additionally, we can optimize this process when we can detect that the
subvector is contained entirely within the low/high split vector type.
While this optimization is valid on scalable vectors, when performing
the 'high' optimization, the subvector must also be a scalable vector.
Note that the 'low' optimization is still conservative: it may be
possible to insert v2i32 into the low half of a split nxv1i32/nxv1i32,
but we can't guarantee it. It is always possible to insert v2i32 into
nxv2i32 or v2i32 into nxv4i32+2 as we know vscale is at least 1.

Lastly, in SelectionDAG::isSplatValue, we try to early-exit on the value
type being a scalable vector, forgetting that we can extract a
fixed-length vector from a scalable one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98495

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/insert-subvector.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98495.330215.patch
Type: text/x-patch
Size: 9906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/572efccc/attachment.bin>


More information about the llvm-commits mailing list