This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Enable SPLAT_VECTOR for fixed vXi64 types on RV32.
ClosedPublic

Authored by craig.topper on Apr 19 2021, 3:54 PM.

Details

Summary

This replaces D98479.

This allows type legalization to form SPLAT_VECTOR_PARTS so we don't
lose the splattedness when the scalar type is split.

I'm handling SPLAT_VECTOR_PARTS for fixed vectors separately so
we can continue using non-VL nodes for scalable vectors.

I limited to RV32+vXi64 because DAGCombiner::visitBUILD_VECTOR likes
to form SPLAT_VECTOR before seeing if it can replace the BUILD_VECTOR
with other operations. Especially interesting is a splat BUILD_VECTOR of
the extract_vector_elt which can become a splat shuffle, but won't if
we form SPLAT_VECTOR first. We either need to reorder visitBUILD_VECTOR
or add visitSPLAT_VECTOR.

Diff Detail

Unit TestsFailed

Event Timeline

craig.topper created this revision.Apr 19 2021, 3:54 PM
craig.topper requested review of this revision.Apr 19 2021, 3:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 3:54 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
craig.topper added inline comments.Apr 19 2021, 3:57 PM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-splat.ll
50–51

This is a regression.

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-vrgather.ll
56 ↗(On Diff #338660)

grr the script deleted the checks.

Fix missing check lines.
clang-format

craig.topper added inline comments.Apr 19 2021, 4:08 PM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-vrgather.ll
56 ↗(On Diff #338661)

This is caused by SPLAT_VECTOR being formed before splat VECTOR_SHUFFLE as noted in the description.

Harbormaster completed remote builds in B99581: Diff 338661.
frasercrmck added inline comments.Apr 20 2021, 9:11 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2788

I'm wondering if you could fold this optimization into splatPartsI64WithVL

Sink constant handling into splatPartsI64WithVL

This is starting to look good. I think it'd be good to have all vectors treated similarly but it isn't time for that yet. Maybe something like visitSplatLike in the DAGCombiner could serve as a generic splat optimization path and avoid us diverging too much like we currently have with BUILD_VECTOR/SPLAT_VECTOR.

Is your plan to address the regressions in this patch or later on? Do you have a feeling of how much work it'd be?

Push SPLAT_VECTOR formation to late in visitBUILD_VECTOR which recovers some of the regressions and doesn't effect any other target lit tests.

craig.topper added inline comments.Apr 21 2021, 10:23 AM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-splat.ll
50–51

Andrew Waterman's advice at least for us was to use stores and a strided load with x0 stride to splat SEW=64 on RV32. This is analogous to the sequence for loading a double precision value from integer data on RV32. Should we use that instead of being clever with shifts/ors?

craig.topper added inline comments.Apr 21 2021, 3:39 PM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-splat.ll
50–51

I've implemented the strided store in splatSplitI64WithVL here https://reviews.llvm.org/D101002

frasercrmck accepted this revision.Apr 29 2021, 4:35 AM

LGTM. There are a couple of areas that need formatting according to clang-tidy.

This revision is now accepted and ready to land.Apr 29 2021, 4:35 AM
This revision was landed with ongoing or failed builds.Apr 29 2021, 8:23 AM
This revision was automatically updated to reflect the committed changes.