Page MenuHomePhabricator

[RISCV] Optimize splats of extracted vector elements
ClosedPublic

Authored by frasercrmck on Jan 28 2022, 4:59 AM.

Details

Summary

This patch adds an optimization to splat-like operations where the
splatted value is extracted from a identically-sized vector. On RVV we
can splat that via vrgather.vx/vrgather.vi without dropping to scalar
beforehand.

We do have a similar VECTOR_SHUFFLE-specific optimization but that only
works on fixed-length vector types and for those with a constant splat
lane. This patch extends this optimization to make it work on
scalable-vector types and on unknown extract indices.

It is performed during fixed-vector BUILD_VECTOR lowering and during a
new DAGCombine on SPLAT_VECTOR for scalable vectors.

Diff Detail

Event Timeline

frasercrmck created this revision.Jan 28 2022, 4:59 AM
frasercrmck requested review of this revision.Jan 28 2022, 4:59 AM
khchen accepted this revision.Feb 7 2022, 8:25 PM

LGTM. Thanks!

This revision is now accepted and ready to land.Feb 7 2022, 8:25 PM
craig.topper added inline comments.Feb 7 2022, 8:58 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2006

const SDLoc &DL

This revision was landed with ongoing or failed builds.Feb 8 2022, 2:46 AM
This revision was automatically updated to reflect the committed changes.
frasercrmck marked an inline comment as done.Feb 8 2022, 2:46 AM
frasercrmck added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2006

Thanks, fixed before landing.